diff --git a/lib/naughty/dbus.lua b/lib/naughty/dbus.lua index 8b86cd1b0..639b0dbc4 100644 --- a/lib/naughty/dbus.lua +++ b/lib/naughty/dbus.lua @@ -73,6 +73,9 @@ local function sendNotificationClosed(notificationId, reason) end end +-- This allow notification to be upadated later. +local counter = 1 + local function convert_icon(w, h, rowstride, channels, data) -- Do the arguments look sane? (e.g. we have enough data) local expected_length = rowstride * (h - 1) + w * channels @@ -201,10 +204,24 @@ capi.dbus.connect_signal("org.freedesktop.Notifications", args.timeout = expire / 1000 end args.freedesktop_hints = hints - notification = nnotif(args) + + -- Try to update existing objects when possible + notification = naughty.get_by_id(replaces_id) + + if notification then + for k, v in pairs(args) do + notification[k] = v + end + else + counter = counter+1 + args.id = counter + notification = nnotif(args) + end + return "u", notification.id end - return "u", "0" + counter = counter+1 + return "u", counter elseif data.member == "CloseNotification" then local obj = naughty.get_by_id(appname) if obj then diff --git a/lib/naughty/layout/legacy.lua b/lib/naughty/layout/legacy.lua index 0e20f0662..b8d1be906 100644 --- a/lib/naughty/layout/legacy.lua +++ b/lib/naughty/layout/legacy.lua @@ -57,10 +57,6 @@ screen.connect_for_each_screen(function(s) } end) --- Counter for the notifications --- Required for later access via DBUS -local counter = 1 - --- Evaluate desired position of the notification by index - internal -- -- @param s Screen to use @@ -342,28 +338,6 @@ function naughty.default_notification_handler(notification, args) local opacity = args.opacity or preset.opacity or beautiful.notification_opacity - -- replace notification if needed - local reuse_box - if args.replaces_id then - local obj = naughty.get_by_id(args.replaces_id) - if obj then - -- destroy this and ... - naughty.destroy(obj, naughty.notification_closed_reason.silent, true) - reuse_box = obj.box - end - -- ... may use its ID - if args.replaces_id <= counter then - notification.id = args.replaces_id - else - counter = counter + 1 - notification.id = counter - end - else - -- get a brand new ID - counter = counter + 1 - notification.id = counter - end - notification.position = position -- hook destroy @@ -515,10 +489,6 @@ function naughty.default_notification_handler(notification, 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 = size_info