Commit 871c11191bfc7214061a3da37c112522a102ddf5

Ryan C. Gordon 2021-07-27T18:24:09

wayland: handle pending resizes immediately, not on SwapWindow. This was originally a workaround for an old Mesa bug, since fixed, apparently, and causes other problems. Fixes #4326.

diff --git a/src/video/wayland/SDL_waylandopengles.c b/src/video/wayland/SDL_waylandopengles.c
index f4736e1..55cd789 100644
--- a/src/video/wayland/SDL_waylandopengles.c
+++ b/src/video/wayland/SDL_waylandopengles.c
@@ -148,9 +148,6 @@ Wayland_GLES_SwapWindow(_THIS, SDL_Window *window)
         return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers");
     }
 
-    // Wayland-EGL forbids drawing calls in-between SwapBuffers and wl_egl_window_resize
-    Wayland_HandlePendingResize(window);
-
     WAYLAND_wl_display_flush( data->waylandData->display );
 
     return 0;
diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c
index 344de83..81d1607 100644
--- a/src/video/wayland/SDL_waylandwindow.c
+++ b/src/video/wayland/SDL_waylandwindow.c
@@ -164,6 +164,9 @@ static const struct wl_callback_listener surface_frame_listener = {
     handle_surface_frame_done
 };
 
+
+static void Wayland_HandlePendingResize(SDL_Window *window);
+
 static void
 handle_configure_xdg_shell_surface(void *data, struct xdg_surface *xdg, uint32_t serial)
 {
@@ -198,9 +201,7 @@ handle_configure_xdg_shell_surface(void *data, struct xdg_surface *xdg, uint32_t
         wind->resize.pending = SDL_TRUE;
         wind->resize.configure = SDL_TRUE;
         wind->resize.serial = serial;
-        if (!(window->flags & SDL_WINDOW_OPENGL)) {
-            Wayland_HandlePendingResize(window);  /* OpenGL windows handle this in SwapWindow */
-        }
+        Wayland_HandlePendingResize(window);
     }
 }
 
@@ -457,9 +458,7 @@ update_scale_factor(SDL_WindowData *window)
         window->resize.height = window->sdlwindow->h;
         window->resize.scale_factor = new_factor;
         window->resize.pending = SDL_TRUE;
-        if (!(window->sdlwindow->flags & SDL_WINDOW_OPENGL)) {
-            Wayland_HandlePendingResize(window->sdlwindow);  /* OpenGL windows handle this in SwapWindow */
-        }
+        Wayland_HandlePendingResize(window->sdlwindow);
     }
 }
 
@@ -929,10 +928,7 @@ Wayland_SetWindowFullscreen(_THIS, SDL_Window * window,
         wind->resize.width = window->windowed.w;
         wind->resize.height = window->windowed.h;
         wind->resize.pending = SDL_TRUE;
-
-        if (!(window->flags & SDL_WINDOW_OPENGL)) {
-            Wayland_HandlePendingResize(window);
-        }
+        Wayland_HandlePendingResize(window);
     }
 }
 
@@ -1204,7 +1200,7 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window)
 }
 
 
-void
+static void
 Wayland_HandlePendingResize(SDL_Window *window)
 {
     SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
diff --git a/src/video/wayland/SDL_waylandwindow.h b/src/video/wayland/SDL_waylandwindow.h
index 01f1614..35774bc 100644
--- a/src/video/wayland/SDL_waylandwindow.h
+++ b/src/video/wayland/SDL_waylandwindow.h
@@ -114,8 +114,6 @@ Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info);
 extern int Wayland_SetWindowHitTest(SDL_Window *window, SDL_bool enabled);
 extern int Wayland_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation);
 
-extern void Wayland_HandlePendingResize(SDL_Window *window);
-
 extern SDL_bool SDL_WAYLAND_own_surface(struct wl_surface *surface);
 
 #endif /* SDL_waylandwindow_h_ */