Set WM_CLASS X11 hints
Posted: Mon Sep 10, 2018 2:03 pm
TL;DR
Set the WM_CLASS hints on the Factorio game window to allow for automatic window management.What ?
As it stands right now, these are the relevant hints set on the game window post-launch:Code: Select all
WM_NAME(UTF8_STRING) = "Factorio 0.16.51"
WM_CLASS(STRING) = "", ""
The WM_CLASS hints, commonly referred to as application "instance" and "class" (notice both are empty in the example), are used by window managers to sort windows. This is not very often seen in Gnome or KDE, but is used all the time in window managers such as i3.
In applications that spawn multiple windows, "class" remains stable, while "instance" changes depending on the type of window spawned. For example, Firefox sets class to Firefox and the main window to Navigator, allowing me to easily set WM rules for it separately from pop-ups.
In the case of Factorio, which does not spawn additional external windows, I would suggest either setting both to "Factorio", or something like "Factorio" and "Game".
This generally involves something like this, but many UI frameworks will offer facilities, but many also make the mistake of setting these hints after creating the window, which is completely useless.
I point this out because Factorio sets WM_NAME post-launch, for example. Many cross-platform UI toolkits make this mistake, sadly.
Why ?
i3 allows for dynamic tagging, a parallel to virtual desktops. I move the factorio window to a dedicated tag (virtual desktop) so that I can keep the game out of the way, but allowing me to switch to it without affecting the layout of other tags. The window manager can do this automatically for me, by reading WM Hints when a window is spawned. I can match on WM_NAME, but this is fiddly, because matching on, for example, /^Factorio\s/ will also match other things like a browser window that has a tab open with a name starting with "Factorio ". WM_CLASS is more reliable, but Factorio does not set these hints.Given that only users of Linux and sort of esoteric window managers will actually care, you might argue that this is in fact a low-value proposition. However, it is also relatively low-effort, assuming your UI toolkit isn't one of the stupid ones. And the benefit to those users is an immense improvement in quality of life. But more than that, I would personally love you a lot!