xdg-desktop-portal-gtk
xdg-desktop-portal-gtk copied to clipboard
notification: Set correct platform data for action activation
Since [1] FDO notifications can transfer a ActivateToken to the client application, we can use this token to set the correct platform data to get wayland startup notification working correctly. GNOME Shell gained the feature already in [2], so this is the last piece missing to get rid of the annoying "<Application> is ready" notifications, when clicking on a notification.
We can set the platform data for actions that are activated via org.freedesktop.Application.
For apps that don't implement the org.freedesktop.Application interface we can add the
platform data to the ActionInvoked signal.
Fixes: https://github.com/flatpak/xdg-desktop-portal-gtk/issues/406
[1] https://gitlab.freedesktop.org/xdg/xdg-specs/-/commit/b9a470004d [2] https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3199/
I didn't actually try the code yet since i didn't find a way to use it without writing a test app therefore it's marked as draft.
GNOME Shell gained the feature already
On GNOME-Shell it shouldn't be using org.freedesktop.Notifications anyway, it will use org.gtk.Notifications.
Ah, it does use FDO in some fallback paths.
I figured out how to try this. We can just monitor DBUS and use ashpd demo.
Oh i didn't notice before doing this that there was already an effort few years back by @3v1n0 with https://github.com/flatpak/xdg-desktop-portal-gtk/pull/380 I think this is a better approach since we don't break or change any API.
The reason why we decided to change the API was because I also wanted to make possible for apps using GNotification or portal api directly to be able to send such info, and not being limited to using the fdo API
If an action is activated via org.freedesktop.Appliaction.ActivateAction the platform data needs to be set by the caller. In our case GNOME Shell, I fixed that see https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3198. Gio/GTK.Application already picks up the platform data (I'm not sure for other toolkits).
Once this is merged we can consume the activation-token passed to ActionInvoked from libnotify https://gitlab.gnome.org/GNOME/libnotify/-/merge_requests/38
I believe this was merged as 48bbf07016e75ec949404265816671a9ef62e722