From 0a96d47599838c2aa36cc6dad9395acb33189539 Mon Sep 17 00:00:00 2001 From: Frank Praznik Date: Sat, 23 May 2026 12:20:30 -0400 Subject: [PATCH] wayland: Remove focus references when a pointer capture ends on a subsurface The core mouse code will unfocus the window when a capture ends outside the window boundaries, but the backend still needs to update the internal focus references. --- src/video/wayland/SDL_waylandevents.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 67f74fe5d1..82369b876b 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -1048,6 +1048,11 @@ static void pointer_dispatch_button(SDL_WaylandSeat *seat, Uint8 sdl_button, boo window->sdlwindow->flags |= SDL_WINDOW_MOUSE_CAPTURE; } else { window->sdlwindow->flags &= ~SDL_WINDOW_MOUSE_CAPTURE; + + // If ending the capture on a subsurface, dispatch a leave event to remove focus. + if (seat->pointer.focus_surface != window->surface) { + seat->pointer.pending_frame.leave_surface = window->surface; + } } }