diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 23:41:31 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 23:41:31 +0300 |
| commit | 76073fe5fad8799e5850805f2f090af2cb62c741 (patch) | |
| tree | 9658019babe4760a3634bdab4da0731a10e42e68 /tests/wayland/test_keyboard.c | |
| parent | dd1775a9927922c14f8679ccbc4d3ca8d5917e20 (diff) | |
Simplify the public event and CPU API
Applications now need far less ceremony: hello.c is a 20-line loop that
handles REFRESH, CLOSE and QUIT and draws into the surface's own pixels.
- Fold GEOMETRY, STATE and FOCUS into one WINDOW event carrying size,
scale and state; unchanged values send nothing.
- Guarantee REFRESH once a window has a size and after every resize,
never at size zero.
- Merge DROP_HOVER into DROP with over/leave/data actions and give drag
and drop actions enums.
- Keep event strings valid until the next wait and drop
yasl_event_release; empty or failed waits report NONE.
- Replace copy-in presentation with a lent pixel buffer:
yasl_cpu_pixels and yasl_cpu_present.
- Remove yasl_poll_event, yasl_cpu_read_pixels, unused event fields and
comments that restated names.
- Wayland: resize floating windows in request_size instead of reporting
it unsupported, and stop marking new GPU surfaces as Vulkan so
yasl_vulkan_create_surface no longer fails with NATIVE_WINDOW_IN_USE.
Also includes the in-progress public API refactor that was uncommitted
in the tree (removal of the app/loop layer, new surface, GL and Vulkan
entry points).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/wayland/test_keyboard.c')
| -rw-r--r-- | tests/wayland/test_keyboard.c | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/tests/wayland/test_keyboard.c b/tests/wayland/test_keyboard.c index bce0a0c..ae4647f 100644 --- a/tests/wayland/test_keyboard.c +++ b/tests/wayland/test_keyboard.c @@ -1,18 +1,18 @@ #include "../../src/platform/wayland/keyboard.c" #include <assert.h> -static struct yasl_event next(struct wayland_surface *w, enum yasl_event_type type) +static struct yasl_private_event next(struct wayland_surface *w, enum yasl_private_event_type type) { - struct yasl_event ev; - assert(yasl_surface_poll_event(&w->base, &ev)); + struct yasl_private_event ev; + assert(yasl_private_surface_poll_event(&w->base, &ev)); assert(ev.type == type && ev.surface == &w->base); return ev; } static void empty(struct wayland_surface *w) { - struct yasl_event ev; - assert(!yasl_surface_poll_event(&w->base, &ev)); + struct yasl_private_event ev; + assert(!yasl_private_surface_poll_event(&w->base, &ev)); } static void layout(struct seat *s, const char *name, const char *variant) @@ -43,7 +43,7 @@ static void key(struct seat *s, uint32_t code, bool down) int main(void) { - struct wayland_display d = {.base.ops = &yasl_wayland_backend}; + struct wayland_display d = {.base.ops = &yasl_private_wayland_backend}; d.xkb_ctx = xkb_context_new(0); assert(d.xkb_ctx); struct wayland_surface w = {.base.display = &d.base, .conn = &d}; @@ -59,65 +59,66 @@ int main(void) xkb_compose_table_unref(table); layout(&s, "us", NULL); key(&s, KEY_A, true); - struct yasl_event ev = next(&w, YASL_EVENT_KEY); + struct yasl_private_event ev = next(&w, YASL_PRIVATE_EVENT_KEY); assert(ev.key.key == YASL_KEY_A && ev.key.native_code == KEY_A); assert(ev.key.codepoint == 'a' && ev.key.shifted == 'A' && !ev.key.mods); - assert(strcmp(next(&w, YASL_EVENT_TEXT).text.data, "a") == 0); + assert(strcmp(next(&w, YASL_PRIVATE_EVENT_TEXT).text.data, "a") == 0); modifiers(&s, XKB_MOD_NAME_SHIFT); key(&s, KEY_A, false); /* Modifier changes cannot change physical identity. */ - ev = next(&w, YASL_EVENT_KEY); + ev = next(&w, YASL_PRIVATE_EVENT_KEY); assert(ev.key.key == YASL_KEY_A && ev.key.action == YASL_KEY_RELEASE); - assert(ev.key.mods == YASL_MOD_SHIFT); + assert(ev.key.mods == YASL_PRIVATE_MOD_SHIFT); empty(&w); key(&s, KEY_A, true); - next(&w, YASL_EVENT_KEY); - assert(strcmp(next(&w, YASL_EVENT_TEXT).text.data, "A") == 0); + next(&w, YASL_PRIVATE_EVENT_KEY); + assert(strcmp(next(&w, YASL_PRIVATE_EVENT_TEXT).text.data, "A") == 0); modifiers(&s, XKB_MOD_NAME_CAPS); key(&s, KEY_A, true); - assert(next(&w, YASL_EVENT_KEY).key.mods == YASL_MOD_CAPS); - assert(strcmp(next(&w, YASL_EVENT_TEXT).text.data, "A") == 0); + assert(next(&w, YASL_PRIVATE_EVENT_KEY).key.mods == YASL_PRIVATE_MOD_CAPS); + assert(strcmp(next(&w, YASL_PRIVATE_EVENT_TEXT).text.data, "A") == 0); const char *shortcuts[] = {XKB_MOD_NAME_CTRL, XKB_MOD_NAME_ALT, XKB_MOD_NAME_LOGO}; for (size_t i = 0; i < sizeof(shortcuts)/sizeof(shortcuts[0]); i++) { modifiers(&s, shortcuts[i]); key(&s, KEY_A, true); - next(&w, YASL_EVENT_KEY); + next(&w, YASL_PRIVATE_EVENT_KEY); empty(&w); /* Shortcut characters never leak into committed text. */ } layout(&s, "fr", NULL); key(&s, KEY_A, true); - ev = next(&w, YASL_EVENT_KEY); + ev = next(&w, YASL_PRIVATE_EVENT_KEY); assert(ev.key.key == YASL_KEY_A && ev.key.codepoint == 'q'); - assert(strcmp(next(&w, YASL_EVENT_TEXT).text.data, "q") == 0); + assert(strcmp(next(&w, YASL_PRIVATE_EVENT_TEXT).text.data, "q") == 0); layout(&s, "de", NULL); modifiers(&s, "Mod5"); /* AltGr is text input, not an Alt shortcut. */ key(&s, KEY_E, true); - assert(next(&w, YASL_EVENT_KEY).key.key == YASL_KEY_E); - assert(strcmp(next(&w, YASL_EVENT_TEXT).text.data, "€") == 0); + assert(next(&w, YASL_PRIVATE_EVENT_KEY).key.key == YASL_KEY_E); + assert(strcmp(next(&w, YASL_PRIVATE_EVENT_TEXT).text.data, "€") == 0); layout(&s, "us", "intl"); key(&s, KEY_APOSTROPHE, true); - next(&w, YASL_EVENT_KEY); + next(&w, YASL_PRIVATE_EVENT_KEY); empty(&w); key(&s, KEY_E, true); - next(&w, YASL_EVENT_KEY); - assert(strcmp(next(&w, YASL_EVENT_TEXT).text.data, "é") == 0); + next(&w, YASL_PRIVATE_EVENT_KEY); + assert(strcmp(next(&w, YASL_PRIVATE_EVENT_TEXT).text.data, "é") == 0); assert(keyboard_dispatch_key(&s, &w, KEY_E, YASL_KEY_REPEAT)); - assert(next(&w, YASL_EVENT_KEY).key.action == YASL_KEY_REPEAT); - assert(strcmp(next(&w, YASL_EVENT_TEXT).text.data, "e") == 0); + assert(next(&w, YASL_PRIVATE_EVENT_KEY).key.action == YASL_KEY_REPEAT); + assert(strcmp(next(&w, YASL_PRIVATE_EVENT_TEXT).text.data, "e") == 0); key(&s, KEY_APOSTROPHE, true); - next(&w, YASL_EVENT_KEY); + next(&w, YASL_PRIVATE_EVENT_KEY); keyboard_reset_keys(&s, &w); key(&s, KEY_E, true); - next(&w, YASL_EVENT_KEY); - assert(strcmp(next(&w, YASL_EVENT_TEXT).text.data, "e") == 0); + next(&w, YASL_PRIVATE_EVENT_KEY); + assert(strcmp(next(&w, YASL_PRIVATE_EVENT_TEXT).text.data, "e") == 0); key(&s, KEY_APOSTROPHE, true); - next(&w, YASL_EVENT_KEY); + next(&w, YASL_PRIVATE_EVENT_KEY); s.ime_focus = &w; + w.base.text_input_active = true; text_input_listener.commit_string(&s, NULL, "字"); text_input_listener.done(&s, NULL, 0); - assert(strcmp(next(&w, YASL_EVENT_TEXT).text.data, "字") == 0); + assert(strcmp(next(&w, YASL_PRIVATE_EVENT_TEXT).text.data, "字") == 0); key(&s, KEY_E, true); - next(&w, YASL_EVENT_KEY); - assert(strcmp(next(&w, YASL_EVENT_TEXT).text.data, "e") == 0); + next(&w, YASL_PRIVATE_EVENT_KEY); + assert(strcmp(next(&w, YASL_PRIVATE_EVENT_TEXT).text.data, "e") == 0); empty(&w); xkb_compose_state_unref(s.compose); xkb_state_unref(s.xkb_state); |
