Skip to content

sdl_glimp: set APPID as WMCLASS on Linux #1702

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

Merged
merged 1 commit into from
Jul 23, 2025
Merged

Conversation

illwieckz
Copy link
Member

Let X11 and Wayland desktops (Linux, FreeBSD…) display the game name on the game windows instead of the engine binary name. This also makes possible to display the correct icon if that WMCLASS is also set in the net.unvanquished.Unvanquished.desktop file.

@illwieckz
Copy link
Member Author

To get the icon properly displayed we need to update the desktop file installed by the updater, but this is enough to make the game name properly displayed.

@illwieckz
Copy link
Member Author

illwieckz commented Jul 19, 2025

I also added the SDL_HINT_APP_ID variable, which is used by SDL3 instead of SDL_VIDEO_X11_WMCLASS and SDL_VIDEO_WAYLAND_WMCLASS from SDL2. We're not using SDL3 yet but this way we are ready. Also some people are already using the SDL2 compatibility layer of SDL3 and maybe the APPID is already supported this way.

See: libsdl-org/SDL@2f75596

@slipher
Copy link
Member

slipher commented Jul 19, 2025

I wondered which desktops do this. Apparently GNOME is one.

@illwieckz illwieckz force-pushed the illwieckz/wmclass branch from 3960a72 to 952ac85 Compare July 19, 2025 17:05
@illwieckz
Copy link
Member Author

Our problem is that the desktop file is starting the updater binary that then launches the daemon binary… So we need some way to let the desktop knows what is what.

It would be good to find a similar mechanism to implement in the updater too. On my end GNOME fails to associate the Unvanquished launcher icon with both the updater window and the engine windows.

@slipher
Copy link
Member

slipher commented Jul 19, 2025

Our problem is that the desktop file is starting the updater binary that then launches the daemon binary… So we need some way to let the desktop knows what is what.

Why is this a problem? According to the SO link, GNOME doesn't know or care which desktop file was used to launch the program. The updater desktop file already uses the name "Unvanquished" and the standard Unvanquished icon. Supposing we associate the updater's desktop file with both applications, the only nicety we would lack is the updater would use the standard icon rather than the updater variant with the little arrows.

name on the game windows instead of the engine binary name. This also
makes possible to display the correct icon if that WMCLASS is also set
in the net.unvanquished.Unvanquished.desktop file. */
Sys::SetEnv( "SDL_VIDEO_X11_WMCLASS", PRODUCT_NAME );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should also be PRODUCT_APPID

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh lol, I did not noticed that the default WMCLASS was the APPID, which makes sense btw.

So now all those hints are using PRODUCT_APPID.

This has the side effect of displaying net.unvanquished.Unvanquished in the taskbar if there is no XDG icon though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the side effect of displaying net.unvanquished.Unvanquished in the taskbar if there is no XDG icon though.

This is probably a bug of the GNOME extension I use. The window name is set properly by SDL_CreateWindow() and is properly displayed in the window title bar and in the GNOME Shell application overview.

@illwieckz illwieckz force-pushed the illwieckz/wmclass branch 2 times, most recently from f8a78d8 to 0cc8b42 Compare July 21, 2025 10:04
@slipher
Copy link
Member

slipher commented Jul 23, 2025

LGTM. Setting SDL_VIDEO_WAYLAND_WMCLASS works for me for setting the icon while using Wayland with KDE.

@illwieckz illwieckz force-pushed the illwieckz/wmclass branch from 0cc8b42 to 1d60d74 Compare July 23, 2025 15:32
@illwieckz illwieckz changed the title sdl_glimp: set PRODUCT_NAME as WMCLASS on Linux sdl_glimp: set APPID as WMCLASS on Linux Jul 23, 2025
@illwieckz
Copy link
Member Author

I only reworded the comment a bit.

@illwieckz illwieckz merged commit d19a2a2 into master Jul 23, 2025
9 checks passed
@illwieckz illwieckz deleted the illwieckz/wmclass branch July 23, 2025 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants