Bug 447803 - Option to have notification actions register as activation/start calls to window system
Summary: Option to have notification actions register as activation/start calls to win...
Status: CONFIRMED
Alias: None
Product: frameworks-knotifications
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-01 23:16 UTC by Friedrich W. H. Kossebau
Modified: 2022-07-02 15:12 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Friedrich W. H. Kossebau 2022-01-01 23:16:54 UTC
Use case: 
In a chat application when showing a notification about a new message, the default action is to "Open" the respective view which holds the new message:

    auto *msg = KNotification::event(...);
    msg->setDefaultAction(i18n("Open"));
    connect(msg, &KNotification::defaultActivated, window, [] {
        window->show();
        window->raise();
        KWindowSystem::activateWindow(window->winId());
    });

If the window is currently on another virtual desktop, given the intent of the user to open/see the new message when activating the action, one would expect that the window system/shell switches the virtual desktop as needed to show the window.

Instead at least with KWin/Plasma on these calls only the window is highlighted on the taskbar, but the virtual desktop not switched. So the user has to do a further action (e.g. click the highlighted window entry) to finally get to the window.

Assumption: this might be related to focus stealing handling? So there needs to be some way for the notification system to tell the window system that the window activation requested by the application is due to a start/activation like event from the notification. Possibly something with X11 startup id/Wayland activation token?

Seen in Konversation & NeoChat.
Comment 1 Nicolas Fella 2022-07-02 15:10:38 UTC
KNotification has a xdgActivationToken() method to allow activation on Wayland: https://api.kde.org/frameworks/knotifications/html/classKNotification.html#afc260039fdbdff0749c161a4cc17cabc

To be used in combination with KWindowSystem::setCurrentXdgActivationToken()

In theory that could also be used for X11 startup ids, but not sure everything is wired up for that.

How that behaves wrt virtual desktops is up to the window manager/wayland compositor
Comment 2 Nicolas Fella 2022-07-02 15:12:34 UTC
NeoChat has all of that wired up, so at least on Wayland it switches to the correct desktop when clicking a notification