From 276a70a84fed5be229c12546df1ac393158a4ec9 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 16:23:07 +0300 Subject: Implement relative pointer mode on Wayland yasl_surface_set_pointer_mode(YASL_POINTER_RELATIVE) now takes a persistent zwp_locked_pointer_v1 on the surface and hides its cursor. While the compositor keeps the lock engaged, zwp_relative_pointer_v1 motion is pushed as POINTER_MOTION with pos frozen and delta in device pixels. When the lock disengages, as on focus loss, motion is absolute again with a delta derived by the input queue. The lock follows the pointer's seat: it moves to another seat when its seat loses the pointer, and is released on NORMAL and on surface destruction. Compositors without both protocols return false. Co-Authored-By: Claude Opus 5.5 --- src/platform/wayland/internal.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/platform/wayland/internal.h') diff --git a/src/platform/wayland/internal.h b/src/platform/wayland/internal.h index d619dba..c35db7f 100644 --- a/src/platform/wayland/internal.h +++ b/src/platform/wayland/internal.h @@ -23,6 +23,8 @@ #include "protocols/commit-timing-v1-client-protocol.h" #include "protocols/xdg-toplevel-drag-v1-client-protocol.h" #include "protocols/primary-selection-unstable-v1-client-protocol.h" +#include "protocols/relative-pointer-unstable-v1-client-protocol.h" +#include "protocols/pointer-constraints-unstable-v1-client-protocol.h" #include #include @@ -131,6 +133,7 @@ struct seat { struct wl_pointer *pointer; struct wl_touch *touch; struct wp_cursor_shape_device_v1 *cursor_shape_dev; + struct zwp_relative_pointer_v1 *relative_pointer; struct wl_surface *cursor_surface; struct wp_viewport *cursor_viewport; struct zwp_tablet_seat_v2 *tablet_seat; @@ -212,6 +215,8 @@ struct wayland_display { struct wl_data_device_manager *data_manager; struct zwp_primary_selection_device_manager_v1 *primary_selection_mgr; struct wp_cursor_shape_manager_v1 *cursor_shape_mgr; + struct zwp_relative_pointer_manager_v1 *relative_pointer_mgr; + struct zwp_pointer_constraints_v1 *pointer_constraints; struct wl_cursor_theme *cursor_theme; const char *cursor_theme_name; struct zwp_tablet_manager_v2 *tablet_mgr; @@ -275,6 +280,9 @@ struct wayland_surface { struct wp_fifo_v1 *fifo; struct wp_commit_timer_v1 *commit_timer; struct wl_callback *frame_cb; + /* Persistent lock held while relative; lock_seat owns the locked wl_pointer. */ + struct zwp_locked_pointer_v1 *pointer_lock; + struct seat *lock_seat; const struct yasl_window_cbs *cbs; void *ud; uint64_t frames_skipped; @@ -316,6 +324,8 @@ struct wayland_surface { bool destroyed; bool opaque; bool want_draw; + bool relative; + bool pointer_locked; }; @@ -388,6 +398,7 @@ int seat_modifiers(const struct seat *s); void surface_init_cursor(struct wayland_display *c); void seat_destroy_tablet(struct seat *s); void seat_pointer_reset(struct seat *s); +void surface_unlock_pointer(struct wayland_surface *w); extern const struct zwp_text_input_v3_listener text_input_listener; void ime_reset(struct wayland_surface *w); -- cgit v1.2.3