فهرست منبع

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.

(cherry picked from commit 266ee41c86db532ba48169bbd4e558300dd95406)
Frank Praznik 1 سال پیش
والد
کامیت
30a6d01cc5
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

@@ -3304,6 +3304,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.
          */