From be29ee676882b98601ab5276f21cc50c191ebfe4 Mon Sep 17 00:00:00 2001 From: Benoit de Chezelles Date: Tue, 23 May 2017 15:37:46 +0200 Subject: [PATCH] naughty: avoid notification flickering on replace (#1785) Fixes https://github.com/awesomeWM/awesome/issues/1737. --- lib/naughty/core.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/naughty/core.lua b/lib/naughty/core.lua index 2cb70185..e69e12f2 100644 --- a/lib/naughty/core.lua +++ b/lib/naughty/core.lua @@ -334,8 +334,9 @@ end -- -- @param notification Notification object to be destroyed -- @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 -function naughty.destroy(notification, reason) +function naughty.destroy(notification, reason, keep_visible) if notification and notification.box.visible then if suspended then for k, v in pairs(naughty.notifications.suspended) do @@ -350,8 +351,12 @@ function naughty.destroy(notification, reason) if notification.timer then notification.timer:stop() 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 notification.destroy_cb(reason or naughty.notificationClosedReason.undefined) end @@ -610,11 +615,13 @@ function naughty.notify(args) local notification = { screen = s, destroy_cb = destroy_cb, timeout = timeout } -- replace notification if needed + local reuse_box if args.replaces_id then local obj = naughty.getById(args.replaces_id) if obj then -- destroy this and ... - naughty.destroy(obj, naughty.notificationClosedReason.silent) + naughty.destroy(obj, naughty.notificationClosedReason.silent, true) + reuse_box = obj.box end -- ... may use its ID if args.replaces_id <= counter then @@ -747,6 +754,10 @@ function naughty.notify(args) shape = shape, type = "notification" }) + if reuse_box then + notification.box = reuse_box + end + if hover_timeout then notification.box:connect_signal("mouse::enter", hover_destroy) end notification.size_info = {