naughty: Auto-reset the timeout when notifications are modified.
This is configurable globally or per-notification. When it is replaced over dbus, it has a new timeout and *that* should be the new timeout (starting when the notification is replaced). Closes #2821
This commit is contained in:
parent
11ef560c5c
commit
bec4de5fab
|
@ -126,9 +126,18 @@ gtable.crush(naughty, require("naughty.constants"))
|
|||
-- @property has_display_handler
|
||||
-- @param boolean
|
||||
|
||||
--- If the timeout needs to be reset when a property changes.
|
||||
--
|
||||
-- This is the global variant of the `naughty.notification` `auto_reset_timeout`
|
||||
-- property.
|
||||
--
|
||||
-- @property auto_reset_timeout
|
||||
-- @tparam[opt=true] boolean auto_reset_timeout
|
||||
|
||||
local properties = {
|
||||
suspended = false,
|
||||
expiration_paused = false
|
||||
expiration_paused = false,
|
||||
auto_reset_timeout= true,
|
||||
}
|
||||
|
||||
--TODO v5 Deprecate the public `naughty.notifications` (to make it private)
|
||||
|
|
|
@ -236,6 +236,9 @@ function notif_methods.Notify(sender, object_path, interface, method, parameters
|
|||
if k == "destroy" then k = "destroy_cb" end
|
||||
notification[k] = v
|
||||
end
|
||||
|
||||
-- Even if no property changed, restart the timeout.
|
||||
notification:reset_timeout()
|
||||
else
|
||||
notification = nnotif(args)
|
||||
end
|
||||
|
|
|
@ -267,6 +267,14 @@ local notification = {}
|
|||
-- @param boolean
|
||||
-- @see naughty.expiration_paused
|
||||
|
||||
--- If the timeout needs to be reset when a property changes.
|
||||
--
|
||||
-- By default it fallsback to `naughty.auto_reset_timeout`, which itself is
|
||||
-- true by default.
|
||||
--
|
||||
-- @property auto_reset_timeout
|
||||
-- @tparam[opt=true] boolean auto_reset_timeout
|
||||
|
||||
--- Emitted when the notification is destroyed.
|
||||
-- @signal destroyed
|
||||
-- @tparam number reason Why it was destroyed
|
||||
|
@ -391,7 +399,7 @@ local properties = {
|
|||
"fg" , "bg" , "height" , "border_color" ,
|
||||
"shape" , "opacity" , "margin" , "ignore_suspend",
|
||||
"destroy" , "preset" , "callback", "actions" ,
|
||||
"run" , "id" , "ignore",
|
||||
"run" , "id" , "ignore" , "auto_reset_timeout"
|
||||
}
|
||||
|
||||
for _, prop in ipairs(properties) do
|
||||
|
@ -408,6 +416,17 @@ for _, prop in ipairs(properties) do
|
|||
notification["set_"..prop] = notification["set_"..prop] or function(self, value)
|
||||
self._private[prop] = value
|
||||
self:emit_signal("property::"..prop, value)
|
||||
|
||||
-- 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)
|
||||
and self.auto_reset_timeout ~= false
|
||||
and naughty.auto_reset_timeout)
|
||||
|
||||
if reset then
|
||||
self:reset_timeout()
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue