naughty: avoid notification flickering on replace (#1785)
Fixes https://github.com/awesomeWM/awesome/issues/1737.
This commit is contained in:
parent
b6e6a04895
commit
be29ee6768
|
@ -334,8 +334,9 @@ end
|
||||||
--
|
--
|
||||||
-- @param notification Notification object to be destroyed
|
-- @param notification Notification object to be destroyed
|
||||||
-- @param reason One of the reasons from notificationClosedReason
|
-- @param reason One of the reasons from notificationClosedReason
|
||||||
|
-- @param[opt=false] keep_visible If true, keep the notification visible
|
||||||
-- @return True if the popup was successfully destroyed, nil otherwise
|
-- @return True if the popup was successfully destroyed, nil otherwise
|
||||||
function naughty.destroy(notification, reason)
|
function naughty.destroy(notification, reason, keep_visible)
|
||||||
if notification and notification.box.visible then
|
if notification and notification.box.visible then
|
||||||
if suspended then
|
if suspended then
|
||||||
for k, v in pairs(naughty.notifications.suspended) do
|
for k, v in pairs(naughty.notifications.suspended) do
|
||||||
|
@ -350,8 +351,12 @@ function naughty.destroy(notification, reason)
|
||||||
if notification.timer then
|
if notification.timer then
|
||||||
notification.timer:stop()
|
notification.timer:stop()
|
||||||
end
|
end
|
||||||
notification.box.visible = false
|
|
||||||
arrange(scr)
|
if not keep_visible then
|
||||||
|
notification.box.visible = false
|
||||||
|
arrange(scr)
|
||||||
|
end
|
||||||
|
|
||||||
if notification.destroy_cb and reason ~= naughty.notificationClosedReason.silent then
|
if notification.destroy_cb and reason ~= naughty.notificationClosedReason.silent then
|
||||||
notification.destroy_cb(reason or naughty.notificationClosedReason.undefined)
|
notification.destroy_cb(reason or naughty.notificationClosedReason.undefined)
|
||||||
end
|
end
|
||||||
|
@ -610,11 +615,13 @@ function naughty.notify(args)
|
||||||
local notification = { screen = s, destroy_cb = destroy_cb, timeout = timeout }
|
local notification = { screen = s, destroy_cb = destroy_cb, timeout = timeout }
|
||||||
|
|
||||||
-- replace notification if needed
|
-- replace notification if needed
|
||||||
|
local reuse_box
|
||||||
if args.replaces_id then
|
if args.replaces_id then
|
||||||
local obj = naughty.getById(args.replaces_id)
|
local obj = naughty.getById(args.replaces_id)
|
||||||
if obj then
|
if obj then
|
||||||
-- destroy this and ...
|
-- destroy this and ...
|
||||||
naughty.destroy(obj, naughty.notificationClosedReason.silent)
|
naughty.destroy(obj, naughty.notificationClosedReason.silent, true)
|
||||||
|
reuse_box = obj.box
|
||||||
end
|
end
|
||||||
-- ... may use its ID
|
-- ... may use its ID
|
||||||
if args.replaces_id <= counter then
|
if args.replaces_id <= counter then
|
||||||
|
@ -747,6 +754,10 @@ function naughty.notify(args)
|
||||||
shape = shape,
|
shape = shape,
|
||||||
type = "notification" })
|
type = "notification" })
|
||||||
|
|
||||||
|
if reuse_box then
|
||||||
|
notification.box = reuse_box
|
||||||
|
end
|
||||||
|
|
||||||
if hover_timeout then notification.box:connect_signal("mouse::enter", hover_destroy) end
|
if hover_timeout then notification.box:connect_signal("mouse::enter", hover_destroy) end
|
||||||
|
|
||||||
notification.size_info = {
|
notification.size_info = {
|
||||||
|
|
Loading…
Reference in New Issue