commit 3425119

pita  ·  2026-07-07 20:13:56 +0000 UTC
parent b5f738a
wayland
3 files changed,  +2814, -125
R src/uxn11.c => src/uxn12.c
+246, -125
  1@@ -1,16 +1,19 @@
  2+#define _GNU_SOURCE
  3 #include <stdio.h>
  4 #include <stdlib.h>
  5 #include <unistd.h>
  6 #include <string.h>
  7-#include <X11/Xlib.h>
  8-#include <X11/Xutil.h>
  9-#include <X11/keysymdef.h>
 10+#include <sys/mman.h>
 11 #include <sys/timerfd.h>
 12 #include <poll.h>
 13+#include <wayland-client.h>
 14+#include <xkbcommon/xkbcommon.h>
 15+#include <linux/input-event-codes.h>
 16+#include "xdg-shell-client-protocol.h"
 17 
 18 /*
 19 Copyright (c) 2021-2026 Devine Lu Linvega, Andrew Alderwick,
 20-Andrew Richards, Eiríkr Åsheim, Sigrid Solveig Haflínudóttir
 21+Andrew Richards, Eir�kr �sheim, Sigrid Solveig Hafl�nud�ttir
 22 
 23 Permission to use, copy, modify, and distribute this software for any
 24 purpose with or without fee is hereby granted, provided that the above
 25@@ -441,12 +444,6 @@ screen_update(void)
 26 	if(screen_vector)
 27 		uxn_eval(screen_vector);
 28 	if(screen_reqsize) {
 29-		static int pixel_capacity;
 30-		int need = screen_width * screen_height * screen_zoom * screen_zoom;
 31-		if(need > pixel_capacity) {
 32-			pixel_capacity = need;
 33-			screen_pixels = realloc(screen_pixels, need * sizeof(unsigned int));
 34-		}
 35 		screen_reqsize = 0;
 36 		emu_resize();
 37 	}
 38@@ -1096,11 +1093,27 @@ uxn_eval(Uint16 start_pc)
 39 
 40 /* clang-format on */
 41 
 42-static Display *emu_dpy;
 43-static Window emu_win;
 44-static XImage *emu_img;
 45-static int emu_x11;
 46+static struct wl_display *emu_dpy;
 47+static struct wl_registry *emu_reg;
 48+static struct wl_compositor *emu_comp;
 49+static struct wl_shm *emu_shm;
 50+static struct wl_seat *emu_seat;
 51+static struct wl_pointer *emu_ptr;
 52+static struct wl_keyboard *emu_kbd;
 53+static struct xdg_wm_base *emu_wm;
 54+static struct wl_surface *emu_surf;
 55+static struct xdg_surface *emu_xdgsurf;
 56+static struct xdg_toplevel *emu_top;
 57+static struct wl_buffer *emu_buf;
 58 static int emu_timer;
 59+static int emu_configured;
 60+
 61+static void *shm_data;
 62+static int shm_size, shm_width, shm_height;
 63+
 64+static struct xkb_context *xkb_ctx;
 65+static struct xkb_keymap *xkb_map;
 66+static struct xkb_state *xkb_state;
 67 
 68 #define CONINBUFSIZE 256
 69 
 70@@ -1109,21 +1122,35 @@ emu_resize(void)
 71 {
 72 	const int width = screen_width * screen_zoom;
 73 	const int height = screen_height * screen_zoom;
 74-	if(emu_img) {
 75-		emu_img->data = NULL;
 76-		XDestroyImage(emu_img);
 77+	if(width != shm_width || height != shm_height) {
 78+		const int stride = width * 4;
 79+		const int size = stride * height;
 80+		struct wl_shm_pool *pool;
 81+		int fd;
 82+		if(shm_data)
 83+			munmap(shm_data, shm_size);
 84+		if(emu_buf)
 85+			wl_buffer_destroy(emu_buf);
 86+		fd = memfd_create("uxn-wl", MFD_CLOEXEC);
 87+		ftruncate(fd, size);
 88+		shm_data = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
 89+		pool = wl_shm_create_pool(emu_shm, fd, size);
 90+		emu_buf = wl_shm_pool_create_buffer(pool, 0, width, height, stride, WL_SHM_FORMAT_XRGB8888);
 91+		wl_shm_pool_destroy(pool);
 92+		close(fd);
 93+		shm_size = size, shm_width = width, shm_height = height;
 94 	}
 95-	emu_img = XCreateImage(emu_dpy, DefaultVisual(emu_dpy, 0), DefaultDepth(emu_dpy, DefaultScreen(emu_dpy)), ZPixmap, 0, (char *)screen_pixels, width, height, 32, 0);
 96-	XResizeWindow(emu_dpy, emu_win, width, height);
 97+	screen_pixels = (int *)shm_data;
 98 }
 99 
100 void
101 emu_redraw(void)
102 {
103-	const int w = screen_width * screen_zoom;
104-	const int h = screen_height * screen_zoom;
105-	XPutImage(emu_dpy, emu_win, DefaultGC(emu_dpy, 0), emu_img, 0, 0, 0, 0, w, h);
106-	XFlush(emu_dpy);
107+	if(!emu_configured)
108+		return;
109+	wl_surface_attach(emu_surf, emu_buf, 0, 0);
110+	wl_surface_damage_buffer(emu_surf, 0, 0, screen_width * screen_zoom, screen_height * screen_zoom);
111+	wl_surface_commit(emu_surf);
112 }
113 
114 static void
115@@ -1166,134 +1193,220 @@ emu_screenshot(void)
116 }
117 
118 static Uint8
119-get_button(KeySym sym)
120+get_button(xkb_keysym_t sym)
121 {
122 	switch(sym) {
123-	case XK_Up: return 0x10;
124-	case XK_Down: return 0x20;
125-	case XK_Left: return 0x40;
126-	case XK_Right: return 0x80;
127-	case XK_Control_L: return 0x01;
128-	case XK_Alt_R:
129-	case XK_Alt_L: return 0x02;
130-	case XK_Shift_L: return 0x04;
131-	case XK_Home: return 0x08;
132-	case XK_Meta_L: return 0x02;
133+	case XKB_KEY_Up: return 0x10;
134+	case XKB_KEY_Down: return 0x20;
135+	case XKB_KEY_Left: return 0x40;
136+	case XKB_KEY_Right: return 0x80;
137+	case XKB_KEY_Control_L: return 0x01;
138+	case XKB_KEY_Alt_R:
139+	case XKB_KEY_Alt_L: return 0x02;
140+	case XKB_KEY_Shift_L: return 0x04;
141+	case XKB_KEY_Home: return 0x08;
142+	case XKB_KEY_Super_L: return 0x02;
143 	}
144 	return 0x00;
145 }
146 
147 static void
148-display_center(void)
149+kbd_keymap(void *d, struct wl_keyboard *k, uint32_t fmt, int32_t fd, uint32_t size)
150 {
151-	Screen *screen = DefaultScreenOfDisplay(emu_dpy);
152-	const int w = screen_width * screen_zoom;
153-	const int h = screen_height * screen_zoom;
154-	const int x = screen->width / 2 - w / 2;
155-	const int y = screen->height / 2 - h / 2;
156-	emu_win = XCreateSimpleWindow(emu_dpy, RootWindow(emu_dpy, 0), x, y, w, h, 1, 0, 0);
157+	char *map;
158+	if(fmt != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) {
159+		close(fd);
160+		return;
161+	}
162+	map = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
163+	if(map != MAP_FAILED) {
164+		xkb_map = xkb_keymap_new_from_string(xkb_ctx, map, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
165+		munmap(map, size);
166+		if(xkb_state)
167+			xkb_state_unref(xkb_state);
168+		xkb_state = xkb_state_new(xkb_map);
169+	}
170+	close(fd);
171+}
172+
173+static void kbd_enter(void *d, struct wl_keyboard *k, uint32_t serial, struct wl_surface *surf, struct wl_array *keys) { }
174+static void kbd_leave(void *d, struct wl_keyboard *k, uint32_t serial, struct wl_surface *surf) { }
175+
176+static void
177+kbd_key(void *d, struct wl_keyboard *k, uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
178+{
179+	xkb_keysym_t sym;
180+	if(!xkb_state)
181+		return;
182+	sym = xkb_state_key_get_one_sym(xkb_state, key + 8);
183+	if(state == WL_KEYBOARD_KEY_STATE_PRESSED) {
184+		char buf[8] = {0};
185+		switch(sym) {
186+		case XKB_KEY_F1: screen_zoom = (screen_zoom % 3) + 1, screen_reqsize = screen_reqdraw = 1; break;
187+		case XKB_KEY_F2: emu_deo(0xe, 0x1); break;
188+		case XKB_KEY_F4: console_close(), emu_restart(0); break;
189+		case XKB_KEY_F5: console_close(), emu_restart(1); break;
190+		case XKB_KEY_F6: emu_deo(0xe, 0x2); break;
191+		}
192+		controller_down(get_button(sym));
193+		xkb_state_key_get_utf8(xkb_state, key + 8, buf, sizeof buf);
194+		if(sym == XKB_KEY_Tab)
195+			buf[0] = 0x9;
196+		controller_key(sym < 0x80 ? (Uint8)sym : (Uint8)buf[0]);
197+	} else
198+		controller_up(get_button(sym));
199 }
200 
201 static void
202-display_hidecursor(void)
203+kbd_modifiers(void *d, struct wl_keyboard *k, uint32_t serial, uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group)
204 {
205-	XColor black = {0};
206-	static const char empty[1] = {0};
207-	Pixmap bitmap = XCreateBitmapFromData(emu_dpy, emu_win, empty, 1, 1);
208-	Cursor blank = XCreatePixmapCursor(emu_dpy, bitmap, bitmap, &black, &black, 0, 0);
209-	XDefineCursor(emu_dpy, emu_win, blank);
210-	XFreeCursor(emu_dpy, blank);
211-	XFreePixmap(emu_dpy, bitmap);
212+	if(xkb_state)
213+		xkb_state_update_mask(xkb_state, depressed, latched, locked, 0, 0, group);
214 }
215 
216+static const struct wl_keyboard_listener kbd_listener = {
217+	.keymap = kbd_keymap,
218+	.enter = kbd_enter,
219+	.leave = kbd_leave,
220+	.key = kbd_key,
221+	.modifiers = kbd_modifiers,
222+};
223+
224 static void
225-display_floating(void)
226+ptr_enter(void *d, struct wl_pointer *p, uint32_t serial, struct wl_surface *surf, wl_fixed_t sx, wl_fixed_t sy)
227 {
228-	Atom wmDelete = XInternAtom(emu_dpy, "WM_DELETE_WINDOW", True);
229-	Atom wmType = XInternAtom(emu_dpy, "_NET_WM_WINDOW_TYPE", False);
230-	Atom wmDialog = XInternAtom(emu_dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False);
231-	XClassHint class = {"uxn11", "Uxn"};
232-	XSetWMProtocols(emu_dpy, emu_win, &wmDelete, 1);
233-	XChangeProperty(emu_dpy, emu_win, wmType, 4, 32, PropModeReplace, (Uint8 *)&wmDialog, 1);
234-	XSelectInput(emu_dpy, emu_win, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask | LeaveWindowMask);
235-	XStoreName(emu_dpy, emu_win, "uxn11");
236-	XSetClassHint(emu_dpy, emu_win, &class);
237+	wl_pointer_set_cursor(p, serial, NULL, 0, 0);
238+	mouse_pos(wl_fixed_to_int(sx) / screen_zoom, wl_fixed_to_int(sy) / screen_zoom);
239 }
240 
241+static void ptr_leave(void *d, struct wl_pointer *p, uint32_t serial, struct wl_surface *surf) { }
242+
243 static void
244-emu_event(void)
245+ptr_motion(void *d, struct wl_pointer *p, uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
246 {
247-	char buf[7];
248-	XEvent ev;
249-	XNextEvent(emu_dpy, &ev);
250-	switch(ev.type) {
251-	case Expose:
252-		screen_redraw();
253-		break;
254-	case ClientMessage:
255-		dev[0x0f] = 0x80;
256-		break;
257-	case KeyPress: {
258-		KeySym sym;
259-		XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
260-		switch(sym) {
261-		case XK_F1: screen_zoom = (screen_zoom % 3) + 1, screen_reqsize = screen_reqdraw = 1; break;
262-		case XK_F2: emu_deo(0xe, 0x1); break;
263-		case XK_F4: console_close(), emu_restart(0); break;
264-		case XK_F5: console_close(), emu_restart(1); break;
265-		case XK_F6: emu_deo(0xe, 0x2); break;
266-		}
267-		controller_down(get_button(sym));
268-		if(sym == XK_Tab)
269-			buf[0] = 0x9;
270-		controller_key(sym < 0x80 ? sym : (Uint8)buf[0]);
271-	} break;
272-	case KeyRelease: {
273-		KeySym sym;
274-		XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0);
275-		controller_up(get_button(sym));
276-	} break;
277-	case ButtonPress: {
278-		XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
279-		switch(e->button) {
280-		case 4: mouse_scroll(0, 1); break;
281-		case 5: mouse_scroll(0, -1); break;
282-		case 6: mouse_scroll(1, 0); break;
283-		case 7: mouse_scroll(-1, 0); break;
284-		default: mouse_down(0x1 << (e->button - 1));
285-		}
286-	} break;
287-	case ButtonRelease: {
288-		XButtonPressedEvent *e = (XButtonPressedEvent *)&ev;
289-		mouse_up(0x1 << (e->button - 1));
290-	} break;
291-	case LeaveNotify:
292-	case MotionNotify: {
293-		XMotionEvent *e = (XMotionEvent *)&ev;
294-		mouse_pos(e->x / screen_zoom, e->y / screen_zoom);
295-	} break;
296+	mouse_pos(wl_fixed_to_int(sx) / screen_zoom, wl_fixed_to_int(sy) / screen_zoom);
297+}
298+
299+static void
300+ptr_button(void *d, struct wl_pointer *p, uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
301+{
302+	Uint8 mask = 0;
303+	switch(button) {
304+	case BTN_LEFT: mask = 0x01; break;
305+	case BTN_MIDDLE: mask = 0x02; break;
306+	case BTN_RIGHT: mask = 0x04; break;
307+	}
308+	if(state == WL_POINTER_BUTTON_STATE_PRESSED)
309+		mouse_down(mask);
310+	else
311+		mouse_up(mask);
312+}
313+
314+static void
315+ptr_axis(void *d, struct wl_pointer *p, uint32_t time, uint32_t axis, wl_fixed_t value)
316+{
317+	const int v = wl_fixed_to_int(value) / 10;
318+	if(axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
319+		mouse_scroll(0, v);
320+	else if(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
321+		mouse_scroll(v, 0);
322+}
323+
324+static const struct wl_pointer_listener ptr_listener = {
325+	.enter = ptr_enter,
326+	.leave = ptr_leave,
327+	.motion = ptr_motion,
328+	.button = ptr_button,
329+	.axis = ptr_axis,
330+};
331+
332+static void
333+seat_caps(void *d, struct wl_seat *seat, uint32_t caps)
334+{
335+	if((caps & WL_SEAT_CAPABILITY_POINTER) && !emu_ptr) {
336+		emu_ptr = wl_seat_get_pointer(seat);
337+		wl_pointer_add_listener(emu_ptr, &ptr_listener, NULL);
338+	}
339+	if((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !emu_kbd) {
340+		emu_kbd = wl_seat_get_keyboard(seat);
341+		wl_keyboard_add_listener(emu_kbd, &kbd_listener, NULL);
342+	}
343+}
344+
345+static const struct wl_seat_listener seat_listener = {
346+	.capabilities = seat_caps,
347+};
348+
349+static void wm_ping(void *d, struct xdg_wm_base *wm, uint32_t serial) { xdg_wm_base_pong(wm, serial); }
350+static const struct xdg_wm_base_listener wm_listener = { .ping = wm_ping };
351+
352+static void
353+xs_configure(void *d, struct xdg_surface *xs, uint32_t serial)
354+{
355+	xdg_surface_ack_configure(xs, serial);
356+	emu_configured = 1;
357+	screen_reqdraw = 1;
358+}
359+
360+static const struct xdg_surface_listener xs_listener = {
361+	.configure = xs_configure,
362+};
363+
364+static void xt_configure(void *d, struct xdg_toplevel *xt, int32_t w, int32_t h, struct wl_array *st) { }
365+/* xt_close takes over X11's ClientMessage/WM_DELETE_WINDOW case. */
366+static void xt_close(void *d, struct xdg_toplevel *xt) { dev[0x0f] = 0x80; }
367+
368+static const struct xdg_toplevel_listener xt_listener = {
369+	.configure = xt_configure,
370+	.close = xt_close,
371+};
372+
373+static void
374+reg_global(void *d, struct wl_registry *reg, uint32_t name, const char *iface, uint32_t ver)
375+{
376+	if(!strcmp(iface, "wl_compositor"))
377+		emu_comp = wl_registry_bind(reg, name, &wl_compositor_interface, 4);
378+	else if(!strcmp(iface, "wl_shm"))
379+		emu_shm = wl_registry_bind(reg, name, &wl_shm_interface, 1);
380+	else if(!strcmp(iface, "xdg_wm_base"))
381+		emu_wm = wl_registry_bind(reg, name, &xdg_wm_base_interface, 1);
382+	else if(!strcmp(iface, "wl_seat")) {
383+		emu_seat = wl_registry_bind(reg, name, &wl_seat_interface, 1);
384+		wl_seat_add_listener(emu_seat, &seat_listener, NULL);
385 	}
386 }
387 
388+static const struct wl_registry_listener reg_listener = {
389+	.global = reg_global,
390+};
391+
392 static int
393 emu_init(void)
394 {
395-	static const struct itimerspec screen_tspec = {
396-		{0, 16666666},
397-		{0, 16666666}};
398-	emu_dpy = XOpenDisplay(NULL);
399+	static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
400+	xkb_ctx = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
401+	emu_dpy = wl_display_connect(NULL);
402 	if(!emu_dpy)
403 		return !fprintf(stderr, "Display: failed\n");
404-	emu_x11 = ConnectionNumber(emu_dpy);
405-	display_center();
406-	display_hidecursor();
407-	display_floating();
408+	emu_reg = wl_display_get_registry(emu_dpy);
409+	wl_registry_add_listener(emu_reg, &reg_listener, NULL);
410+	wl_display_roundtrip(emu_dpy);
411+	if(!emu_comp || !emu_shm || !emu_wm)
412+		return !fprintf(stderr, "Wayland: missing globals\n");
413+	xdg_wm_base_add_listener(emu_wm, &wm_listener, NULL);
414+	emu_surf = wl_compositor_create_surface(emu_comp);
415+	emu_xdgsurf = xdg_wm_base_get_xdg_surface(emu_wm, emu_surf);
416+	xdg_surface_add_listener(emu_xdgsurf, &xs_listener, NULL);
417+	emu_top = xdg_surface_get_toplevel(emu_xdgsurf);
418+	xdg_toplevel_add_listener(emu_top, &xt_listener, NULL);
419+	xdg_toplevel_set_title(emu_top, "uxn-wl");
420+	xdg_toplevel_set_app_id(emu_top, "uxn-wl");
421+	wl_surface_commit(emu_surf);
422+	wl_display_roundtrip(emu_dpy);
423 	emu_timer = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
424 	if(emu_timer < 0)
425 		return !fprintf(stderr, "timerfd_create: failed\n");
426 	timerfd_settime(emu_timer, 0, &screen_tspec, NULL);
427-	XMapWindow(emu_dpy, emu_win);
428-	XFlush(emu_dpy);
429 	return 1;
430 }
431 
432@@ -1303,15 +1416,17 @@ emu_run(void)
433 	int has_input, stdin_active = 1;
434 	char expirations[8], coninp[CONINBUFSIZE];
435 	struct pollfd fds[3];
436-	fds[0].fd = emu_x11, fds[0].events = POLLIN;
437+	fds[0].fd = wl_display_get_fd(emu_dpy), fds[0].events = POLLIN;
438 	fds[1].fd = emu_timer, fds[1].events = POLLIN;
439 	fds[2].fd = STDIN_FILENO, fds[2].events = POLLIN | POLLHUP;
440 	while(!dev[0x0f]) {
441+		wl_display_dispatch_pending(emu_dpy);
442+		wl_display_flush(emu_dpy);
443 		/* only poll stdin while it's still active */
444 		if(poll(fds, stdin_active ? 3 : 2, -1) <= 0)
445 			continue;
446-		while(XPending(emu_dpy))
447-			emu_event();
448+		if(fds[0].revents & POLLIN)
449+			wl_display_dispatch(emu_dpy);
450 		if(fds[1].revents & POLLIN) {
451 			read(emu_timer, expirations, sizeof expirations);
452 			screen_update();
453@@ -1331,10 +1446,16 @@ emu_run(void)
454 	}
455 	if(emu_timer >= 0)
456 		close(emu_timer);
457-	if(emu_win)
458-		XDestroyWindow(emu_dpy, emu_win);
459+	if(emu_buf)
460+		wl_buffer_destroy(emu_buf);
461+	if(emu_top)
462+		xdg_toplevel_destroy(emu_top);
463+	if(emu_xdgsurf)
464+		xdg_surface_destroy(emu_xdgsurf);
465+	if(emu_surf)
466+		wl_surface_destroy(emu_surf);
467 	if(emu_dpy)
468-		XCloseDisplay(emu_dpy);
469+		wl_display_disconnect(emu_dpy);
470 	console_close();
471 }
472 
+2384, -0
   1@@ -0,0 +1,2384 @@
   2+/* Generated by wayland-scanner 1.25.0 */
   3+
   4+#ifndef XDG_SHELL_CLIENT_PROTOCOL_H
   5+#define XDG_SHELL_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_xdg_shell The xdg_shell protocol
  17+ * @section page_ifaces_xdg_shell Interfaces
  18+ * - @subpage page_iface_xdg_wm_base - create desktop-style surfaces
  19+ * - @subpage page_iface_xdg_positioner - child surface positioner
  20+ * - @subpage page_iface_xdg_surface - desktop user interface surface base interface
  21+ * - @subpage page_iface_xdg_toplevel - toplevel surface
  22+ * - @subpage page_iface_xdg_popup - short-lived, popup surfaces for menus
  23+ * @section page_copyright_xdg_shell Copyright
  24+ * <pre>
  25+ *
  26+ * Copyright © 2008-2013 Kristian Høgsberg
  27+ * Copyright © 2013      Rafael Antognolli
  28+ * Copyright © 2013      Jasper St. Pierre
  29+ * Copyright © 2010-2013 Intel Corporation
  30+ * Copyright © 2015-2017 Samsung Electronics Co., Ltd
  31+ * Copyright © 2015-2017 Red Hat Inc.
  32+ *
  33+ * Permission is hereby granted, free of charge, to any person obtaining a
  34+ * copy of this software and associated documentation files (the "Software"),
  35+ * to deal in the Software without restriction, including without limitation
  36+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  37+ * and/or sell copies of the Software, and to permit persons to whom the
  38+ * Software is furnished to do so, subject to the following conditions:
  39+ *
  40+ * The above copyright notice and this permission notice (including the next
  41+ * paragraph) shall be included in all copies or substantial portions of the
  42+ * Software.
  43+ *
  44+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  45+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  47+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  48+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  49+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  50+ * DEALINGS IN THE SOFTWARE.
  51+ * </pre>
  52+ */
  53+struct wl_output;
  54+struct wl_seat;
  55+struct wl_surface;
  56+struct xdg_popup;
  57+struct xdg_positioner;
  58+struct xdg_surface;
  59+struct xdg_toplevel;
  60+struct xdg_wm_base;
  61+
  62+#ifndef XDG_WM_BASE_INTERFACE
  63+#define XDG_WM_BASE_INTERFACE
  64+/**
  65+ * @page page_iface_xdg_wm_base xdg_wm_base
  66+ * @section page_iface_xdg_wm_base_desc Description
  67+ *
  68+ * The xdg_wm_base interface is exposed as a global object enabling clients
  69+ * to turn their wl_surfaces into windows in a desktop environment. It
  70+ * defines the basic functionality needed for clients and the compositor to
  71+ * create windows that can be dragged, resized, maximized, etc, as well as
  72+ * creating transient windows such as popup menus.
  73+ * @section page_iface_xdg_wm_base_api API
  74+ * See @ref iface_xdg_wm_base.
  75+ */
  76+/**
  77+ * @defgroup iface_xdg_wm_base The xdg_wm_base interface
  78+ *
  79+ * The xdg_wm_base interface is exposed as a global object enabling clients
  80+ * to turn their wl_surfaces into windows in a desktop environment. It
  81+ * defines the basic functionality needed for clients and the compositor to
  82+ * create windows that can be dragged, resized, maximized, etc, as well as
  83+ * creating transient windows such as popup menus.
  84+ */
  85+extern const struct wl_interface xdg_wm_base_interface;
  86+#endif
  87+#ifndef XDG_POSITIONER_INTERFACE
  88+#define XDG_POSITIONER_INTERFACE
  89+/**
  90+ * @page page_iface_xdg_positioner xdg_positioner
  91+ * @section page_iface_xdg_positioner_desc Description
  92+ *
  93+ * The xdg_positioner provides a collection of rules for the placement of a
  94+ * child surface relative to a parent surface. Rules can be defined to ensure
  95+ * the child surface remains within the visible area's borders, and to
  96+ * specify how the child surface changes its position, such as sliding along
  97+ * an axis, or flipping around a rectangle. These positioner-created rules are
  98+ * constrained by the requirement that a child surface must intersect with or
  99+ * be at least partially adjacent to its parent surface.
 100+ *
 101+ * See the various requests for details about possible rules.
 102+ *
 103+ * At the time of the request, the compositor makes a copy of the rules
 104+ * specified by the xdg_positioner. Thus, after the request is complete the
 105+ * xdg_positioner object can be destroyed or reused; further changes to the
 106+ * object will have no effect on previous usages.
 107+ *
 108+ * For an xdg_positioner object to be considered complete, it must have a
 109+ * non-zero size set by set_size, and a non-zero anchor rectangle set by
 110+ * set_anchor_rect. Passing an incomplete xdg_positioner object when
 111+ * positioning a surface raises an invalid_positioner error.
 112+ * @section page_iface_xdg_positioner_api API
 113+ * See @ref iface_xdg_positioner.
 114+ */
 115+/**
 116+ * @defgroup iface_xdg_positioner The xdg_positioner interface
 117+ *
 118+ * The xdg_positioner provides a collection of rules for the placement of a
 119+ * child surface relative to a parent surface. Rules can be defined to ensure
 120+ * the child surface remains within the visible area's borders, and to
 121+ * specify how the child surface changes its position, such as sliding along
 122+ * an axis, or flipping around a rectangle. These positioner-created rules are
 123+ * constrained by the requirement that a child surface must intersect with or
 124+ * be at least partially adjacent to its parent surface.
 125+ *
 126+ * See the various requests for details about possible rules.
 127+ *
 128+ * At the time of the request, the compositor makes a copy of the rules
 129+ * specified by the xdg_positioner. Thus, after the request is complete the
 130+ * xdg_positioner object can be destroyed or reused; further changes to the
 131+ * object will have no effect on previous usages.
 132+ *
 133+ * For an xdg_positioner object to be considered complete, it must have a
 134+ * non-zero size set by set_size, and a non-zero anchor rectangle set by
 135+ * set_anchor_rect. Passing an incomplete xdg_positioner object when
 136+ * positioning a surface raises an invalid_positioner error.
 137+ */
 138+extern const struct wl_interface xdg_positioner_interface;
 139+#endif
 140+#ifndef XDG_SURFACE_INTERFACE
 141+#define XDG_SURFACE_INTERFACE
 142+/**
 143+ * @page page_iface_xdg_surface xdg_surface
 144+ * @section page_iface_xdg_surface_desc Description
 145+ *
 146+ * An interface that may be implemented by a wl_surface, for
 147+ * implementations that provide a desktop-style user interface.
 148+ *
 149+ * It provides a base set of functionality required to construct user
 150+ * interface elements requiring management by the compositor, such as
 151+ * toplevel windows, menus, etc. The types of functionality are split into
 152+ * xdg_surface roles.
 153+ *
 154+ * Creating an xdg_surface does not set the role for a wl_surface. In order
 155+ * to map an xdg_surface, the client must create a role-specific object
 156+ * using, e.g., get_toplevel, get_popup. The wl_surface for any given
 157+ * xdg_surface can have at most one role, and may not be assigned any role
 158+ * not based on xdg_surface.
 159+ *
 160+ * A role must be assigned before any other requests are made to the
 161+ * xdg_surface object.
 162+ *
 163+ * The client must call wl_surface.commit on the corresponding wl_surface
 164+ * for the xdg_surface state to take effect.
 165+ *
 166+ * Creating an xdg_surface from a wl_surface which has a buffer attached or
 167+ * committed is a client error, and any attempts by a client to attach or
 168+ * manipulate a buffer prior to the first xdg_surface.configure call must
 169+ * also be treated as errors.
 170+ *
 171+ * After creating a role-specific object and setting it up (e.g. by sending
 172+ * the title, app ID, size constraints, parent, etc), the client must
 173+ * perform an initial commit without any buffer attached. The compositor
 174+ * will reply with initial wl_surface state such as
 175+ * wl_surface.preferred_buffer_scale followed by an xdg_surface.configure
 176+ * event. The client must acknowledge it and is then allowed to attach a
 177+ * buffer to map the surface.
 178+ *
 179+ * Mapping an xdg_surface-based role surface is defined as making it
 180+ * possible for the surface to be shown by the compositor. Note that
 181+ * a mapped surface is not guaranteed to be visible once it is mapped.
 182+ *
 183+ * For an xdg_surface to be mapped by the compositor, the following
 184+ * conditions must be met:
 185+ * (1) the client has assigned an xdg_surface-based role to the surface
 186+ * (2) the client has set and committed the xdg_surface state and the
 187+ * role-dependent state to the surface
 188+ * (3) the client has committed a buffer to the surface
 189+ *
 190+ * A newly-unmapped surface is considered to have met condition (1) out
 191+ * of the 3 required conditions for mapping a surface if its role surface
 192+ * has not been destroyed, i.e. the client must perform the initial commit
 193+ * again before attaching a buffer.
 194+ * @section page_iface_xdg_surface_api API
 195+ * See @ref iface_xdg_surface.
 196+ */
 197+/**
 198+ * @defgroup iface_xdg_surface The xdg_surface interface
 199+ *
 200+ * An interface that may be implemented by a wl_surface, for
 201+ * implementations that provide a desktop-style user interface.
 202+ *
 203+ * It provides a base set of functionality required to construct user
 204+ * interface elements requiring management by the compositor, such as
 205+ * toplevel windows, menus, etc. The types of functionality are split into
 206+ * xdg_surface roles.
 207+ *
 208+ * Creating an xdg_surface does not set the role for a wl_surface. In order
 209+ * to map an xdg_surface, the client must create a role-specific object
 210+ * using, e.g., get_toplevel, get_popup. The wl_surface for any given
 211+ * xdg_surface can have at most one role, and may not be assigned any role
 212+ * not based on xdg_surface.
 213+ *
 214+ * A role must be assigned before any other requests are made to the
 215+ * xdg_surface object.
 216+ *
 217+ * The client must call wl_surface.commit on the corresponding wl_surface
 218+ * for the xdg_surface state to take effect.
 219+ *
 220+ * Creating an xdg_surface from a wl_surface which has a buffer attached or
 221+ * committed is a client error, and any attempts by a client to attach or
 222+ * manipulate a buffer prior to the first xdg_surface.configure call must
 223+ * also be treated as errors.
 224+ *
 225+ * After creating a role-specific object and setting it up (e.g. by sending
 226+ * the title, app ID, size constraints, parent, etc), the client must
 227+ * perform an initial commit without any buffer attached. The compositor
 228+ * will reply with initial wl_surface state such as
 229+ * wl_surface.preferred_buffer_scale followed by an xdg_surface.configure
 230+ * event. The client must acknowledge it and is then allowed to attach a
 231+ * buffer to map the surface.
 232+ *
 233+ * Mapping an xdg_surface-based role surface is defined as making it
 234+ * possible for the surface to be shown by the compositor. Note that
 235+ * a mapped surface is not guaranteed to be visible once it is mapped.
 236+ *
 237+ * For an xdg_surface to be mapped by the compositor, the following
 238+ * conditions must be met:
 239+ * (1) the client has assigned an xdg_surface-based role to the surface
 240+ * (2) the client has set and committed the xdg_surface state and the
 241+ * role-dependent state to the surface
 242+ * (3) the client has committed a buffer to the surface
 243+ *
 244+ * A newly-unmapped surface is considered to have met condition (1) out
 245+ * of the 3 required conditions for mapping a surface if its role surface
 246+ * has not been destroyed, i.e. the client must perform the initial commit
 247+ * again before attaching a buffer.
 248+ */
 249+extern const struct wl_interface xdg_surface_interface;
 250+#endif
 251+#ifndef XDG_TOPLEVEL_INTERFACE
 252+#define XDG_TOPLEVEL_INTERFACE
 253+/**
 254+ * @page page_iface_xdg_toplevel xdg_toplevel
 255+ * @section page_iface_xdg_toplevel_desc Description
 256+ *
 257+ * This interface defines an xdg_surface role which allows a surface to,
 258+ * among other things, set window-like properties such as maximize,
 259+ * fullscreen, and minimize, set application-specific metadata like title and
 260+ * id, and well as trigger user interactive operations such as interactive
 261+ * resize and move.
 262+ *
 263+ * A xdg_toplevel by default is responsible for providing the full intended
 264+ * visual representation of the toplevel, which depending on the window
 265+ * state, may mean things like a title bar, window controls and drop shadow.
 266+ *
 267+ * Unmapping an xdg_toplevel means that the surface cannot be shown
 268+ * by the compositor until it is explicitly mapped again.
 269+ * All active operations (e.g., move, resize) are canceled and all
 270+ * attributes (e.g. title, state, stacking, ...) are discarded for
 271+ * an xdg_toplevel surface when it is unmapped. The xdg_toplevel returns to
 272+ * the state it had right after xdg_surface.get_toplevel. The client
 273+ * can re-map the toplevel by performing a commit without any buffer
 274+ * attached, waiting for a configure event and handling it as usual (see
 275+ * xdg_surface description).
 276+ *
 277+ * Attaching a null buffer to a toplevel unmaps the surface.
 278+ * @section page_iface_xdg_toplevel_api API
 279+ * See @ref iface_xdg_toplevel.
 280+ */
 281+/**
 282+ * @defgroup iface_xdg_toplevel The xdg_toplevel interface
 283+ *
 284+ * This interface defines an xdg_surface role which allows a surface to,
 285+ * among other things, set window-like properties such as maximize,
 286+ * fullscreen, and minimize, set application-specific metadata like title and
 287+ * id, and well as trigger user interactive operations such as interactive
 288+ * resize and move.
 289+ *
 290+ * A xdg_toplevel by default is responsible for providing the full intended
 291+ * visual representation of the toplevel, which depending on the window
 292+ * state, may mean things like a title bar, window controls and drop shadow.
 293+ *
 294+ * Unmapping an xdg_toplevel means that the surface cannot be shown
 295+ * by the compositor until it is explicitly mapped again.
 296+ * All active operations (e.g., move, resize) are canceled and all
 297+ * attributes (e.g. title, state, stacking, ...) are discarded for
 298+ * an xdg_toplevel surface when it is unmapped. The xdg_toplevel returns to
 299+ * the state it had right after xdg_surface.get_toplevel. The client
 300+ * can re-map the toplevel by performing a commit without any buffer
 301+ * attached, waiting for a configure event and handling it as usual (see
 302+ * xdg_surface description).
 303+ *
 304+ * Attaching a null buffer to a toplevel unmaps the surface.
 305+ */
 306+extern const struct wl_interface xdg_toplevel_interface;
 307+#endif
 308+#ifndef XDG_POPUP_INTERFACE
 309+#define XDG_POPUP_INTERFACE
 310+/**
 311+ * @page page_iface_xdg_popup xdg_popup
 312+ * @section page_iface_xdg_popup_desc Description
 313+ *
 314+ * A popup surface is a short-lived, temporary surface. It can be used to
 315+ * implement for example menus, popovers, tooltips and other similar user
 316+ * interface concepts.
 317+ *
 318+ * A popup can be made to take an explicit grab. See xdg_popup.grab for
 319+ * details.
 320+ *
 321+ * When the popup is dismissed, a popup_done event will be sent out, and at
 322+ * the same time the surface will be unmapped. See the xdg_popup.popup_done
 323+ * event for details.
 324+ *
 325+ * Explicitly destroying the xdg_popup object will also dismiss the popup and
 326+ * unmap the surface. Clients that want to dismiss the popup when another
 327+ * surface of their own is clicked should dismiss the popup using the destroy
 328+ * request.
 329+ *
 330+ * A newly created xdg_popup will be stacked on top of all previously created
 331+ * xdg_popup surfaces associated with the same xdg_toplevel.
 332+ *
 333+ * The parent of an xdg_popup must be mapped (see the xdg_surface
 334+ * description) before the xdg_popup itself.
 335+ *
 336+ * The client must call wl_surface.commit on the corresponding wl_surface
 337+ * for the xdg_popup state to take effect.
 338+ * @section page_iface_xdg_popup_api API
 339+ * See @ref iface_xdg_popup.
 340+ */
 341+/**
 342+ * @defgroup iface_xdg_popup The xdg_popup interface
 343+ *
 344+ * A popup surface is a short-lived, temporary surface. It can be used to
 345+ * implement for example menus, popovers, tooltips and other similar user
 346+ * interface concepts.
 347+ *
 348+ * A popup can be made to take an explicit grab. See xdg_popup.grab for
 349+ * details.
 350+ *
 351+ * When the popup is dismissed, a popup_done event will be sent out, and at
 352+ * the same time the surface will be unmapped. See the xdg_popup.popup_done
 353+ * event for details.
 354+ *
 355+ * Explicitly destroying the xdg_popup object will also dismiss the popup and
 356+ * unmap the surface. Clients that want to dismiss the popup when another
 357+ * surface of their own is clicked should dismiss the popup using the destroy
 358+ * request.
 359+ *
 360+ * A newly created xdg_popup will be stacked on top of all previously created
 361+ * xdg_popup surfaces associated with the same xdg_toplevel.
 362+ *
 363+ * The parent of an xdg_popup must be mapped (see the xdg_surface
 364+ * description) before the xdg_popup itself.
 365+ *
 366+ * The client must call wl_surface.commit on the corresponding wl_surface
 367+ * for the xdg_popup state to take effect.
 368+ */
 369+extern const struct wl_interface xdg_popup_interface;
 370+#endif
 371+
 372+#ifndef XDG_WM_BASE_ERROR_ENUM
 373+#define XDG_WM_BASE_ERROR_ENUM
 374+enum xdg_wm_base_error {
 375+	/**
 376+	 * given wl_surface has another role
 377+	 */
 378+	XDG_WM_BASE_ERROR_ROLE = 0,
 379+	/**
 380+	 * xdg_wm_base was destroyed before children
 381+	 */
 382+	XDG_WM_BASE_ERROR_DEFUNCT_SURFACES = 1,
 383+	/**
 384+	 * the client tried to map or destroy a non-topmost popup
 385+	 */
 386+	XDG_WM_BASE_ERROR_NOT_THE_TOPMOST_POPUP = 2,
 387+	/**
 388+	 * the client specified an invalid popup parent surface
 389+	 */
 390+	XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT = 3,
 391+	/**
 392+	 * the client provided an invalid surface state
 393+	 */
 394+	XDG_WM_BASE_ERROR_INVALID_SURFACE_STATE = 4,
 395+	/**
 396+	 * the client provided an invalid positioner
 397+	 */
 398+	XDG_WM_BASE_ERROR_INVALID_POSITIONER = 5,
 399+	/**
 400+	 * the client didn’t respond to a ping event in time
 401+	 */
 402+	XDG_WM_BASE_ERROR_UNRESPONSIVE = 6,
 403+};
 404+#endif /* XDG_WM_BASE_ERROR_ENUM */
 405+
 406+/**
 407+ * @ingroup iface_xdg_wm_base
 408+ * @struct xdg_wm_base_listener
 409+ */
 410+struct xdg_wm_base_listener {
 411+	/**
 412+	 * check if the client is alive
 413+	 *
 414+	 * The ping event asks the client if it's still alive. Pass the
 415+	 * serial specified in the event back to the compositor by sending
 416+	 * a "pong" request back with the specified serial. See
 417+	 * xdg_wm_base.pong.
 418+	 *
 419+	 * Compositors can use this to determine if the client is still
 420+	 * alive. It's unspecified what will happen if the client doesn't
 421+	 * respond to the ping request, or in what timeframe. Clients
 422+	 * should try to respond in a reasonable amount of time. The
 423+	 * “unresponsive” error is provided for compositors that wish
 424+	 * to disconnect unresponsive clients.
 425+	 *
 426+	 * A compositor is free to ping in any way it wants, but a client
 427+	 * must always respond to any xdg_wm_base object it created.
 428+	 * @param serial pass this to the pong request
 429+	 */
 430+	void (*ping)(void *data,
 431+		     struct xdg_wm_base *xdg_wm_base,
 432+		     uint32_t serial);
 433+};
 434+
 435+/**
 436+ * @ingroup iface_xdg_wm_base
 437+ */
 438+static inline int
 439+xdg_wm_base_add_listener(struct xdg_wm_base *xdg_wm_base,
 440+			 const struct xdg_wm_base_listener *listener, void *data)
 441+{
 442+	return wl_proxy_add_listener((struct wl_proxy *) xdg_wm_base,
 443+				     (void (**)(void)) listener, data);
 444+}
 445+
 446+#define XDG_WM_BASE_DESTROY 0
 447+#define XDG_WM_BASE_CREATE_POSITIONER 1
 448+#define XDG_WM_BASE_GET_XDG_SURFACE 2
 449+#define XDG_WM_BASE_PONG 3
 450+
 451+/**
 452+ * @ingroup iface_xdg_wm_base
 453+ */
 454+#define XDG_WM_BASE_PING_SINCE_VERSION 1
 455+
 456+/**
 457+ * @ingroup iface_xdg_wm_base
 458+ */
 459+#define XDG_WM_BASE_DESTROY_SINCE_VERSION 1
 460+/**
 461+ * @ingroup iface_xdg_wm_base
 462+ */
 463+#define XDG_WM_BASE_CREATE_POSITIONER_SINCE_VERSION 1
 464+/**
 465+ * @ingroup iface_xdg_wm_base
 466+ */
 467+#define XDG_WM_BASE_GET_XDG_SURFACE_SINCE_VERSION 1
 468+/**
 469+ * @ingroup iface_xdg_wm_base
 470+ */
 471+#define XDG_WM_BASE_PONG_SINCE_VERSION 1
 472+
 473+/** @ingroup iface_xdg_wm_base */
 474+static inline void
 475+xdg_wm_base_set_user_data(struct xdg_wm_base *xdg_wm_base, void *user_data)
 476+{
 477+	wl_proxy_set_user_data((struct wl_proxy *) xdg_wm_base, user_data);
 478+}
 479+
 480+/** @ingroup iface_xdg_wm_base */
 481+static inline void *
 482+xdg_wm_base_get_user_data(struct xdg_wm_base *xdg_wm_base)
 483+{
 484+	return wl_proxy_get_user_data((struct wl_proxy *) xdg_wm_base);
 485+}
 486+
 487+static inline uint32_t
 488+xdg_wm_base_get_version(struct xdg_wm_base *xdg_wm_base)
 489+{
 490+	return wl_proxy_get_version((struct wl_proxy *) xdg_wm_base);
 491+}
 492+
 493+/**
 494+ * @ingroup iface_xdg_wm_base
 495+ *
 496+ * Destroy this xdg_wm_base object.
 497+ *
 498+ * Destroying a bound xdg_wm_base object while there are surfaces
 499+ * still alive created by this xdg_wm_base object instance is illegal
 500+ * and will result in a defunct_surfaces error.
 501+ */
 502+static inline void
 503+xdg_wm_base_destroy(struct xdg_wm_base *xdg_wm_base)
 504+{
 505+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_wm_base,
 506+			 XDG_WM_BASE_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_wm_base), WL_MARSHAL_FLAG_DESTROY);
 507+}
 508+
 509+/**
 510+ * @ingroup iface_xdg_wm_base
 511+ *
 512+ * Create a positioner object. A positioner object is used to position
 513+ * surfaces relative to some parent surface. See the interface description
 514+ * and xdg_surface.get_popup for details.
 515+ */
 516+static inline struct xdg_positioner *
 517+xdg_wm_base_create_positioner(struct xdg_wm_base *xdg_wm_base)
 518+{
 519+	struct wl_proxy *id;
 520+
 521+	id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_wm_base,
 522+			 XDG_WM_BASE_CREATE_POSITIONER, &xdg_positioner_interface, wl_proxy_get_version((struct wl_proxy *) xdg_wm_base), 0, NULL);
 523+
 524+	return (struct xdg_positioner *) id;
 525+}
 526+
 527+/**
 528+ * @ingroup iface_xdg_wm_base
 529+ *
 530+ * This creates an xdg_surface for the given surface. While xdg_surface
 531+ * itself is not a role, the corresponding surface may only be assigned
 532+ * a role extending xdg_surface, such as xdg_toplevel or xdg_popup. It is
 533+ * illegal to create an xdg_surface for a wl_surface which already has an
 534+ * assigned role and this will result in a role error.
 535+ *
 536+ * This creates an xdg_surface for the given surface. An xdg_surface is
 537+ * used as basis to define a role to a given surface, such as xdg_toplevel
 538+ * or xdg_popup. It also manages functionality shared between xdg_surface
 539+ * based surface roles.
 540+ *
 541+ * See the documentation of xdg_surface for more details about what an
 542+ * xdg_surface is and how it is used.
 543+ */
 544+static inline struct xdg_surface *
 545+xdg_wm_base_get_xdg_surface(struct xdg_wm_base *xdg_wm_base, struct wl_surface *surface)
 546+{
 547+	struct wl_proxy *id;
 548+
 549+	id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_wm_base,
 550+			 XDG_WM_BASE_GET_XDG_SURFACE, &xdg_surface_interface, wl_proxy_get_version((struct wl_proxy *) xdg_wm_base), 0, NULL, surface);
 551+
 552+	return (struct xdg_surface *) id;
 553+}
 554+
 555+/**
 556+ * @ingroup iface_xdg_wm_base
 557+ *
 558+ * A client must respond to a ping event with a pong request or
 559+ * the client may be deemed unresponsive. See xdg_wm_base.ping
 560+ * and xdg_wm_base.error.unresponsive.
 561+ */
 562+static inline void
 563+xdg_wm_base_pong(struct xdg_wm_base *xdg_wm_base, uint32_t serial)
 564+{
 565+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_wm_base,
 566+			 XDG_WM_BASE_PONG, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_wm_base), 0, serial);
 567+}
 568+
 569+#ifndef XDG_POSITIONER_ERROR_ENUM
 570+#define XDG_POSITIONER_ERROR_ENUM
 571+enum xdg_positioner_error {
 572+	/**
 573+	 * invalid input provided
 574+	 */
 575+	XDG_POSITIONER_ERROR_INVALID_INPUT = 0,
 576+};
 577+#endif /* XDG_POSITIONER_ERROR_ENUM */
 578+
 579+#ifndef XDG_POSITIONER_ANCHOR_ENUM
 580+#define XDG_POSITIONER_ANCHOR_ENUM
 581+enum xdg_positioner_anchor {
 582+	XDG_POSITIONER_ANCHOR_NONE = 0,
 583+	XDG_POSITIONER_ANCHOR_TOP = 1,
 584+	XDG_POSITIONER_ANCHOR_BOTTOM = 2,
 585+	XDG_POSITIONER_ANCHOR_LEFT = 3,
 586+	XDG_POSITIONER_ANCHOR_RIGHT = 4,
 587+	XDG_POSITIONER_ANCHOR_TOP_LEFT = 5,
 588+	XDG_POSITIONER_ANCHOR_BOTTOM_LEFT = 6,
 589+	XDG_POSITIONER_ANCHOR_TOP_RIGHT = 7,
 590+	XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT = 8,
 591+};
 592+#endif /* XDG_POSITIONER_ANCHOR_ENUM */
 593+
 594+#ifndef XDG_POSITIONER_GRAVITY_ENUM
 595+#define XDG_POSITIONER_GRAVITY_ENUM
 596+enum xdg_positioner_gravity {
 597+	XDG_POSITIONER_GRAVITY_NONE = 0,
 598+	XDG_POSITIONER_GRAVITY_TOP = 1,
 599+	XDG_POSITIONER_GRAVITY_BOTTOM = 2,
 600+	XDG_POSITIONER_GRAVITY_LEFT = 3,
 601+	XDG_POSITIONER_GRAVITY_RIGHT = 4,
 602+	XDG_POSITIONER_GRAVITY_TOP_LEFT = 5,
 603+	XDG_POSITIONER_GRAVITY_BOTTOM_LEFT = 6,
 604+	XDG_POSITIONER_GRAVITY_TOP_RIGHT = 7,
 605+	XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT = 8,
 606+};
 607+#endif /* XDG_POSITIONER_GRAVITY_ENUM */
 608+
 609+#ifndef XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM
 610+#define XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM
 611+/**
 612+ * @ingroup iface_xdg_positioner
 613+ * constraint adjustments
 614+ *
 615+ * The constraint adjustment value define ways the compositor will adjust
 616+ * the position of the surface, if the unadjusted position would result
 617+ * in the surface being partly constrained.
 618+ *
 619+ * Whether a surface is considered 'constrained' is left to the compositor
 620+ * to determine. For example, the surface may be partly outside the
 621+ * compositor's defined 'work area', thus necessitating the child surface's
 622+ * position be adjusted until it is entirely inside the work area.
 623+ *
 624+ * The adjustments can be combined, according to a defined precedence: 1)
 625+ * Flip, 2) Slide, 3) Resize.
 626+ */
 627+enum xdg_positioner_constraint_adjustment {
 628+	/**
 629+	 * don't move the child surface when constrained
 630+	 *
 631+	 * Don't alter the surface position even if it is constrained on
 632+	 * some axis, for example partially outside the edge of an output.
 633+	 */
 634+	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE = 0,
 635+	/**
 636+	 * move along the x axis until unconstrained
 637+	 *
 638+	 * Slide the surface along the x axis until it is no longer
 639+	 * constrained.
 640+	 *
 641+	 * First try to slide towards the direction of the gravity on the x
 642+	 * axis until either the edge in the opposite direction of the
 643+	 * gravity is unconstrained or the edge in the direction of the
 644+	 * gravity is constrained.
 645+	 *
 646+	 * Then try to slide towards the opposite direction of the gravity
 647+	 * on the x axis until either the edge in the direction of the
 648+	 * gravity is unconstrained or the edge in the opposite direction
 649+	 * of the gravity is constrained.
 650+	 */
 651+	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X = 1,
 652+	/**
 653+	 * move along the y axis until unconstrained
 654+	 *
 655+	 * Slide the surface along the y axis until it is no longer
 656+	 * constrained.
 657+	 *
 658+	 * First try to slide towards the direction of the gravity on the y
 659+	 * axis until either the edge in the opposite direction of the
 660+	 * gravity is unconstrained or the edge in the direction of the
 661+	 * gravity is constrained.
 662+	 *
 663+	 * Then try to slide towards the opposite direction of the gravity
 664+	 * on the y axis until either the edge in the direction of the
 665+	 * gravity is unconstrained or the edge in the opposite direction
 666+	 * of the gravity is constrained.
 667+	 */
 668+	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y = 2,
 669+	/**
 670+	 * invert the anchor and gravity on the x axis
 671+	 *
 672+	 * Invert the anchor and gravity on the x axis if the surface is
 673+	 * constrained on the x axis. For example, if the left edge of the
 674+	 * surface is constrained, the gravity is 'left' and the anchor is
 675+	 * 'left', change the gravity to 'right' and the anchor to 'right'.
 676+	 *
 677+	 * If the adjusted position also ends up being constrained, the
 678+	 * resulting position of the flip_x adjustment will be the one
 679+	 * before the adjustment.
 680+	 */
 681+	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X = 4,
 682+	/**
 683+	 * invert the anchor and gravity on the y axis
 684+	 *
 685+	 * Invert the anchor and gravity on the y axis if the surface is
 686+	 * constrained on the y axis. For example, if the bottom edge of
 687+	 * the surface is constrained, the gravity is 'bottom' and the
 688+	 * anchor is 'bottom', change the gravity to 'top' and the anchor
 689+	 * to 'top'.
 690+	 *
 691+	 * The adjusted position is calculated given the original anchor
 692+	 * rectangle and offset, but with the new flipped anchor and
 693+	 * gravity values.
 694+	 *
 695+	 * If the adjusted position also ends up being constrained, the
 696+	 * resulting position of the flip_y adjustment will be the one
 697+	 * before the adjustment.
 698+	 */
 699+	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y = 8,
 700+	/**
 701+	 * horizontally resize the surface
 702+	 *
 703+	 * Resize the surface horizontally so that it is completely
 704+	 * unconstrained.
 705+	 */
 706+	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X = 16,
 707+	/**
 708+	 * vertically resize the surface
 709+	 *
 710+	 * Resize the surface vertically so that it is completely
 711+	 * unconstrained.
 712+	 */
 713+	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32,
 714+};
 715+#endif /* XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM */
 716+
 717+#define XDG_POSITIONER_DESTROY 0
 718+#define XDG_POSITIONER_SET_SIZE 1
 719+#define XDG_POSITIONER_SET_ANCHOR_RECT 2
 720+#define XDG_POSITIONER_SET_ANCHOR 3
 721+#define XDG_POSITIONER_SET_GRAVITY 4
 722+#define XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT 5
 723+#define XDG_POSITIONER_SET_OFFSET 6
 724+#define XDG_POSITIONER_SET_REACTIVE 7
 725+#define XDG_POSITIONER_SET_PARENT_SIZE 8
 726+#define XDG_POSITIONER_SET_PARENT_CONFIGURE 9
 727+
 728+
 729+/**
 730+ * @ingroup iface_xdg_positioner
 731+ */
 732+#define XDG_POSITIONER_DESTROY_SINCE_VERSION 1
 733+/**
 734+ * @ingroup iface_xdg_positioner
 735+ */
 736+#define XDG_POSITIONER_SET_SIZE_SINCE_VERSION 1
 737+/**
 738+ * @ingroup iface_xdg_positioner
 739+ */
 740+#define XDG_POSITIONER_SET_ANCHOR_RECT_SINCE_VERSION 1
 741+/**
 742+ * @ingroup iface_xdg_positioner
 743+ */
 744+#define XDG_POSITIONER_SET_ANCHOR_SINCE_VERSION 1
 745+/**
 746+ * @ingroup iface_xdg_positioner
 747+ */
 748+#define XDG_POSITIONER_SET_GRAVITY_SINCE_VERSION 1
 749+/**
 750+ * @ingroup iface_xdg_positioner
 751+ */
 752+#define XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT_SINCE_VERSION 1
 753+/**
 754+ * @ingroup iface_xdg_positioner
 755+ */
 756+#define XDG_POSITIONER_SET_OFFSET_SINCE_VERSION 1
 757+/**
 758+ * @ingroup iface_xdg_positioner
 759+ */
 760+#define XDG_POSITIONER_SET_REACTIVE_SINCE_VERSION 3
 761+/**
 762+ * @ingroup iface_xdg_positioner
 763+ */
 764+#define XDG_POSITIONER_SET_PARENT_SIZE_SINCE_VERSION 3
 765+/**
 766+ * @ingroup iface_xdg_positioner
 767+ */
 768+#define XDG_POSITIONER_SET_PARENT_CONFIGURE_SINCE_VERSION 3
 769+
 770+/** @ingroup iface_xdg_positioner */
 771+static inline void
 772+xdg_positioner_set_user_data(struct xdg_positioner *xdg_positioner, void *user_data)
 773+{
 774+	wl_proxy_set_user_data((struct wl_proxy *) xdg_positioner, user_data);
 775+}
 776+
 777+/** @ingroup iface_xdg_positioner */
 778+static inline void *
 779+xdg_positioner_get_user_data(struct xdg_positioner *xdg_positioner)
 780+{
 781+	return wl_proxy_get_user_data((struct wl_proxy *) xdg_positioner);
 782+}
 783+
 784+static inline uint32_t
 785+xdg_positioner_get_version(struct xdg_positioner *xdg_positioner)
 786+{
 787+	return wl_proxy_get_version((struct wl_proxy *) xdg_positioner);
 788+}
 789+
 790+/**
 791+ * @ingroup iface_xdg_positioner
 792+ *
 793+ * Notify the compositor that the xdg_positioner will no longer be used.
 794+ */
 795+static inline void
 796+xdg_positioner_destroy(struct xdg_positioner *xdg_positioner)
 797+{
 798+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner,
 799+			 XDG_POSITIONER_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), WL_MARSHAL_FLAG_DESTROY);
 800+}
 801+
 802+/**
 803+ * @ingroup iface_xdg_positioner
 804+ *
 805+ * Set the size of the surface that is to be positioned with the positioner
 806+ * object. The size is in surface-local coordinates and corresponds to the
 807+ * window geometry. See xdg_surface.set_window_geometry.
 808+ *
 809+ * If a zero or negative size is set the invalid_input error is raised.
 810+ */
 811+static inline void
 812+xdg_positioner_set_size(struct xdg_positioner *xdg_positioner, int32_t width, int32_t height)
 813+{
 814+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner,
 815+			 XDG_POSITIONER_SET_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, width, height);
 816+}
 817+
 818+/**
 819+ * @ingroup iface_xdg_positioner
 820+ *
 821+ * Specify the anchor rectangle within the parent surface that the child
 822+ * surface will be placed relative to. The rectangle is relative to the
 823+ * window geometry as defined by xdg_surface.set_window_geometry of the
 824+ * parent surface.
 825+ *
 826+ * When the xdg_positioner object is used to position a child surface, the
 827+ * anchor rectangle may not extend outside the window geometry of the
 828+ * positioned child's parent surface.
 829+ *
 830+ * If a negative size is set the invalid_input error is raised.
 831+ */
 832+static inline void
 833+xdg_positioner_set_anchor_rect(struct xdg_positioner *xdg_positioner, int32_t x, int32_t y, int32_t width, int32_t height)
 834+{
 835+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner,
 836+			 XDG_POSITIONER_SET_ANCHOR_RECT, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, x, y, width, height);
 837+}
 838+
 839+/**
 840+ * @ingroup iface_xdg_positioner
 841+ *
 842+ * Defines the anchor point for the anchor rectangle. The specified anchor
 843+ * is used derive an anchor point that the child surface will be
 844+ * positioned relative to. If a corner anchor is set (e.g. 'top_left' or
 845+ * 'bottom_right'), the anchor point will be at the specified corner;
 846+ * otherwise, the derived anchor point will be centered on the specified
 847+ * edge, or in the center of the anchor rectangle if no edge is specified.
 848+ */
 849+static inline void
 850+xdg_positioner_set_anchor(struct xdg_positioner *xdg_positioner, uint32_t anchor)
 851+{
 852+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner,
 853+			 XDG_POSITIONER_SET_ANCHOR, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, anchor);
 854+}
 855+
 856+/**
 857+ * @ingroup iface_xdg_positioner
 858+ *
 859+ * Defines in what direction a surface should be positioned, relative to
 860+ * the anchor point of the parent surface. If a corner gravity is
 861+ * specified (e.g. 'bottom_right' or 'top_left'), then the child surface
 862+ * will be placed towards the specified gravity; otherwise, the child
 863+ * surface will be centered over the anchor point on any axis that had no
 864+ * gravity specified. If the gravity is not in the ‘gravity’ enum, an
 865+ * invalid_input error is raised.
 866+ */
 867+static inline void
 868+xdg_positioner_set_gravity(struct xdg_positioner *xdg_positioner, uint32_t gravity)
 869+{
 870+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner,
 871+			 XDG_POSITIONER_SET_GRAVITY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, gravity);
 872+}
 873+
 874+/**
 875+ * @ingroup iface_xdg_positioner
 876+ *
 877+ * Specify how the window should be positioned if the originally intended
 878+ * position caused the surface to be constrained, meaning at least
 879+ * partially outside positioning boundaries set by the compositor. The
 880+ * adjustment is set by constructing a bitmask describing the adjustment to
 881+ * be made when the surface is constrained on that axis.
 882+ *
 883+ * If no bit for one axis is set, the compositor will assume that the child
 884+ * surface should not change its position on that axis when constrained.
 885+ *
 886+ * If more than one bit for one axis is set, the order of how adjustments
 887+ * are applied is specified in the corresponding adjustment descriptions.
 888+ *
 889+ * The default adjustment is none.
 890+ */
 891+static inline void
 892+xdg_positioner_set_constraint_adjustment(struct xdg_positioner *xdg_positioner, uint32_t constraint_adjustment)
 893+{
 894+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner,
 895+			 XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, constraint_adjustment);
 896+}
 897+
 898+/**
 899+ * @ingroup iface_xdg_positioner
 900+ *
 901+ * Specify the surface position offset relative to the position of the
 902+ * anchor on the anchor rectangle and the anchor on the surface. For
 903+ * example if the anchor of the anchor rectangle is at (x, y), the surface
 904+ * has the gravity bottom|right, and the offset is (ox, oy), the calculated
 905+ * surface position will be (x + ox, y + oy). The offset position of the
 906+ * surface is the one used for constraint testing. See
 907+ * set_constraint_adjustment.
 908+ *
 909+ * An example use case is placing a popup menu on top of a user interface
 910+ * element, while aligning the user interface element of the parent surface
 911+ * with some user interface element placed somewhere in the popup surface.
 912+ */
 913+static inline void
 914+xdg_positioner_set_offset(struct xdg_positioner *xdg_positioner, int32_t x, int32_t y)
 915+{
 916+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner,
 917+			 XDG_POSITIONER_SET_OFFSET, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, x, y);
 918+}
 919+
 920+/**
 921+ * @ingroup iface_xdg_positioner
 922+ *
 923+ * When set reactive, the surface is reconstrained if the conditions used
 924+ * for constraining changed, e.g. the parent window moved.
 925+ *
 926+ * If the conditions changed and the popup was reconstrained, an
 927+ * xdg_popup.configure event is sent with updated geometry, followed by an
 928+ * xdg_surface.configure event.
 929+ */
 930+static inline void
 931+xdg_positioner_set_reactive(struct xdg_positioner *xdg_positioner)
 932+{
 933+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner,
 934+			 XDG_POSITIONER_SET_REACTIVE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0);
 935+}
 936+
 937+/**
 938+ * @ingroup iface_xdg_positioner
 939+ *
 940+ * Set the parent window geometry the compositor should use when
 941+ * positioning the popup. The compositor may use this information to
 942+ * determine the future state the popup should be constrained using. If
 943+ * this doesn't match the dimension of the parent the popup is eventually
 944+ * positioned against, the behavior is undefined.
 945+ *
 946+ * The arguments are given in the surface-local coordinate space.
 947+ */
 948+static inline void
 949+xdg_positioner_set_parent_size(struct xdg_positioner *xdg_positioner, int32_t parent_width, int32_t parent_height)
 950+{
 951+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner,
 952+			 XDG_POSITIONER_SET_PARENT_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, parent_width, parent_height);
 953+}
 954+
 955+/**
 956+ * @ingroup iface_xdg_positioner
 957+ *
 958+ * Set the serial of an xdg_surface.configure event this positioner will be
 959+ * used in response to. The compositor may use this information together
 960+ * with set_parent_size to determine what future state the popup should be
 961+ * constrained using.
 962+ */
 963+static inline void
 964+xdg_positioner_set_parent_configure(struct xdg_positioner *xdg_positioner, uint32_t serial)
 965+{
 966+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner,
 967+			 XDG_POSITIONER_SET_PARENT_CONFIGURE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, serial);
 968+}
 969+
 970+#ifndef XDG_SURFACE_ERROR_ENUM
 971+#define XDG_SURFACE_ERROR_ENUM
 972+enum xdg_surface_error {
 973+	/**
 974+	 * Surface was not fully constructed
 975+	 */
 976+	XDG_SURFACE_ERROR_NOT_CONSTRUCTED = 1,
 977+	/**
 978+	 * Surface was already constructed
 979+	 */
 980+	XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED = 2,
 981+	/**
 982+	 * Attaching a buffer to an unconfigured surface
 983+	 */
 984+	XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER = 3,
 985+	/**
 986+	 * Invalid serial number when acking a configure event
 987+	 */
 988+	XDG_SURFACE_ERROR_INVALID_SERIAL = 4,
 989+	/**
 990+	 * Width or height was zero or negative
 991+	 */
 992+	XDG_SURFACE_ERROR_INVALID_SIZE = 5,
 993+	/**
 994+	 * Surface was destroyed before its role object
 995+	 */
 996+	XDG_SURFACE_ERROR_DEFUNCT_ROLE_OBJECT = 6,
 997+};
 998+#endif /* XDG_SURFACE_ERROR_ENUM */
 999+
