wvdakker / gtkterm

GTKTerm: A GTK+ Serial Port Terminal
GNU General Public License v3.0
104 stars 35 forks source link

Using --class on the command line doesn't work in Wayland #55

Open beville opened 1 year ago

beville commented 1 year ago

I've been using Ubuntu 20.04 (using gtkterm 1.0.1) for my work machine for a while. I have a few ".desktop" files set up, so with a single click I could launch gtkterm with a few different profiles from disctinct dock icons. For example:

[Desktop Entry]
Encoding=UTF-8
Name=TTY USB0
Comment=Communicate with the serial port
Exec=gtkterm -c ttyusb0 --class="TTYUSB0"
Terminal=false
Type=Application
Categories=GNOME;Application;Utility;
Icon=gtkterm.png
X-AppStream-Ignore=true
StartupWMClass=TTYUSB0

By launching with the --class option and matching with the "StartupWMClass" in the desktop file, the dock launcher would only have one instance of that profile at a time, which is perfect for resources like serial ports.

I recently updated to Ubuntu 22.04 (running 1.1.1). I set up the same files and unfortunately the --class option doesn't seem to work now, so that the GUI shows a new app running in the dock.

I tested some other gtk applications (such as gparted) and using "--class still works.

Any thoughts on why this might have changed?

beville commented 1 year ago

Following up, I just tried copying the binary for 1.0.1 from an Ubuntu 20.04 system, and it seems to have the same new behavior. So maybe nothing changed on the app side. Maybe it's the GTK libraries? I'm a bit confused!

wvdakker commented 1 year ago

I browsed the original gtkterm source and source from the Ubuntu repository. --class is not a gtkterm command line parameter. I think it is more Ubuntu (Unity ?) kind of thing.

beville commented 1 year ago

Yeah, --class is a pass-through GTK option. Any GTK app will let you use that option, and I guess it's passed down via the application object.

I looked into this a bit more, and realized that I was using the Wayland desktop, not X.org. Restarting the desktop with X.org, and the classes work as expected.

You can see this by running the looking glass inspector (Alt+F2, then lg). If you select the windows tab, you see a list of windows including their "wmclass". Under X.org, I see my custom window class name for gtkterm, but under Wayland, it's the default class of "gtkterm".

Some notable other GTK apps that do support this under Wayland are gimp and gparted

No idea how this could be addressed, but maybe there's some call that could be done at the application level?

For now, I'll run under X.org.