wayland: Unref the libdecor window when hiding

Hiding the decorations while not unreferencing the frame was a workaround for an internal libdecor use-after-free bug that was fixed some time ago. Revert to unreferencing the window when hiding to ensure that it is properly destroyed.

Reverts dd2e318
This commit is contained in:
Frank Praznik
2023-03-18 12:03:08 -04:00
parent 26f511a8f4
commit 6bb48b4fe9

View File

@@ -1227,11 +1227,6 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
/* Create the shell surface and map the toplevel/popup */ /* Create the shell surface and map the toplevel/popup */
#ifdef HAVE_LIBDECOR_H #ifdef HAVE_LIBDECOR_H
if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) {
if (data->shell_surface.libdecor.frame) {
/* If the frame already exists, just set the visibility. */
libdecor_frame_set_visibility(data->shell_surface.libdecor.frame, true);
libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname);
} else {
data->shell_surface.libdecor.frame = libdecor_decorate(c->shell.libdecor, data->shell_surface.libdecor.frame = libdecor_decorate(c->shell.libdecor,
data->surface, data->surface,
&libdecor_frame_interface, &libdecor_frame_interface,
@@ -1242,7 +1237,6 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname); libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, c->classname);
libdecor_frame_map(data->shell_surface.libdecor.frame); libdecor_frame_map(data->shell_surface.libdecor.frame);
} }
}
} else } else
#endif #endif
if ((data->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL || data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) && c->shell.xdg) { if ((data->shell_surface_type == WAYLAND_SURFACE_XDG_TOPLEVEL || data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP) && c->shell.xdg) {
@@ -1473,8 +1467,8 @@ void Wayland_HideWindow(_THIS, SDL_Window *window)
#ifdef HAVE_LIBDECOR_H #ifdef HAVE_LIBDECOR_H
if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) {
if (wind->shell_surface.libdecor.frame) { if (wind->shell_surface.libdecor.frame) {
libdecor_frame_set_visibility(wind->shell_surface.libdecor.frame, false); libdecor_frame_unref(wind->shell_surface.libdecor.frame);
libdecor_frame_set_app_id(wind->shell_surface.libdecor.frame, data->classname); wind->shell_surface.libdecor.frame = NULL;
} }
} else } else
#endif #endif