From cbd1fc7ee6dced7ad6beecd5b9ad56a7f977f0c4 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 16:57:59 +0300 Subject: Report held pointer buttons on every pointer event Pointer events set button only on press and release, so wsap_term tracked held buttons itself to tell a drag from a hover. yasl_pointer_event.buttons now holds a YASL_BUTTON_BIT() mask of the buttons held after each event. The common input queue tracks it from the DOWN and UP events it queues, and clears it on INPUT_RESET and on allocation failure. Wayland also clears it on leave, since the compositor sends leave during a press only when it takes the pointer and no release follows. X11 and Cocoa keep it, because they deliver motion and the release to the pressed window after leave. Co-Authored-By: Claude Opus 5.5 --- include/yasl/yasl.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/yasl/yasl.h b/include/yasl/yasl.h index de9a62c..973c39d 100644 --- a/include/yasl/yasl.h +++ b/include/yasl/yasl.h @@ -299,6 +299,9 @@ enum yasl_pointer_button { YASL_BUTTON_FORWARD = 4, /**< Side "forward" button. */ }; +/** Bit for a yasl_pointer_button in yasl_pointer_event.buttons. */ +#define YASL_BUTTON_BIT(button) (1u << (button)) + /** Pointer capture mode for a surface. */ enum yasl_pointer_mode { YASL_POINTER_NORMAL = 0, /**< Absolute positions; cursor per yasl_surface_set_cursor(). */ @@ -376,6 +379,12 @@ struct yasl_pointer_event { struct yasl_vector2d scroll; /** DOWN/UP: which button changed. */ enum yasl_pointer_button button; + /** YASL_BUTTON_BIT() mask of buttons held after this event, on every + * POINTER_* type. Tracked from this queue's DOWN and UP events for all + * devices; INPUT_RESET clears it. On Wayland LEAVE clears it too, since the + * compositor sends leave during a press only when it takes the pointer. + * X11 and Cocoa keep sending motion and the release after LEAVE. */ + uint32_t buttons; /** Mouse, touch, pen, or eraser. */ enum yasl_pointer_device device; /** yasl_mod bitmask at this event. */ -- cgit v1.2.3