Bug 441005 - kwin doesn't read WM_CLASS with a single string (bitwig studio)
Summary: kwin doesn't read WM_CLASS with a single string (bitwig studio)
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: rules (show other bugs)
Version: 5.22.4
Platform: Other Linux
: NOR minor
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-15 14:03 UTC by lars
Modified: 2021-08-28 05:27 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.23
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lars 2021-08-15 14:03:22 UTC
SUMMARY
kwin can't read WM_CLASS of a specific application (bitwig studio), even though xprop can. Because of this, i have to use the window title to create an application rule, which could potentially break.

STEPS TO REPRODUCE
1. install bitwig studio and launch the application in demo or guest mode
2. open system settings and navigate to Window Management -> Window Rules -> New -> Detect Window Properties and click the bitwig studio window.
3. open a terminal, run xprop and click the bitwig studio window

OBSERVED RESULT
xprop correctly shows "WM_CLASS(STRING) = 'com.bitwig.BitwigStudio'", which is exactly what is specified in the .dekstop file. kwin however returns "()" as window class.

EXPECTED RESULT
kwin should be able to read the WM_CLASS just like xprop

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Kubuntu 20.04.2 LTS
(available in About System)
KDE Plasma Version: 5.18.5
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8

ADDITIONAL INFORMATION
1. The Bitwig GUI is written in Java as far as i know, and the window also has no title bar.
2. Im new to KDE and Linux in general as well as bug reporting so please excuse me if this has been fixed. I searched for a bit but i couldn't find a similar issue. Im on Kubuntu 20.04.2 LTS, which means that kwin is stuck in version 5.18.5. No idea if this has been fixed since.
Comment 1 Nate Graham 2021-08-16 18:00:02 UTC
Window rules have changed a lot since Plasma 5.18. Any chance you can try again with 5.22? Kubuntu 21.04 with the backports PPA should have it.
Comment 2 lars 2021-08-23 09:31:35 UTC
I just upgraded to 5.22 using the backport PPA but the issue still persists.

The exact version numbers in the system settings are now:
KDE Plasma Version 5.22.4
KDE Frameworks Version 5.85.0
Qt Version 5.15.2
Kernel Version 5.11.0-31-generic (64-bit)
Graphics Platform X11

kwin -v also reports 5.22.4
Comment 3 lars 2021-08-23 09:33:26 UTC
Should i update the kwin version in the initial bug report or is it fine to leave it for now?
Comment 4 Nate Graham 2021-08-23 15:13:44 UTC
Darn, thanks for checking. We can update the version.
Comment 5 Ismael Asensio 2021-08-23 18:25:53 UTC
Can reproduce.

The information we retrieve from the window has in fact the relevant fields empty:

> qdbus org.kde.KWin /KWin org.kde.KWin.queryWindowInfo
caption: Bitwig Studio - New 1
clientMachine: localhost
resourceClass: 
resourceName: 
. . .

Investigating into the issue, while xprop reports a string for WM_CLASS, the application is not fully following the X.org specification, as `WM_CLASS` should have two null-terminated strings, instead of just one, the `instance` and the `class` (excerpt of the spec here:
https://unix.stackexchange.com/questions/494169/wm-class-vs-wm-instance).

This is probably what's causing the issue. I haven't still find where the information is loaded to see if we could maybe use that single string.

It also happens on Wayland session, since it loads via XWayland.
Comment 6 Bug Janitor Service 2021-08-23 19:12:33 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kwindowsystem/-/merge_requests/32
Comment 7 lars 2021-08-23 21:11:01 UTC
Wow, thanks for following up on this so fast :)

I just wrote a mail to Bitwig's support, describing the issue to them and linking the specification. Please hit me up if there's anything else I can do or test.
Comment 8 lars 2021-08-26 17:24:19 UTC
I've shortly read the conversation you had over at the merge request. While you could argue that it is Bitwigs fault in this case, I would also argue that its possible to read the data correctly, as xprop shows. So why wouldn't we include this fallback? It would definitively be helpful with future applications that fail to meet spec. Just my two cents.
Comment 9 Nate Graham 2021-08-27 16:22:45 UTC
Git commit 8bba48ba30009713f54990d880a4e0e4513386a4 by Nate Graham, on behalf of Ismael Asensio.
Committed on 27/08/2021 at 16:22.
Pushed by ngraham into branch 'master'.

Read uncomplete WM_CLASS string

While X.org spec tells that WM_CLASS must contain two
null-terminated strings (the instance and the class),
some thrid party applications may not fully comply with this.

In that case, use the single string provided for both fields:
`resourceName` and `resourceClass`, instead of leaving them empty.
Those fields having the same string is fairly common also on
well-behaved apps.

M  +3    -0    src/platforms/xcb/netwm.cpp

https://invent.kde.org/frameworks/kwindowsystem/commit/8bba48ba30009713f54990d880a4e0e4513386a4
Comment 10 lars 2021-08-28 05:27:42 UTC
Thank you very much <3