xdg-desktop-portal-gtk icon indicating copy to clipboard operation
xdg-desktop-portal-gtk copied to clipboard

notification: Set correct platform data for action activation

Open jsparber opened this issue 1 year ago • 7 comments

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/

jsparber avatar Feb 19 '24 17:02 jsparber

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.

jsparber avatar Feb 19 '24 18:02 jsparber

GNOME Shell gained the feature already

On GNOME-Shell it shouldn't be using org.freedesktop.Notifications anyway, it will use org.gtk.Notifications.

TingPing avatar Feb 19 '24 18:02 TingPing

Ah, it does use FDO in some fallback paths.

TingPing avatar Feb 19 '24 18:02 TingPing

I figured out how to try this. We can just monitor DBUS and use ashpd demo.

jsparber avatar Mar 01 '24 16:03 jsparber

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.

jsparber avatar Mar 01 '24 16:03 jsparber

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).

jsparber avatar Mar 01 '24 18:03 jsparber

Once this is merged we can consume the activation-token passed to ActionInvoked from libnotify https://gitlab.gnome.org/GNOME/libnotify/-/merge_requests/38

jsparber avatar Mar 03 '24 00:03 jsparber

I believe this was merged as 48bbf07016e75ec949404265816671a9ef62e722

TingPing avatar Jun 26 '24 17:06 TingPing