From 76073fe5fad8799e5850805f2f090af2cb62c741 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Tue, 13 Oct 2026 23:41:31 +0300 Subject: 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 --- src/platform/wayland/keyboard.c | 60 ++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'src/platform/wayland/keyboard.c') diff --git a/src/platform/wayland/keyboard.c b/src/platform/wayland/keyboard.c index 7f8274d..6f9dec9 100644 --- a/src/platform/wayland/keyboard.c +++ b/src/platform/wayland/keyboard.c @@ -133,8 +133,8 @@ bool conn_keyboard_on(const struct wayland_display *c, const struct wayland_surf static void push_focus(struct wayland_surface *w, bool focused) { - struct yasl_event ev = { - .type = YASL_EVENT_FOCUS, + struct yasl_private_event ev = { + .type = YASL_PRIVATE_EVENT_FOCUS, .surface = &w->base, .focus = { .focused = focused }, }; @@ -218,18 +218,18 @@ static uint32_t key_codepoint_at_level(struct seat *s, uint32_t key, xkb_layout_ return n == 1 ? xkb_keysym_to_utf32(syms[0]) : 0; } -static struct yasl_key_event xkb_key_event(struct seat *s, uint32_t key, +static struct yasl_private_key_event xkb_key_event(struct seat *s, uint32_t key, enum yasl_key_action action) { uint32_t code = key + XKB_EVDEV_OFFSET; xkb_layout_index_t layout = xkb_state_key_get_layout(s->xkb_state, code); - struct yasl_key_event k = { - .key = yasl_key_from_evdev(key), + struct yasl_private_key_event k = { + .key = yasl_private_key_from_evdev(key), .action = action, .mods = input_modifiers(s), - .codepoint = yasl_key_label(key_codepoint_at_level(s, key, layout, 0)), - .shifted = yasl_key_label(key_codepoint_at_level(s, key, layout, 1)), + .codepoint = yasl_private_key_label(key_codepoint_at_level(s, key, layout, 0)), + .shifted = yasl_private_key_label(key_codepoint_at_level(s, key, layout, 1)), .native_code = key, }; return k; @@ -239,8 +239,8 @@ static void keyboard_text(struct seat *s, struct wayland_surface *w, uint32_t ke { uint32_t code = key + XKB_EVDEV_OFFSET; unsigned mods = input_modifiers(s); - if ((mods & (YASL_MOD_CTRL | YASL_MOD_SUPER)) || - ((mods & YASL_MOD_ALT) && + if ((mods & (YASL_PRIVATE_MOD_CTRL | YASL_PRIVATE_MOD_SUPER)) || + ((mods & YASL_PRIVATE_MOD_ALT) && !xkb_state_mod_index_is_consumed(s->xkb_state, code, s->mod_alt))) { keyboard_text_reset(s); return; @@ -278,13 +278,13 @@ static void keyboard_text(struct seat *s, struct wayland_surface *w, uint32_t ke else xkb_state_key_get_utf8(s->xkb_state, code, text, (size_t)len + 1); /* Editing commands belong to key events, not text insertion. */ if ((unsigned char)text[0] >= 0x20 && text[0] != 0x7f) { - struct yasl_event ev = {.type = YASL_EVENT_TEXT, + struct yasl_private_event ev = {.type = YASL_PRIVATE_EVENT_TEXT, .surface = &w->base, .text = {.data = text, .len = (size_t)len}}; input_queue_push(&w->input, &ev); } if (text != local) free(text); } else { - struct yasl_event ev = {.type = YASL_EVENT_INPUT_RESET, .surface = &w->base}; + struct yasl_private_event ev = {.type = YASL_PRIVATE_EVENT_INPUT_RESET, .surface = &w->base}; input_queue_push(&w->input, &ev); } } @@ -296,9 +296,9 @@ static bool keyboard_dispatch_key(struct seat *s, struct wayland_surface *w, uin { if (!s->xkb_state || !w->cbs) return false; - struct yasl_key_event k = xkb_key_event(s, key, action); - struct yasl_event ev = { - .type = YASL_EVENT_KEY, + struct yasl_private_key_event k = xkb_key_event(s, key, action); + struct yasl_private_event ev = { + .type = YASL_PRIVATE_EVENT_KEY, .surface = &w->base, .key = k, }; @@ -329,7 +329,7 @@ static void keyboard_key(void *data, struct wl_keyboard *keyboard, if (keyboard_dispatch_key(s, w, key, YASL_KEY_PRESS) && repeatable) { s->repeat_key = key; s->repeat_held = true; - s->repeat_started_ns = yasl_loop_now_ns(); + s->repeat_started_ns = yasl_private_loop_now_ns(); keyboard_repeat_sync(s); } } @@ -389,7 +389,7 @@ int keyboard_repeat_init(struct seat *s) if (s->repeat_fd >= 0) return 0; s->repeat_fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC); if (s->repeat_fd < 0) return -1; - s->repeat_watch = yasl_loop_add_fd(s->conn->loop, s->repeat_fd, POLLIN, + s->repeat_watch = yasl_private_loop_add_fd(s->conn->loop, s->repeat_fd, POLLIN, keyboard_repeat_ready, s); if (s->repeat_watch <= 0) { s->repeat_watch = 0; @@ -406,18 +406,18 @@ int seat_modifiers(const struct seat *s) if (unlikely(!s || !s->xkb_state)) return 0; return ((s->mod_shift != XKB_MOD_INVALID && xkb_state_mod_index_is_active(s->xkb_state, s->mod_shift, - XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_MOD_SHIFT) | + XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_PRIVATE_MOD_SHIFT) | ((s->mod_alt != XKB_MOD_INVALID && xkb_state_mod_index_is_active(s->xkb_state, s->mod_alt, - XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_MOD_ALT) | + XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_PRIVATE_MOD_ALT) | ((s->mod_ctrl != XKB_MOD_INVALID && xkb_state_mod_index_is_active(s->xkb_state, s->mod_ctrl, - XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_MOD_CTRL) | + XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_PRIVATE_MOD_CTRL) | ((s->mod_super != XKB_MOD_INVALID && xkb_state_mod_index_is_active(s->xkb_state, s->mod_super, - XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_MOD_SUPER) | + XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_PRIVATE_MOD_SUPER) | ((xkb_state_mod_name_is_active(s->xkb_state, XKB_MOD_NAME_CAPS, - XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_MOD_CAPS); + XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_PRIVATE_MOD_CAPS); } int wayland_display_modifiers(const struct wayland_display *c) @@ -425,12 +425,12 @@ int wayland_display_modifiers(const struct wayland_display *c) return c ? seat_modifiers(c->active_seat ? c->active_seat : c->seats) : 0; } -void wayland_display_copy(struct wayland_display *c, enum yasl_selection sel, const char *text) +void wayland_display_copy(struct wayland_display *c, enum yasl_private_selection sel, const char *text) { (void)wayland_display_copy_text(c, sel, text); } -bool wayland_display_copy_text(struct wayland_display *c, enum yasl_selection sel, +bool wayland_display_copy_text(struct wayland_display *c, enum yasl_private_selection sel, const char *text) { struct seat *s = c ? (c->active_seat ? c->active_seat : c->seats) : NULL; @@ -447,28 +447,28 @@ bool wayland_display_copy_text(struct wayland_display *c, enum yasl_selection se return false; } errno = 0; - bool ok = sel == YASL_PRIMARY ? + bool ok = sel == YASL_PRIVATE_PRIMARY ? clipboard_copy_primary(s->clipboard, text, s->input_serial) : clipboard_copy(s->clipboard, text, s->input_serial); return ok; } -void wayland_display_paste(struct wayland_display *c, enum yasl_selection sel, struct wayland_surface *target) +void wayland_display_paste(struct wayland_display *c, enum yasl_private_selection sel, struct wayland_surface *target) { struct seat *s = c ? (c->active_seat ? c->active_seat : c->seats) : NULL; if (!target || target->closed || target->destroyed) return; if (!s || !s->clipboard) { - yasl_surface_complete_paste(&target->base, 0, - YASL_TRANSFER_UNAVAILABLE, NULL, 0); + yasl_private_surface_complete_paste(&target->base, 0, + YASL_PRIVATE_TRANSFER_UNAVAILABLE, NULL, 0); return; } - if (sel == YASL_PRIMARY) + if (sel == YASL_PRIVATE_PRIMARY) clipboard_paste_primary(s->clipboard, target->surface); else clipboard_paste(s->clipboard, target->surface); } -bool wayland_display_request_paste(struct wayland_display *c, enum yasl_selection sel, +bool wayland_display_request_paste(struct wayland_display *c, enum yasl_private_selection sel, struct wayland_surface *target, uint64_t request_id) { struct seat *s = c ? (c->active_seat ? c->active_seat : c->seats) : NULL; @@ -486,7 +486,7 @@ bool wayland_display_request_paste(struct wayland_display *c, enum yasl_selectio return ok; } -bool wayland_surface_poll_event(struct wayland_surface *w, struct yasl_event *ev) +bool wayland_surface_poll_event(struct wayland_surface *w, struct yasl_private_event *ev) { return w && ev && input_queue_pop(&w->input, ev); } -- cgit v1.2.3