Web lists-archives.com

PSA: how to prepare apps for non-Plasma X-based shells and their app panels


quick heads-up for anyone maintaining applications which also target non-
Plasma shells (X-based, no issue with wayland-based systems):

TL;DR  Make sure to have "StartupWMClass=myapp" in the (main) application 
desktop file if both WM_CLASS properties of the application window do _not_ 
match in lowercased version the basename of the application desktop file. 
This enables non-Plasma shells map the application windows to application 
menu entries (e.g. on the panel)

Your (Qt/KF-based) application should also properly integrate with non-Plasma 
shells? If so, here another thing to check if you haven't yet:

1. start your application
2. start "xprop WM_CLASS" on the commandline and click the app window with 
the cross mouse cursor

Example output for Okular:
WM_CLASS(STRING) = "okular", "okular"

3. check the basename of the (main) desktop file of your application (the one 
which matches the desktop file name you register to the QApplication, either 
via KAboutData::setApplicationData() or directly via 
QGuiApplication::setDesktopFileName(), see also result of "xprop 

Example for Okular:

This mismatch is a challenge for non-Plasma shells. We need to help them here 
over it, by adding another line to the application desktop file, which 
matches the second entry (or the first, seems both supported) of WM_CLASS. As 
this is what they/some use then for mapping windows to applications.

Example for Okular:
org.kde.okular.desktop gets a new line:

Once this is done, Gnome Shell & Co. should properly map windows/running 
instances to launcher entries.

BTW, while you touch the desktop files, you might also want to change keys 
"X-KDE-StartupNotify" to "StartupNotify", given this key is official part of 
the desktop specification since >10 years. It's not totally clear which 
shells support the official key properly besides Plasma, but if they start to 
do, better start to help them now already.

Cmp. https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html#recognized-keys

While in wayland-based systems the desktop id (i.e. the name of an 
application's desktop file name) is used by design to map windows to 
registered applications, there is no same thing for X-based systems.
While there was a proposal to use also something desktop-file-based by KDE 
developers, this was not picked up by the full XDG team, only Plasma/
KWindowSystems implemented support for this (cmp. also the "_KDE" prefix of 
the "_KDE_NET_WM_DESKTOP_FILE" property set on windows of Qt-based apps 
running with the Plasma QPA).
Possibly everyone looking forward to "wayland fixes it" and not investing 
more resources into the X-based solutions. So applications have to go and 
embrace what works on such systems.

See also related discussion with some insights:

Disclaimer: all above written as result of research in last 2 days, small 
chance I missed a detail, so best test before applying any related changes.