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

SDL2 should default to "wayland" video driver #11748

Closed
ell1e opened this issue Dec 27, 2024 · 7 comments
Closed

SDL2 should default to "wayland" video driver #11748

ell1e opened this issue Dec 27, 2024 · 7 comments

Comments

@ell1e
Copy link
Contributor

ell1e commented Dec 27, 2024

Even for the old SDL2, the "wayland" video driver seems to be vastly superior when using a Wayland desktop. The X11 backend of SDL2 seems to have major touch bugs, and it can cause blurriness if XWayland is configured to not let legacy apps scale themselves which sadly is often needed due to misbehaving applications other than SDL2. Using SDL_VIDEODRIVER=wayland manually fixes all this, but since most users won't do that, it will leave them with an unnecessarily bad out of the box experience unless the default changes.

Edit: if the reason this wasn't done is libdecor perhaps not being as widely available yet as desired, perhaps the default should be changed such that it defaults to wayland if libdecor is available, rather than never.

Tested with SDL2 version: 2.30.9

Tested on system: postmarketOS 24.12 Linux

Tested with compositor: kwin_wayland 6.2.4

@Kontrabant
Copy link
Contributor

SDL 3 defaults to Wayland as long as the FIFO protocol is supported to ensure proper frame pacing and that apps/games won't possibly block presentation forever if the window is occluded.

Switching SDL 2 at this point in its lifecycle is not likely to happen, as it would potentially break clients that depend on X being the default, and such a potentially breaking change doesn't really make sense with the final SDL 3 release on the horizon.

@Kontrabant Kontrabant closed this as not planned Won't fix, can't repro, duplicate, stale Dec 27, 2024
@ell1e
Copy link
Contributor Author

ell1e commented Dec 27, 2024

On some Linux distributions, the X11 default just doesn't make too much sense even for legacy applications due to the touch problem. Is there an easy to maintain way to override the default in a way that won't affect SDL3? I assume setting SDL_VIDEODRIVER in /etc/environment will affect both. Edit: I think Fedora also changed it a while ago in their SDL2 copy somehow, don't ask me how, unless it was some other bug that caused that on my old Fedora machine a while back.

@ell1e
Copy link
Contributor Author

ell1e commented Dec 27, 2024

I personally find the touch behavior being plain broken and the blurry scaling to be both such big issues that I would never want my application to launch with X11 at this point if Wayland is available. I'm wondering now, can I set this on the application side in some way that won't force Wayland to be used when in some time future, some other default than Wayland and X11 should ever arrive?

@Kontrabant
Copy link
Contributor

Application-side, you can enumerate the available video drivers and set the driver hint programmatically. See SDL_GetVideoDriver and SDL_GetNumVideoDrivers,

@ell1e
Copy link
Contributor Author

ell1e commented Dec 27, 2024

As far as I can tell from the API overview there doesn't seem to be a way to get the default and only change it if it were to be X11 with Wayland available. In that case I could simply override the SDL_VIDEODRIVER hint after all if I detect the environment variable wasn't explicitly set by the user, but this would of course not be future proof since it would override SDL's default to all eternity no matter if it was X11 or not. That seems a little unsatisfactory.

@Kontrabant
Copy link
Contributor

Hints set as envvars will automatically override hints set by the application, unless you use SDL_SetHintWithPriority with SDL_HINT_OVERRIDE, so just set the hint as normal with SDL_SetHint, and if it was already set via an envvar, nothing will be overwritten.

Also, it took 40 years for X to be supplanted by Wayland, and the transition is still ongoing, so I don't think we have to worry about a migration from Wayland to whatever else in our working lifetimes :).

@ell1e
Copy link
Contributor Author

ell1e commented Dec 27, 2024

Well you never know, once apps are encouraged to overwrite this it's probably going to stay in there for a long time. This is why I think it might be a better idea to set a reasonable default. Given how many things break with X11 with SDL2, I don't think it's a good default in many cases.

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

No branches or pull requests

2 participants