naughty: Suspend existing notifications.
Previously, it would just suspend new notification, but do nothing about the existing ones.
This commit is contained in:
parent
075935fd37
commit
3458c89040
|
@ -292,14 +292,20 @@ local conns = gobject._setup_class_signals(
|
|||
|
||||
local function resume()
|
||||
properties.suspended = false
|
||||
for _, v in pairs(naughty.notifications.suspended) do
|
||||
for _, v in ipairs(naughty.notifications.suspended) do
|
||||
local args = v._private.args
|
||||
assert(args)
|
||||
v._private.args = nil
|
||||
|
||||
v:emit_signal("property::suspended", false)
|
||||
|
||||
naughty.emit_signal("added", v, args)
|
||||
naughty.emit_signal("request::display", v, "resume", args)
|
||||
if v.timer then v.timer:start() end
|
||||
|
||||
if not v._private.args then
|
||||
v._private.args = args
|
||||
end
|
||||
end
|
||||
naughty.notifications.suspended = { }
|
||||
end
|
||||
|
@ -465,7 +471,7 @@ local function cleanup(self, reason)
|
|||
assert(reason, "Use n:destroy() instead of emitting the signal directly")
|
||||
|
||||
if properties.suspended then
|
||||
for k, v in pairs(naughty.notifications.suspended) do
|
||||
for k, v in ipairs(naughty.notifications.suspended) do
|
||||
if v == self then
|
||||
table.remove(naughty.notifications.suspended, k)
|
||||
break
|
||||
|
@ -507,6 +513,25 @@ local function get_suspended(self)
|
|||
return properties.suspended and not self.ignore_suspend
|
||||
end
|
||||
|
||||
function naughty.set_suspended(value)
|
||||
if properties["suspended"] == value then return end
|
||||
|
||||
properties["suspended"] = value
|
||||
|
||||
if value then
|
||||
for _, n in pairs(naughty._active) do
|
||||
if n.timer and n.timer.started then
|
||||
n.timer:stop()
|
||||
end
|
||||
|
||||
n:emit_signal("property::suspended", true)
|
||||
table.insert(naughty.notifications.suspended, n)
|
||||
end
|
||||
else
|
||||
resume()
|
||||
end
|
||||
end
|
||||
|
||||
function naughty.set_expiration_paused(p)
|
||||
properties.expiration_paused = p
|
||||
|
||||
|
@ -669,8 +694,9 @@ local function register(notification, args)
|
|||
|
||||
notification._private.registered = true
|
||||
|
||||
if properties.suspended and not args.ignore_suspend then
|
||||
notification._private.args = args
|
||||
|
||||
if properties.suspended and not args.ignore_suspend then
|
||||
table.insert(naughty.notifications.suspended, notification)
|
||||
else
|
||||
naughty.emit_signal("added", notification, args)
|
||||
|
@ -702,9 +728,6 @@ local function set_index_miss(_, key, value)
|
|||
elseif properties[key] ~= nil then
|
||||
assert(type(value) == "boolean")
|
||||
properties[key] = value
|
||||
if not value then
|
||||
resume()
|
||||
end
|
||||
|
||||
naughty.emit_signal("property::"..key, value)
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue