From 29a8910556b47e1c78b23a84f12b698e115ffea8 Mon Sep 17 00:00:00 2001 From: Rakarake Date: Thu, 25 Dec 2025 23:59:11 +0100 Subject: [PATCH] WIP wlr_layer_shell --- glonkers.c | 7 +++++-- wayland.c | 13 +++++++++++++ wayland.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/glonkers.c b/glonkers.c index b660871..fed3237 100644 --- a/glonkers.c +++ b/glonkers.c @@ -36,10 +36,13 @@ int main(int argc, char *argv[]) { } if (argc >= 3) { // xdg toplevel window (window) or wlr_layer_shell window (layer) - if (strcmp(argv[2], "window")) { + if (strcmp(argv[2], "window") == 0) { output_type = OUTPUT_WINDOW; - } else if (strcmp(argv[2], "layer")) { + } else if (strcmp(argv[2], "layer") == 0) { output_type = OUTPUT_LAYER; + } else { + printf("argument 2 is either 'window' or 'layer' 🍰\n"); + return 1; } } diff --git a/wayland.c b/wayland.c index 6660521..8d06d9c 100644 --- a/wayland.c +++ b/wayland.c @@ -54,6 +54,17 @@ static const struct xdg_toplevel_listener xdg_toplevel_listener = { .close = xdg_toplevel_close, }; +static void zwlr_layer_surface_v1_configure(void *data, struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial, uint32_t width, uint32_t height) { + struct client_state *state = data; + state->width = width; + state->height = height; + wl_egl_window_resize(state->egl_window, width, height, 0, 0); +} + +static const struct zwlr_layer_surface_v1_listener zwlr_layer_surface_v1_listener = { + .configure = zwlr_layer_surface_v1_configure, +}; + static void registry_handle_global( void *data, struct wl_registry *registry, @@ -87,6 +98,8 @@ static void registry_handle_global( } if ((strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) && (state->output_type == OUTPUT_LAYER)) { state->zwlr_layer_shell_v1 = wl_registry_bind(registry, name, &zwlr_layer_shell_v1_interface, 4); + int layer = ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND; + state->zwlr_layer_surface_v1 = zwlr_layer_shell_v1_get_layer_surface(state->zwlr_layer_shell_v1, state->wl_surface, NULL, layer, "wallpaper"); } if (strcmp(interface, wl_output_interface.name) == 0) { state->wl_output = wl_registry_bind( diff --git a/wayland.h b/wayland.h index 6b705ff..cfaf7b8 100644 --- a/wayland.h +++ b/wayland.h @@ -26,6 +26,7 @@ struct client_state { // wlr_layer_shell struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1; + struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1; struct wl_output *wl_output; EGLDisplay egl_display;