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

Properly set window class in Wayland #92252

Merged
merged 1 commit into from
May 23, 2024

Conversation

poiati
Copy link
Contributor

@poiati poiati commented May 22, 2024

When using the Wayland display server, the window is initialized before the class is set. This means that every window has the same initial class as the Editor, making it impossible to create rules in compositors to, for instance, set the game window to a different monitor (this is important, as in Wayland, it's not possible to choose a monitor through the application).

Example: $ hyprctl clients

Master:

{
    "address": "0x5aedf5158070",
    "mapped": true,
    "hidden": false,
    "at": [1933, 748],
    "size": [1259, 679],
    "workspace": {
        "id": 1,
        "name": "1"
    },
    "floating": false,
    "monitor": 1,
    "class": "test",
    "title": "test (DEBUG)",
    "initialClass": "org.godotengine.Editor",
    "initialTitle": "Godot",
    "pid": 35734,
    "xwayland": false,
    "pinned": false,
    "fullscreen": false,
    "fullscreenMode": 0,
    "fakeFullscreen": false,
    "grouped": [],
    "swallowing": "0x0",
    "focusHistoryID": 1
}

This build:

{
    "address": "0x5aedf5178610",
    "mapped": true,
    "hidden": false,
    "at": [1933, 53],
    "size": [1259, 679],
    "workspace": {
        "id": 1,
        "name": "1"
    },
    "floating": false,
    "monitor": 1,
    "class": "test",
    "title": "test (DEBUG)",
    "initialClass": "test",
    "initialTitle": "Godot",
    "pid": 36466,
    "xwayland": false,
    "pinned": false,
    "fullscreen": false,
    "fullscreenMode": 0,
    "fakeFullscreen": false,
    "grouped": [],
    "swallowing": "0x0",
    "focusHistoryID": 1
}

@poiati poiati requested review from a team as code owners May 22, 2024 12:26
@@ -5501,7 +5501,7 @@ void DisplayServerWindows::tablet_set_current_driver(const String &p_driver) {
}
}

DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Error &r_error) {
DisplayServerWindows::DisplayServerWindows(const String &p_rendering_driver, WindowMode p_mode, VSyncMode p_vsync_mode, uint32_t p_flags, const Vector2i *p_position, const Vector2i &p_resolution, int p_screen, Context p_context, Error &r_error) {
KeyMappingWindows::initialize();
Copy link
Member

Choose a reason for hiding this comment

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

Note: Windows DisplayServer do the similar stuff with a local check (was done for the same reason, AppID should be set before showing window), with this PR merged, it can be changed to use context as well.

appname = "Godot.GodotEditor." + String(VERSION_BRANCH);

appname = "Godot.GodotEditor." + String(VERSION_BRANCH);

platform/linuxbsd/x11/display_server_x11.cpp Outdated Show resolved Hide resolved
platform/linuxbsd/x11/display_server_x11.cpp Outdated Show resolved Hide resolved
@Riteo
Copy link
Contributor

Riteo commented May 22, 2024

Mh that's interesting. I had no idea rules had an "initial" set of properties.

I'm not against the change, but I'm curious what stops people from using the non-initial window properties?

Copy link
Contributor

@Riteo Riteo left a comment

Choose a reason for hiding this comment

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

Anyways, the code looks nice and simple! Wayland/X11-side things look A-OK, but don't forget to also take into account bruvzg's review :)

@poiati
Copy link
Contributor Author

poiati commented May 22, 2024

Anyways, the code looks nice and simple! Wayland/X11-side things look A-OK, but don't forget to also take into account bruvzg's review :)

Hi Riteo,

In Hyprland, we have two types of window rules: static and dynamic. Static rules only take the initial properties, as they are executed when the window is instantiated. This is where I would select in which monitor I want to display the window, or whether I want it to be fullscreen or floating. Unfortunately, I cannot do that through dynamic rules, which read the current title and class. You can read more about it here: https://wiki.hyprland.org/Configuring/Window-Rules/.

PS: You did amazing work with the Wayland display server. Thank you!

@Riteo
Copy link
Contributor

Riteo commented May 22, 2024

@poiati

Unfortunately, I cannot do that through dynamic rules, which read the current title and class.

Makes perfect sense, thanks for clarifying!

PS: You did amazing work with the Wayland display server. Thank you!

You're welcome :D

There's still a lot to do and your testing and contribution is very appreciated!

@akien-mga akien-mga merged commit 7870b28 into godotengine:master May 23, 2024
16 checks passed
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants