From 94c5e361fbb229b0cd6853e2102a7d95f1f358b3 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Mon, 12 Oct 2026 22:12:02 +0300 Subject: better public interface and doxygen --- tests/wayland/test_tablet.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'tests/wayland/test_tablet.c') diff --git a/tests/wayland/test_tablet.c b/tests/wayland/test_tablet.c index 449c446..f8982b0 100644 --- a/tests/wayland/test_tablet.c +++ b/tests/wayland/test_tablet.c @@ -50,6 +50,7 @@ int main(void) tool_frame(&tool, NULL, 0); ev = next(&surface); assert(ev.kind == YASL_PTR_SCROLL && ev.device == YASL_PTR_DEV_ERASER); + assert(ev.scroll.x == 0 && ev.scroll.y == 1); tablet_tool_proximity_out(&tool, NULL); ev = next(&surface); assert(ev.kind == YASL_PTR_LEAVE && ev.device == YASL_PTR_DEV_ERASER && !ev.pen.pressure); @@ -57,6 +58,42 @@ int main(void) assert(!(yasl_display_caps(&display.base) & YASL_CAP_TABLET)); display.tablet_mgr = (void *)&display; /* Capability depends on protocol availability. */ assert(yasl_display_caps(&display.base) & YASL_CAP_TABLET); + + seat.pointer_focus = &surface; + /* A compositor may describe the same detent in three ways. value120 wins, + * and both axes belong to one event, without whole-line truncation. */ + pointer_axis(&seat, NULL, 0, WL_POINTER_AXIS_VERTICAL_SCROLL, wl_fixed_from_int(10)); + pointer_axis_discrete(&seat, NULL, WL_POINTER_AXIS_VERTICAL_SCROLL, 1); + pointer_axis_value120(&seat, NULL, WL_POINTER_AXIS_VERTICAL_SCROLL, 30); + pointer_axis_value120(&seat, NULL, WL_POINTER_AXIS_HORIZONTAL_SCROLL, -60); + pointer_frame(&seat, NULL); + ev = next(&surface); + assert(ev.kind == YASL_PTR_SCROLL && ev.device == YASL_PTR_DEV_MOUSE); + assert(ev.scroll.x == -0.5 && ev.scroll.y == 0.25); + struct yasl_input_event unused; + assert(!yasl_surface_input_poll(&surface.base, &unused)); + pointer_frame(&seat, NULL); + assert(!yasl_surface_input_poll(&surface.base, &unused)); + + /* Stops preserve offsets from the same frame. Repeated tiny movements + * must be visible immediately rather than held until a whole detent. */ + for (int i = 0; i < 3; i++) { + pointer_axis_source(&seat, NULL, WL_POINTER_AXIS_SOURCE_FINGER); + pointer_axis(&seat, NULL, 0, WL_POINTER_AXIS_VERTICAL_SCROLL, wl_fixed_from_double(1.25)); + pointer_axis(&seat, NULL, 0, WL_POINTER_AXIS_HORIZONTAL_SCROLL, wl_fixed_from_double(-2.5)); + pointer_axis_stop(&seat, NULL, 0, WL_POINTER_AXIS_VERTICAL_SCROLL); + pointer_frame(&seat, NULL); + ev = next(&surface); + assert(ev.scroll.x == -0.25 && ev.scroll.y == 0.125); + } + pointer_axis_discrete(&seat, NULL, WL_POINTER_AXIS_HORIZONTAL_SCROLL, 2); + pointer_frame(&seat, NULL); + ev = next(&surface); + assert(ev.scroll.x == 2 && ev.scroll.y == 0); + pointer_axis_value120(&seat, NULL, WL_POINTER_AXIS_VERTICAL_SCROLL, 60); + seat_pointer_reset(&seat); + pointer_frame(&seat, NULL); + assert(!yasl_surface_input_poll(&surface.base, &unused)); input_queue_clear(&surface.input); return 0; } -- cgit v1.2.3