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/shell.c | 50 ++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 18 deletions(-) (limited to 'src/platform/wayland/shell.c') diff --git a/src/platform/wayland/shell.c b/src/platform/wayland/shell.c index fc2ce2e..c2578e7 100644 --- a/src/platform/wayland/shell.c +++ b/src/platform/wayland/shell.c @@ -173,7 +173,7 @@ uint32_t conn_output_scale_120(const struct wayland_display *c, uint64_t outputs for (const struct wl_conn_output *o = c->outputs; o; o = o->next) if ((o->mask & outputs) && o->scale > scale) scale = o->scale; - return (uint32_t)scale * YASL_SCALE_UNIT; + return (uint32_t)scale * YASL_PRIVATE_SCALE_UNIT; } static void registry_global(void *data, struct wl_registry *registry, @@ -227,6 +227,8 @@ static void registry_global(void *data, struct wl_registry *registry, } else if (strcmp(interface, zwp_text_input_manager_v3_interface.name) == 0) { c->text_input_mgr = wl_registry_bind(registry, name, &zwp_text_input_manager_v3_interface, 1); + for (struct seat *seat = c->seats; seat; seat = seat->next) + seat_ensure_text_input(seat); } else if (strcmp(interface, wp_tearing_control_manager_v1_interface.name) == 0) { c->tearing_mgr = wl_registry_bind(registry, name, &wp_tearing_control_manager_v1_interface, 1); @@ -277,7 +279,7 @@ static void set_state(struct wayland_surface *w, uint32_t state) { if (state == w->base.state) return; w->base.state = state; - yasl_surface_notify_state(&w->base, state); + yasl_private_surface_notify_state(&w->base, state); } static void toplevel_configure(void *data, struct xdg_toplevel *toplevel, @@ -286,21 +288,21 @@ static void toplevel_configure(void *data, struct xdg_toplevel *toplevel, (void)toplevel; struct wayland_surface *w = data; - uint32_t state = w->base.state & ~(YASL_STATE_FULLSCREEN | - YASL_STATE_MAXIMIZED | YASL_STATE_ACTIVATED | - YASL_STATE_SUSPENDED | YASL_STATE_TILED); + uint32_t state = w->base.state & ~(YASL_PRIVATE_STATE_FULLSCREEN | + YASL_PRIVATE_STATE_MAXIMIZED | YASL_PRIVATE_STATE_ACTIVATED | + YASL_PRIVATE_STATE_SUSPENDED | YASL_PRIVATE_STATE_TILED); uint32_t *s; wl_array_for_each(s, states) { switch (*s) { - case XDG_TOPLEVEL_STATE_FULLSCREEN: state |= YASL_STATE_FULLSCREEN; break; - case XDG_TOPLEVEL_STATE_MAXIMIZED: state |= YASL_STATE_MAXIMIZED; break; - case XDG_TOPLEVEL_STATE_ACTIVATED: state |= YASL_STATE_ACTIVATED; break; - case XDG_TOPLEVEL_STATE_SUSPENDED: state |= YASL_STATE_SUSPENDED; break; + case XDG_TOPLEVEL_STATE_FULLSCREEN: state |= YASL_PRIVATE_STATE_FULLSCREEN; break; + case XDG_TOPLEVEL_STATE_MAXIMIZED: state |= YASL_PRIVATE_STATE_MAXIMIZED; break; + case XDG_TOPLEVEL_STATE_ACTIVATED: state |= YASL_PRIVATE_STATE_ACTIVATED; break; + case XDG_TOPLEVEL_STATE_SUSPENDED: state |= YASL_PRIVATE_STATE_SUSPENDED; break; case XDG_TOPLEVEL_STATE_TILED_LEFT: case XDG_TOPLEVEL_STATE_TILED_RIGHT: case XDG_TOPLEVEL_STATE_TILED_TOP: case XDG_TOPLEVEL_STATE_TILED_BOTTOM: - state |= YASL_STATE_TILED; + state |= YASL_PRIVATE_STATE_TILED; break; default: break; } @@ -316,7 +318,7 @@ static void toplevel_close(void *data, struct xdg_toplevel *toplevel) (void)toplevel; struct wayland_surface *w = data; if (w && !w->closed) - yasl_surface_notify_close(&w->base); + yasl_private_surface_notify_close(&w->base); } static void toplevel_configure_bounds(void *data, struct xdg_toplevel *toplevel, @@ -349,11 +351,21 @@ static const struct xdg_toplevel_listener toplevel_listener = { static void xdg_surface_configure(void *data, struct xdg_surface *xdg_surface, uint32_t serial) { struct wayland_surface *w = data; - (void)xdg_surface; w->pending_serial = serial; w->has_pending_serial = true; w->size_pending = true; w->configured = true; + /* CPU surfaces acknowledge with their SHM commit. External presenters + * commit through EGL/Vulkan, so apply the configure and acknowledge it + * before renderer code can submit that first native buffer. */ + if (w->base.presenter != YASL_PRIVATE_PRESENTER_CPU) { + xdg_surface_ack_configure(xdg_surface, serial); + w->has_pending_serial = false; + if (apply_pending_geometry(w) < 0) { + surface_fail(w); + return; + } + } wayland_surface_schedule_redraw(w); } @@ -368,9 +380,9 @@ static void toplevel_decoration_configure(void *data, struct wayland_surface *w = data; uint32_t state = w->base.state; if (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE) - state &= ~YASL_STATE_CSD; + state &= ~YASL_PRIVATE_STATE_CSD; else - state |= YASL_STATE_CSD; + state |= YASL_PRIVATE_STATE_CSD; set_state(w, state); } @@ -387,11 +399,11 @@ int surface_init_shell(struct wayland_surface *w, const char *title) if (!w->toplevel) return -1; xdg_toplevel_add_listener(w->toplevel, &toplevel_listener, w); - wayland_surface_set_title(w, title ? title : "yasl_app"); + wayland_surface_set_title(w, title ? title : "yasl_private_app"); - const char *app_id = w->conn->app_id ? w->conn->app_id : "yasl_app"; + const char *app_id = w->conn->app_id ? w->conn->app_id : "yasl_private_app"; xdg_toplevel_set_app_id(w->toplevel, app_id); - xdg_toplevel_set_min_size(w->toplevel, YASL_MIN_LOGICAL_PX, YASL_MIN_LOGICAL_PX); + xdg_toplevel_set_min_size(w->toplevel, YASL_PRIVATE_MIN_LOGICAL_PX, YASL_PRIVATE_MIN_LOGICAL_PX); if (w->conn->decor_mgr) { w->toplevel_decor = zxdg_decoration_manager_v1_get_toplevel_decoration( @@ -400,7 +412,9 @@ int surface_init_shell(struct wayland_surface *w, const char *title) zxdg_toplevel_decoration_v1_add_listener(w->toplevel_decor, &toplevel_decoration_listener, w); zxdg_toplevel_decoration_v1_set_mode(w->toplevel_decor, - ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); + (w->base.creation_flags & YASL_PRIVATE_SURFACE_UNDECORATED) + ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE + : ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); } return 0; } -- cgit v1.2.3