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 --fullscreen does resize properly under XWayland and Wayland without libdecor
  • testgles2 --fullscreen resizes properly under Wayland with libdecor
  • Adding --resizable fixes resizing under Wayland with libdecor

Reproduced on: cfcdfb7

Steps to reproduce:

  1. SDL_VIDEODRIVER=wayland ./testgl2 --fullscreen
  2. Press Ctrl+Enter to exit fullscreen

Without libdecor, after exiting fullscreen: Screenshot from 2021-08-01 19-22-19

With libdecor, aftering exiting fullscreen: Screenshot from 2021-08-01 19-21-52

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 21 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Why do you have to wl_display_dispatch when 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’s simple-egl example. It only uses dispatching in the main loop. A more complex weston example is window.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_commit is 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.