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_app_input.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_app_input.c')
| -rw-r--r-- | tests/wayland/test_app_input.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/tests/wayland/test_app_input.c b/tests/wayland/test_app_input.c index c8c5687..843f38d 100644 --- a/tests/wayland/test_app_input.c +++ b/tests/wayland/test_app_input.c @@ -15,15 +15,15 @@ struct test_state { static void push_key(struct yasl_surface *s) { - struct yasl_input_event ev = { + struct yasl_event ev = { .surface = s, - .kind = YASL_INPUT_KEY, + .type = YASL_EVENT_KEY, .key = { .key = YASL_KEY_A, .action = YASL_KEY_PRESS }, }; assert(input_queue_push(&((struct wayland_surface *)s)->input, &ev)); } -static int on_init(void *ud, struct yasl_display *d) +static enum yasl_app_result on_init(void *ud, struct yasl_display *d) { struct test_state *state = ud; if (state->end) { @@ -39,42 +39,42 @@ static int on_init(void *ud, struct yasl_display *d) assert(s); struct input_queue *queue = &((struct wayland_surface *)s)->input; input_queue_clear(queue); - struct yasl_input_event event = {.surface = s, .kind = YASL_INPUT_MOUSE, - .mouse = {.kind = YASL_PTR_PRESS, .device = YASL_PTR_DEV_ERASER, + struct yasl_event event = {.surface = s, .type = YASL_EVENT_POINTER_DOWN, + .pointer = {.device = YASL_PTR_DEV_ERASER, .button = YASL_BUTTON_PRIMARY, .pos = {12, 34}, .pen = {.pressure = 50000, .tilt_x = -20, .tilt_y = 30}}}; assert(input_queue_push(queue, &event)); - event.mouse.kind = YASL_PTR_MOTION; - event.mouse.pos = (struct yasl_vector2i){15, 39}; + event.type = YASL_EVENT_POINTER_MOTION; + event.pointer.pos = (struct yasl_vector2i){15, 39}; assert(input_queue_push(queue, &event)); - struct yasl_input_event reset = {.surface = s, .kind = YASL_INPUT_RESET}; + struct yasl_event reset = {.surface = s, .type = YASL_EVENT_INPUT_RESET}; assert(input_queue_push(queue, &reset)); - event.mouse.device = YASL_PTR_DEV_PEN; - event.mouse.pos = (struct yasl_vector2i){100, 200}; + event.pointer.device = YASL_PTR_DEV_PEN; + event.pointer.pos = (struct yasl_vector2i){100, 200}; assert(input_queue_push(queue, &event)); push_key(s); push_key(s); return YASL_APP_CONTINUE; } -static int on_event(void *ud, const struct yasl_event *ev) +static enum yasl_app_result on_event(void *ud, const struct yasl_event *ev) { struct test_state *state = ud; - if (ev->type == YASL_EVENT_MOUSE_BUTTON) { - assert(ev->mouse_button.device == YASL_PTR_DEV_ERASER); - assert(ev->mouse_button.pressed && ev->mouse_button.button == 0); - assert(ev->mouse_button.pos.x == 12 && ev->mouse_button.pos.y == 34); - assert(ev->mouse_button.pen.pressure == 50000); - assert(ev->mouse_button.pen.tilt_x == -20 && ev->mouse_button.pen.tilt_y == 30); + if (ev->type == YASL_EVENT_POINTER_DOWN) { + assert(ev->pointer.device == YASL_PTR_DEV_ERASER); + assert(ev->pointer.button == YASL_BUTTON_PRIMARY); + assert(ev->pointer.pos.x == 12 && ev->pointer.pos.y == 34); + assert(ev->pointer.pen.pressure == 50000); + assert(ev->pointer.pen.tilt_x == -20 && ev->pointer.pen.tilt_y == 30); state->buttons++; - } else if (ev->type == YASL_EVENT_MOUSE_MOTION) { + } else if (ev->type == YASL_EVENT_POINTER_MOTION) { if (!state->motions) { - assert(ev->mouse_motion.device == YASL_PTR_DEV_ERASER); - assert(ev->mouse_motion.delta.x == 3 && ev->mouse_motion.delta.y == 5); + assert(ev->pointer.device == YASL_PTR_DEV_ERASER); + assert(ev->pointer.delta.x == 3 && ev->pointer.delta.y == 5); } else { - assert(ev->mouse_motion.device == YASL_PTR_DEV_PEN); - assert(!ev->mouse_motion.delta.x && !ev->mouse_motion.delta.y); + assert(ev->pointer.device == YASL_PTR_DEV_PEN); + assert(!ev->pointer.delta.x && !ev->pointer.delta.y); } - assert(ev->mouse_motion.pen.pressure == 50000); + assert(ev->pointer.pen.pressure == 50000); state->motions++; } else if (ev->type == YASL_EVENT_INPUT_RESET) { state->resets++; |
