From 0b075761e31a927590eab8862437752b00ae53cd Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Thu, 14 Oct 2021 13:58:11 -0700 Subject: [PATCH] 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