Git master everything KDE on top of Fedora KDE 37. Probably an activation protocol implementation issue. I know this works with my browser (Firefox) because it just implemented activation protocol support, and opening links from Thunderbird (which also recently implemented activation protocol support) raises Firefox.
Neochat does use xdg-activation when opening URLs and it works fine for me
Hmm, it's not working for me. Same thing when clicking on a notification background to raise NeoChat's window, in fact.
I've submitted a bug report on this before, but later closed it because it started working. But then it broke again. So it seems like the activation support is intermittent, not 100% for me.
How would one debug this?
And now both are working again, after being broken earlier today when I filed the bug report.
I can confirm that activation from notifications is flaky. Opening links works perfectly though.
I think I understand what's going on with notifications:
When clicking the notification Plasma requests a token and sends that to Neochat. Then the notification window closes and the active window changes from the notification window to whatever window you have open (*). KWin reacts to the active window changing (https://invent.kde.org/plasma/kwin/-/blob/master/src/xdgactivationv1.cpp#L58) and, after performing some checks, clears the currently active token. Then Neochat uses the received token to activate itself, but at that point the token KWin expects was already cleared and KWin denies the activation.
(*) That part seems racy and doesn't always happen. Adding a QThread::sleep(1) in https://invent.kde.org/network/neochat/-/blob/master/src/windowcontroller.cpp#L43 makes it easier to reproduce
Now why does switching focus to the open window clear the token? There are some checks that try to prevent that. One of them is comparing the input serials of the current token and newly focussed window: "if (window->lastUsageSerial() < m_currentActivationToken->serial)"
Plasma's notification code always sends 0 as input serial. This is because we call KWindowSytem::lastInputSerial() with a nullptr QWindow always: https://invent.kde.org/plasma/plasma-workspace/-/blob/master/libnotificationmanager/server.cpp#L69
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/2493
Git commit af0f73f13bb067b6ad28535f4ef14eb631303446 by Aleix Pol Gonzalez, on behalf of Aleix Pol.
Committed on 13/01/2023 at 11:05.
Pushed by apol into branch 'master'.
notifications: Improve activation infrastructure
The Wayland activation protocol xdg_activation_v1 requires us to send
the input serial that triggers the notification as one of the inputs. So
far we were always using 0 because it's not trivial to infer which
window is the one that triggers the action.
This change adds API to specify the calling window so this is not a
M +1 -0 applets/notifications/package/contents/ui/global/Globals.qml
M +1 -1 dataengines/notifications/notificationaction.cpp
M +22 -0 libnotificationmanager/abstractnotificationsmodel.cpp
M +6 -0 libnotificationmanager/abstractnotificationsmodel.h
M +1 -0 libnotificationmanager/abstractnotificationsmodel_p.h
M +15 -0 libnotificationmanager/notifications.cpp
M +12 -2 libnotificationmanager/notifications.h
M +5 -4 libnotificationmanager/notificationsmodel.cpp
M +5 -2 libnotificationmanager/server.cpp
M +12 -1 libnotificationmanager/server.h