notification: Fix rendering during early screen creation.

If the problem happens early enough, it was possible that the
screen arrway wasn't initialized yet. In that case, the notification
would fail to render.
This commit is contained in:
Emmanuel Lepage Vallee 2021-07-05 01:26:33 -07:00
parent 2a8c17daea
commit 4b606fb3d7
1 changed files with 10 additions and 2 deletions

View File

@ -191,7 +191,9 @@ naughty.notifications = { suspended = { }, _expired = {{}} }
naughty._active = {}
screen.connect_for_each_screen(function(s)
local function init_screen(s)
if naughty.notifications[s] then return end
naughty.notifications[s] = {
top_left = {},
top_middle = {},
@ -201,7 +203,9 @@ screen.connect_for_each_screen(function(s)
bottom_right = {},
middle = {},
}
end)
end
screen.connect_for_each_screen(init_screen)
capi.screen.connect_signal("removed", function(scr)
-- Allow the notifications to be moved to another screen.
@ -646,6 +650,10 @@ local function register(notification, args)
assert(s)
if not naughty.notifications[s] then
init_screen(get_screen(s))
end
-- insert the notification to the table
table.insert(naughty._active, notification)
table.insert(naughty.notifications[s][notification.position], notification)