naughty: Add a `request::screen` handler.
This commit is contained in:
parent
636cc2bf9c
commit
f5b5e6d90d
|
@ -196,6 +196,16 @@ screen.connect_for_each_screen(function(s)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
capi.screen.connect_signal("removed", function(scr)
|
capi.screen.connect_signal("removed", function(scr)
|
||||||
|
-- Allow the notifications to be moved to another screen.
|
||||||
|
|
||||||
|
for _, list in pairs(naughty.notifications[scr]) do
|
||||||
|
-- Clone the list to avoid having an iterator while mutating.
|
||||||
|
list = gtable.clone(list, false)
|
||||||
|
|
||||||
|
for _, n in ipairs(list) do
|
||||||
|
naughty.emit_signal("request::screen", n, "removed", {})
|
||||||
|
end
|
||||||
|
end
|
||||||
-- Destroy all notifications on this screen
|
-- Destroy all notifications on this screen
|
||||||
naughty.destroy_all_notifications({scr})
|
naughty.destroy_all_notifications({scr})
|
||||||
naughty.notifications[scr] = nil
|
naughty.notifications[scr] = nil
|
||||||
|
@ -231,7 +241,6 @@ local function update_index(n)
|
||||||
table.insert(naughty.notifications[s][n.position], n)
|
table.insert(naughty.notifications[s][n.position], n)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Notification state.
|
--- Notification state.
|
||||||
--
|
--
|
||||||
-- This function is deprecated, use `naughty.suspended`.
|
-- This function is deprecated, use `naughty.suspended`.
|
||||||
|
@ -500,6 +509,20 @@ function naughty.set_expiration_paused(p)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- The default handler for `request::screen`.
|
||||||
|
--
|
||||||
|
-- It selects `awful.screen.focused()`.
|
||||||
|
--
|
||||||
|
-- @signalhandler naughty.default_screen_handler
|
||||||
|
|
||||||
|
function naughty.default_screen_handler(n)
|
||||||
|
if n.screen and n.screen.valid then return end
|
||||||
|
|
||||||
|
n.screen = screen.focused()
|
||||||
|
end
|
||||||
|
|
||||||
|
naughty.connect_signal("request::screen", naughty.default_screen_handler)
|
||||||
|
|
||||||
--- Emitted when an error occurred and requires attention.
|
--- Emitted when an error occurred and requires attention.
|
||||||
-- @signal request::display_error
|
-- @signal request::display_error
|
||||||
-- @tparam string message The error message.
|
-- @tparam string message The error message.
|
||||||
|
|
Loading…
Reference in New Issue