mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-02-06 02:02:09 +08:00
wayland: More pointer related code deduplication
This commit is contained in:
@@ -858,7 +858,7 @@ static void pointer_handle_enter(void *data, struct wl_pointer *pointer,
|
||||
}
|
||||
}
|
||||
|
||||
static void pointer_dispatch_leave(SDL_WaylandSeat *seat)
|
||||
static void pointer_dispatch_leave(SDL_WaylandSeat *seat, bool update_pointer)
|
||||
{
|
||||
SDL_WindowData *window = seat->pointer.pending_frame.leave_window;
|
||||
|
||||
@@ -882,6 +882,11 @@ static void pointer_dispatch_leave(SDL_WaylandSeat *seat)
|
||||
if (!--window->pointer_focus_count && had_focus && !window->active_touch_count) {
|
||||
SDL_SetMouseFocus(NULL);
|
||||
}
|
||||
|
||||
if (update_pointer) {
|
||||
Wayland_SeatUpdatePointerGrab(seat);
|
||||
Wayland_SeatUpdatePointerCursor(seat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -902,9 +907,7 @@ static void pointer_handle_leave(void *data, struct wl_pointer *pointer,
|
||||
SDL_WaylandSeat *seat = (SDL_WaylandSeat *)data;
|
||||
seat->pointer.pending_frame.leave_window = window;
|
||||
if (wl_pointer_get_version(seat->pointer.wl_pointer) < WL_POINTER_FRAME_SINCE_VERSION && window == seat->pointer.focus) {
|
||||
pointer_dispatch_leave(seat);
|
||||
Wayland_SeatUpdatePointerGrab(seat);
|
||||
Wayland_SeatUpdatePointerCursor(seat);
|
||||
pointer_dispatch_leave(seat, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1277,7 +1280,7 @@ static void pointer_handle_frame(void *data, struct wl_pointer *pointer)
|
||||
if (seat->pointer.pending_frame.enter_window) {
|
||||
if (seat->pointer.focus && seat->pointer.pending_frame.leave_window == seat->pointer.focus) {
|
||||
// Leaving the previous surface before entering a new surface.
|
||||
pointer_dispatch_leave(seat);
|
||||
pointer_dispatch_leave(seat, false);
|
||||
}
|
||||
pointer_dispatch_enter(seat);
|
||||
}
|
||||
@@ -1307,9 +1310,7 @@ static void pointer_handle_frame(void *data, struct wl_pointer *pointer)
|
||||
}
|
||||
|
||||
if (seat->pointer.focus && seat->pointer.pending_frame.leave_window == seat->pointer.focus) {
|
||||
pointer_dispatch_leave(seat);
|
||||
Wayland_SeatUpdatePointerGrab(seat);
|
||||
Wayland_SeatUpdatePointerCursor(seat);
|
||||
pointer_dispatch_leave(seat, true);
|
||||
}
|
||||
|
||||
SDL_zero(seat->pointer.pending_frame);
|
||||
@@ -2394,7 +2395,7 @@ static void Wayland_SeatDestroyPointer(SDL_WaylandSeat *seat)
|
||||
// Make sure focus is removed from a surface before the pointer is destroyed.
|
||||
if (seat->pointer.focus) {
|
||||
seat->pointer.pending_frame.leave_window = seat->pointer.focus;
|
||||
pointer_dispatch_leave(seat);
|
||||
pointer_dispatch_leave(seat, false);
|
||||
seat->pointer.pending_frame.leave_window = NULL;
|
||||
}
|
||||
|
||||
@@ -3663,9 +3664,7 @@ void Wayland_DisplayRemoveWindowReferencesFromSeats(SDL_VideoData *display, SDL_
|
||||
|
||||
if (seat->pointer.focus == window) {
|
||||
seat->pointer.pending_frame.leave_window = seat->pointer.focus;
|
||||
pointer_dispatch_leave(seat);
|
||||
Wayland_SeatUpdatePointerGrab(seat);
|
||||
Wayland_SeatUpdatePointerCursor(seat);
|
||||
pointer_dispatch_leave(seat, true);
|
||||
seat->pointer.pending_frame.leave_window = NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user