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

SetWindowTitle should properly set CLASS_NAME and INSTANCE_NAME on X11 platforms #2904

Closed
3 of 11 tasks
elee1766 opened this issue Feb 7, 2024 · 5 comments
Closed
3 of 11 tasks

Comments

@elee1766
Copy link

elee1766 commented Feb 7, 2024

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

What feature would you like to be added?

SetWindowTitle should properly set CLASS_NAME and INSTANCE_NAME on X11

in the case of GLFW, which is the default backend being used for x11, this is not happening. one can see using xprop that the class_name and instance_name are the defaults, despite a custom title having been set.

image

two things need to be done

  1. initial WINDOW_HINTS when creating the glfw window here https://github.com/hajimehoshi/ebiten/blob/main/internal/glfw/x11_window_linbsd.c#L781-L793
  2. change WINDOW_HINTS when SetWindowTitle is called, perhaps using this function https://github.com/hajimehoshi/ebiten/blob/main/internal/glfw/window_unix.c#L376

Why is this needed?

on X11, it is standard for programs to differentiate themselves to the WM or other applications via their window and instance class.

the most common use is for window managers to read the initial window hints in order to perform different behaviors, for instance, starting an application in windowed, tiled, fullscreen mode, a specific desktop, etc.

window_class/instance is also sometimes used to identify applications for automation. technically, "instance" should be unique and "class" not necessarily unique, though these conventions are hardly followed.

can read more here:
https://tronche.com/gui/x/icccm/sec-4.html#WM_CLASS

https://manpages.ubuntu.com/manpages/bionic/man3/X11::Protocol::WM.3pm.html (ctrl-f WM_CLASS)

@tinne26
Copy link

tinne26 commented Feb 7, 2024

While I agree that this would be nice to have, I think a new RunGameOptions field would be a more suitable target than SetWindowTitle. Some programs will use the title for changing values, like indicating the latest changes haven't been saved with a *, indicating the current scene / status, debugging fps or others. Also, they might include emojis or other characters that you wouldn't generally want on the internal window name. To me, the internal window name should be customizable but more static in nature. I would be against coupling it to the window title.

@elee1766
Copy link
Author

elee1766 commented Feb 7, 2024

While I agree that this would be nice to have, I think a new RunGameOptions field would be a more suitable target than SetWindowTitle. Some programs will use the title for changing values, like indicating the latest changes haven't been saved with a *, indicating the current scene / status, debugging fps or others. Also, they might include emojis or other characters that you wouldn't generally want on the internal window name. To me, the internal window name should be customizable but more static in nature. I would be against coupling it to the window title.

I agree it makes more sense to me to have a separate field. if that's the case it probably makes sense to allow setting a separate instance and class as well?

@hajimehoshi
Copy link
Owner

While we can provide such API, this API would work only on Linux (and other UNIX family). Let me implement this to sync with the window title so far, and let's revisit Tinne's idea later.

@hajimehoshi
Copy link
Owner

hajimehoshi commented Feb 11, 2024

On second thought, as GLFW provides separate options for a class name and an instance name, providing this as different options sounds better. Hmm 🤔

@hajimehoshi
Copy link
Owner

Added RunOptions.X11ClassName and RunOptions.X11InstanceName.

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