diff --git a/cage.c b/cage.c index 8f14746..2969c86 100644 --- a/cage.c +++ b/cage.c @@ -1,7 +1,7 @@ /* * Cage: A Wayland kiosk. * - * Copyright (C) 2018-2020 Jente Hidskes + * Copyright (C) 2018-2021 Jente Hidskes * * See the LICENSE file accompanying this file. */ @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,7 @@ #endif #include "idle_inhibit_v1.h" +#include "layer_shell_v1.h" #include "output.h" #include "seat.h" #include "server.h" @@ -461,6 +463,15 @@ main(int argc, char *argv[]) goto end; } + server.layer_shell_v1 = wlr_layer_shell_v1_create(server.wl_display, 4); + if (!server.layer_shell_v1) { + wlr_log(WLR_ERROR, "Unable to create the layer shell"); + ret = 1; + goto end; + } + server.new_layer_shell_v1_surface.notify = handle_layer_shell_v1_surface_new; + wl_signal_add(&server.layer_shell_v1->events.new_surface, &server.new_layer_shell_v1_surface); + if (!wlr_export_dmabuf_manager_v1_create(server.wl_display)) { wlr_log(WLR_ERROR, "Unable to create the export DMABUF manager"); ret = 1; diff --git a/layer_shell_v1.c b/layer_shell_v1.c new file mode 100644 index 0000000..c66ef05 --- /dev/null +++ b/layer_shell_v1.c @@ -0,0 +1,27 @@ +/* + * Cage: A Wayland kiosk. + * + * Copyright (C) 2021 Jente Hidskes + * + * See the LICENSE file accompanying this file. + */ + +#include "layer_shell_v1.h" +#include "server.h" + +#include +#include +#include + +void +handle_layer_shell_v1_surface_new(struct wl_listener *listener, void *data) +{ + struct cg_server *server = wl_container_of(listener, server, new_layer_shell_v1_surface); + struct wlr_layer_surface_v1 *layer_surface = data; + + wlr_log(WLR_DEBUG, "New layer shell surface: namespace %s layer %d anchor %d size %dx%d margin %d,%d,%d,%d", + layer_surface->namespace, layer_surface->pending.layer, layer_surface->pending.anchor, + layer_surface->pending.desired_width, layer_surface->pending.desired_height, + layer_surface->pending.margin.top, layer_surface->pending.margin.right, + layer_surface->pending.margin.bottom, layer_surface->pending.margin.left); +} diff --git a/layer_shell_v1.h b/layer_shell_v1.h new file mode 100644 index 0000000..d7ade6e --- /dev/null +++ b/layer_shell_v1.h @@ -0,0 +1,8 @@ +#ifndef CG_LAYER_SHELL_V1_H +#define CG_LAYER_SHELL_V1_H + +#include + +void handle_layer_shell_v1_surface_new(struct wl_listener *listener, void *data); + +#endif diff --git a/meson.build b/meson.build index 998fe8c..ba2469b 100644 --- a/meson.build +++ b/meson.build @@ -92,6 +92,7 @@ endif cage_sources = [ 'cage.c', 'idle_inhibit_v1.c', + 'layer_shell_v1.c', 'output.c', 'seat.c', 'view.c', @@ -103,6 +104,7 @@ cage_headers = [ output: 'config.h', configuration: conf_data), 'idle_inhibit_v1.h', + 'layer_shell_v1.h', 'output.h', 'seat.h', 'server.h', diff --git a/server.h b/server.h index 00c2a61..95a083b 100644 --- a/server.h +++ b/server.h @@ -52,6 +52,9 @@ struct cg_server { struct wl_listener new_virtual_keyboard; struct wl_listener new_virtual_pointer; + + struct wlr_layer_shell_v1 *layer_shell_v1; + struct wl_listener new_layer_shell_v1_surface; #if CAGE_HAS_XWAYLAND struct wl_listener new_xwayland_surface; #endif