commit c4bb1f9
pita
·
2026-07-16 20:07:24 +0000 UTC
parent 287f5d8
layer shell
4 files changed,
+721,
-12
M
makefile
+2,
-2
1@@ -43,10 +43,10 @@ archive:
2
3 bin/uxn12: src/uxn12.c
4 mkdir -p bin
5- cc ${RELEASE_flags} ${CFLAGS} -s src/uxn12.c src/xdg-shell-protocol.c -lwayland-client -lxkbcommon -o bin/uxn12
6+ cc ${RELEASE_flags} ${CFLAGS} -s src/uxn12.c src/wlr-layer-shell-client-protocol.c src/xdg-shell-protocol.c -lwayland-client -lxkbcommon -o bin/uxn12
7 bin/uxn12-debug: src/uxn12.c
8 mkdir -p bin
9- cc ${DEBUG_flags} ${CFLAGS} -s src/uxn12.c src/xdg-shell-protocol.c -lwayland-client -lxkbcommon -o bin/uxn12
10+ cc ${DEBUG_flags} ${CFLAGS} -s src/uxn12.c src/wlr-layer-shell-client-protocol.c src/xdg-shell-protocol.c -lwayland-client -lxkbcommon -o bin/uxn12
11
12 # Tools
13
+64,
-10
1@@ -10,6 +10,7 @@
2 #include <xkbcommon/xkbcommon.h>
3 #include <linux/input-event-codes.h>
4 #include "xdg-shell-client-protocol.h"
5+#include "wlr-layer-shell-client-protocol.h"
6
7 /*
8 Copyright (c) 2021-2026 Devine Lu Linvega, Andrew Alderwick,
9@@ -1104,6 +1105,11 @@ static struct wl_surface *emu_surf;
10 static struct xdg_surface *emu_xdgsurf;
11 static struct xdg_toplevel *emu_top;
12 static struct wl_buffer *emu_buf;
13+static struct zwlr_layer_shell_v1 *emu_layer_shell;
14+static struct zwlr_layer_surface_v1 *emu_layer_surf;
15+static int use_layer_shell = 0;
16+static int layer_shell_x = 0;
17+static int layer_shell_y = 0;
18 static int emu_timer;
19 static int emu_configured;
20
21@@ -1360,6 +1366,22 @@ static const struct xdg_toplevel_listener xt_listener = {
22 .close = xt_close,
23 };
24
25+static void
26+ls_configure(void *d, struct zwlr_layer_surface_v1 *ls, uint32_t serial, uint32_t w, uint32_t h)
27+{
28+ zwlr_layer_surface_v1_ack_configure(ls, serial);
29+ emu_configured = 1;
30+ screen_reqdraw = 1;
31+}
32+
33+static void
34+ls_closed(void *d, struct zwlr_layer_surface_v1 *ls) { dev[0x0f] = 0x80; }
35+
36+static const struct zwlr_layer_surface_v1_listener ls_listener = {
37+ .configure = ls_configure,
38+ .closed = ls_closed,
39+};
40+
41 static void
42 reg_global(void *d, struct wl_registry *reg, uint32_t name, const char *iface, uint32_t ver)
43 {
44@@ -1369,6 +1391,8 @@ reg_global(void *d, struct wl_registry *reg, uint32_t name, const char *iface, u
45 emu_shm = wl_registry_bind(reg, name, &wl_shm_interface, 1);
46 else if(!strcmp(iface, "xdg_wm_base"))
47 emu_wm = wl_registry_bind(reg, name, &xdg_wm_base_interface, 1);
48+ else if(!strcmp(iface, "zwlr_layer_shell_v1"))
49+ emu_layer_shell = wl_registry_bind(reg, name, &zwlr_layer_shell_v1_interface, 4);
50 else if(!strcmp(iface, "wl_seat")) {
51 emu_seat = wl_registry_bind(reg, name, &wl_seat_interface, 1);
52 wl_seat_add_listener(emu_seat, &seat_listener, NULL);
53@@ -1390,17 +1414,31 @@ emu_init(void)
54 emu_reg = wl_display_get_registry(emu_dpy);
55 wl_registry_add_listener(emu_reg, ®_listener, NULL);
56 wl_display_roundtrip(emu_dpy);
57- if(!emu_comp || !emu_shm || !emu_wm)
58+ if(!emu_comp || !emu_shm || (!emu_wm && !use_layer_shell ))
59 return !fprintf(stderr, "Wayland: missing globals\n");
60- xdg_wm_base_add_listener(emu_wm, &wm_listener, NULL);
61+
62 emu_surf = wl_compositor_create_surface(emu_comp);
63- emu_xdgsurf = xdg_wm_base_get_xdg_surface(emu_wm, emu_surf);
64- xdg_surface_add_listener(emu_xdgsurf, &xs_listener, NULL);
65- emu_top = xdg_surface_get_toplevel(emu_xdgsurf);
66- xdg_toplevel_add_listener(emu_top, &xt_listener, NULL);
67- xdg_toplevel_set_title(emu_top, "uxn-wl");
68- xdg_toplevel_set_app_id(emu_top, "uxn-wl");
69- wl_surface_commit(emu_surf);
70+ if(use_layer_shell && emu_layer_shell) {
71+ emu_layer_surf = zwlr_layer_shell_v1_get_layer_surface(
72+ emu_layer_shell, emu_surf, NULL,
73+ ZWLR_LAYER_SHELL_V1_LAYER_TOP, "uxn-wl");
74+ zwlr_layer_surface_v1_add_listener(emu_layer_surf, &ls_listener, NULL);
75+ zwlr_layer_surface_v1_set_size(emu_layer_surf, screen_width, screen_height);
76+ zwlr_layer_surface_v1_set_anchor(emu_layer_surf,
77+ ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT);
78+ zwlr_layer_surface_v1_set_margin(emu_layer_surf, layer_shell_y, 0, 0, layer_shell_x);
79+ zwlr_layer_surface_v1_set_keyboard_interactivity(emu_layer_surf, 1);
80+ wl_surface_commit(emu_surf);
81+ } else if(emu_wm) {
82+ xdg_wm_base_add_listener(emu_wm, &wm_listener, NULL);
83+ emu_xdgsurf = xdg_wm_base_get_xdg_surface(emu_wm, emu_surf);
84+ xdg_surface_add_listener(emu_xdgsurf, &xs_listener, NULL);
85+ emu_top = xdg_surface_get_toplevel(emu_xdgsurf);
86+ xdg_toplevel_add_listener(emu_top, &xt_listener, NULL);
87+ xdg_toplevel_set_title(emu_top, "uxn-wl");
88+ xdg_toplevel_set_app_id(emu_top, "uxn-wl");
89+ wl_surface_commit(emu_surf);
90+ }
91 wl_display_roundtrip(emu_dpy);
92 emu_timer = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
93 if(emu_timer < 0)
94@@ -1451,6 +1489,8 @@ emu_run(void)
95 xdg_toplevel_destroy(emu_top);
96 if(emu_xdgsurf)
97 xdg_surface_destroy(emu_xdgsurf);
98+ if(emu_layer_surf)
99+ zwlr_layer_surface_v1_destroy(emu_layer_surf);
100 if(emu_surf)
101 wl_surface_destroy(emu_surf);
102 if(emu_dpy)
103@@ -1466,7 +1506,21 @@ main(int argc, char **argv)
104 return !fprintf(stdout, "%s - Varvara Emulator(79K), 10 Jul 2026.\n", argv[0]);
105 else if(argc == 1)
106 return !fprintf(stdout, "usage: %s [-v] file.rom [args..]\n", argv[0]);
107- else if(!system_boot(argv[i++], argc > 2))
108+
109+ if(argv[1][0] == '-' && argv[1][1] == 'l') {
110+ if(argc < 5)
111+ return !fprintf(stdout, "usage: %s [-l x y] file.rom [args..]\n", argv[0]);
112+
113+ use_layer_shell = 1;
114+ layer_shell_x = atoi(argv[2]);
115+ layer_shell_y = atoi(argv[3]);
116+ i+=3;
117+
118+ if(i >= argc)
119+ return !fprintf(stdout, "usage: %s [-l x y] file.rom [args..]\n", argv[0]);
120+ if(!system_boot(argv[i++], argc > i))
121+ return !fprintf(stdout, "Could not load %s.\n", argv[i - 1]);
122+ } else if(!system_boot(argv[i++], argc > 2))
123 return !fprintf(stdout, "Could not load %s.\n", argv[i - 1]);
124 screen_resize(WIDTH, HEIGHT);
125 if(uxn_eval(0x100) && console_vector) {
+92,
-0
1@@ -0,0 +1,92 @@
2+/* Generated by wayland-scanner 1.25.0 */
3+
4+/*
5+ * Copyright © 2017 Drew DeVault
6+ *
7+ * Permission to use, copy, modify, distribute, and sell this
8+ * software and its documentation for any purpose is hereby granted
9+ * without fee, provided that the above copyright notice appear in
10+ * all copies and that both that copyright notice and this permission
11+ * notice appear in supporting documentation, and that the name of
12+ * the copyright holders not be used in advertising or publicity
13+ * pertaining to distribution of the software without specific,
14+ * written prior permission. The copyright holders make no
15+ * representations about the suitability of this software for any
16+ * purpose. It is provided "as is" without express or implied
17+ * warranty.
18+ *
19+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
20+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
21+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
22+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
23+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
24+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
26+ * THIS SOFTWARE.
27+ */
28+
29+#include <stdbool.h>
30+#include <stdlib.h>
31+#include <stdint.h>
32+#include "wayland-util.h"
33+
34+#ifndef __has_attribute
35+# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
36+#endif
37+
38+#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
39+#define WL_PRIVATE __attribute__ ((visibility("hidden")))
40+#else
41+#define WL_PRIVATE
42+#endif
43+
44+extern const struct wl_interface wl_output_interface;
45+extern const struct wl_interface wl_surface_interface;
46+extern const struct wl_interface xdg_popup_interface;
47+extern const struct wl_interface zwlr_layer_surface_v1_interface;
48+
49+static const struct wl_interface *wlr_layer_shell_unstable_v1_types[] = {
50+ NULL,
51+ NULL,
52+ NULL,
53+ NULL,
54+ &zwlr_layer_surface_v1_interface,
55+ &wl_surface_interface,
56+ &wl_output_interface,
57+ NULL,
58+ NULL,
59+ &xdg_popup_interface,
60+};
61+
62+static const struct wl_message zwlr_layer_shell_v1_requests[] = {
63+ { "get_layer_surface", "no?ous", wlr_layer_shell_unstable_v1_types + 4 },
64+};
65+
66+WL_PRIVATE const struct wl_interface zwlr_layer_shell_v1_interface = {
67+ "zwlr_layer_shell_v1", 1,
68+ 1, zwlr_layer_shell_v1_requests,
69+ 0, NULL,
70+};
71+
72+static const struct wl_message zwlr_layer_surface_v1_requests[] = {
73+ { "set_size", "uu", wlr_layer_shell_unstable_v1_types + 0 },
74+ { "set_anchor", "u", wlr_layer_shell_unstable_v1_types + 0 },
75+ { "set_exclusive_zone", "i", wlr_layer_shell_unstable_v1_types + 0 },
76+ { "set_margin", "iiii", wlr_layer_shell_unstable_v1_types + 0 },
77+ { "set_keyboard_interactivity", "u", wlr_layer_shell_unstable_v1_types + 0 },
78+ { "get_popup", "o", wlr_layer_shell_unstable_v1_types + 9 },
79+ { "ack_configure", "u", wlr_layer_shell_unstable_v1_types + 0 },
80+ { "destroy", "", wlr_layer_shell_unstable_v1_types + 0 },
81+};
82+
83+static const struct wl_message zwlr_layer_surface_v1_events[] = {
84+ { "configure", "uuu", wlr_layer_shell_unstable_v1_types + 0 },
85+ { "closed", "", wlr_layer_shell_unstable_v1_types + 0 },
86+};
87+
88+WL_PRIVATE const struct wl_interface zwlr_layer_surface_v1_interface = {
89+ "zwlr_layer_surface_v1", 1,
90+ 8, zwlr_layer_surface_v1_requests,
91+ 2, zwlr_layer_surface_v1_events,
92+};
93+
+563,
-0
1@@ -0,0 +1,563 @@
2+/* Generated by wayland-scanner 1.25.0 */
3+
4+#ifndef WLR_LAYER_SHELL_UNSTABLE_V1_CLIENT_PROTOCOL_H
5+#define WLR_LAYER_SHELL_UNSTABLE_V1_CLIENT_PROTOCOL_H
6+
7+#include <stdint.h>
8+#include <stddef.h>
9+#include "wayland-client.h"
10+
11+#ifdef __cplusplus
12+extern "C" {
13+#endif
14+
15+/**
16+ * @page page_wlr_layer_shell_unstable_v1 The wlr_layer_shell_unstable_v1 protocol
17+ * @section page_ifaces_wlr_layer_shell_unstable_v1 Interfaces
18+ * - @subpage page_iface_zwlr_layer_shell_v1 - create surfaces that are layers of the desktop
19+ * - @subpage page_iface_zwlr_layer_surface_v1 - layer metadata interface
20+ * @section page_copyright_wlr_layer_shell_unstable_v1 Copyright
21+ * <pre>
22+ *
23+ * Copyright © 2017 Drew DeVault
24+ *
25+ * Permission to use, copy, modify, distribute, and sell this
26+ * software and its documentation for any purpose is hereby granted
27+ * without fee, provided that the above copyright notice appear in
28+ * all copies and that both that copyright notice and this permission
29+ * notice appear in supporting documentation, and that the name of
30+ * the copyright holders not be used in advertising or publicity
31+ * pertaining to distribution of the software without specific,
32+ * written prior permission. The copyright holders make no
33+ * representations about the suitability of this software for any
34+ * purpose. It is provided "as is" without express or implied
35+ * warranty.
36+ *
37+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
38+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
39+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
40+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
41+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
42+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
43+ * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
44+ * THIS SOFTWARE.
45+ * </pre>
46+ */
47+struct wl_output;
48+struct wl_surface;
49+struct xdg_popup;
50+struct zwlr_layer_shell_v1;
51+struct zwlr_layer_surface_v1;
52+
53+#ifndef ZWLR_LAYER_SHELL_V1_INTERFACE
54+#define ZWLR_LAYER_SHELL_V1_INTERFACE
55+/**
56+ * @page page_iface_zwlr_layer_shell_v1 zwlr_layer_shell_v1
57+ * @section page_iface_zwlr_layer_shell_v1_desc Description
58+ *
59+ * Clients can use this interface to assign the surface_layer role to
60+ * wl_surfaces. Such surfaces are assigned to a "layer" of the output and
61+ * rendered with a defined z-depth respective to each other. They may also be
62+ * anchored to the edges and corners of a screen and specify input handling
63+ * semantics. This interface should be suitable for the implementation of
64+ * many desktop shell components, and a broad number of other applications
65+ * that interact with the desktop.
66+ * @section page_iface_zwlr_layer_shell_v1_api API
67+ * See @ref iface_zwlr_layer_shell_v1.
68+ */
69+/**
70+ * @defgroup iface_zwlr_layer_shell_v1 The zwlr_layer_shell_v1 interface
71+ *
72+ * Clients can use this interface to assign the surface_layer role to
73+ * wl_surfaces. Such surfaces are assigned to a "layer" of the output and
74+ * rendered with a defined z-depth respective to each other. They may also be
75+ * anchored to the edges and corners of a screen and specify input handling
76+ * semantics. This interface should be suitable for the implementation of
77+ * many desktop shell components, and a broad number of other applications
78+ * that interact with the desktop.
79+ */
80+extern const struct wl_interface zwlr_layer_shell_v1_interface;
81+#endif
82+#ifndef ZWLR_LAYER_SURFACE_V1_INTERFACE
83+#define ZWLR_LAYER_SURFACE_V1_INTERFACE
84+/**
85+ * @page page_iface_zwlr_layer_surface_v1 zwlr_layer_surface_v1
86+ * @section page_iface_zwlr_layer_surface_v1_desc Description
87+ *
88+ * An interface that may be implemented by a wl_surface, for surfaces that
89+ * are designed to be rendered as a layer of a stacked desktop-like
90+ * environment.
91+ *
92+ * Layer surface state (size, anchor, exclusive zone, margin, interactivity)
93+ * is double-buffered, and will be applied at the time wl_surface.commit of
94+ * the corresponding wl_surface is called.
95+ * @section page_iface_zwlr_layer_surface_v1_api API
96+ * See @ref iface_zwlr_layer_surface_v1.
97+ */
98+/**
99+ * @defgroup iface_zwlr_layer_surface_v1 The zwlr_layer_surface_v1 interface
100+ *
101+ * An interface that may be implemented by a wl_surface, for surfaces that
102+ * are designed to be rendered as a layer of a stacked desktop-like
103+ * environment.
104+ *
105+ * Layer surface state (size, anchor, exclusive zone, margin, interactivity)
106+ * is double-buffered, and will be applied at the time wl_surface.commit of
107+ * the corresponding wl_surface is called.
108+ */
109+extern const struct wl_interface zwlr_layer_surface_v1_interface;
110+#endif
111+
112+#ifndef ZWLR_LAYER_SHELL_V1_ERROR_ENUM
113+#define ZWLR_LAYER_SHELL_V1_ERROR_ENUM
114+enum zwlr_layer_shell_v1_error {
115+ /**
116+ * wl_surface has another role
117+ */
118+ ZWLR_LAYER_SHELL_V1_ERROR_ROLE = 0,
119+ /**
120+ * layer value is invalid
121+ */
122+ ZWLR_LAYER_SHELL_V1_ERROR_INVALID_LAYER = 1,
123+ /**
124+ * wl_surface has a buffer attached or committed
125+ */
126+ ZWLR_LAYER_SHELL_V1_ERROR_ALREADY_CONSTRUCTED = 2,
127+};
128+#endif /* ZWLR_LAYER_SHELL_V1_ERROR_ENUM */
129+
130+#ifndef ZWLR_LAYER_SHELL_V1_LAYER_ENUM
131+#define ZWLR_LAYER_SHELL_V1_LAYER_ENUM
132+/**
133+ * @ingroup iface_zwlr_layer_shell_v1
134+ * available layers for surfaces
135+ *
136+ * These values indicate which layers a surface can be rendered in. They
137+ * are ordered by z depth, bottom-most first. Traditional shell surfaces
138+ * will typically be rendered between the bottom and top layers.
139+ * Fullscreen shell surfaces are typically rendered at the top layer.
140+ * Multiple surfaces can share a single layer, and ordering within a
141+ * single layer is undefined.
142+ */
143+enum zwlr_layer_shell_v1_layer {
144+ ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND = 0,
145+ ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM = 1,
146+ ZWLR_LAYER_SHELL_V1_LAYER_TOP = 2,
147+ ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY = 3,
148+};
149+#endif /* ZWLR_LAYER_SHELL_V1_LAYER_ENUM */
150+
151+#define ZWLR_LAYER_SHELL_V1_GET_LAYER_SURFACE 0
152+
153+
154+/**
155+ * @ingroup iface_zwlr_layer_shell_v1
156+ */
157+#define ZWLR_LAYER_SHELL_V1_GET_LAYER_SURFACE_SINCE_VERSION 1
158+
159+/** @ingroup iface_zwlr_layer_shell_v1 */
160+static inline void
161+zwlr_layer_shell_v1_set_user_data(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1, void *user_data)
162+{
163+ wl_proxy_set_user_data((struct wl_proxy *) zwlr_layer_shell_v1, user_data);
164+}
165+
166+/** @ingroup iface_zwlr_layer_shell_v1 */
167+static inline void *
168+zwlr_layer_shell_v1_get_user_data(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1)
169+{
170+ return wl_proxy_get_user_data((struct wl_proxy *) zwlr_layer_shell_v1);
171+}
172+
173+static inline uint32_t
174+zwlr_layer_shell_v1_get_version(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1)
175+{
176+ return wl_proxy_get_version((struct wl_proxy *) zwlr_layer_shell_v1);
177+}
178+
179+/** @ingroup iface_zwlr_layer_shell_v1 */
180+static inline void
181+zwlr_layer_shell_v1_destroy(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1)
182+{
183+ wl_proxy_destroy((struct wl_proxy *) zwlr_layer_shell_v1);
184+}
185+
186+/**
187+ * @ingroup iface_zwlr_layer_shell_v1
188+ *
189+ * Create a layer surface for an existing surface. This assigns the role of
190+ * layer_surface, or raises a protocol error if another role is already
191+ * assigned.
192+ *
193+ * Creating a layer surface from a wl_surface which has a buffer attached
194+ * or committed is a client error, and any attempts by a client to attach
195+ * or manipulate a buffer prior to the first layer_surface.configure call
196+ * must also be treated as errors.
197+ *
198+ * You may pass NULL for output to allow the compositor to decide which
199+ * output to use. Generally this will be the one that the user most
200+ * recently interacted with.
201+ *
202+ * Clients can specify a namespace that defines the purpose of the layer
203+ * surface.
204+ */
205+static inline struct zwlr_layer_surface_v1 *
206+zwlr_layer_shell_v1_get_layer_surface(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1, struct wl_surface *surface, struct wl_output *output, uint32_t layer, const char *namespace)
207+{
208+ struct wl_proxy *id;
209+
210+ id = wl_proxy_marshal_flags((struct wl_proxy *) zwlr_layer_shell_v1,
211+ ZWLR_LAYER_SHELL_V1_GET_LAYER_SURFACE, &zwlr_layer_surface_v1_interface, wl_proxy_get_version((struct wl_proxy *) zwlr_layer_shell_v1), 0, NULL, surface, output, layer, namespace);
212+
213+ return (struct zwlr_layer_surface_v1 *) id;
214+}
215+
216+#ifndef ZWLR_LAYER_SURFACE_V1_ERROR_ENUM
217+#define ZWLR_LAYER_SURFACE_V1_ERROR_ENUM
218+enum zwlr_layer_surface_v1_error {
219+ /**
220+ * provided surface state is invalid
221+ */
222+ ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SURFACE_STATE = 0,
223+ /**
224+ * size is invalid
225+ */
226+ ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SIZE = 1,
227+ /**
228+ * anchor bitfield is invalid
229+ */
230+ ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_ANCHOR = 2,
231+};
232+#endif /* ZWLR_LAYER_SURFACE_V1_ERROR_ENUM */
233+
234+#ifndef ZWLR_LAYER_SURFACE_V1_ANCHOR_ENUM
235+#define ZWLR_LAYER_SURFACE_V1_ANCHOR_ENUM
236+enum zwlr_layer_surface_v1_anchor {
237+ /**
238+ * the top edge of the anchor rectangle
239+ */
240+ ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP = 1,
241+ /**
242+ * the bottom edge of the anchor rectangle
243+ */
244+ ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM = 2,
245+ /**
246+ * the left edge of the anchor rectangle
247+ */
248+ ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT = 4,
249+ /**
250+ * the right edge of the anchor rectangle
251+ */
252+ ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT = 8,
253+};
254+#endif /* ZWLR_LAYER_SURFACE_V1_ANCHOR_ENUM */
255+
256+/**
257+ * @ingroup iface_zwlr_layer_surface_v1
258+ * @struct zwlr_layer_surface_v1_listener
259+ */
260+struct zwlr_layer_surface_v1_listener {
261+ /**
262+ * suggest a surface change
263+ *
264+ * The configure event asks the client to resize its surface.
265+ *
266+ * Clients should arrange their surface for the new states, and
267+ * then send an ack_configure request with the serial sent in this
268+ * configure event at some point before committing the new surface.
269+ *
270+ * The client is free to dismiss all but the last configure event
271+ * it received.
272+ *
273+ * The width and height arguments specify the size of the window in
274+ * surface-local coordinates.
275+ *
276+ * The size is a hint, in the sense that the client is free to
277+ * ignore it if it doesn't resize, pick a smaller size (to satisfy
278+ * aspect ratio or resize in steps of NxM pixels). If the client
279+ * picks a smaller size and is anchored to two opposite anchors
280+ * (e.g. 'top' and 'bottom'), the surface will be centered on this
281+ * axis.
282+ *
283+ * If the width or height arguments are zero, it means the client
284+ * should decide its own window dimension.
285+ */
286+ void (*configure)(void *data,
287+ struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1,
288+ uint32_t serial,
289+ uint32_t width,
290+ uint32_t height);
291+ /**
292+ * surface should be closed
293+ *
294+ * The closed event is sent by the compositor when the surface
295+ * will no longer be shown. The output may have been destroyed or
296+ * the user may have asked for it to be removed. Further changes to
297+ * the surface will be ignored. The client should destroy the
298+ * resource after receiving this event, and create a new surface if
299+ * they so choose.
300+ */
301+ void (*closed)(void *data,
302+ struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1);
303+};
304+
305+/**
306+ * @ingroup iface_zwlr_layer_surface_v1
307+ */
308+static inline int
309+zwlr_layer_surface_v1_add_listener(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1,
310+ const struct zwlr_layer_surface_v1_listener *listener, void *data)
311+{
312+ return wl_proxy_add_listener((struct wl_proxy *) zwlr_layer_surface_v1,
313+ (void (**)(void)) listener, data);
314+}
315+
316+#define ZWLR_LAYER_SURFACE_V1_SET_SIZE 0
317+#define ZWLR_LAYER_SURFACE_V1_SET_ANCHOR 1
318+#define ZWLR_LAYER_SURFACE_V1_SET_EXCLUSIVE_ZONE 2
319+#define ZWLR_LAYER_SURFACE_V1_SET_MARGIN 3
320+#define ZWLR_LAYER_SURFACE_V1_SET_KEYBOARD_INTERACTIVITY 4
321+#define ZWLR_LAYER_SURFACE_V1_GET_POPUP 5
322+#define ZWLR_LAYER_SURFACE_V1_ACK_CONFIGURE 6
323+#define ZWLR_LAYER_SURFACE_V1_DESTROY 7
324+
325+/**
326+ * @ingroup iface_zwlr_layer_surface_v1
327+ */
328+#define ZWLR_LAYER_SURFACE_V1_CONFIGURE_SINCE_VERSION 1
329+/**
330+ * @ingroup iface_zwlr_layer_surface_v1
331+ */
332+#define ZWLR_LAYER_SURFACE_V1_CLOSED_SINCE_VERSION 1
333+
334+/**
335+ * @ingroup iface_zwlr_layer_surface_v1
336+ */
337+#define ZWLR_LAYER_SURFACE_V1_SET_SIZE_SINCE_VERSION 1
338+/**
339+ * @ingroup iface_zwlr_layer_surface_v1
340+ */
341+#define ZWLR_LAYER_SURFACE_V1_SET_ANCHOR_SINCE_VERSION 1
342+/**
343+ * @ingroup iface_zwlr_layer_surface_v1
344+ */
345+#define ZWLR_LAYER_SURFACE_V1_SET_EXCLUSIVE_ZONE_SINCE_VERSION 1
346+/**
347+ * @ingroup iface_zwlr_layer_surface_v1
348+ */
349+#define ZWLR_LAYER_SURFACE_V1_SET_MARGIN_SINCE_VERSION 1
350+/**
351+ * @ingroup iface_zwlr_layer_surface_v1
352+ */
353+#define ZWLR_LAYER_SURFACE_V1_SET_KEYBOARD_INTERACTIVITY_SINCE_VERSION 1
354+/**
355+ * @ingroup iface_zwlr_layer_surface_v1
356+ */
357+#define ZWLR_LAYER_SURFACE_V1_GET_POPUP_SINCE_VERSION 1
358+/**
359+ * @ingroup iface_zwlr_layer_surface_v1
360+ */
361+#define ZWLR_LAYER_SURFACE_V1_ACK_CONFIGURE_SINCE_VERSION 1
362+/**
363+ * @ingroup iface_zwlr_layer_surface_v1
364+ */
365+#define ZWLR_LAYER_SURFACE_V1_DESTROY_SINCE_VERSION 1
366+
367+/** @ingroup iface_zwlr_layer_surface_v1 */
368+static inline void
369+zwlr_layer_surface_v1_set_user_data(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, void *user_data)
370+{
371+ wl_proxy_set_user_data((struct wl_proxy *) zwlr_layer_surface_v1, user_data);
372+}
373+
374+/** @ingroup iface_zwlr_layer_surface_v1 */
375+static inline void *
376+zwlr_layer_surface_v1_get_user_data(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1)
377+{
378+ return wl_proxy_get_user_data((struct wl_proxy *) zwlr_layer_surface_v1);
379+}
380+
381+static inline uint32_t
382+zwlr_layer_surface_v1_get_version(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1)
383+{
384+ return wl_proxy_get_version((struct wl_proxy *) zwlr_layer_surface_v1);
385+}
386+
387+/**
388+ * @ingroup iface_zwlr_layer_surface_v1
389+ *
390+ * Sets the size of the surface in surface-local coordinates. The
391+ * compositor will display the surface centered with respect to its
392+ * anchors.
393+ *
394+ * If you pass 0 for either value, the compositor will assign it and
395+ * inform you of the assignment in the configure event. You must set your
396+ * anchor to opposite edges in the dimensions you omit; not doing so is a
397+ * protocol error. Both values are 0 by default.
398+ *
399+ * Size is double-buffered, see wl_surface.commit.
400+ */
401+static inline void
402+zwlr_layer_surface_v1_set_size(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t width, uint32_t height)
403+{
404+ wl_proxy_marshal_flags((struct wl_proxy *) zwlr_layer_surface_v1,
405+ ZWLR_LAYER_SURFACE_V1_SET_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) zwlr_layer_surface_v1), 0, width, height);
406+}
407+
408+/**
409+ * @ingroup iface_zwlr_layer_surface_v1
410+ *
411+ * Requests that the compositor anchor the surface to the specified edges
412+ * and corners. If two orthoginal edges are specified (e.g. 'top' and
413+ * 'left'), then the anchor point will be the intersection of the edges
414+ * (e.g. the top left corner of the output); otherwise the anchor point
415+ * will be centered on that edge, or in the center if none is specified.
416+ *
417+ * Anchor is double-buffered, see wl_surface.commit.
418+ */
419+static inline void
420+zwlr_layer_surface_v1_set_anchor(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t anchor)
421+{
422+ wl_proxy_marshal_flags((struct wl_proxy *) zwlr_layer_surface_v1,
423+ ZWLR_LAYER_SURFACE_V1_SET_ANCHOR, NULL, wl_proxy_get_version((struct wl_proxy *) zwlr_layer_surface_v1), 0, anchor);
424+}
425+
426+/**
427+ * @ingroup iface_zwlr_layer_surface_v1
428+ *
429+ * Requests that the compositor avoids occluding an area of the surface
430+ * with other surfaces. The compositor's use of this information is
431+ * implementation-dependent - do not assume that this region will not
432+ * actually be occluded.
433+ *
434+ * A positive value is only meaningful if the surface is anchored to an
435+ * edge, rather than a corner. The zone is the number of surface-local
436+ * coordinates from the edge that are considered exclusive.
437+ *
438+ * Surfaces that do not wish to have an exclusive zone may instead specify
439+ * how they should interact with surfaces that do. If set to zero, the
440+ * surface indicates that it would like to be moved to avoid occluding
441+ * surfaces with a positive excluzive zone. If set to -1, the surface
442+ * indicates that it would not like to be moved to accommodate for other
443+ * surfaces, and the compositor should extend it all the way to the edges
444+ * it is anchored to.
445+ *
446+ * For example, a panel might set its exclusive zone to 10, so that
447+ * maximized shell surfaces are not shown on top of it. A notification
448+ * might set its exclusive zone to 0, so that it is moved to avoid
449+ * occluding the panel, but shell surfaces are shown underneath it. A
450+ * wallpaper or lock screen might set their exclusive zone to -1, so that
451+ * they stretch below or over the panel.
452+ *
453+ * The default value is 0.
454+ *
455+ * Exclusive zone is double-buffered, see wl_surface.commit.
456+ */
457+static inline void
458+zwlr_layer_surface_v1_set_exclusive_zone(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, int32_t zone)
459+{
460+ wl_proxy_marshal_flags((struct wl_proxy *) zwlr_layer_surface_v1,
461+ ZWLR_LAYER_SURFACE_V1_SET_EXCLUSIVE_ZONE, NULL, wl_proxy_get_version((struct wl_proxy *) zwlr_layer_surface_v1), 0, zone);
462+}
463+
464+/**
465+ * @ingroup iface_zwlr_layer_surface_v1
466+ *
467+ * Requests that the surface be placed some distance away from the anchor
468+ * point on the output, in surface-local coordinates. Setting this value
469+ * for edges you are not anchored to has no effect.
470+ *
471+ * The exclusive zone includes the margin.
472+ *
473+ * Margin is double-buffered, see wl_surface.commit.
474+ */
475+static inline void
476+zwlr_layer_surface_v1_set_margin(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, int32_t top, int32_t right, int32_t bottom, int32_t left)
477+{
478+ wl_proxy_marshal_flags((struct wl_proxy *) zwlr_layer_surface_v1,
479+ ZWLR_LAYER_SURFACE_V1_SET_MARGIN, NULL, wl_proxy_get_version((struct wl_proxy *) zwlr_layer_surface_v1), 0, top, right, bottom, left);
480+}
481+
482+/**
483+ * @ingroup iface_zwlr_layer_surface_v1
484+ *
485+ * Set to 1 to request that the seat send keyboard events to this layer
486+ * surface. For layers below the shell surface layer, the seat will use
487+ * normal focus semantics. For layers above the shell surface layers, the
488+ * seat will always give exclusive keyboard focus to the top-most layer
489+ * which has keyboard interactivity set to true.
490+ *
491+ * Layer surfaces receive pointer, touch, and tablet events normally. If
492+ * you do not want to receive them, set the input region on your surface
493+ * to an empty region.
494+ *
495+ * Events is double-buffered, see wl_surface.commit.
496+ */
497+static inline void
498+zwlr_layer_surface_v1_set_keyboard_interactivity(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t keyboard_interactivity)
499+{
500+ wl_proxy_marshal_flags((struct wl_proxy *) zwlr_layer_surface_v1,
501+ ZWLR_LAYER_SURFACE_V1_SET_KEYBOARD_INTERACTIVITY, NULL, wl_proxy_get_version((struct wl_proxy *) zwlr_layer_surface_v1), 0, keyboard_interactivity);
502+}
503+
504+/**
505+ * @ingroup iface_zwlr_layer_surface_v1
506+ *
507+ * This assigns an xdg_popup's parent to this layer_surface. This popup
508+ * should have been created via xdg_surface::get_popup with the parent set
509+ * to NULL, and this request must be invoked before committing the popup's
510+ * initial state.
511+ *
512+ * See the documentation of xdg_popup for more details about what an
513+ * xdg_popup is and how it is used.
514+ */
515+static inline void
516+zwlr_layer_surface_v1_get_popup(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, struct xdg_popup *popup)
517+{
518+ wl_proxy_marshal_flags((struct wl_proxy *) zwlr_layer_surface_v1,
519+ ZWLR_LAYER_SURFACE_V1_GET_POPUP, NULL, wl_proxy_get_version((struct wl_proxy *) zwlr_layer_surface_v1), 0, popup);
520+}
521+
522+/**
523+ * @ingroup iface_zwlr_layer_surface_v1
524+ *
525+ * When a configure event is received, if a client commits the
526+ * surface in response to the configure event, then the client
527+ * must make an ack_configure request sometime before the commit
528+ * request, passing along the serial of the configure event.
529+ *
530+ * If the client receives multiple configure events before it
531+ * can respond to one, it only has to ack the last configure event.
532+ *
533+ * A client is not required to commit immediately after sending
534+ * an ack_configure request - it may even ack_configure several times
535+ * before its next surface commit.
536+ *
537+ * A client may send multiple ack_configure requests before committing, but
538+ * only the last request sent before a commit indicates which configure
539+ * event the client really is responding to.
540+ */
541+static inline void
542+zwlr_layer_surface_v1_ack_configure(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial)
543+{
544+ wl_proxy_marshal_flags((struct wl_proxy *) zwlr_layer_surface_v1,
545+ ZWLR_LAYER_SURFACE_V1_ACK_CONFIGURE, NULL, wl_proxy_get_version((struct wl_proxy *) zwlr_layer_surface_v1), 0, serial);
546+}
547+
548+/**
549+ * @ingroup iface_zwlr_layer_surface_v1
550+ *
551+ * This request destroys the layer surface.
552+ */
553+static inline void
554+zwlr_layer_surface_v1_destroy(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1)
555+{
556+ wl_proxy_marshal_flags((struct wl_proxy *) zwlr_layer_surface_v1,
557+ ZWLR_LAYER_SURFACE_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwlr_layer_surface_v1), WL_MARSHAL_FLAG_DESTROY);
558+}
559+
560+#ifdef __cplusplus
561+}
562+#endif
563+
564+#endif