From eb15b4e962dc388fae85f89915604a219ca65288 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Fri, 11 Jun 2021 23:40:09 -0400 Subject: [PATCH] wayland: Drop SwapWindow calls for hidden windows --- src/video/wayland/SDL_waylandopengles.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/video/wayland/SDL_waylandopengles.c b/src/video/wayland/SDL_waylandopengles.c index e4739a8a6..7b33223e3 100644 --- a/src/video/wayland/SDL_waylandopengles.c +++ b/src/video/wayland/SDL_waylandopengles.c @@ -114,6 +114,18 @@ Wayland_GLES_SwapWindow(_THIS, SDL_Window *window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; const int swap_interval = _this->egl_data->egl_swapinterval; + /* For windows that we know are hidden, skip swaps entirely, if we don't do + * this compositors will intentionally stall us indefinitely and there's no + * way for an end user to show the window, unlike other situations (i.e. + * the window is minimized, behind another window, etc.). + * + * FIXME: Request EGL_WAYLAND_swap_buffers_with_timeout. + * -flibit + */ + if (window->flags & SDL_WINDOW_HIDDEN) { + return 0; + } + /* Control swap interval ourselves. See comments on Wayland_GLES_SetSwapInterval */ if (swap_interval != 0) { struct wl_display *display = ((SDL_VideoData *)_this->driverdata)->display;