wayland: Add support for the pointer warp event

This commit is contained in:
Frank Praznik
2026-02-05 09:13:32 -05:00
parent d98661ff7f
commit 73010447c3
3 changed files with 22 additions and 11 deletions

View File

@@ -1336,18 +1336,28 @@ static void pointer_handle_axis_value120(void *data, struct wl_pointer *pointer,
pointer_handle_axis_common(seat, SDL_WAYLAND_AXIS_EVENT_VALUE120, axis, wl_fixed_from_int(value120));
}
static void pointer_handle_warp(void *data, struct wl_pointer *wl_pointer, wl_fixed_t surface_x, wl_fixed_t surface_y)
{
SDL_WaylandSeat *seat = (SDL_WaylandSeat *)data;
seat->pointer.pending_frame.have_absolute = true;
seat->pointer.pending_frame.absolute.sx = surface_x;
seat->pointer.pending_frame.absolute.sy = surface_y;
}
static const struct wl_pointer_listener pointer_listener = {
pointer_handle_enter,
pointer_handle_leave,
pointer_handle_motion,
pointer_handle_button,
pointer_handle_axis,
pointer_handle_frame, // Version 5
pointer_handle_axis_source, // Version 5
pointer_handle_axis_stop, // Version 5
pointer_handle_axis_discrete, // Version 5
pointer_handle_axis_value120, // Version 8
pointer_handle_axis_relative_direction // Version 9
pointer_handle_frame, // Version 5
pointer_handle_axis_source, // Version 5
pointer_handle_axis_stop, // Version 5
pointer_handle_axis_discrete, // Version 5
pointer_handle_axis_value120, // Version 8
pointer_handle_axis_relative_direction, // Version 9
pointer_handle_warp // Version 11
};
static void relative_pointer_handle_relative_motion(void *data,

View File

@@ -1198,10 +1198,9 @@ void Wayland_SeatWarpMouse(SDL_WaylandSeat *seat, SDL_WindowData *window, float
}
}
/* NOTE: There is a pending warp event under discussion that should replace this when available.
* https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/340
*/
SDL_SendMouseMotion(0, window->sdlwindow, seat->pointer.sdl_id, false, x, y);
if (wl_pointer_get_version(seat->pointer.wl_pointer) < WL_POINTER_WARP_SINCE_VERSION) {
SDL_SendMouseMotion(0, window->sdlwindow, seat->pointer.sdl_id, false, x, y);
}
}
}

View File

@@ -86,7 +86,9 @@
#define SDL_WL_COMPOSITOR_VERSION 4
#endif
#if SDL_WAYLAND_CHECK_VERSION(1, 24, 0)
#if SDL_WAYLAND_CHECK_VERSION(1, 26, 0)
#define SDL_WL_SEAT_VERSION 11
#elif SDL_WAYLAND_CHECK_VERSION(1, 24, 0)
#define SDL_WL_SEAT_VERSION 10
#elif SDL_WAYLAND_CHECK_VERSION(1, 22, 0)
#define SDL_WL_SEAT_VERSION 9