From 20928550350d4d4c5d78f98b61e7e08d219a5475 Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Sat, 1 May 2021 09:00:24 -0400 Subject: [PATCH] wayland: Guard surface_frame_listener for OpenGL, document why it exists --- src/video/wayland/SDL_waylandwindow.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 50b16d12f..2e4edcda7 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -1012,8 +1012,14 @@ int Wayland_CreateWindow(_THIS, SDL_Window *window) wl_compositor_create_surface(c->compositor); wl_surface_add_listener(data->surface, &surface_listener, data); - /* fire a callback when the compositor wants a new frame rendered. */ - wl_callback_add_listener(wl_surface_frame(data->surface), &surface_frame_listener, data); + /* Fire a callback when the compositor wants a new frame rendered. + * Right now this only matters for OpenGL; we use this callback to add a + * wait timeout that avoids getting deadlocked by the compositor when the + * window isn't visible. + */ + if (window->flags & SDL_WINDOW_OPENGL) { + wl_callback_add_listener(wl_surface_frame(data->surface), &surface_frame_listener, data); + } #ifdef SDL_VIDEO_DRIVER_WAYLAND_QT_TOUCH if (c->surface_extension) {