瀏覽代碼

wayland: Defer creating cursor confinement regions until the surface is mapped

Otherwise, the confinement area will be lost if the window is recreated when initializing the renderer.
Frank Praznik 2 周之前
父節點
當前提交
266ee41c86
共有 2 個文件被更改,包括 8 次插入0 次删除
  1. 5 0
      src/video/wayland/SDL_waylandevents.c
  2. 3 0
      src/video/wayland/SDL_waylandwindow.c

+ 5 - 0
src/video/wayland/SDL_waylandevents.c

@@ -3312,6 +3312,11 @@ bool Wayland_input_confine_pointer(struct SDL_WaylandInput *input, SDL_Window *w
         return SDL_SetError("No pointer to confine");
     }
 
+    // The confinement region will be created when the window is mapped.
+    if (w->shell_surface_status != WAYLAND_SHELL_SURFACE_STATUS_SHOWN) {
+        return true;
+    }
+
     /* A confine may already be active, in which case we should destroy it and
      * create a new one.
      */

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

@@ -707,6 +707,9 @@ static void surface_frame_done(void *data, struct wl_callback *cb, uint32_t time
             }
         }
 
+        // Create the pointer confinement region, if necessary.
+        Wayland_input_confine_pointer(wind->waylandData->input, wind->sdlwindow);
+
         /* If the window was initially set to the suspended state, send the occluded event now,
          * as we don't want to mark the window as occluded until at least one frame has been submitted.
          */