From 6eac0a5f2c552728efca420b1129fae7d4fea773 Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Sun, 11 Oct 2026 23:40:57 +0300 Subject: feat: backend selection (Wayland, X11, Cocoa) --- src/wayland/shell.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/wayland/shell.c') diff --git a/src/wayland/shell.c b/src/wayland/shell.c index ef72512..f068f48 100644 --- a/src/wayland/shell.c +++ b/src/wayland/shell.c @@ -7,7 +7,7 @@ static void presentation_clock_id(void *data, struct wp_presentation *presentati uint32_t clk_id) { (void)presentation; - struct yasl_display *c = data; + struct wayland_display *c = data; struct timespec ts; c->pres_clock = (clockid_t)clk_id; c->pres_clock_known = clock_gettime(c->pres_clock, &ts) == 0; @@ -21,7 +21,7 @@ static uint64_t clock_ns(clockid_t clock) return (uint64_t)ts.tv_sec * 1000000000ull + (uint64_t)ts.tv_nsec; } -uint64_t conn_pres_to_mono(const struct yasl_display *c, uint64_t ns) +uint64_t conn_pres_to_mono(const struct wayland_display *c, uint64_t ns) { if (c->pres_clock == CLOCK_MONOTONIC) return ns; @@ -30,7 +30,7 @@ uint64_t conn_pres_to_mono(const struct yasl_display *c, uint64_t ns) return ns + mono - pres; } -uint64_t conn_mono_to_pres(const struct yasl_display *c, uint64_t ns) +uint64_t conn_mono_to_pres(const struct wayland_display *c, uint64_t ns) { if (c->pres_clock == CLOCK_MONOTONIC) return ns; @@ -61,9 +61,9 @@ static void output_mode(void *data, struct wl_output *output, uint32_t flags, o->pending_refresh_ns = (uint32_t)(1000000000000ull / (uint32_t)refresh); } -static void conn_follow_outputs(struct yasl_display *c) +static void conn_follow_outputs(struct wayland_display *c) { - for (struct yasl_surface *w = c->surfaces; w; w = w->conn_next) + for (struct wayland_surface *w = c->surfaces; w; w = w->conn_next) surface_follow_outputs(w); } @@ -101,7 +101,7 @@ static const struct wl_output_listener output_listener = { .scale = output_scale, }; -static void conn_bind_output(struct yasl_display *c, struct wl_registry *registry, +static void conn_bind_output(struct wayland_display *c, struct wl_registry *registry, uint32_t name, uint32_t version) { struct wl_conn_output *o = calloc(1, sizeof(*o)); @@ -134,7 +134,7 @@ static void output_destroy(struct wl_conn_output *o) free(o); } -static bool conn_remove_output(struct yasl_display *c, uint32_t name) +static bool conn_remove_output(struct wayland_display *c, uint32_t name) { struct wl_conn_output **link = &c->outputs; while (*link && (*link)->name != name) @@ -143,14 +143,14 @@ static bool conn_remove_output(struct yasl_display *c, uint32_t name) if (!o) return false; *link = o->next; - for (struct yasl_surface *w = c->surfaces; w; w = w->conn_next) + for (struct wayland_surface *w = c->surfaces; w; w = w->conn_next) w->outputs &= ~o->mask; output_destroy(o); conn_follow_outputs(c); return true; } -void conn_destroy_outputs(struct yasl_display *c) +void conn_destroy_outputs(struct wayland_display *c) { while (c->outputs) { struct wl_conn_output *o = c->outputs; @@ -159,7 +159,7 @@ void conn_destroy_outputs(struct yasl_display *c) } } -uint64_t conn_output_mask(const struct yasl_display *c, const struct wl_output *proxy) +uint64_t conn_output_mask(const struct wayland_display *c, const struct wl_output *proxy) { for (const struct wl_conn_output *o = c->outputs; o; o = o->next) if (o->proxy == proxy) @@ -167,7 +167,7 @@ uint64_t conn_output_mask(const struct yasl_display *c, const struct wl_output * return 0; } -uint32_t conn_output_scale_120(const struct yasl_display *c, uint64_t outputs) +uint32_t conn_output_scale_120(const struct wayland_display *c, uint64_t outputs) { int32_t scale = 0; for (const struct wl_conn_output *o = c->outputs; o; o = o->next) @@ -179,7 +179,7 @@ uint32_t conn_output_scale_120(const struct yasl_display *c, uint64_t outputs) static void registry_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) { - struct yasl_display *c = data; + struct wayland_display *c = data; if (strcmp(interface, wl_compositor_interface.name) == 0) { c->compositor = wl_registry_bind(registry, name, &wl_compositor_interface, version < 6 ? version : 6); @@ -245,7 +245,7 @@ static void registry_global_remove(void *data, struct wl_registry *registry, uint32_t name) { (void)registry; - struct yasl_display *c = data; + struct wayland_display *c = data; if (c && !conn_remove_output(c, name)) seat_remove(c, name); } @@ -265,17 +265,17 @@ static const struct xdg_wm_base_listener wm_base_listener = { .ping = wm_base_ping, }; -static void notify_state(struct yasl_surface *w) +static void notify_state(struct wayland_surface *w) { if (w->cbs && w->cbs->state) - w->cbs->state(w, yasl_surface_state(w), w->ud); + w->cbs->state(&w->base, wayland_surface_state(w), w->ud); } static void toplevel_configure(void *data, struct xdg_toplevel *toplevel, int32_t width, int32_t height, struct wl_array *states) { (void)toplevel; - struct yasl_surface *w = data; + struct wayland_surface *w = data; bool fs = false, max = false, act = false, susp = false, tiled = false; uint32_t *s; @@ -317,13 +317,13 @@ static void toplevel_configure_bounds(void *data, struct xdg_toplevel *toplevel, int32_t width, int32_t height) { (void)toplevel; - struct yasl_surface *w = data; + struct wayland_surface *w = data; w->bound_width = width; w->bound_height = height; if ((width > 0 && w->logical_width > width) || (height > 0 && w->logical_height > height)) { w->size_pending = true; - yasl_surface_schedule_redraw(w); + wayland_surface_schedule_redraw(w); } } @@ -342,13 +342,13 @@ static const struct xdg_toplevel_listener toplevel_listener = { static void xdg_surface_configure(void *data, struct xdg_surface *xdg_surface, uint32_t serial) { - struct yasl_surface *w = data; + struct wayland_surface *w = data; (void)xdg_surface; w->pending_serial = serial; w->has_pending_serial = true; w->size_pending = true; w->configured = true; - yasl_surface_schedule_redraw(w); + wayland_surface_schedule_redraw(w); } const struct xdg_surface_listener shell_surface_listener = { @@ -359,7 +359,7 @@ static void toplevel_decoration_configure(void *data, struct zxdg_toplevel_decoration_v1 *toplevel_decor, uint32_t mode) { (void)toplevel_decor; - struct yasl_surface *w = data; + struct wayland_surface *w = data; bool was_server = w->server_decorated; w->server_decorated = (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE); if (was_server != w->server_decorated) @@ -370,7 +370,7 @@ static const struct zxdg_toplevel_decoration_v1_listener toplevel_decoration_lis .configure = toplevel_decoration_configure, }; -int surface_init_shell(struct yasl_surface *w, const char *title) +int surface_init_shell(struct wayland_surface *w, const char *title) { w->xdg_surface = xdg_wm_base_get_xdg_surface(w->conn->wm_base, w->surface); if (!w->xdg_surface) return -1; @@ -379,7 +379,7 @@ int surface_init_shell(struct yasl_surface *w, const char *title) if (!w->toplevel) return -1; xdg_toplevel_add_listener(w->toplevel, &toplevel_listener, w); - yasl_surface_set_title(w, title ? title : "yasl_app"); + wayland_surface_set_title(w, title ? title : "yasl_app"); const char *app_id = w->conn->app_id ? w->conn->app_id : "yasl_app"; xdg_toplevel_set_app_id(w->toplevel, app_id); -- cgit v1.2.3