diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index ef91b4307c..a392c6e310 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/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. */ diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 7e5558315c..523d2e4bb2 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/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. */