diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 15:41:39 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 15:41:39 +0300 |
| commit | 482f799d356a8fbb8f585c4de7cc0992b8dc6fd3 (patch) | |
| tree | 85551a69e3c356da7b9b514224e25a6c2f8d29b9 /tests/wayland/test_tablet.c | |
| parent | 537b2d768b31deb0f95c5122e0d562e4406ae9a0 (diff) | |
Migrate tests to the unified event API
Port backend, input, tablet and app tests from yasl_input_event and
YASL_INPUT_* to struct yasl_event and YASL_EVENT_*. The input allocation
test links input.c on its own, so it stubs yasl_loop_now_ns() for the new
event timestamps.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/wayland/test_tablet.c')
| -rw-r--r-- | tests/wayland/test_tablet.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/tests/wayland/test_tablet.c b/tests/wayland/test_tablet.c index 8723df2..c76ddf8 100644 --- a/tests/wayland/test_tablet.c +++ b/tests/wayland/test_tablet.c @@ -1,12 +1,12 @@ #include "../../src/platform/wayland/pointer.c" #include <assert.h> -static struct yasl_mouse_event next(struct wayland_surface *surface) +static struct yasl_event next(struct wayland_surface *surface) { - struct yasl_input_event event; - assert(yasl_surface_input_poll(&surface->base, &event)); - assert(event.surface == &surface->base && event.kind == YASL_INPUT_MOUSE); - return event.mouse; + struct yasl_event event; + assert(yasl_surface_poll_event(&surface->base, &event)); + assert(event.surface == &surface->base); + return event; } int main(void) @@ -22,38 +22,38 @@ int main(void) tool_tilt(&tool, NULL, wl_fixed_from_int(-35), wl_fixed_from_int(42)); tablet_tool_down(&tool, NULL, 1); tool_frame(&tool, NULL, 0); - struct yasl_mouse_event ev = next(&surface); - assert(ev.kind == YASL_PTR_MOTION && ev.device == YASL_PTR_DEV_PEN); - assert(ev.pos.x == 150 && ev.pos.y == 180 && ev.pen.pressure == 32768); - assert(ev.pen.tilt_x == -35 && ev.pen.tilt_y == 42); + struct yasl_event ev = next(&surface); + assert(ev.type == YASL_EVENT_POINTER_MOTION && ev.pointer.device == YASL_PTR_DEV_PEN); + assert(ev.pointer.pos.x == 150 && ev.pointer.pos.y == 180 && ev.pointer.pen.pressure == 32768); + assert(ev.pointer.pen.tilt_x == -35 && ev.pointer.pen.tilt_y == 42); ev = next(&surface); - assert(ev.kind == YASL_PTR_PRESS && ev.button == 0 && ev.pen.pressure == 32768); + assert(ev.type == YASL_EVENT_POINTER_DOWN && ev.pointer.button == YASL_BUTTON_PRIMARY && ev.pointer.pen.pressure == 32768); /* Stationary pressure and tilt changes are still motion samples. */ tool_pressure(&tool, NULL, 100000); tool_tilt(&tool, NULL, wl_fixed_from_int(-120), wl_fixed_from_int(120)); tool_frame(&tool, NULL, 0); ev = next(&surface); - assert(ev.kind == YASL_PTR_MOTION && ev.pen.pressure == 65535); - assert(ev.pos.x == 150 && ev.pos.y == 180); - assert(ev.pen.tilt_x == -90 && ev.pen.tilt_y == 90); + assert(ev.type == YASL_EVENT_POINTER_MOTION && ev.pointer.pen.pressure == 65535); + assert(ev.pointer.pos.x == 150 && ev.pointer.pos.y == 180); + assert(ev.pointer.pen.tilt_x == -90 && ev.pointer.pen.tilt_y == 90); tablet_tool_up(&tool, NULL); tool_frame(&tool, NULL, 0); ev = next(&surface); - assert(ev.kind == YASL_PTR_RELEASE && ev.button == 0 && !ev.pen.pressure); + assert(ev.type == YASL_EVENT_POINTER_UP && ev.pointer.button == YASL_BUTTON_PRIMARY && !ev.pointer.pen.pressure); tool_type(&tool, NULL, ZWP_TABLET_TOOL_V2_TYPE_ERASER); tool_pressure(&tool, NULL, 22000); tool_frame(&tool, NULL, 0); - assert(next(&surface).device == YASL_PTR_DEV_ERASER); + assert(next(&surface).pointer.device == YASL_PTR_DEV_ERASER); tool_wheel(&tool, NULL, 0, 1); 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); + assert(ev.type == YASL_EVENT_POINTER_SCROLL && ev.pointer.device == YASL_PTR_DEV_ERASER); + assert(ev.pointer.scroll.x == 0 && ev.pointer.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); + assert(ev.type == YASL_EVENT_POINTER_LEAVE && ev.pointer.device == YASL_PTR_DEV_ERASER && !ev.pointer.pen.pressure); assert(!seat.tool && !seat.tablet_focus && !seat.tool_buttons); assert(!(yasl_display_caps(&display.base) & YASL_CAP_TABLET)); display.tablet_mgr = (void *)&display; /* Capability depends on protocol availability. */ @@ -68,12 +68,12 @@ int main(void) 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)); + assert(ev.type == YASL_EVENT_POINTER_SCROLL && ev.pointer.device == YASL_PTR_DEV_MOUSE); + assert(ev.pointer.scroll.x == -0.5 && ev.pointer.scroll.y == 0.25); + struct yasl_event unused; + assert(!yasl_surface_poll_event(&surface.base, &unused)); pointer_frame(&seat, NULL); - assert(!yasl_surface_input_poll(&surface.base, &unused)); + assert(!yasl_surface_poll_event(&surface.base, &unused)); /* Stops preserve offsets from the same frame. Repeated tiny movements * must be visible immediately rather than held until a whole detent. */ @@ -84,16 +84,16 @@ int main(void) 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); + assert(ev.pointer.scroll.x == -0.25 && ev.pointer.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); + assert(ev.pointer.scroll.x == 2 && ev.pointer.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)); + assert(!yasl_surface_poll_event(&surface.base, &unused)); input_queue_clear(&surface.input); return 0; } |
