-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix x11 taskbar icon/title #8132
Conversation
For clarity, here's an example image: The window icon has been change and the title to "some title". But the executable name "Python (v3.10)" still gets thrown to the top and the icon here wont change. The window itself is fine. Commit means the icon here is the same as the window, and "some title" here becomes the main title instead of the parent/child name layout. Also, I would really appreciate someone double checking the logic here. |
Are there any limitations on WM_CLASS? Like, must it only be low-ASCII characters or something? |
It supports an X11 string so latin-1, but not UTF-8. I suppose the commit can just use the title variable directly though. There is some talk about the same issue in SMFL. The thing is though that I've realised the same issue exist on Windows. |
SDL3 has the X11 WM_CLASS and Wayland app id rolled into the The class/app id aren't supposed to match the window title though; it's used by desktops for grouping windows together (e.g. all Firefox/Chrome windows appear under the same alt-tab icon because they have the same class/id). Additionally, while it defaults to the executable name if undefined, it really should be a string in reverse-DNS notation (com.my_company.my_app) with an accompanying |
Uh, do we need to handle this better in SDL3? |
The problem is that the WM_CLASS should be a two-part string. Currently the first part is always pulled from the current exe name (SDL_GetExeName) and the second part is pulled from SDL_GetAppID. (SDL_x11window.c line 631) The second part can be modified using the hint, but as far as I can see, the first part will always just taken from the exe name. In the case of calling SDL from a python interpreter, the interpreter is picked up as the executable. This means that any SDL windows are just grouped with every other python window on the desktop, related or unrelated to the current program. They all just take the python interpreter name and logo. As you say, simply pushing the window title to the taskbar is not an ideal solution. But it does break the link and make the current programs windows independent of some other python application on the machine. Is there a way to set this I'm not aware of? Else, some way to set this programmatically would be desirable. |
If I try your example in the linked issue and set the envvar
The X11 Anyway, setting the class to always match the window title will break packaging for many existing apps, so this pull is a no-go. |
Yes I see that, working now in SDL2 👍
Sorry to drag this on but can you confirm how this works in SDL3? I tried just setting this hint from Python and it didn't see to work as expected. There's some sample code here which I used:
If I run xprop on the window, I get
Agreed :) |
The example code has some bugs: window handles are pointers, not ints, and the parameter code for setting the icon was incorrect (it should be argtypes, plural). It works as expected for me with these fixes. I'm surprised it ran for you at all, as it was just crashing for me.
|
Ah that's so stupid. Thanks. Confirm it's working 👍 |
Currently on linux, the "taskbar window title" aka the X11 class property (
WM_CLASS
) is pulled from the executable name - which is reasonable but there is no way for clients to change it.Moreover, when making SDL calls from another language, for example Python, the python interpreter itself gets detected as the executable. This means that when opening a window in SDL called through Python, the window title will be according to the
SDL_CreateWindow
command, but the taskbar title will just be the Python interpreter.This also stops calls to set window icon from propagating correctly to the taskbar. No matter how the window icon changes, the taskbar icon will always be the python logo.
Proposed change is whenever the window title is set, to also change the
WM_CLASS
, updating the taskbar title to the current window title.Description
Whenever the window title is set/changed, the x11
WM_CLASS
is also changed to match.Existing Issue(s)
py-sdl/py-sdl2#268