We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3948

Summary: [patch] Wayland: SDL applications start in XWayland by default
Product: SDL Reporter: Andrey Alexeyev <akari>
Component: videoAssignee: Ryan C. Gordon <icculus>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: akari, david, icculus
Version: 2.0.10   
Hardware: x86_64   
OS: Linux   
Bug Depends on: 4845    
Bug Blocks:    
Attachments: prefer-wayland-over-x11.patch

Description Andrey Alexeyev 2017-11-07 21:42:34 UTC
This is because SDL prefers the X11 driver. If XWayland is running on the default display, SDL will happily settle for it, even if the Wayland driver could be used instead.

This is far from ideal. I've experienced subpar performance and visual artifacts, both specific to XWayland, in my OpenGL game.

Applications can work around this by attempting to initialize video with the Wayland driver explicitly first.

This issue probably applies to every other video system where an X11 compatibility layer could be present, e.g. Mir, though I haven't tested that.

Simply moving X11 lower on the priority list should fix this.
Comment 1 David Heidelberg (okias) 2019-10-23 14:07:49 UTC
I believe this patch [1] solves this issue. It's took from new linux Librem 5 phone gitlab [2].

Since two years passed and Wayland became preferred solution in Linux world, would make sense to prefer it over X11 backend?

[1] https://source.puri.sm/Librem5/libsdl2/raw/997f974c1d0a3acb869cee956c06ba33480f5e58/debian/patches/prefer-wayland-over-x11.patch
[2] https://source.puri.sm/Librem5/libsdl2/commit/997f974c1d0a3acb869cee956c06ba33480f5e58
Comment 2 David Heidelberg (okias) 2019-10-23 14:14:00 UTC
Created attachment 4017 [details]
prefer-wayland-over-x11.patch
Comment 3 Ryan C. Gordon 2019-10-23 16:49:05 UTC
(In reply to David Heidelberg (okias) from comment #1)
> Since two years passed and Wayland became preferred solution in Linux world,
> would make sense to prefer it over X11 backend?

SDL's wayland target needs client-side decorations in some form, at a minimum, before it can be favored over X11.

This is definitely not going to happen for 2.0.12.

--ryan.