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

Only set GDK_BACKEND to "x11" if GDK_BACKEND is unset and XDG_SESSION_TYPE is not "wayland" #1811

Merged
merged 2 commits into from
Aug 31, 2022

Conversation

prurigro
Copy link
Contributor

@prurigro prurigro commented Aug 31, 2022

The existing logic always sets the GDK_BACKEND variable to x11, which prevents the application from using the wayland backend (or running at all in a wayland compositor if xwayland is unavailable). The reason this logic is present is because windows would fail to centre without it, so we need to keep the behaviour in x11 sessions.

The GDK_BACKEND variable can and typically should remain unset in a wayland session, and the XDG_SESSION_TYPE variable is usually set and can have a value of unspecified, tty, x11, wayland or mir.

The logic in the patch is as follows; if the system has already set the GDK_BACKEND variable, we should assume that it knows what it's doing and keep the existing value. If the GDK_BACKEND variable is empty however, we check to see if the XDG_SESSION_TYPE variable is set to wayland, and if it is we shouldn't touch the GDK_BACKEND variable. If the XDG_SESSION_TYPE variable is not set to wayland though, we can assume we're most likely in an x11 environment in those cases. If we're in an x11 environment, we set GDK_BACKEND to x11 and windows can be centred :)

I tested this in x11 and wayland with xwayland disabled using all combinations of XDG_SESSION_TYPE and GDK_BACKEND being set appropriately, inappropriately and being unset, and got the expected behaviour in all cases.

This resolves #1420

@prurigro
Copy link
Contributor Author

I just pushed a second commit to this PR after deciding that GDK_BACKEND probably also shouldn't be overridden if XDG_SESSION_TYPE is mir, tty or some future session type. Rather than ensure it isn't wayland, it now ensures it is either unset, unspecified or x11.

I also ran another set of tests to make sure everything is still working as expected.

Copy link
Member

@leaanthony leaanthony left a comment

Choose a reason for hiding this comment

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

Thanks so much for this! I think this is a more than acceptable way of dealing with the different backends 👍

@leaanthony leaanthony merged commit 27f36a8 into wailsapp:master Aug 31, 2022
stendler added a commit to stendler/wails that referenced this pull request Jul 15, 2024
Incorporated from this v2 change:
wailsapp#1811
stendler added a commit to stendler/wails that referenced this pull request Jul 21, 2024
Incorporated from this v2 change:
wailsapp#1811
stendler added a commit to stendler/wails that referenced this pull request Jul 22, 2024
Incorporated from this v2 change:
wailsapp#1811
stendler added a commit to stendler/wails that referenced this pull request Jul 22, 2024
Incorporated from this v2 change:
wailsapp#1811
stendler added a commit to stendler/wails that referenced this pull request Jul 22, 2024
Incorporated from this v2 change:
wailsapp#1811
stendler added a commit to stendler/wails that referenced this pull request Jul 22, 2024
Incorporated from this v2 change:
wailsapp#1811
stendler added a commit to stendler/wails that referenced this pull request Jul 22, 2024
Incorporated from this v2 change:
wailsapp#1811
stendler added a commit to stendler/wails that referenced this pull request Jul 22, 2024
Incorporated from this v2 change:
wailsapp#1811
github-actions bot pushed a commit to stendler/wails that referenced this pull request Jul 22, 2024
Incorporated from this v2 change:
wailsapp#1811
stendler added a commit to stendler/wails that referenced this pull request Jul 22, 2024
Incorporated from this v2 change:
wailsapp#1811
github-actions bot pushed a commit to stendler/wails that referenced this pull request Jul 29, 2024
Incorporated from this v2 change:
wailsapp#1811
github-actions bot pushed a commit to stendler/wails that referenced this pull request Aug 1, 2024
Incorporated from this v2 change:
wailsapp#1811
github-actions bot pushed a commit to stendler/wails that referenced this pull request Aug 5, 2024
Incorporated from this v2 change:
wailsapp#1811
github-actions bot pushed a commit to stendler/wails that referenced this pull request Aug 12, 2024
Incorporated from this v2 change:
wailsapp#1811
github-actions bot pushed a commit to stendler/wails that referenced this pull request Aug 19, 2024
Incorporated from this v2 change:
wailsapp#1811
github-actions bot pushed a commit to stendler/wails that referenced this pull request Aug 22, 2024
Incorporated from this v2 change:
wailsapp#1811
stendler added a commit to stendler/wails that referenced this pull request Aug 23, 2024
Incorporated from this v2 change:
wailsapp#1811
stendler added a commit to stendler/wails that referenced this pull request Aug 23, 2024
Incorporated from this v2 change:
wailsapp#1811
leaanthony pushed a commit that referenced this pull request Aug 25, 2024
fix: enable to run natively in wayland

Incorporated from this v2 change:
#1811
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.

[v2] [Linux] Feat - Wayland Support
2 participants