Browse Source

wayland: Try to detach at the beginning of ShowWindow, just in case.

It's possible that an external component (probably a GL/VK context) committed, so we need to cover our bases and detach in both HideWindow and ShowWindow.

Fixes a crash in UE5 editor's pop-ups.
Ethan Lee 3 years ago
parent
commit
3ada694e62
1 changed files with 15 additions and 0 deletions
  1. 15 0
      src/video/wayland/SDL_waylandwindow.c

+ 15 - 0
src/video/wayland/SDL_waylandwindow.c

@@ -995,6 +995,21 @@ void Wayland_ShowWindow(_THIS, SDL_Window *window)
     SDL_VideoData *c = _this->driverdata;
     SDL_WindowData *data = window->driverdata;
 
+    /* Detach any previous buffers before resetting everything, otherwise when
+     * calling this a second time you'll get an annoying protocol error!
+     *
+     * FIXME: This was originally moved to HideWindow, which _should_ make
+     * sense, but for whatever reason UE5's popups require that this actually
+     * be in both places at once? Possibly from renderers making commits? I can't
+     * fully remember if this location caused crashes or if I was fixing a pair
+     * of Hide/Show calls. In any case, UE gives us a pretty good test and having
+     * both detach calls passes.
+     *
+     * -flibit
+     */
+    wl_surface_attach(data->surface, NULL, 0, 0);
+    wl_surface_commit(data->surface);
+
     /* Create the shell surface and map the toplevel */
 #ifdef HAVE_LIBDECOR_H
     if (c->shell.libdecor) {