From bb73bf548ca7ebc607bcb2f9e89aaa5786233f93 Mon Sep 17 00:00:00 2001 From: Julian Sparber Date: Mon, 19 Feb 2024 17:31:52 +0100 Subject: [PATCH] FdoNotificationDaemon: Emit ActivationToken before ActionInvoked signal Two years ago FDO notifications spec gained the ability to pass an activation token (often called startup id) let's finally implement it. See: https://gitlab.freedesktop.org/xdg/xdg-specs/-/commit/b9a470004d Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/358 Part-of: --- .../org.freedesktop.Notifications.xml | 4 ++++ js/dbusServices/notifications/notificationDaemon.js | 8 ++++++++ js/ui/notificationDaemon.js | 12 ++++++++++++ 3 files changed, 24 insertions(+) diff --git a/data/dbus-interfaces/org.freedesktop.Notifications.xml b/data/dbus-interfaces/org.freedesktop.Notifications.xml index 0ed865743..dde758500 100644 --- a/data/dbus-interfaces/org.freedesktop.Notifications.xml +++ b/data/dbus-interfaces/org.freedesktop.Notifications.xml @@ -31,5 +31,9 @@ + + + + diff --git a/js/dbusServices/notifications/notificationDaemon.js b/js/dbusServices/notifications/notificationDaemon.js index 38ad9118f..0be91cef9 100644 --- a/js/dbusServices/notifications/notificationDaemon.js +++ b/js/dbusServices/notifications/notificationDaemon.js @@ -27,6 +27,14 @@ export const NotificationDaemon = class extends ServiceImplementation { log(error.message); }); + this._proxy.connectSignal('ActivationToken', + (proxy, sender, params) => { + const [id] = params; + this._emitSignal( + this._activeNotifications.get(id), + 'ActivationToken', + new GLib.Variant('(us)', params)); + }); this._proxy.connectSignal('ActionInvoked', (proxy, sender, params) => { const [id] = params; diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js index 4aceb2468..09c1c6b18 100644 --- a/js/ui/notificationDaemon.js +++ b/js/ui/notificationDaemon.js @@ -217,6 +217,7 @@ class FdoNotificationDaemon { hasDefaultAction = true; } else { notification.addAction(label, () => { + this._emitActivationToken(source, ndata.id); this._emitActionInvoked(ndata.id, actionId); }); } @@ -225,6 +226,7 @@ class FdoNotificationDaemon { if (hasDefaultAction) { notification.connect('activated', () => { + this._emitActivationToken(source, ndata.id); this._emitActionInvoked(ndata.id, 'default'); }); } else { @@ -301,6 +303,16 @@ class FdoNotificationDaemon { this._dbusImpl.emit_signal('ActionInvoked', GLib.Variant.new('(us)', [id, action])); } + + _emitActivationToken(source, id) { + const context = global.create_app_launch_context(0, -1); + const info = source.app?.get_app_info(); + if (info) { + const token = context.get_startup_notify_id(info, []); + this._dbusImpl.emit_signal('ActivationToken', + GLib.Variant.new('(us)', [id, token])); + } + } } export const FdoNotificationDaemonSource = GObject.registerClass(