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
This commit is contained in:
Emmanuel Lepage Vallee 2021-10-14 13:58:11 -07:00
parent 5a27eaa973
commit 0b075761e3
2 changed files with 18 additions and 11 deletions

View File

@ -520,6 +520,7 @@ function naughty.set_suspended(value)
if value then if value then
for _, n in pairs(naughty._active) do for _, n in pairs(naughty._active) do
if not n.ignore_suspend then
if n.timer and n.timer.started then if n.timer and n.timer.started then
n.timer:stop() n.timer:stop()
end end
@ -527,6 +528,7 @@ function naughty.set_suspended(value)
n:emit_signal("property::suspended", true) n:emit_signal("property::suspended", true)
table.insert(naughty.notifications.suspended, n) table.insert(naughty.notifications.suspended, n)
end end
end
else else
resume() resume()
end end

View File

@ -523,6 +523,11 @@ function notification:set_id(new_id)
self:emit_signal("property::id", new_id) self:emit_signal("property::id", new_id)
end 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) function notification:set_timeout(timeout)
timeout = timeout or 0 timeout = timeout or 0
@ -554,7 +559,7 @@ function notification:set_timeout(timeout)
end) end)
--FIXME there's still a dependency loop to fix before it works --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() timer_die:start()
end end
@ -636,9 +641,9 @@ for _, prop in ipairs(properties) do
-- When a notification is updated over dbus or by setting a property, -- When a notification is updated over dbus or by setting a property,
-- it is usually convenient to reset the timeout. -- 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 self.auto_reset_timeout ~= false
and naughty.auto_reset_timeout) and naughty.auto_reset_timeout
if reset then if reset then
self:reset_timeout() 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, -- When a notification is updated over dbus or by setting a property,
-- it is usually convenient to reset the timeout. -- 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 self.auto_reset_timeout ~= false
and naughty.auto_reset_timeout) and naughty.auto_reset_timeout
if reset then if reset then
self:reset_timeout() self:reset_timeout()
@ -1033,7 +1038,7 @@ local function create(args)
end end
-- Let all listeners handle the actual visual aspects -- 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::display" , n, "new", args)
naughty.emit_signal("request::fallback", n, "new", args) naughty.emit_signal("request::fallback", n, "new", args)
end end