From 0b075761e31a927590eab8862437752b00ae53cd Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 14 Oct 2021 13:58:11 -0700 Subject: [PATCH 1/3] naughty: Fix the `ignore_suspend` property. By fixing some suspend bugs a few weeks ago, I "regressed" this a little. By that, I mean there were bugs in the suspend code which caused `ignore_suspend` to work simply because suspend globally failed rather than `ignore_suspend` being implemented correctly. Fix #3465 --- lib/naughty/core.lua | 12 +++++++----- lib/naughty/notification.lua | 17 +++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/naughty/core.lua b/lib/naughty/core.lua index eead84018..046ff0586 100644 --- a/lib/naughty/core.lua +++ b/lib/naughty/core.lua @@ -520,12 +520,14 @@ function naughty.set_suspended(value) if value then for _, n in pairs(naughty._active) do - if n.timer and n.timer.started then - n.timer:stop() - end + if not n.ignore_suspend then + if n.timer and n.timer.started then + n.timer:stop() + end - n:emit_signal("property::suspended", true) - table.insert(naughty.notifications.suspended, n) + n:emit_signal("property::suspended", true) + table.insert(naughty.notifications.suspended, n) + end end else resume() diff --git a/lib/naughty/notification.lua b/lib/naughty/notification.lua index 980e123ba..c25c41a5e 100644 --- a/lib/naughty/notification.lua +++ b/lib/naughty/notification.lua @@ -523,6 +523,11 @@ function notification:set_id(new_id) self:emit_signal("property::id", new_id) end +-- Return true is `self` is suspended. +local function get_suspended(self) + return naughty.suspended and (not self._private.ignore_suspend) +end + function notification:set_timeout(timeout) timeout = timeout or 0 @@ -554,7 +559,7 @@ function notification:set_timeout(timeout) end) --FIXME there's still a dependency loop to fix before it works - if not self.suspended then + if not get_suspended(self) then timer_die:start() end @@ -636,9 +641,9 @@ for _, prop in ipairs(properties) do -- When a notification is updated over dbus or by setting a property, -- it is usually convenient to reset the timeout. - local reset = ((not self.suspended) + local reset = ((not self.suspended) or self._private.ignore_suspend) and self.auto_reset_timeout ~= false - and naughty.auto_reset_timeout) + and naughty.auto_reset_timeout if reset then self:reset_timeout() @@ -774,9 +779,9 @@ function notification.set_actions(self, new_actions) -- When a notification is updated over dbus or by setting a property, -- it is usually convenient to reset the timeout. - local reset = ((not self.suspended) + local reset = (not get_suspended(self)) and self.auto_reset_timeout ~= false - and naughty.auto_reset_timeout) + and naughty.auto_reset_timeout if reset then self:reset_timeout() @@ -1033,7 +1038,7 @@ local function create(args) end -- Let all listeners handle the actual visual aspects - if (not n.ignore) and ((not n.preset) or n.preset.ignore ~= true) and (not naughty.suspended) then + if (not n.ignore) and ((not n.preset) or n.preset.ignore ~= true) and (not get_suspended(n)) then naughty.emit_signal("request::display" , n, "new", args) naughty.emit_signal("request::fallback", n, "new", args) end From 187b766cbe393fb8d8bc296f8e31cb5c83bd18e3 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 14 Oct 2021 13:59:45 -0700 Subject: [PATCH 2/3] tests: Test naughty.notification.ignore_suspend --- tests/test-naughty-suspended.lua | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/test-naughty-suspended.lua b/tests/test-naughty-suspended.lua index f3264c4f1..24328dccf 100644 --- a/tests/test-naughty-suspended.lua +++ b/tests/test-naughty-suspended.lua @@ -103,4 +103,40 @@ table.insert(steps, function() return true end) +-- Test `ignore_suspend`. +table.insert(steps, function() + naughty.suspended = true + display_count = 0 + + notifs[1] = notification { + title = "test3", + ignore_suspend = true, + } + + notifs[2] = notification { + title = "test4" + } + + return true +end) + +table.insert(steps, function() + if display_count ~= 1 then return end + + notifs[2]:destroy() + + naughty.suspended = false + + + return true +end) + +table.insert(steps, function() + if display_count ~= 1 then return end + + notifs[1]:destroy() + + return true +end) + require("_runner").run_steps(steps) From 5f29d6d056b445d2865256be86b991873521e134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Lepage=20Vall=C3=A9e?= Date: Thu, 14 Oct 2021 20:51:31 -0700 Subject: [PATCH 3/3] Update lib/naughty/notification.lua Co-authored-by: Aire-One --- lib/naughty/notification.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/naughty/notification.lua b/lib/naughty/notification.lua index c25c41a5e..09623b033 100644 --- a/lib/naughty/notification.lua +++ b/lib/naughty/notification.lua @@ -523,7 +523,7 @@ function notification:set_id(new_id) self:emit_signal("property::id", new_id) end --- Return true is `self` is suspended. +-- Return true if `self` is suspended. local function get_suspended(self) return naughty.suspended and (not self._private.ignore_suspend) end