1000+/**
1001+ * @ingroup iface_xdg_surface
1002+ * @struct xdg_surface_listener
1003+ */
1004+struct xdg_surface_listener {
1005+	/**
1006+	 * suggest a surface change
1007+	 *
1008+	 * The configure event marks the end of a configure sequence. A
1009+	 * configure sequence is a set of one or more events configuring
1010+	 * the state of the xdg_surface, including the final
1011+	 * xdg_surface.configure event.
1012+	 *
1013+	 * Where applicable, xdg_surface surface roles will during a
1014+	 * configure sequence extend this event as a latched state sent as
1015+	 * events before the xdg_surface.configure event. Such events
1016+	 * should be considered to make up a set of atomically applied
1017+	 * configuration states, where the xdg_surface.configure commits
1018+	 * the accumulated state.
1019+	 *
1020+	 * Clients should arrange their surface for the new states, and
1021+	 * then send an ack_configure request with the serial sent in this
1022+	 * configure event at some point before committing the new surface.
1023+	 *
1024+	 * If the client receives multiple configure events before it can
1025+	 * respond to one, it is free to discard all but the last event it
1026+	 * received.
1027+	 * @param serial serial of the configure event
1028+	 */
1029+	void (*configure)(void *data,
1030+			  struct xdg_surface *xdg_surface,
1031+			  uint32_t serial);
1032+};
1033+
1034+/**
1035+ * @ingroup iface_xdg_surface
1036+ */
1037+static inline int
1038+xdg_surface_add_listener(struct xdg_surface *xdg_surface,
1039+			 const struct xdg_surface_listener *listener, void *data)
1040+{
1041+	return wl_proxy_add_listener((struct wl_proxy *) xdg_surface,
1042+				     (void (**)(void)) listener, data);
1043+}
1044+
1045+#define XDG_SURFACE_DESTROY 0
1046+#define XDG_SURFACE_GET_TOPLEVEL 1
1047+#define XDG_SURFACE_GET_POPUP 2
1048+#define XDG_SURFACE_SET_WINDOW_GEOMETRY 3
1049+#define XDG_SURFACE_ACK_CONFIGURE 4
1050+
1051+/**
1052+ * @ingroup iface_xdg_surface
1053+ */
1054+#define XDG_SURFACE_CONFIGURE_SINCE_VERSION 1
1055+
1056+/**
1057+ * @ingroup iface_xdg_surface
1058+ */
1059+#define XDG_SURFACE_DESTROY_SINCE_VERSION 1
1060+/**
1061+ * @ingroup iface_xdg_surface
1062+ */
1063+#define XDG_SURFACE_GET_TOPLEVEL_SINCE_VERSION 1
1064+/**
1065+ * @ingroup iface_xdg_surface
1066+ */
1067+#define XDG_SURFACE_GET_POPUP_SINCE_VERSION 1
1068+/**
1069+ * @ingroup iface_xdg_surface
1070+ */
1071+#define XDG_SURFACE_SET_WINDOW_GEOMETRY_SINCE_VERSION 1
1072+/**
1073+ * @ingroup iface_xdg_surface
1074+ */
1075+#define XDG_SURFACE_ACK_CONFIGURE_SINCE_VERSION 1
1076+
1077+/** @ingroup iface_xdg_surface */
1078+static inline void
1079+xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data)
1080+{
1081+	wl_proxy_set_user_data((struct wl_proxy *) xdg_surface, user_data);
1082+}
1083+
1084+/** @ingroup iface_xdg_surface */
1085+static inline void *
1086+xdg_surface_get_user_data(struct xdg_surface *xdg_surface)
1087+{
1088+	return wl_proxy_get_user_data((struct wl_proxy *) xdg_surface);
1089+}
1090+
1091+static inline uint32_t
1092+xdg_surface_get_version(struct xdg_surface *xdg_surface)
1093+{
1094+	return wl_proxy_get_version((struct wl_proxy *) xdg_surface);
1095+}
1096+
1097+/**
1098+ * @ingroup iface_xdg_surface
1099+ *
1100+ * Destroy the xdg_surface object. An xdg_surface must only be destroyed
1101+ * after its role object has been destroyed, otherwise
1102+ * a defunct_role_object error is raised.
1103+ */
1104+static inline void
1105+xdg_surface_destroy(struct xdg_surface *xdg_surface)
1106+{
1107+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface,
1108+			 XDG_SURFACE_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_surface), WL_MARSHAL_FLAG_DESTROY);
1109+}
1110+
1111+/**
1112+ * @ingroup iface_xdg_surface
1113+ *
1114+ * This creates an xdg_toplevel object for the given xdg_surface and gives
1115+ * the associated wl_surface the xdg_toplevel role.
1116+ *
1117+ * See the documentation of xdg_toplevel for more details about what an
1118+ * xdg_toplevel is and how it is used.
1119+ */
1120+static inline struct xdg_toplevel *
1121+xdg_surface_get_toplevel(struct xdg_surface *xdg_surface)
1122+{
1123+	struct wl_proxy *id;
1124+
1125+	id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface,
1126+			 XDG_SURFACE_GET_TOPLEVEL, &xdg_toplevel_interface, wl_proxy_get_version((struct wl_proxy *) xdg_surface), 0, NULL);
1127+
1128+	return (struct xdg_toplevel *) id;
1129+}
1130+
1131+/**
1132+ * @ingroup iface_xdg_surface
1133+ *
1134+ * This creates an xdg_popup object for the given xdg_surface and gives
1135+ * the associated wl_surface the xdg_popup role.
1136+ *
1137+ * If null is passed as a parent, a parent surface must be specified using
1138+ * some other protocol, before committing the initial state.
1139+ *
1140+ * See the documentation of xdg_popup for more details about what an
1141+ * xdg_popup is and how it is used.
1142+ */
1143+static inline struct xdg_popup *
1144+xdg_surface_get_popup(struct xdg_surface *xdg_surface, struct xdg_surface *parent, struct xdg_positioner *positioner)
1145+{
1146+	struct wl_proxy *id;
1147+
1148+	id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface,
1149+			 XDG_SURFACE_GET_POPUP, &xdg_popup_interface, wl_proxy_get_version((struct wl_proxy *) xdg_surface), 0, NULL, parent, positioner);
1150+
1151+	return (struct xdg_popup *) id;
1152+}
1153+
1154+/**
1155+ * @ingroup iface_xdg_surface
1156+ *
1157+ * The window geometry of a surface is its "visible bounds" from the
1158+ * user's perspective. Client-side decorations often have invisible
1159+ * portions like drop-shadows which should be ignored for the
1160+ * purposes of aligning, placing and constraining windows. Note that
1161+ * in some situations, compositors may clip rendering to the window
1162+ * geometry, so the client should avoid putting functional elements
1163+ * outside of it.
1164+ *
1165+ * The window geometry is double-buffered state, see wl_surface.commit.
1166+ *
1167+ * When maintaining a position, the compositor should treat the (x, y)
1168+ * coordinate of the window geometry as the top left corner of the window.
1169+ * A client changing the (x, y) window geometry coordinate should in
1170+ * general not alter the position of the window.
1171+ *
1172+ * Once the window geometry of the surface is set, it is not possible to
1173+ * unset it, and it will remain the same until set_window_geometry is
1174+ * called again, even if a new subsurface or buffer is attached.
1175+ *
1176+ * If never set, the value is the full bounds of the surface,
1177+ * including any subsurfaces. This updates dynamically on every
1178+ * commit. This unset is meant for extremely simple clients.
1179+ *
1180+ * The arguments are given in the surface-local coordinate space of
1181+ * the wl_surface associated with this xdg_surface, and may extend outside
1182+ * of the wl_surface itself to mark parts of the subsurface tree as part of
1183+ * the window geometry.
1184+ *
1185+ * When applied, the effective window geometry will be the set window
1186+ * geometry clamped to the bounding rectangle of the combined
1187+ * geometry of the surface of the xdg_surface and the associated
1188+ * subsurfaces.
1189+ *
1190+ * The effective geometry will not be recalculated unless a new call to
1191+ * set_window_geometry is done and the new pending surface state is
1192+ * subsequently applied.
1193+ *
1194+ * The width and height of the effective window geometry must be
1195+ * greater than zero. Setting an invalid size will raise an
1196+ * invalid_size error.
1197+ */
1198+static inline void
1199+xdg_surface_set_window_geometry(struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height)
1200+{
1201+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface,
1202+			 XDG_SURFACE_SET_WINDOW_GEOMETRY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_surface), 0, x, y, width, height);
1203+}
1204+
1205+/**
1206+ * @ingroup iface_xdg_surface
1207+ *
1208+ * When a configure event is received, if a client commits the
1209+ * surface in response to the configure event, then the client
1210+ * must make an ack_configure request sometime before the commit
1211+ * request, passing along the serial of the configure event.
1212+ *
1213+ * For instance, for toplevel surfaces the compositor might use this
1214+ * information to move a surface to the top left only when the client has
1215+ * drawn itself for the maximized or fullscreen state.
1216+ *
1217+ * If the client receives multiple configure events before it
1218+ * can respond to one, it only has to ack the last configure event.
1219+ * Acking a configure event that was never sent raises an invalid_serial
1220+ * error.
1221+ *
1222+ * A client is not required to commit immediately after sending
1223+ * an ack_configure request - it may even ack_configure several times
1224+ * before its next surface commit.
1225+ *
1226+ * A client may send multiple ack_configure requests before committing, but
1227+ * only the last request sent before a commit indicates which configure
1228+ * event the client really is responding to.
1229+ *
1230+ * Sending an ack_configure request consumes the serial number sent with
1231+ * the request, as well as serial numbers sent by all configure events
1232+ * sent on this xdg_surface prior to the configure event referenced by
1233+ * the committed serial.
1234+ *
1235+ * It is an error to issue multiple ack_configure requests referencing a
1236+ * serial from the same configure event, or to issue an ack_configure
1237+ * request referencing a serial from a configure event issued before the
1238+ * event identified by the last ack_configure request for the same
1239+ * xdg_surface. Doing so will raise an invalid_serial error.
1240+ */
1241+static inline void
1242+xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial)
1243+{
1244+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface,
1245+			 XDG_SURFACE_ACK_CONFIGURE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_surface), 0, serial);
1246+}
1247+
1248+#ifndef XDG_TOPLEVEL_ERROR_ENUM
1249+#define XDG_TOPLEVEL_ERROR_ENUM
1250+enum xdg_toplevel_error {
1251+	/**
1252+	 * provided value is         not a valid variant of the resize_edge enum
1253+	 */
1254+	XDG_TOPLEVEL_ERROR_INVALID_RESIZE_EDGE = 0,
1255+	/**
1256+	 * invalid parent toplevel
1257+	 */
1258+	XDG_TOPLEVEL_ERROR_INVALID_PARENT = 1,
1259+	/**
1260+	 * client provided an invalid min or max size
1261+	 */
1262+	XDG_TOPLEVEL_ERROR_INVALID_SIZE = 2,
1263+};
1264+#endif /* XDG_TOPLEVEL_ERROR_ENUM */
1265+
1266+#ifndef XDG_TOPLEVEL_RESIZE_EDGE_ENUM
1267+#define XDG_TOPLEVEL_RESIZE_EDGE_ENUM
1268+/**
1269+ * @ingroup iface_xdg_toplevel
1270+ * edge values for resizing
1271+ *
1272+ * These values are used to indicate which edge of a surface
1273+ * is being dragged in a resize operation.
1274+ */
1275+enum xdg_toplevel_resize_edge {
1276+	XDG_TOPLEVEL_RESIZE_EDGE_NONE = 0,
1277+	XDG_TOPLEVEL_RESIZE_EDGE_TOP = 1,
1278+	XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM = 2,
1279+	XDG_TOPLEVEL_RESIZE_EDGE_LEFT = 4,
1280+	XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT = 5,
1281+	XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT = 6,
1282+	XDG_TOPLEVEL_RESIZE_EDGE_RIGHT = 8,
1283+	XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT = 9,
1284+	XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT = 10,
1285+};
1286+#endif /* XDG_TOPLEVEL_RESIZE_EDGE_ENUM */
1287+
1288+#ifndef XDG_TOPLEVEL_STATE_ENUM
1289+#define XDG_TOPLEVEL_STATE_ENUM
1290+/**
1291+ * @ingroup iface_xdg_toplevel
1292+ * types of state on the surface
1293+ *
1294+ * The different state values used on the surface. This is designed for
1295+ * state values like maximized, fullscreen. It is paired with the
1296+ * configure event to ensure that both the client and the compositor
1297+ * setting the state can be synchronized.
1298+ *
1299+ * States set in this way are double-buffered, see wl_surface.commit.
1300+ */
1301+enum xdg_toplevel_state {
1302+	/**
1303+	 * the surface is maximized
1304+	 * the surface is maximized
1305+	 *
1306+	 * The surface is maximized. The window geometry specified in the
1307+	 * configure event must be obeyed by the client, or the
1308+	 * xdg_wm_base.invalid_surface_state error is raised.
1309+	 *
1310+	 * The client should draw without shadow or other decoration
1311+	 * outside of the window geometry.
1312+	 */
1313+	XDG_TOPLEVEL_STATE_MAXIMIZED = 1,
1314+	/**
1315+	 * the surface is fullscreen
1316+	 * the surface is fullscreen
1317+	 *
1318+	 * The surface is fullscreen. The window geometry specified in
1319+	 * the configure event is a maximum; the client cannot resize
1320+	 * beyond it. For a surface to cover the whole fullscreened area,
1321+	 * the geometry dimensions must be obeyed by the client. For more
1322+	 * details, see xdg_toplevel.set_fullscreen.
1323+	 */
1324+	XDG_TOPLEVEL_STATE_FULLSCREEN = 2,
1325+	/**
1326+	 * the surface is being resized
1327+	 * the surface is being resized
1328+	 *
1329+	 * The surface is being resized. The window geometry specified in
1330+	 * the configure event is a maximum; the client cannot resize
1331+	 * beyond it. Clients that have aspect ratio or cell sizing
1332+	 * configuration can use a smaller size, however.
1333+	 */
1334+	XDG_TOPLEVEL_STATE_RESIZING = 3,
1335+	/**
1336+	 * the surface is now activated
1337+	 * the surface is now activated
1338+	 *
1339+	 * Client window decorations should be painted as if the window
1340+	 * is active. Do not assume this means that the window actually has
1341+	 * keyboard or pointer focus.
1342+	 */
1343+	XDG_TOPLEVEL_STATE_ACTIVATED = 4,
1344+	/**
1345+	 * the surface’s left edge is tiled
1346+	 *
1347+	 * The window is currently in a tiled layout and the left edge is
1348+	 * considered to be adjacent to another part of the tiling grid.
1349+	 *
1350+	 * The client should draw without shadow or other decoration
1351+	 * outside of the window geometry on the left edge.
1352+	 * @since 2
1353+	 */
1354+	XDG_TOPLEVEL_STATE_TILED_LEFT = 5,
1355+	/**
1356+	 * the surface’s right edge is tiled
1357+	 *
1358+	 * The window is currently in a tiled layout and the right edge
1359+	 * is considered to be adjacent to another part of the tiling grid.
1360+	 *
1361+	 * The client should draw without shadow or other decoration
1362+	 * outside of the window geometry on the right edge.
1363+	 * @since 2
1364+	 */
1365+	XDG_TOPLEVEL_STATE_TILED_RIGHT = 6,
1366+	/**
1367+	 * the surface’s top edge is tiled
1368+	 *
1369+	 * The window is currently in a tiled layout and the top edge is
1370+	 * considered to be adjacent to another part of the tiling grid.
1371+	 *
1372+	 * The client should draw without shadow or other decoration
1373+	 * outside of the window geometry on the top edge.
1374+	 * @since 2
1375+	 */
1376+	XDG_TOPLEVEL_STATE_TILED_TOP = 7,
1377+	/**
1378+	 * the surface’s bottom edge is tiled
1379+	 *
1380+	 * The window is currently in a tiled layout and the bottom edge
1381+	 * is considered to be adjacent to another part of the tiling grid.
1382+	 *
1383+	 * The client should draw without shadow or other decoration
1384+	 * outside of the window geometry on the bottom edge.
1385+	 * @since 2
1386+	 */
1387+	XDG_TOPLEVEL_STATE_TILED_BOTTOM = 8,
1388+	/**
1389+	 * surface repaint is suspended
1390+	 *
1391+	 * The surface is currently not ordinarily being repainted; for
1392+	 * example because its content is occluded by another window, or
1393+	 * its outputs are switched off due to screen locking.
1394+	 * @since 6
1395+	 */
1396+	XDG_TOPLEVEL_STATE_SUSPENDED = 9,
1397+	/**
1398+	 * the surface’s left edge is constrained
1399+	 *
1400+	 * The left edge of the window is currently constrained, meaning
1401+	 * it shouldn't attempt to resize from that edge. It can for
1402+	 * example mean it's tiled next to a monitor edge on the
1403+	 * constrained side of the window.
1404+	 * @since 7
1405+	 */
1406+	XDG_TOPLEVEL_STATE_CONSTRAINED_LEFT = 10,
1407+	/**
1408+	 * the surface’s right edge is constrained
1409+	 *
1410+	 * The right edge of the window is currently constrained, meaning
1411+	 * it shouldn't attempt to resize from that edge. It can for
1412+	 * example mean it's tiled next to a monitor edge on the
1413+	 * constrained side of the window.
1414+	 * @since 7
1415+	 */
1416+	XDG_TOPLEVEL_STATE_CONSTRAINED_RIGHT = 11,
1417+	/**
1418+	 * the surface’s top edge is constrained
1419+	 *
1420+	 * The top edge of the window is currently constrained, meaning
1421+	 * it shouldn't attempt to resize from that edge. It can for
1422+	 * example mean it's tiled next to a monitor edge on the
1423+	 * constrained side of the window.
1424+	 * @since 7
1425+	 */
1426+	XDG_TOPLEVEL_STATE_CONSTRAINED_TOP = 12,
1427+	/**
1428+	 * the surface’s bottom edge is constrained
1429+	 *
1430+	 * The bottom edge of the window is currently constrained,
1431+	 * meaning it shouldn't attempt to resize from that edge. It can
1432+	 * for example mean it's tiled next to a monitor edge on the
1433+	 * constrained side of the window.
1434+	 * @since 7
1435+	 */
1436+	XDG_TOPLEVEL_STATE_CONSTRAINED_BOTTOM = 13,
1437+};
1438+/**
1439+ * @ingroup iface_xdg_toplevel
1440+ */
1441+#define XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION 2
1442+/**
1443+ * @ingroup iface_xdg_toplevel
1444+ */
1445+#define XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION 2
1446+/**
1447+ * @ingroup iface_xdg_toplevel
1448+ */
1449+#define XDG_TOPLEVEL_STATE_TILED_TOP_SINCE_VERSION 2
1450+/**
1451+ * @ingroup iface_xdg_toplevel
1452+ */
1453+#define XDG_TOPLEVEL_STATE_TILED_BOTTOM_SINCE_VERSION 2
1454+/**
1455+ * @ingroup iface_xdg_toplevel
1456+ */
1457+#define XDG_TOPLEVEL_STATE_SUSPENDED_SINCE_VERSION 6
1458+/**
1459+ * @ingroup iface_xdg_toplevel
1460+ */
1461+#define XDG_TOPLEVEL_STATE_CONSTRAINED_LEFT_SINCE_VERSION 7
1462+/**
1463+ * @ingroup iface_xdg_toplevel
1464+ */
1465+#define XDG_TOPLEVEL_STATE_CONSTRAINED_RIGHT_SINCE_VERSION 7
1466+/**
1467+ * @ingroup iface_xdg_toplevel
1468+ */
1469+#define XDG_TOPLEVEL_STATE_CONSTRAINED_TOP_SINCE_VERSION 7
1470+/**
1471+ * @ingroup iface_xdg_toplevel
1472+ */
1473+#define XDG_TOPLEVEL_STATE_CONSTRAINED_BOTTOM_SINCE_VERSION 7
1474+#endif /* XDG_TOPLEVEL_STATE_ENUM */
1475+
1476+#ifndef XDG_TOPLEVEL_WM_CAPABILITIES_ENUM
1477+#define XDG_TOPLEVEL_WM_CAPABILITIES_ENUM
1478+enum xdg_toplevel_wm_capabilities {
1479+	/**
1480+	 * show_window_menu is available
1481+	 */
1482+	XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU = 1,
1483+	/**
1484+	 * set_maximized and unset_maximized are available
1485+	 */
1486+	XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE = 2,
1487+	/**
1488+	 * set_fullscreen and unset_fullscreen are available
1489+	 */
1490+	XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN = 3,
1491+	/**
1492+	 * set_minimized is available
1493+	 */
1494+	XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE = 4,
1495+};
1496+#endif /* XDG_TOPLEVEL_WM_CAPABILITIES_ENUM */
1497+
1498+/**
1499+ * @ingroup iface_xdg_toplevel
1500+ * @struct xdg_toplevel_listener
1501+ */
1502+struct xdg_toplevel_listener {
1503+	/**
1504+	 * suggest a surface change
1505+	 *
1506+	 * This configure event asks the client to resize its toplevel
1507+	 * surface or to change its state. The configured state should not
1508+	 * be applied immediately. See xdg_surface.configure for details.
1509+	 *
1510+	 * The width and height arguments specify a hint to the window
1511+	 * about how its surface should be resized in window geometry
1512+	 * coordinates. See set_window_geometry.
1513+	 *
1514+	 * If the width or height arguments are zero, it means the client
1515+	 * should decide its own window dimension. This may happen when the
1516+	 * compositor needs to configure the state of the surface but
1517+	 * doesn't have any information about any previous or expected
1518+	 * dimension.
1519+	 *
1520+	 * The states listed in the event specify how the width/height
1521+	 * arguments should be interpreted, and possibly how it should be
1522+	 * drawn.
1523+	 *
1524+	 * Clients must send an ack_configure in response to this event.
1525+	 * See xdg_surface.configure and xdg_surface.ack_configure for
1526+	 * details.
1527+	 */
1528+	void (*configure)(void *data,
1529+			  struct xdg_toplevel *xdg_toplevel,
1530+			  int32_t width,
1531+			  int32_t height,
1532+			  struct wl_array *states);
1533+	/**
1534+	 * surface wants to be closed
1535+	 *
1536+	 * The close event is sent by the compositor when the user wants
1537+	 * the surface to be closed. This should be equivalent to the user
1538+	 * clicking the close button in client-side decorations, if your
1539+	 * application has any.
1540+	 *
1541+	 * This is only a request that the user intends to close the
1542+	 * window. The client may choose to ignore this request, or show a
1543+	 * dialog to ask the user to save their data, etc.
1544+	 */
1545+	void (*close)(void *data,
1546+		      struct xdg_toplevel *xdg_toplevel);
1547+	/**
1548+	 * recommended window geometry bounds
1549+	 *
1550+	 * The configure_bounds event may be sent prior to a
1551+	 * xdg_toplevel.configure event to communicate the bounds a window
1552+	 * geometry size is recommended to constrain to.
1553+	 *
1554+	 * The passed width and height are in surface coordinate space. If
1555+	 * width and height are 0, it means bounds is unknown and
1556+	 * equivalent to as if no configure_bounds event was ever sent for
1557+	 * this surface.
1558+	 *
1559+	 * The bounds can for example correspond to the size of a monitor
1560+	 * excluding any panels or other shell components, so that a
1561+	 * surface isn't created in a way that it cannot fit.
1562+	 *
1563+	 * The bounds may change at any point, and in such a case, a new
1564+	 * xdg_toplevel.configure_bounds will be sent, followed by
1565+	 * xdg_toplevel.configure and xdg_surface.configure.
1566+	 * @since 4
1567+	 */
1568+	void (*configure_bounds)(void *data,
1569+				 struct xdg_toplevel *xdg_toplevel,
1570+				 int32_t width,
1571+				 int32_t height);
1572+	/**
1573+	 * compositor capabilities
1574+	 *
1575+	 * This event advertises the capabilities supported by the
1576+	 * compositor. If a capability isn't supported, clients should hide
1577+	 * or disable the UI elements that expose this functionality. For
1578+	 * instance, if the compositor doesn't advertise support for
1579+	 * minimized toplevels, a button triggering the set_minimized
1580+	 * request should not be displayed.
1581+	 *
1582+	 * The compositor will ignore requests it doesn't support. For
1583+	 * instance, a compositor which doesn't advertise support for
1584+	 * minimized will ignore set_minimized requests.
1585+	 *
1586+	 * Compositors must send this event once before the first
1587+	 * xdg_surface.configure event. When the capabilities change,
1588+	 * compositors must send this event again and then send an
1589+	 * xdg_surface.configure event.
1590+	 *
1591+	 * The configured state should not be applied immediately. See
1592+	 * xdg_surface.configure for details.
1593+	 *
1594+	 * The capabilities are sent as an array of 32-bit unsigned
1595+	 * integers in native endianness.
1596+	 * @param capabilities array of 32-bit capabilities
1597+	 * @since 5
1598+	 */
1599+	void (*wm_capabilities)(void *data,
1600+				struct xdg_toplevel *xdg_toplevel,
1601+				struct wl_array *capabilities);
1602+};
1603+
1604+/**
1605+ * @ingroup iface_xdg_toplevel
1606+ */
1607+static inline int
1608+xdg_toplevel_add_listener(struct xdg_toplevel *xdg_toplevel,
1609+			  const struct xdg_toplevel_listener *listener, void *data)
1610+{
1611+	return wl_proxy_add_listener((struct wl_proxy *) xdg_toplevel,
1612+				     (void (**)(void)) listener, data);
1613+}
1614+
1615+#define XDG_TOPLEVEL_DESTROY 0
1616+#define XDG_TOPLEVEL_SET_PARENT 1
1617+#define XDG_TOPLEVEL_SET_TITLE 2
1618+#define XDG_TOPLEVEL_SET_APP_ID 3
1619+#define XDG_TOPLEVEL_SHOW_WINDOW_MENU 4
1620+#define XDG_TOPLEVEL_MOVE 5
1621+#define XDG_TOPLEVEL_RESIZE 6
1622+#define XDG_TOPLEVEL_SET_MAX_SIZE 7
1623+#define XDG_TOPLEVEL_SET_MIN_SIZE 8
1624+#define XDG_TOPLEVEL_SET_MAXIMIZED 9
1625+#define XDG_TOPLEVEL_UNSET_MAXIMIZED 10
1626+#define XDG_TOPLEVEL_SET_FULLSCREEN 11
1627+#define XDG_TOPLEVEL_UNSET_FULLSCREEN 12
1628+#define XDG_TOPLEVEL_SET_MINIMIZED 13
1629+
1630+/**
1631+ * @ingroup iface_xdg_toplevel
1632+ */
1633+#define XDG_TOPLEVEL_CONFIGURE_SINCE_VERSION 1
1634+/**
1635+ * @ingroup iface_xdg_toplevel
1636+ */
1637+#define XDG_TOPLEVEL_CLOSE_SINCE_VERSION 1
1638+/**
1639+ * @ingroup iface_xdg_toplevel
1640+ */
1641+#define XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION 4
1642+/**
1643+ * @ingroup iface_xdg_toplevel
1644+ */
1645+#define XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION 5
1646+
1647+/**
1648+ * @ingroup iface_xdg_toplevel
1649+ */
1650+#define XDG_TOPLEVEL_DESTROY_SINCE_VERSION 1
1651+/**
1652+ * @ingroup iface_xdg_toplevel
1653+ */
1654+#define XDG_TOPLEVEL_SET_PARENT_SINCE_VERSION 1
1655+/**
1656+ * @ingroup iface_xdg_toplevel
1657+ */
1658+#define XDG_TOPLEVEL_SET_TITLE_SINCE_VERSION 1
1659+/**
1660+ * @ingroup iface_xdg_toplevel
1661+ */
1662+#define XDG_TOPLEVEL_SET_APP_ID_SINCE_VERSION 1
1663+/**
1664+ * @ingroup iface_xdg_toplevel
1665+ */
1666+#define XDG_TOPLEVEL_SHOW_WINDOW_MENU_SINCE_VERSION 1
1667+/**
1668+ * @ingroup iface_xdg_toplevel
1669+ */
1670+#define XDG_TOPLEVEL_MOVE_SINCE_VERSION 1
1671+/**
1672+ * @ingroup iface_xdg_toplevel
1673+ */
1674+#define XDG_TOPLEVEL_RESIZE_SINCE_VERSION 1
1675+/**
1676+ * @ingroup iface_xdg_toplevel
1677+ */
1678+#define XDG_TOPLEVEL_SET_MAX_SIZE_SINCE_VERSION 1
1679+/**
1680+ * @ingroup iface_xdg_toplevel
1681+ */
1682+#define XDG_TOPLEVEL_SET_MIN_SIZE_SINCE_VERSION 1
1683+/**
1684+ * @ingroup iface_xdg_toplevel
1685+ */
1686+#define XDG_TOPLEVEL_SET_MAXIMIZED_SINCE_VERSION 1
1687+/**
1688+ * @ingroup iface_xdg_toplevel
1689+ */
1690+#define XDG_TOPLEVEL_UNSET_MAXIMIZED_SINCE_VERSION 1
1691+/**
1692+ * @ingroup iface_xdg_toplevel
1693+ */
1694+#define XDG_TOPLEVEL_SET_FULLSCREEN_SINCE_VERSION 1
1695+/**
1696+ * @ingroup iface_xdg_toplevel
1697+ */
1698+#define XDG_TOPLEVEL_UNSET_FULLSCREEN_SINCE_VERSION 1
1699+/**
1700+ * @ingroup iface_xdg_toplevel
1701+ */
1702+#define XDG_TOPLEVEL_SET_MINIMIZED_SINCE_VERSION 1
1703+
1704+/** @ingroup iface_xdg_toplevel */
1705+static inline void
1706+xdg_toplevel_set_user_data(struct xdg_toplevel *xdg_toplevel, void *user_data)
1707+{
1708+	wl_proxy_set_user_data((struct wl_proxy *) xdg_toplevel, user_data);
1709+}
1710+
1711+/** @ingroup iface_xdg_toplevel */
1712+static inline void *
1713+xdg_toplevel_get_user_data(struct xdg_toplevel *xdg_toplevel)
1714+{
1715+	return wl_proxy_get_user_data((struct wl_proxy *) xdg_toplevel);
1716+}
1717+
1718+static inline uint32_t
1719+xdg_toplevel_get_version(struct xdg_toplevel *xdg_toplevel)
1720+{
1721+	return wl_proxy_get_version((struct wl_proxy *) xdg_toplevel);
1722+}
1723+
1724+/**
1725+ * @ingroup iface_xdg_toplevel
1726+ *
1727+ * This request destroys the role surface and unmaps the surface;
1728+ * see "Unmapping" behavior in interface section for details.
1729+ */
1730+static inline void
1731+xdg_toplevel_destroy(struct xdg_toplevel *xdg_toplevel)
1732+{
1733+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
1734+			 XDG_TOPLEVEL_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), WL_MARSHAL_FLAG_DESTROY);
1735+}
1736+
1737+/**
1738+ * @ingroup iface_xdg_toplevel
1739+ *
1740+ * Set the "parent" of this surface. This surface should be stacked
1741+ * above the parent surface and all other ancestor surfaces.
1742+ *
1743+ * Parent surfaces should be set on dialogs, toolboxes, or other
1744+ * "auxiliary" surfaces, so that the parent is raised when the dialog
1745+ * is raised.
1746+ *
1747+ * Setting a null parent for a child surface unsets its parent. Setting
1748+ * a null parent for a surface which currently has no parent is a no-op.
1749+ *
1750+ * Only mapped surfaces can have child surfaces. Setting a parent which
1751+ * is not mapped is equivalent to setting a null parent. If a surface
1752+ * becomes unmapped, its children's parent is set to the parent of
1753+ * the now-unmapped surface. If the now-unmapped surface has no parent,
1754+ * its children's parent is unset. If the now-unmapped surface becomes
1755+ * mapped again, its parent-child relationship is not restored.
1756+ *
1757+ * The parent toplevel must not be one of the child toplevel's
1758+ * descendants, and the parent must be different from the child toplevel,
1759+ * otherwise the invalid_parent protocol error is raised.
1760+ */
1761+static inline void
1762+xdg_toplevel_set_parent(struct xdg_toplevel *xdg_toplevel, struct xdg_toplevel *parent)
1763+{
1764+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
1765+			 XDG_TOPLEVEL_SET_PARENT, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, parent);
1766+}
1767+
1768+/**
1769+ * @ingroup iface_xdg_toplevel
1770+ *
1771+ * Set a short title for the surface.
1772+ *
1773+ * This string may be used to identify the surface in a task bar,
1774+ * window list, or other user interface elements provided by the
1775+ * compositor.
1776+ *
1777+ * The string must be encoded in UTF-8.
1778+ */
1779+static inline void
1780+xdg_toplevel_set_title(struct xdg_toplevel *xdg_toplevel, const char *title)
1781+{
1782+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
1783+			 XDG_TOPLEVEL_SET_TITLE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, title);
1784+}
1785+
1786+/**
1787+ * @ingroup iface_xdg_toplevel
1788+ *
1789+ * Set an application identifier for the surface.
1790+ *
1791+ * The app ID identifies the general class of applications to which
1792+ * the surface belongs. The compositor can use this to group multiple
1793+ * surfaces together, or to determine how to launch a new application.
1794+ *
1795+ * For D-Bus activatable applications, the app ID is used as the D-Bus
1796+ * service name.
1797+ *
1798+ * The compositor shell will try to group application surfaces together
1799+ * by their app ID. As a best practice, it is suggested to select app
1800+ * ID's that match the basename of the application's .desktop file.
1801+ * For example, "org.freedesktop.FooViewer" where the .desktop file is
1802+ * "org.freedesktop.FooViewer.desktop".
1803+ *
1804+ * Like other properties, a set_app_id request can be sent after the
1805+ * xdg_toplevel has been mapped to update the property.
1806+ *
1807+ * See the desktop-entry specification [0] for more details on
1808+ * application identifiers and how they relate to well-known D-Bus
1809+ * names and .desktop files.
1810+ *
1811+ * [0] https://standards.freedesktop.org/desktop-entry-spec/
1812+ */
1813+static inline void
1814+xdg_toplevel_set_app_id(struct xdg_toplevel *xdg_toplevel, const char *app_id)
1815+{
1816+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
1817+			 XDG_TOPLEVEL_SET_APP_ID, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, app_id);
1818+}
1819+
1820+/**
1821+ * @ingroup iface_xdg_toplevel
1822+ *
1823+ * Clients implementing client-side decorations might want to show
1824+ * a context menu when right-clicking on the decorations, giving the
1825+ * user a menu that they can use to maximize or minimize the window.
1826+ *
1827+ * This request asks the compositor to pop up such a window menu at
1828+ * the given position, relative to the local surface coordinates of
1829+ * the parent surface. There are no guarantees as to what menu items
1830+ * the window menu contains, or even if a window menu will be drawn
1831+ * at all.
1832+ *
1833+ * This request must be used in response to some sort of user action
1834+ * like a button press, key press, or touch down event.
1835+ */
1836+static inline void
1837+xdg_toplevel_show_window_menu(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
1838+{
1839+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
1840+			 XDG_TOPLEVEL_SHOW_WINDOW_MENU, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, seat, serial, x, y);
1841+}
1842+
1843+/**
1844+ * @ingroup iface_xdg_toplevel
1845+ *
1846+ * Start an interactive, user-driven move of the surface.
1847+ *
1848+ * This request must be used in response to some sort of user action
1849+ * like a button press, key press, or touch down event. The passed
1850+ * serial is used to determine the type of interactive move (touch,
1851+ * pointer, etc).
1852+ *
1853+ * The server may ignore move requests depending on the state of
1854+ * the surface (e.g. fullscreen or maximized), or if the passed serial
1855+ * is no longer valid.
1856+ *
1857+ * If triggered, the surface will lose the focus of the device
1858+ * (wl_pointer, wl_touch, etc) used for the move. It is up to the
1859+ * compositor to visually indicate that the move is taking place, such as
1860+ * updating a pointer cursor, during the move. There is no guarantee
1861+ * that the device focus will return when the move is completed.
1862+ */
1863+static inline void
1864+xdg_toplevel_move(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial)
1865+{
1866+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
1867+			 XDG_TOPLEVEL_MOVE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, seat, serial);
1868+}
1869+
1870+/**
1871+ * @ingroup iface_xdg_toplevel
1872+ *
1873+ * Start a user-driven, interactive resize of the surface.
1874+ *
1875+ * This request must be used in response to some sort of user action
1876+ * like a button press, key press, or touch down event. The passed
1877+ * serial is used to determine the type of interactive resize (touch,
1878+ * pointer, etc).
1879+ *
1880+ * The server may ignore resize requests depending on the state of
1881+ * the surface (e.g. fullscreen or maximized).
1882+ *
1883+ * If triggered, the client will receive configure events with the
1884+ * "resize" state enum value and the expected sizes. See the "resize"
1885+ * enum value for more details about what is required. The client
1886+ * must also acknowledge configure events using "ack_configure". After
1887+ * the resize is completed, the client will receive another "configure"
1888+ * event without the resize state.
1889+ *
1890+ * If triggered, the surface also will lose the focus of the device
1891+ * (wl_pointer, wl_touch, etc) used for the resize. It is up to the
1892+ * compositor to visually indicate that the resize is taking place,
1893+ * such as updating a pointer cursor, during the resize. There is no
1894+ * guarantee that the device focus will return when the resize is
1895+ * completed.
1896+ *
1897+ * The edges parameter specifies how the surface should be resized, and
1898+ * is one of the values of the resize_edge enum. Values not matching
1899+ * a variant of the enum will cause the invalid_resize_edge protocol error.
1900+ * The compositor may use this information to update the surface position
1901+ * for example when dragging the top left corner. The compositor may also
1902+ * use this information to adapt its behavior, e.g. choose an appropriate
1903+ * cursor image.
1904+ */
1905+static inline void
1906+xdg_toplevel_resize(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial, uint32_t edges)
1907+{
1908+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
1909+			 XDG_TOPLEVEL_RESIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, seat, serial, edges);
1910+}
1911+
1912+/**
1913+ * @ingroup iface_xdg_toplevel
1914+ *
1915+ * Set a maximum size for the window.
1916+ *
1917+ * The client can specify a maximum size so that the compositor does
1918+ * not try to configure the window beyond this size.
1919+ *
1920+ * The width and height arguments are in window geometry coordinates.
1921+ * See xdg_surface.set_window_geometry.
1922+ *
1923+ * Values set in this way are double-buffered, see wl_surface.commit.
1924+ *
1925+ * The compositor can use this information to allow or disallow
1926+ * different states like maximize or fullscreen and draw accurate
1927+ * animations.
1928+ *
1929+ * Similarly, a tiling window manager may use this information to
1930+ * place and resize client windows in a more effective way.
1931+ *
1932+ * The client should not rely on the compositor to obey the maximum
1933+ * size. The compositor may decide to ignore the values set by the
1934+ * client and request a larger size.
1935+ *
1936+ * If never set, or a value of zero in the request, means that the
1937+ * client has no expected maximum size in the given dimension.
1938+ * As a result, a client wishing to reset the maximum size
1939+ * to an unspecified state can use zero for width and height in the
1940+ * request.
1941+ *
1942+ * Requesting a maximum size to be smaller than the minimum size of
1943+ * a surface is illegal and will result in an invalid_size error.
1944+ *
1945+ * The width and height must be greater than or equal to zero. Using
1946+ * strictly negative values for width or height will result in a
1947+ * invalid_size error.
1948+ */
1949+static inline void
1950+xdg_toplevel_set_max_size(struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height)
1951+{
1952+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
1953+			 XDG_TOPLEVEL_SET_MAX_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, width, height);
1954+}
1955+
1956+/**
1957+ * @ingroup iface_xdg_toplevel
1958+ *
1959+ * Set a minimum size for the window.
1960+ *
1961+ * The client can specify a minimum size so that the compositor does
1962+ * not try to configure the window below this size.
1963+ *
1964+ * The width and height arguments are in window geometry coordinates.
1965+ * See xdg_surface.set_window_geometry.
1966+ *
1967+ * Values set in this way are double-buffered, see wl_surface.commit.
1968+ *
1969+ * The compositor can use this information to allow or disallow
1970+ * different states like maximize or fullscreen and draw accurate
1971+ * animations.
1972+ *
1973+ * Similarly, a tiling window manager may use this information to
1974+ * place and resize client windows in a more effective way.
1975+ *
1976+ * The client should not rely on the compositor to obey the minimum
1977+ * size. The compositor may decide to ignore the values set by the
1978+ * client and request a smaller size.
1979+ *
1980+ * If never set, or a value of zero in the request, means that the
1981+ * client has no expected minimum size in the given dimension.
1982+ * As a result, a client wishing to reset the minimum size
1983+ * to an unspecified state can use zero for width and height in the
1984+ * request.
1985+ *
1986+ * Requesting a minimum size to be larger than the maximum size of
1987+ * a surface is illegal and will result in an invalid_size error.
1988+ *
1989+ * The width and height must be greater than or equal to zero. Using
1990+ * strictly negative values for width and height will result in a
1991+ * invalid_size error.
1992+ */
1993+static inline void
1994+xdg_toplevel_set_min_size(struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height)
1995+{
1996+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
1997+			 XDG_TOPLEVEL_SET_MIN_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, width, height);
1998+}
1999+
2000+/**
2001+ * @ingroup iface_xdg_toplevel
2002+ *
2003+ * Maximize the surface.
2004+ *
2005+ * After requesting that the surface should be maximized, the compositor
2006+ * will respond by emitting a configure event. Whether this configure
2007+ * actually sets the window maximized is subject to compositor policies.
2008+ * The client must then update its content, drawing in the configured
2009+ * state. The client must also acknowledge the configure when committing
2010+ * the new content (see ack_configure).
2011+ *
2012+ * It is up to the compositor to decide how and where to maximize the
2013+ * surface, for example which output and what region of the screen should
2014+ * be used.
2015+ *
2016+ * If the surface was already maximized, the compositor will still emit
2017+ * a configure event with the "maximized" state.
2018+ *
2019+ * If the surface is in a fullscreen state, this request has no direct
2020+ * effect. It may alter the state the surface is returned to when
2021+ * unmaximized unless overridden by the compositor.
2022+ */
2023+static inline void
2024+xdg_toplevel_set_maximized(struct xdg_toplevel *xdg_toplevel)
2025+{
2026+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
2027+			 XDG_TOPLEVEL_SET_MAXIMIZED, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0);
2028+}
2029+
2030+/**
2031+ * @ingroup iface_xdg_toplevel
2032+ *
2033+ * Unmaximize the surface.
2034+ *
2035+ * After requesting that the surface should be unmaximized, the compositor
2036+ * will respond by emitting a configure event. Whether this actually
2037+ * un-maximizes the window is subject to compositor policies.
2038+ * If available and applicable, the compositor will include the window
2039+ * geometry dimensions the window had prior to being maximized in the
2040+ * configure event. The client must then update its content, drawing it in
2041+ * the configured state. The client must also acknowledge the configure
2042+ * when committing the new content (see ack_configure).
2043+ *
2044+ * It is up to the compositor to position the surface after it was
2045+ * unmaximized; usually the position the surface had before maximizing, if
2046+ * applicable.
2047+ *
2048+ * If the surface was already not maximized, the compositor will still
2049+ * emit a configure event without the "maximized" state.
2050+ *
2051+ * If the surface is in a fullscreen state, this request has no direct
2052+ * effect. It may alter the state the surface is returned to when
2053+ * unmaximized unless overridden by the compositor.
2054+ */
2055+static inline void
2056+xdg_toplevel_unset_maximized(struct xdg_toplevel *xdg_toplevel)
2057+{
2058+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
2059+			 XDG_TOPLEVEL_UNSET_MAXIMIZED, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0);
2060+}
2061+
2062+/**
2063+ * @ingroup iface_xdg_toplevel
2064+ *
2065+ * Make the surface fullscreen.
2066+ *
2067+ * After requesting that the surface should be fullscreened, the
2068+ * compositor will respond by emitting a configure event. Whether the
2069+ * client is actually put into a fullscreen state is subject to compositor
2070+ * policies. The client must also acknowledge the configure when
2071+ * committing the new content (see ack_configure).
2072+ *
2073+ * The output passed by the request indicates the client's preference as
2074+ * to which display it should be set fullscreen on. If this value is NULL,
2075+ * it's up to the compositor to choose which display will be used to map
2076+ * this surface.
2077+ *
2078+ * If the surface doesn't cover the whole output, the compositor will
2079+ * position the surface in the center of the output and compensate with
2080+ * with border fill covering the rest of the output. The content of the
2081+ * border fill is undefined, but should be assumed to be in some way that
2082+ * attempts to blend into the surrounding area (e.g. solid black).
2083+ *
2084+ * If the fullscreened surface is not opaque, the compositor must make
2085+ * sure that other screen content not part of the same surface tree (made
2086+ * up of subsurfaces, popups or similarly coupled surfaces) are not
2087+ * visible below the fullscreened surface.
2088+ */
2089+static inline void
2090+xdg_toplevel_set_fullscreen(struct xdg_toplevel *xdg_toplevel, struct wl_output *output)
2091+{
2092+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
2093+			 XDG_TOPLEVEL_SET_FULLSCREEN, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, output);
2094+}
2095+
2096+/**
2097+ * @ingroup iface_xdg_toplevel
2098+ *
2099+ * Make the surface no longer fullscreen.
2100+ *
2101+ * After requesting that the surface should be unfullscreened, the
2102+ * compositor will respond by emitting a configure event.
2103+ * Whether this actually removes the fullscreen state of the client is
2104+ * subject to compositor policies.
2105+ *
2106+ * Making a surface unfullscreen sets states for the surface based on the following:
2107+ * * the state(s) it may have had before becoming fullscreen
2108+ * * any state(s) decided by the compositor
2109+ * * any state(s) requested by the client while the surface was fullscreen
2110+ *
2111+ * The compositor may include the previous window geometry dimensions in
2112+ * the configure event, if applicable.
2113+ *
2114+ * The client must also acknowledge the configure when committing the new
2115+ * content (see ack_configure).
2116+ */
2117+static inline void
2118+xdg_toplevel_unset_fullscreen(struct xdg_toplevel *xdg_toplevel)
2119+{
2120+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
2121+			 XDG_TOPLEVEL_UNSET_FULLSCREEN, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0);
2122+}
2123+
2124+/**
2125+ * @ingroup iface_xdg_toplevel
2126+ *
2127+ * Request that the compositor minimize your surface. There is no
2128+ * way to know if the surface is currently minimized, nor is there
2129+ * any way to unset minimization on this surface.
2130+ *
2131+ * If you are looking to throttle redrawing when minimized, please
2132+ * instead use the wl_surface.frame event for this, as this will
2133+ * also work with live previews on windows in Alt-Tab, Expose or
2134+ * similar compositor features.
2135+ */
2136+static inline void
2137+xdg_toplevel_set_minimized(struct xdg_toplevel *xdg_toplevel)
2138+{
2139+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel,
2140+			 XDG_TOPLEVEL_SET_MINIMIZED, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0);
2141+}
2142+
2143+#ifndef XDG_POPUP_ERROR_ENUM
2144+#define XDG_POPUP_ERROR_ENUM
2145+enum xdg_popup_error {
2146+	/**
2147+	 * tried to grab after being mapped
2148+	 */
2149+	XDG_POPUP_ERROR_INVALID_GRAB = 0,
2150+};
2151+#endif /* XDG_POPUP_ERROR_ENUM */
2152+
2153+/**
2154+ * @ingroup iface_xdg_popup
2155+ * @struct xdg_popup_listener
2156+ */
2157+struct xdg_popup_listener {
2158+	/**
2159+	 * configure the popup surface
2160+	 *
2161+	 * This event asks the popup surface to configure itself given
2162+	 * the configuration. The configured state should not be applied
2163+	 * immediately. See xdg_surface.configure for details.
2164+	 *
2165+	 * The x and y arguments represent the position the popup was
2166+	 * placed at given the xdg_positioner rule, relative to the upper
2167+	 * left corner of the window geometry of the parent surface.
2168+	 *
2169+	 * For version 2 or older, the configure event for an xdg_popup is
2170+	 * only ever sent once for the initial configuration. Starting with
2171+	 * version 3, it may be sent again if the popup is setup with an
2172+	 * xdg_positioner with set_reactive requested, or in response to
2173+	 * xdg_popup.reposition requests.
2174+	 * @param x x position relative to parent surface window geometry
2175+	 * @param y y position relative to parent surface window geometry
2176+	 * @param width window geometry width
2177+	 * @param height window geometry height
2178+	 */
2179+	void (*configure)(void *data,
2180+			  struct xdg_popup *xdg_popup,
2181+			  int32_t x,
2182+			  int32_t y,
2183+			  int32_t width,
2184+			  int32_t height);
2185+	/**
2186+	 * popup interaction is done
2187+	 *
2188+	 * The popup_done event is sent out when a popup is dismissed by
2189+	 * the compositor. The client should destroy the xdg_popup object
2190+	 * at this point.
2191+	 */
2192+	void (*popup_done)(void *data,
2193+			   struct xdg_popup *xdg_popup);
2194+	/**
2195+	 * signal the completion of a repositioned request
2196+	 *
2197+	 * The repositioned event is sent as part of a popup
2198+	 * configuration sequence, together with xdg_popup.configure and
2199+	 * lastly xdg_surface.configure to notify the completion of a
2200+	 * reposition request.
2201+	 *
2202+	 * The repositioned event is to notify about the completion of a
2203+	 * xdg_popup.reposition request. The token argument is the token
2204+	 * passed in the xdg_popup.reposition request.
2205+	 *
2206+	 * Immediately after this event is emitted, xdg_popup.configure and
2207+	 * xdg_surface.configure will be sent with the updated size and
2208+	 * position, as well as a new configure serial.
2209+	 *
2210+	 * The client should optionally update the content of the popup,
2211+	 * but must acknowledge the new popup configuration for the new
2212+	 * position to take effect. See xdg_surface.ack_configure for
2213+	 * details.
2214+	 * @param token reposition request token
2215+	 * @since 3
2216+	 */
2217+	void (*repositioned)(void *data,
2218+			     struct xdg_popup *xdg_popup,
2219+			     uint32_t token);
2220+};
2221+
2222+/**
2223+ * @ingroup iface_xdg_popup
2224+ */
2225+static inline int
2226+xdg_popup_add_listener(struct xdg_popup *xdg_popup,
2227+		       const struct xdg_popup_listener *listener, void *data)
2228+{
2229+	return wl_proxy_add_listener((struct wl_proxy *) xdg_popup,
2230+				     (void (**)(void)) listener, data);
2231+}
2232+
2233+#define XDG_POPUP_DESTROY 0
2234+#define XDG_POPUP_GRAB 1
2235+#define XDG_POPUP_REPOSITION 2
2236+
2237+/**
2238+ * @ingroup iface_xdg_popup
2239+ */
2240+#define XDG_POPUP_CONFIGURE_SINCE_VERSION 1
2241+/**
2242+ * @ingroup iface_xdg_popup
2243+ */
2244+#define XDG_POPUP_POPUP_DONE_SINCE_VERSION 1
2245+/**
2246+ * @ingroup iface_xdg_popup
2247+ */
2248+#define XDG_POPUP_REPOSITIONED_SINCE_VERSION 3
2249+
2250+/**
2251+ * @ingroup iface_xdg_popup
2252+ */
2253+#define XDG_POPUP_DESTROY_SINCE_VERSION 1
2254+/**
2255+ * @ingroup iface_xdg_popup
2256+ */
2257+#define XDG_POPUP_GRAB_SINCE_VERSION 1
2258+/**
2259+ * @ingroup iface_xdg_popup
2260+ */
2261+#define XDG_POPUP_REPOSITION_SINCE_VERSION 3
2262+
2263+/** @ingroup iface_xdg_popup */
2264+static inline void
2265+xdg_popup_set_user_data(struct xdg_popup *xdg_popup, void *user_data)
2266+{
2267+	wl_proxy_set_user_data((struct wl_proxy *) xdg_popup, user_data);
2268+}
2269+
2270+/** @ingroup iface_xdg_popup */
2271+static inline void *
2272+xdg_popup_get_user_data(struct xdg_popup *xdg_popup)
2273+{
2274+	return wl_proxy_get_user_data((struct wl_proxy *) xdg_popup);
2275+}
2276+
2277+static inline uint32_t
2278+xdg_popup_get_version(struct xdg_popup *xdg_popup)
2279+{
2280+	return wl_proxy_get_version((struct wl_proxy *) xdg_popup);
2281+}
2282+
2283+/**
2284+ * @ingroup iface_xdg_popup
2285+ *
2286+ * This destroys the popup. Explicitly destroying the xdg_popup
2287+ * object will also dismiss the popup, and unmap the surface.
2288+ *
2289+ * If this xdg_popup is not the "topmost" popup, the
2290+ * xdg_wm_base.not_the_topmost_popup protocol error will be sent.
2291+ */
2292+static inline void
2293+xdg_popup_destroy(struct xdg_popup *xdg_popup)
2294+{
2295+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_popup,
2296+			 XDG_POPUP_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_popup), WL_MARSHAL_FLAG_DESTROY);
2297+}
2298+
2299+/**
2300+ * @ingroup iface_xdg_popup
2301+ *
2302+ * This request makes the created popup take an explicit grab. An explicit
2303+ * grab will be dismissed when the user dismisses the popup, or when the
2304+ * client destroys the xdg_popup. This can be done by the user clicking
2305+ * outside the surface, using the keyboard, or even locking the screen
2306+ * through closing the lid or a timeout.
2307+ *
2308+ * If the compositor denies the grab, the popup will be immediately
2309+ * dismissed.
2310+ *
2311+ * This request must be used in response to some sort of user action like a
2312+ * button press, key press, or touch down event. The serial number of the
2313+ * event should be passed as 'serial'.
2314+ *
2315+ * The parent of a grabbing popup must either be an xdg_toplevel surface or
2316+ * another xdg_popup with an explicit grab. If the parent is another
2317+ * xdg_popup it means that the popups are nested, with this popup now being
2318+ * the topmost popup.
2319+ *
2320+ * Nested popups must be destroyed in the reverse order they were created
2321+ * in, e.g. the only popup you are allowed to destroy at all times is the
2322+ * topmost one.
2323+ *
2324+ * When compositors choose to dismiss a popup, they may dismiss every
2325+ * nested grabbing popup as well. When a compositor dismisses popups, it
2326+ * will follow the same dismissing order as required from the client.
2327+ *
2328+ * If the topmost grabbing popup is destroyed, the grab will be returned to
2329+ * the parent of the popup, if that parent previously had an explicit grab.
2330+ *
2331+ * If the parent is a grabbing popup which has already been dismissed, this
2332+ * popup will be immediately dismissed. If the parent is a popup that did
2333+ * not take an explicit grab, an error will be raised.
2334+ *
2335+ * During a popup grab, the client owning the grab will receive pointer
2336+ * and touch events for all their surfaces as normal (similar to an
2337+ * "owner-events" grab in X11 parlance), while the top most grabbing popup
2338+ * will always have keyboard focus.
2339+ */
2340+static inline void
2341+xdg_popup_grab(struct xdg_popup *xdg_popup, struct wl_seat *seat, uint32_t serial)
2342+{
2343+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_popup,
2344+			 XDG_POPUP_GRAB, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_popup), 0, seat, serial);
2345+}
2346+
2347+/**
2348+ * @ingroup iface_xdg_popup
2349+ *
2350+ * Reposition an already-mapped popup. The popup will be placed given the
2351+ * details in the passed xdg_positioner object, and a
2352+ * xdg_popup.repositioned followed by xdg_popup.configure and
2353+ * xdg_surface.configure will be emitted in response. Any parameters set
2354+ * by the previous positioner will be discarded.
2355+ *
2356+ * The passed token will be sent in the corresponding
2357+ * xdg_popup.repositioned event. The new popup position will not take
2358+ * effect until the corresponding configure event is acknowledged by the
2359+ * client. See xdg_popup.repositioned for details. The token itself is
2360+ * opaque, and has no other special meaning.
2361+ *
2362+ * If multiple reposition requests are sent, the compositor may skip all
2363+ * but the last one.
2364+ *
2365+ * If the popup is repositioned in response to a configure event for its
2366+ * parent, the client should send an xdg_positioner.set_parent_configure
2367+ * and possibly an xdg_positioner.set_parent_size request to allow the
2368+ * compositor to properly constrain the popup.
2369+ *
2370+ * If the popup is repositioned together with a parent that is being
2371+ * resized, but not in response to a configure event, the client should
2372+ * send an xdg_positioner.set_parent_size request.
2373+ */
2374+static inline void
2375+xdg_popup_reposition(struct xdg_popup *xdg_popup, struct xdg_positioner *positioner, uint32_t token)
2376+{
2377+	wl_proxy_marshal_flags((struct wl_proxy *) xdg_popup,
2378+			 XDG_POPUP_REPOSITION, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_popup), 0, positioner, token);
2379+}
2380+
2381+#ifdef  __cplusplus
2382+}
2383+#endif
2384+
2385+#endif
+184, -0
  1@@ -0,0 +1,184 @@
  2+/* Generated by wayland-scanner 1.25.0 */
  3+
  4+/*
  5+ * Copyright © 2008-2013 Kristian Høgsberg
  6+ * Copyright © 2013      Rafael Antognolli
  7+ * Copyright © 2013      Jasper St. Pierre
  8+ * Copyright © 2010-2013 Intel Corporation
  9+ * Copyright © 2015-2017 Samsung Electronics Co., Ltd
 10+ * Copyright © 2015-2017 Red Hat Inc.
 11+ *
 12+ * Permission is hereby granted, free of charge, to any person obtaining a
 13+ * copy of this software and associated documentation files (the "Software"),
 14+ * to deal in the Software without restriction, including without limitation
 15+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 16+ * and/or sell copies of the Software, and to permit persons to whom the
 17+ * Software is furnished to do so, subject to the following conditions:
 18+ *
 19+ * The above copyright notice and this permission notice (including the next
 20+ * paragraph) shall be included in all copies or substantial portions of the
 21+ * Software.
 22+ *
 23+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 24+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 25+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 26+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 27+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 28+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 29+ * DEALINGS IN THE SOFTWARE.
 30+ */
 31+
 32+#include <stdbool.h>
 33+#include <stdlib.h>
 34+#include <stdint.h>
 35+#include "wayland-util.h"
 36+
 37+#ifndef __has_attribute
 38+# define __has_attribute(x) 0  /* Compatibility with non-clang compilers. */
 39+#endif
 40+
 41+#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
 42+#define WL_PRIVATE __attribute__ ((visibility("hidden")))
 43+#else
 44+#define WL_PRIVATE
 45+#endif
 46+
 47+extern const struct wl_interface wl_output_interface;
 48+extern const struct wl_interface wl_seat_interface;
 49+extern const struct wl_interface wl_surface_interface;
 50+extern const struct wl_interface xdg_popup_interface;
 51+extern const struct wl_interface xdg_positioner_interface;
 52+extern const struct wl_interface xdg_surface_interface;
 53+extern const struct wl_interface xdg_toplevel_interface;
 54+
 55+static const struct wl_interface *xdg_shell_types[] = {
 56+	NULL,
 57+	NULL,
 58+	NULL,
 59+	NULL,
 60+	&xdg_positioner_interface,
 61+	&xdg_surface_interface,
 62+	&wl_surface_interface,
 63+	&xdg_toplevel_interface,
 64+	&xdg_popup_interface,
 65+	&xdg_surface_interface,
 66+	&xdg_positioner_interface,
 67+	&xdg_toplevel_interface,
 68+	&wl_seat_interface,
 69+	NULL,
 70+	NULL,
 71+	NULL,
 72+	&wl_seat_interface,
 73+	NULL,
 74+	&wl_seat_interface,
 75+	NULL,
 76+	NULL,
 77+	&wl_output_interface,
 78+	&wl_seat_interface,
 79+	NULL,
 80+	&xdg_positioner_interface,
 81+	NULL,
 82+};
 83+
 84+static const struct wl_message xdg_wm_base_requests[] = {
 85+	{ "destroy", "", xdg_shell_types + 0 },
 86+	{ "create_positioner", "n", xdg_shell_types + 4 },
 87+	{ "get_xdg_surface", "no", xdg_shell_types + 5 },
 88+	{ "pong", "u", xdg_shell_types + 0 },
 89+};
 90+
 91+static const struct wl_message xdg_wm_base_events[] = {
 92+	{ "ping", "u", xdg_shell_types + 0 },
 93+};
 94+
 95+WL_PRIVATE const struct wl_interface xdg_wm_base_interface = {
 96+	"xdg_wm_base", 7,
 97+	4, xdg_wm_base_requests,
 98+	1, xdg_wm_base_events,
 99+};
