Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux Qt5 version changes its WM_CLASS after startup, causing it to be unpinnable to taskbar #4246

Open
TiZ-HugLife opened this issue Jul 27, 2022 · 11 comments

Comments

@TiZ-HugLife
Copy link

Hi there. CudaText currently has some incorrect behavior after startup with regards to its own WM_CLASS property, which causes it to not be able to be pinned to the taskbar on KDE Plasma. During startup, as seen by Devilspie2 when its window is created, it has a correct value for the class field of WM_CLASS of "CudaText", but after startup, it changes it to "Untitled1 - CudaText", even if it's immediately opening a file.

Documentation for this property says that these values should not be changed. It seems like "Untitled1 - CudaText" is supposed to go into WM_NAME at some point, but instead it ends up in the class field of WM_CLASS.

This is a regression; it works in version 1.166.5, and does not work in 1.167.5. I tested by reverting the Flathub package. There was no build for 1.167.0 in Flathub to test against. It would not surprise me if this is a Lazarus bug.

@Alexey-T
Copy link
Owner

Alexey-T commented Jul 27, 2022

I will ask at Lazarus forum. for the last month, I have little different FPC+Lazarus setup on a different PC.

@Alexey-T
Copy link
Owner

Alexey-T commented Jul 28, 2022

Let's test on simplest demo.
src + compiled demo 'app':
tst_qt5_wm_class.zip

After you check one or both CheckBoxes, app writes 'app.ini'. On next start, it uses this ini-file and changes app title. Do you see bug with any of checkboxes On?

@TiZ-HugLife
Copy link
Author

TiZ-HugLife commented Jul 29, 2022

Here are my results for the test. First run, then with OnCreate checked, then with OnShow checked, and then with both checked.

❯ xprop WM_CLASS
WM_CLASS(STRING) = "app", "App"

~ 
❯ xprop WM_CLASS
WM_CLASS(STRING) = "app", "OnCreate - App"

~ 
❯ xprop WM_CLASS
WM_CLASS(STRING) = "app", "OnShow - App"

~ 
❯ xprop WM_CLASS
WM_CLASS(STRING) = "app", "OnShow - App"

So there's incorrect behavior in all cases. The second value of WM_CLASS is being changed to the window title, but that's not what it's for. It's supposed to be a consistent identifier for the app regardless of what its title is, as explained by the link I shared in the OP. The ICCCM docs explain it even more in depth, in addition to why there are two values. Firefox's WM_CLASS is "Navigator", "firefox". The second field is the application name.

With this minimal test case, you've shown that Lazarus's current behavior is wrong. Thank you for making that! :)

@TiZ-HugLife
Copy link
Author

Have the Lazarus folks responded about this? I have to stay back on 1.166.5 because of this issue. It's still present in 1.170.

@bogen85
Copy link
Contributor

bogen85 commented Sep 3, 2022

Interesting... I'll add what I see on this.

I'm running 1.170 via flatpak. I'm seeing the same thing.

$ wmctrl -xl | blah blah blah...
0x04000011  0 cudatext.Untitled1 - CudaText  MYHOSTNAME Untitled4 - CudaText

I installed the 1.170 via AUR on arch, and first time I ran it, I saw this:

$ wmctrl -xl | blah blah blah...
0x04000006  0 cudatext.(welcome) - CudaText  MYHOSTNAME (welcome) - CudaText

Second time, this:

$ wmctrl -xl | blah blah blah...
0x04000006  0 cudatext.Untitled1 - CudaText  MYHOSTNAME Untitled1 - CudaText

What is before MYHOSTNAME should be the WMCLASS
For instance:

$ wmctrl -xl | blah blah blah...
0x00e00003 -1 xfce4-panel.Xfce4-panel  MYHOSTNAME xfce4-panel
0x00e00009 -1 xfce4-panel.Xfce4-panel  MYHOSTNAME xfce4-panel
0x01c00007  0 virt-manager.Virt-manager  MYHOSTNAME Virtual Machine Manager
0x0460002b  0 Navigator.firefox     MYHOSTNAME Linux Qt5 version changes its WM_CLASS after startup, causing it to be unpinnable to taskbar · Issue #4246 · Alexey-T/CudaText — Mozilla Firefox

@bogen85
Copy link
Contributor

bogen85 commented Sep 3, 2022

$ flatpak list | fgrep CudaText
CudaText	io.github.cudatext.CudaText-Qt5	1.170.0	stable	system

$ pacman -Qs cudatext
local/cudatext-qt5-bin 1.170.0.0-0
    Cross-platform text editor, written in Lazarus. Qt5 edition.

@Alexey-T
Copy link
Owner

Alexey-T commented Sep 4, 2022

no reply to me on Laz forum - yet
I tried to find the Qt5 APIs which sets the 'class name' and found only some crap. if someone knows this qt5 API, tell me.

@TiZ-HugLife
Copy link
Author

TiZ-HugLife commented Nov 30, 2022

The current version of CudaText Qt5 is still exhibiting the incorrect behavior, but Plasma as of 5.25 (what's available in Kubuntu 22.04's backports-extra) seems to be working around it somehow.

I haven't been able to find any information on APIs in Qt for manipulating this. Regular Qt apps like Dolphin the file manager, Dolphin the emulator, and ProtonUp-Qt are doing the right thing. As far as I can tell, the various application classes within Qt will set the WM_CLASS of any windows created according to the application name you give them. Which tells me that not only is Lazarus doing things very wrong, it's going out of its way to do so.

@Alexey-T
Copy link
Owner

I still wait the reaction of Lazarus developer Zeljko.

@Alexey-T
Copy link
Owner

Alexey-T commented Feb 4, 2023

i am closing this, due to lacking of Laz dev reaction.

@Alexey-T Alexey-T closed this as completed Feb 4, 2023
@TiZ-HugLife
Copy link
Author

Uhhh... lack of reaction from the Lazarus developer doesn't mean the issue doesn't exist, it just means that the Lazarus developer sucks. I'm not sure I can trust any application built on Lazarus if the developer goes out of his way to break correct application behavior on Linux and doesn't respond to bringing it up.

@Alexey-T Alexey-T reopened this Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants