From f5b5e6d90df55449255bfee78113d25c344d0215 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 10 Feb 2020 02:51:06 -0500 Subject: [PATCH] naughty: Add a `request::screen` handler. --- lib/naughty/core.lua | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/naughty/core.lua b/lib/naughty/core.lua index 497528790..b260839b2 100644 --- a/lib/naughty/core.lua +++ b/lib/naughty/core.lua @@ -196,6 +196,16 @@ screen.connect_for_each_screen(function(s) end) 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 naughty.destroy_all_notifications({scr}) naughty.notifications[scr] = nil @@ -231,7 +241,6 @@ local function update_index(n) table.insert(naughty.notifications[s][n.position], n) end - --- Notification state. -- -- This function is deprecated, use `naughty.suspended`. @@ -500,6 +509,20 @@ function naughty.set_expiration_paused(p) 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. -- @signal request::display_error -- @tparam string message The error message.