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..09623b033 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 if `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 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)