SDL icon indicating copy to clipboard operation
SDL copied to clipboard

[SDL3] SDL_SetWindowFullscreenMode() implementation seems inconsistent and unreliable

Open WH473V37 opened this issue 7 months ago • 6 comments

1920 x 1080 display. OpenGL window. SDL_SetWindowFullscreenMode() used to set fullscreen window to 1280 x 720. SDL version application is compiled with is 3.2.8, ran with 3.2.10 too, same results. Fedora 41, Gnome 47, tried wlroots based labwc too, same result for Wayland.

X11.

  • [x] SDL_GetDesktopDisplayMode() gives 1920 x 1080.
  • [ ] SDL_GetCurrentDisplayMode() gives 1920 x 1080. Not good.
  • [x] SDL_GetWindowFullscreenMode() gives 1280 x 720. The display actually changes resolution this is good.
  • [x] SDL_GetWindowSizeInPixels() gives 1280 x 720. Good.
  • [x] Running SDL_SyncWindow() after does not change the resolution. Good.

Wayland.

  • [x] SDL_GetDesktopDisplayMode() gives 1920 x 1080.
  • [ ] SDL_GetCurrentDisplayMode() gives 1920 x 1080. Not good!? (is actually kind of true)
  • [ ] SDL_GetWindowFullscreenMode() gives 1280 x 720. The display does not actually change resolution, some type of emulation going on. Not good!?
  • [ ] SDL_GetWindowSizeInPixels() gives 1280 x 720. Not good!?
  • [ ] Running SDL_SyncWindow() after sets the fullscreen window to 1920 x 1080. Not good.

The issues with these outputs that are already not obvious.

  1. On Wayland, the resolution of main frame buffer is actually 1920 x 1080, while on X11 it is 1280 x 720, so doing something simple like blitting off-screen 1280 x 720 buffer to 1280 x 720 main buffer based on SDL_GetWindowSizeInPixels() or even SDL_GetWindowFullscreenMode() does not work on Wayland (black besides bottom-left 1280 x 720), works on X11.

  2. Blitting to 1920 x 1080 buffer based on SDL_GetCurrentDisplayMode() works on Wayland, does not on X11 (cut off).

  3. Should the wiki of SDL_SetWindowFullscreenMode() say it changes display mode, when it does not?

  4. Finally what value should I rely on for getting the correct pixel dimensions to use for blitting and similar?

Hope these are actually bugs, and not me missing something obvious, thank you! :)

WH473V37 avatar Apr 26 '25 23:04 WH473V37

Update.

Just updated to Fedora 42, for Wayland the output values I shared are same, however good or weird they look, BUT no issues like before at all, I use the SDL_GetWindowSizeInPixels() for the blit area and mouse coordinates and stuff, and without any change, everything seems to work as expected now.

No X11 option for Gnome here, so can not check that yet. Will try and update.

Likely not an SDL issue, at least not in full.

WH473V37 avatar Apr 27 '25 04:04 WH473V37

Managed to get X11 to test. Plus more Wayland with wlroots based labwc.

Gnome on Xorg. (X11)

SDL_GetCurrentDisplayMode() now gives 1280 x 720. Changes display resolution and works perfectly as expected.

Openbox. (X11)

~~Both SDL_GetDesktopDisplayMode() and SDL_GetCurrentDisplayMode() gave 1280 x 720, did not reset the display mode to original 1920 x 1080 while quitting.~~ Seems good after compiling the latest SDL release.

labwc. (Wayland)

SDL_GetCurrentDisplayMode() now gives 1280 x 720, everything else same, but issue persists, where only the bottom left 1280 x 720 is filled with the render, rest black.

No code changes, the area of the main buffer (provided by SDL) I am blitting to is 1280 x 720 based on SDL_GetWindowSizeInPixels(), for every situation I mentioned.

Fresh install, older intel igpu.

I am confused, more and more seems like not SDL issue!? but not sure.

WH473V37 avatar Apr 27 '25 05:04 WH473V37

Just updated to Fedora 42, for Wayland the output values I shared are same, however good or weird they look, BUT no issues like before at all, I use the SDL_GetWindowSizeInPixels() for the blit area and mouse coordinates and stuff, and without any change, everything seems to work as expected now.

This is probably related to #12451. XWayland seems to have broken mode switching emulation at some point, and Fedora 42 works because it defaults to the Wayland backend and uses SDL's own mode switching emulation instead of XWayland.

Kontrabant avatar Apr 28 '25 18:04 Kontrabant

Got it, I am not sure what the program was using at the time for sure, but I can share that I was using Wayland, like was logged into a Wayland session, and vaguely remember reading somewhere that SDL3 defaults to Wayland when available.

Just noticed another issue, however not as concerning in my view, on Gnome.

if I set the window to full screen twice before a call to SDL_SetWindowFullscreenMode(), the render area scales in opposite way on Gnome, can be a call to SDL_SetWindowFullscreen() with true twice, or once with true after the initial window creation call with SDL_WINDOW_FULLSCREEN flag (which I believe does the same thing). details;

With labwc, the 1280 x 720 render area stay the same and fill only bottom-left part of the screen, everything else black. Nothing changed.

With Gnome, everything works fine besides the outputs in normal situation, but if this situation is triggered, only part of the render (bottom-left) fills the whole screen, everything else cut off. ~~I am not sure if the render resolution is still 1280 x720 or that changed too~~.

No changes with outputs.

Quick summary for experienced peeps trying to figure out the issue, X11 seems good with latest everything I could get, some Wayland issues remains.

WH473V37 avatar Apr 29 '25 21:04 WH473V37

For me SDL_GetDesktopDisplayMode seems inconsistent

Ubuntu 25.04 2 4K displays

X11

display 1: 3840x2160 (refreshRate=59.98)
display 2: 3840x2160 (refreshRate=59.98)

Wayland

display 3: 1920x1080 (refreshRate=59.99)
display 4: 1920x1080 (refreshRate=59.99)

SDL_GetFullscreenDisplayModes returns the same list for both drivers

francisdb avatar May 22 '25 09:05 francisdb

Wayland desktop dimensions are in scaled points, so a 4k display at 200% scaling will appear as 1920x1080.

Kontrabant avatar May 22 '25 11:05 Kontrabant