From 93988e28c04dd41bcb718a17d890e8098279d684 Mon Sep 17 00:00:00 2001 From: A1029384756 Date: Fri, 1 Aug 2025 00:08:35 -0400 Subject: [PATCH] wayland: reorder surface destruction to avoid premature blanking (cherry picked from commit 9034375d2f0c6739f480138842289616d1c9a7cb) --- src/video/wayland/SDL_waylandwindow.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 04849f9fe3..d5d7c869a8 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -2116,12 +2116,6 @@ void Wayland_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) wind->server_decoration = NULL; } - // Be sure to detach after this is done, otherwise ShowWindow crashes! - if (wind->shell_surface_type != WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP) { - wl_surface_attach(wind->surface, NULL, 0, 0); - wl_surface_commit(wind->surface); - } - // Clean up the export handle. if (wind->exported) { zxdg_exported_v2_destroy(wind->exported); @@ -2159,6 +2153,12 @@ void Wayland_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) } } + // Be sure to detach after this is done, otherwise ShowWindow crashes! + if (wind->shell_surface_type != WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP) { + wl_surface_attach(wind->surface, NULL, 0, 0); + wl_surface_commit(wind->surface); + } + SDL_zero(wind->shell_surface); wind->show_hide_sync_required = true; struct wl_callback *cb = wl_display_sync(_this->internal->display);