SDL: wayland libdecor: testgl2 fails to resize after leaving fullscreen
When exiting fullscreen on GNOME 40 under Wayland when SDL is built with libdecor, testgl2 --fullscreen does not resize the window back to 640x480.
Some interesting observations:
testgl2 --fullscreendoes resize properly under XWayland and Wayland without libdecortestgles2 --fullscreenresizes properly under Wayland with libdecor- Adding
--resizablefixes resizing under Wayland with libdecor
Reproduced on: cfcdfb7
Steps to reproduce:
SDL_VIDEODRIVER=wayland ./testgl2 --fullscreen- Press Ctrl+Enter to exit fullscreen
Without libdecor, after exiting fullscreen:

With libdecor, aftering exiting fullscreen:

About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21 (7 by maintainers)
Commits related to this issue
- wayland: Only dispatch on fullscreen set when the window is visible. Fixes hang-on-startup described in #4572. — committed to libsdl-org/SDL by flibitijibibo 3 years ago
Why do you have to
wl_display_dispatchwhen setting fullscreen? I think you should as much as possible avoid flushing and dispatching the file descriptor to prevent undesired effects.If you search the GTK3 source code, you will find that it dispatches only twice: Once blocking (
wl_display_dispatch) when the Wayland connection is established (_gdk_wayland_display_open), and once non-blocking (wl_display_dispatch_pending) when “feeding” the events. The same for weston’ssimple-eglexample. It only uses dispatching in the main loop. A more complex weston example iswindow.c, which implements a small toolkit and also just dispatches in the main loop. This toolkit is closer to SDL’s functionality than the standalone examples.I seriously recommend to have a look at these reference implementations of how to use the Wayland event loop and apply this to SDL. You will also see that
wl_surface_commitis only used sparely after creating a new surface and after the painting of surfaces is finished. This makes sure that there are not glitches with intermediate surface and buffer states. Only if you do it this way, “every frame will be perfect”.So please, don’t dispatch, flush and commit throughout the state changes. Only do these things when really necessary and when they are intended to be used. This will make the Wayland implementation much more stable a visually pleasing with less glitches.
Edit: For debugging the Wayland communication on the file descriptor, you can set
WAYLAND_DEBUG=1, e.g.WAYLAND_DEBUG=1 weston-simple-egl. This will print all requests and events. So it is easily visible when fullscreen is requested or when configure events (including the suggested surface dimensions) are received.