mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-07-23 01:02:36 +00:00
wayland: Add support for the pointer warp event
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user