Desktop file names for activation tokens when invoking notification actions
When invoking a notification action (by clicking on an action button or the whole notification for the default action) on Wayland Plasma requests an XDG activation token and passes that to the application. This is done so that the application can raise its own window in response. When requesting the token one can optionally pass a desktop file name. Passing a (valid) desktop file name triggers startup feedback (i.e. the bouncing cursor by default, but could be anything).
What desktop file name does Plasma use to request the token? Currently it reads a x-kde-xdgTokenAppId
hint from the notification: https://invent.kde.org/plasma/plasma-workspace/-/blob/master/libnotificationmanager/notification.cpp#L357. KNotifications sets this hint to QGuiApplication::desktopFileName()
: https://invent.kde.org/frameworks/knotifications/-/blob/master/src/knotification.cpp#L52
This has several problems:
- It introduces an inconsistency between apps using KNotifications and other apps (e.g. using libnotify or DBus directly). The former always gets this hint and thus always a desktop file name in the token, the latter never (unless they manually set the x-kde- hint). This could be solved by also considering the
desktop-entry
notification hint. - xdg-desktop-portal-kde uses KNotifications to implement portal notification. This means all portal notification get "org.freedesktop.impl.portal.desktop.kde" as desktop file name in their activation token. This can be seen e.g. when clicking on a Telegram notification, where you will get a bouncing cursor with a generic KDE icon. This could be solved in xdg-desktop-portal-kde by overriding the
x-kde-xdgTokenAppId
hint with the proper value. - The desktop file name of the program that creates the notification does not necessarily match the one of the program getting opened when clicking the notification. For example the discover update notifier creates a notification about updates being available and when clicking the "Show updates" button discover is launched. The notifier and Discover itself have different desktop file names and icons, so when clicking "Show updates" you get a bouncing cursor with the notifier icon instead of the Discover icon. This could be fixed by overriding the hint in the notifier.
- There are cases where we do not want any visible startup feedback. For example when the calendar reminder background program shows a notification like "Annoying Meeting in 5 Minutes [Dismiss] [Remind again in 5 Minutes]" then clicking dismiss doesn't result in any window getting activated and there should be no bouncing cursor. That would be achievable by overriding the hint to be empty. However, we would also need to ensure that Plasma doesn't fall back to "desktop-entry" as part of the solution to problem 1). There's a catch though. Assume the notification also has a "Open Meeting URL" button that opens the meeting URL in your browser. When clicking that you want to have startup feedback, but with the browser's icon, not the icon of the calendar system. This shows that we want some ability to customize the desktop file name on a per-action basis instead of only a per-notification basis