seat/pointer: add wl_pointer.warp event support

Add support for the wl_pointer.warp event from Wayland protocol version 11.
https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/340

This allows the compositor to notify clients when the pointer position has
changed due to surface movement or compositor action, rather than input device
motion. This is useful for tracking cursor position across surface boundaries
and dynamic repositioning.
This commit is contained in:
Lu YaNing 2026-01-13 20:43:36 +08:00
parent 1f0fb95e3b
commit f175c2f592
5 changed files with 54 additions and 2 deletions

View file

@ -211,6 +211,22 @@ static void pointer_handle_axis_relative_direction(void *data,
pointer->axis_relative_direction = direction;
}
static void pointer_handle_warp(void *data, struct wl_pointer *wl_pointer,
wl_fixed_t sx, wl_fixed_t sy) {
struct wlr_wl_seat *seat = data;
struct wlr_wl_pointer *pointer = seat->active_pointer;
if (pointer == NULL) {
return;
}
struct wlr_pointer_warp_event event = {
.pointer = &pointer->wlr_pointer,
.sx = wl_fixed_to_double(sx),
.sy = wl_fixed_to_double(sy),
};
wl_signal_emit_mutable(&pointer->wlr_pointer.events.warp, &event);
}
static const struct wl_pointer_listener pointer_listener = {
.enter = pointer_handle_enter,
.leave = pointer_handle_leave,
@ -223,6 +239,7 @@ static const struct wl_pointer_listener pointer_listener = {
.axis_discrete = pointer_handle_axis_discrete,
.axis_value120 = pointer_handle_axis_value120,
.axis_relative_direction = pointer_handle_axis_relative_direction,
.warp = pointer_handle_warp,
};
static void gesture_swipe_begin(void *data,