100+
101+static const struct wl_message xdg_positioner_requests[] = {
102+	{ "destroy", "", xdg_shell_types + 0 },
103+	{ "set_size", "ii", xdg_shell_types + 0 },
104+	{ "set_anchor_rect", "iiii", xdg_shell_types + 0 },
105+	{ "set_anchor", "u", xdg_shell_types + 0 },
106+	{ "set_gravity", "u", xdg_shell_types + 0 },
107+	{ "set_constraint_adjustment", "u", xdg_shell_types + 0 },
108+	{ "set_offset", "ii", xdg_shell_types + 0 },
109+	{ "set_reactive", "3", xdg_shell_types + 0 },
110+	{ "set_parent_size", "3ii", xdg_shell_types + 0 },
111+	{ "set_parent_configure", "3u", xdg_shell_types + 0 },
112+};
113+
114+WL_PRIVATE const struct wl_interface xdg_positioner_interface = {
115+	"xdg_positioner", 7,
116+	10, xdg_positioner_requests,
117+	0, NULL,
118+};
119+
120+static const struct wl_message xdg_surface_requests[] = {
121+	{ "destroy", "", xdg_shell_types + 0 },
122+	{ "get_toplevel", "n", xdg_shell_types + 7 },
123+	{ "get_popup", "n?oo", xdg_shell_types + 8 },
124+	{ "set_window_geometry", "iiii", xdg_shell_types + 0 },
125+	{ "ack_configure", "u", xdg_shell_types + 0 },
126+};
127+
128+static const struct wl_message xdg_surface_events[] = {
129+	{ "configure", "u", xdg_shell_types + 0 },
130+};
131+
132+WL_PRIVATE const struct wl_interface xdg_surface_interface = {
133+	"xdg_surface", 7,
134+	5, xdg_surface_requests,
135+	1, xdg_surface_events,
136+};
137+
138+static const struct wl_message xdg_toplevel_requests[] = {
139+	{ "destroy", "", xdg_shell_types + 0 },
140+	{ "set_parent", "?o", xdg_shell_types + 11 },
141+	{ "set_title", "s", xdg_shell_types + 0 },
142+	{ "set_app_id", "s", xdg_shell_types + 0 },
143+	{ "show_window_menu", "ouii", xdg_shell_types + 12 },
144+	{ "move", "ou", xdg_shell_types + 16 },
145+	{ "resize", "ouu", xdg_shell_types + 18 },
146+	{ "set_max_size", "ii", xdg_shell_types + 0 },
147+	{ "set_min_size", "ii", xdg_shell_types + 0 },
148+	{ "set_maximized", "", xdg_shell_types + 0 },
149+	{ "unset_maximized", "", xdg_shell_types + 0 },
150+	{ "set_fullscreen", "?o", xdg_shell_types + 21 },
151+	{ "unset_fullscreen", "", xdg_shell_types + 0 },
152+	{ "set_minimized", "", xdg_shell_types + 0 },
153+};
154+
155+static const struct wl_message xdg_toplevel_events[] = {
156+	{ "configure", "iia", xdg_shell_types + 0 },
157+	{ "close", "", xdg_shell_types + 0 },
158+	{ "configure_bounds", "4ii", xdg_shell_types + 0 },
159+	{ "wm_capabilities", "5a", xdg_shell_types + 0 },
160+};
161+
162+WL_PRIVATE const struct wl_interface xdg_toplevel_interface = {
163+	"xdg_toplevel", 7,
164+	14, xdg_toplevel_requests,
165+	4, xdg_toplevel_events,
166+};
167+
168+static const struct wl_message xdg_popup_requests[] = {
169+	{ "destroy", "", xdg_shell_types + 0 },
170+	{ "grab", "ou", xdg_shell_types + 22 },
171+	{ "reposition", "3ou", xdg_shell_types + 24 },
172+};
173+
174+static const struct wl_message xdg_popup_events[] = {
175+	{ "configure", "iiii", xdg_shell_types + 0 },
176+	{ "popup_done", "", xdg_shell_types + 0 },
177+	{ "repositioned", "3u", xdg_shell_types + 0 },
178+};
179+
180+WL_PRIVATE const struct wl_interface xdg_popup_interface = {
181+	"xdg_popup", 7,
182+	3, xdg_popup_requests,
183+	3, xdg_popup_events,
184+};
185+