1 /* Generated by wayland-scanner 1.17.0 */
2 
3 #ifndef XDG_SHELL_CLIENT_PROTOCOL_H
4 #define XDG_SHELL_CLIENT_PROTOCOL_H
5 
6 #include <stdint.h>
7 #include <stddef.h>
8 #include "wayland-client.h"
9 
10 #ifdef  __cplusplus
11 extern "C" {
12 #endif
13 
14 /**
15  * @page page_xdg_shell The xdg_shell protocol
16  * @section page_ifaces_xdg_shell Interfaces
17  * - @subpage page_iface_xdg_wm_base - create desktop-style surfaces
18  * - @subpage page_iface_xdg_positioner - child surface positioner
19  * - @subpage page_iface_xdg_surface - desktop user interface surface base interface
20  * - @subpage page_iface_xdg_toplevel - toplevel surface
21  * - @subpage page_iface_xdg_popup - short-lived, popup surfaces for menus
22  * @section page_copyright_xdg_shell Copyright
23  * <pre>
24  *
25  * Copyright © 2008-2013 Kristian Høgsberg
26  * Copyright © 2013      Rafael Antognolli
27  * Copyright © 2013      Jasper St. Pierre
28  * Copyright © 2010-2013 Intel Corporation
29  * Copyright © 2015-2017 Samsung Electronics Co., Ltd
30  * Copyright © 2015-2017 Red Hat Inc.
31  *
32  * Permission is hereby granted, free of charge, to any person obtaining a
33  * copy of this software and associated documentation files (the "Software"),
34  * to deal in the Software without restriction, including without limitation
35  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
36  * and/or sell copies of the Software, and to permit persons to whom the
37  * Software is furnished to do so, subject to the following conditions:
38  *
39  * The above copyright notice and this permission notice (including the next
40  * paragraph) shall be included in all copies or substantial portions of the
41  * Software.
42  *
43  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
44  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
45  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
46  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
47  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
48  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
49  * DEALINGS IN THE SOFTWARE.
50  * </pre>
51  */
52 struct wl_output;
53 struct wl_seat;
54 struct wl_surface;
55 struct xdg_popup;
56 struct xdg_positioner;
57 struct xdg_surface;
58 struct xdg_toplevel;
59 struct xdg_wm_base;
60 
61 /**
62  * @page page_iface_xdg_wm_base xdg_wm_base
63  * @section page_iface_xdg_wm_base_desc Description
64  *
65  * The xdg_wm_base interface is exposed as a global object enabling clients
66  * to turn their wl_surfaces into windows in a desktop environment. It
67  * defines the basic functionality needed for clients and the compositor to
68  * create windows that can be dragged, resized, maximized, etc, as well as
69  * creating transient windows such as popup menus.
70  * @section page_iface_xdg_wm_base_api API
71  * See @ref iface_xdg_wm_base.
72  */
73 /**
74  * @defgroup iface_xdg_wm_base The xdg_wm_base interface
75  *
76  * The xdg_wm_base interface is exposed as a global object enabling clients
77  * to turn their wl_surfaces into windows in a desktop environment. It
78  * defines the basic functionality needed for clients and the compositor to
79  * create windows that can be dragged, resized, maximized, etc, as well as
80  * creating transient windows such as popup menus.
81  */
82 extern const struct wl_interface xdg_wm_base_interface;
83 /**
84  * @page page_iface_xdg_positioner xdg_positioner
85  * @section page_iface_xdg_positioner_desc Description
86  *
87  * The xdg_positioner provides a collection of rules for the placement of a
88  * child surface relative to a parent surface. Rules can be defined to ensure
89  * the child surface remains within the visible area's borders, and to
90  * specify how the child surface changes its position, such as sliding along
91  * an axis, or flipping around a rectangle. These positioner-created rules are
92  * constrained by the requirement that a child surface must intersect with or
93  * be at least partially adjacent to its parent surface.
94  *
95  * See the various requests for details about possible rules.
96  *
97  * At the time of the request, the compositor makes a copy of the rules
98  * specified by the xdg_positioner. Thus, after the request is complete the
99  * xdg_positioner object can be destroyed or reused; further changes to the
100  * object will have no effect on previous usages.
101  *
102  * For an xdg_positioner object to be considered complete, it must have a
103  * non-zero size set by set_size, and a non-zero anchor rectangle set by
104  * set_anchor_rect. Passing an incomplete xdg_positioner object when
105  * positioning a surface raises an error.
106  * @section page_iface_xdg_positioner_api API
107  * See @ref iface_xdg_positioner.
108  */
109 /**
110  * @defgroup iface_xdg_positioner The xdg_positioner interface
111  *
112  * The xdg_positioner provides a collection of rules for the placement of a
113  * child surface relative to a parent surface. Rules can be defined to ensure
114  * the child surface remains within the visible area's borders, and to
115  * specify how the child surface changes its position, such as sliding along
116  * an axis, or flipping around a rectangle. These positioner-created rules are
117  * constrained by the requirement that a child surface must intersect with or
118  * be at least partially adjacent to its parent surface.
119  *
120  * See the various requests for details about possible rules.
121  *
122  * At the time of the request, the compositor makes a copy of the rules
123  * specified by the xdg_positioner. Thus, after the request is complete the
124  * xdg_positioner object can be destroyed or reused; further changes to the
125  * object will have no effect on previous usages.
126  *
127  * For an xdg_positioner object to be considered complete, it must have a
128  * non-zero size set by set_size, and a non-zero anchor rectangle set by
129  * set_anchor_rect. Passing an incomplete xdg_positioner object when
130  * positioning a surface raises an error.
131  */
132 extern const struct wl_interface xdg_positioner_interface;
133 /**
134  * @page page_iface_xdg_surface xdg_surface
135  * @section page_iface_xdg_surface_desc Description
136  *
137  * An interface that may be implemented by a wl_surface, for
138  * implementations that provide a desktop-style user interface.
139  *
140  * It provides a base set of functionality required to construct user
141  * interface elements requiring management by the compositor, such as
142  * toplevel windows, menus, etc. The types of functionality are split into
143  * xdg_surface roles.
144  *
145  * Creating an xdg_surface does not set the role for a wl_surface. In order
146  * to map an xdg_surface, the client must create a role-specific object
147  * using, e.g., get_toplevel, get_popup. The wl_surface for any given
148  * xdg_surface can have at most one role, and may not be assigned any role
149  * not based on xdg_surface.
150  *
151  * A role must be assigned before any other requests are made to the
152  * xdg_surface object.
153  *
154  * The client must call wl_surface.commit on the corresponding wl_surface
155  * for the xdg_surface state to take effect.
156  *
157  * Creating an xdg_surface from a wl_surface which has a buffer attached or
158  * committed is a client error, and any attempts by a client to attach or
159  * manipulate a buffer prior to the first xdg_surface.configure call must
160  * also be treated as errors.
161  *
162  * Mapping an xdg_surface-based role surface is defined as making it
163  * possible for the surface to be shown by the compositor. Note that
164  * a mapped surface is not guaranteed to be visible once it is mapped.
165  *
166  * For an xdg_surface to be mapped by the compositor, the following
167  * conditions must be met:
168  * (1) the client has assigned an xdg_surface-based role to the surface
169  * (2) the client has set and committed the xdg_surface state and the
170  * role-dependent state to the surface
171  * (3) the client has committed a buffer to the surface
172  *
173  * A newly-unmapped surface is considered to have met condition (1) out
174  * of the 3 required conditions for mapping a surface if its role surface
175  * has not been destroyed.
176  * @section page_iface_xdg_surface_api API
177  * See @ref iface_xdg_surface.
178  */
179 /**
180  * @defgroup iface_xdg_surface The xdg_surface interface
181  *
182  * An interface that may be implemented by a wl_surface, for
183  * implementations that provide a desktop-style user interface.
184  *
185  * It provides a base set of functionality required to construct user
186  * interface elements requiring management by the compositor, such as
187  * toplevel windows, menus, etc. The types of functionality are split into
188  * xdg_surface roles.
189  *
190  * Creating an xdg_surface does not set the role for a wl_surface. In order
191  * to map an xdg_surface, the client must create a role-specific object
192  * using, e.g., get_toplevel, get_popup. The wl_surface for any given
193  * xdg_surface can have at most one role, and may not be assigned any role
194  * not based on xdg_surface.
195  *
196  * A role must be assigned before any other requests are made to the
197  * xdg_surface object.
198  *
199  * The client must call wl_surface.commit on the corresponding wl_surface
200  * for the xdg_surface state to take effect.
201  *
202  * Creating an xdg_surface from a wl_surface which has a buffer attached or
203  * committed is a client error, and any attempts by a client to attach or
204  * manipulate a buffer prior to the first xdg_surface.configure call must
205  * also be treated as errors.
206  *
207  * Mapping an xdg_surface-based role surface is defined as making it
208  * possible for the surface to be shown by the compositor. Note that
209  * a mapped surface is not guaranteed to be visible once it is mapped.
210  *
211  * For an xdg_surface to be mapped by the compositor, the following
212  * conditions must be met:
213  * (1) the client has assigned an xdg_surface-based role to the surface
214  * (2) the client has set and committed the xdg_surface state and the
215  * role-dependent state to the surface
216  * (3) the client has committed a buffer to the surface
217  *
218  * A newly-unmapped surface is considered to have met condition (1) out
219  * of the 3 required conditions for mapping a surface if its role surface
220  * has not been destroyed.
221  */
222 extern const struct wl_interface xdg_surface_interface;
223 /**
224  * @page page_iface_xdg_toplevel xdg_toplevel
225  * @section page_iface_xdg_toplevel_desc Description
226  *
227  * This interface defines an xdg_surface role which allows a surface to,
228  * among other things, set window-like properties such as maximize,
229  * fullscreen, and minimize, set application-specific metadata like title and
230  * id, and well as trigger user interactive operations such as interactive
231  * resize and move.
232  *
233  * Unmapping an xdg_toplevel means that the surface cannot be shown
234  * by the compositor until it is explicitly mapped again.
235  * All active operations (e.g., move, resize) are canceled and all
236  * attributes (e.g. title, state, stacking, ...) are discarded for
237  * an xdg_toplevel surface when it is unmapped.
238  *
239  * Attaching a null buffer to a toplevel unmaps the surface.
240  * @section page_iface_xdg_toplevel_api API
241  * See @ref iface_xdg_toplevel.
242  */
243 /**
244  * @defgroup iface_xdg_toplevel The xdg_toplevel interface
245  *
246  * This interface defines an xdg_surface role which allows a surface to,
247  * among other things, set window-like properties such as maximize,
248  * fullscreen, and minimize, set application-specific metadata like title and
249  * id, and well as trigger user interactive operations such as interactive
250  * resize and move.
251  *
252  * Unmapping an xdg_toplevel means that the surface cannot be shown
253  * by the compositor until it is explicitly mapped again.
254  * All active operations (e.g., move, resize) are canceled and all
255  * attributes (e.g. title, state, stacking, ...) are discarded for
256  * an xdg_toplevel surface when it is unmapped.
257  *
258  * Attaching a null buffer to a toplevel unmaps the surface.
259  */
260 extern const struct wl_interface xdg_toplevel_interface;
261 /**
262  * @page page_iface_xdg_popup xdg_popup
263  * @section page_iface_xdg_popup_desc Description
264  *
265  * A popup surface is a short-lived, temporary surface. It can be used to
266  * implement for example menus, popovers, tooltips and other similar user
267  * interface concepts.
268  *
269  * A popup can be made to take an explicit grab. See xdg_popup.grab for
270  * details.
271  *
272  * When the popup is dismissed, a popup_done event will be sent out, and at
273  * the same time the surface will be unmapped. See the xdg_popup.popup_done
274  * event for details.
275  *
276  * Explicitly destroying the xdg_popup object will also dismiss the popup and
277  * unmap the surface. Clients that want to dismiss the popup when another
278  * surface of their own is clicked should dismiss the popup using the destroy
279  * request.
280  *
281  * A newly created xdg_popup will be stacked on top of all previously created
282  * xdg_popup surfaces associated with the same xdg_toplevel.
283  *
284  * The parent of an xdg_popup must be mapped (see the xdg_surface
285  * description) before the xdg_popup itself.
286  *
287  * The x and y arguments passed when creating the popup object specify
288  * where the top left of the popup should be placed, relative to the
289  * local surface coordinates of the parent surface. See
290  * xdg_surface.get_popup. An xdg_popup must intersect with or be at least
291  * partially adjacent to its parent surface.
292  *
293  * The client must call wl_surface.commit on the corresponding wl_surface
294  * for the xdg_popup state to take effect.
295  * @section page_iface_xdg_popup_api API
296  * See @ref iface_xdg_popup.
297  */
298 /**
299  * @defgroup iface_xdg_popup The xdg_popup interface
300  *
301  * A popup surface is a short-lived, temporary surface. It can be used to
302  * implement for example menus, popovers, tooltips and other similar user
303  * interface concepts.
304  *
305  * A popup can be made to take an explicit grab. See xdg_popup.grab for
306  * details.
307  *
308  * When the popup is dismissed, a popup_done event will be sent out, and at
309  * the same time the surface will be unmapped. See the xdg_popup.popup_done
310  * event for details.
311  *
312  * Explicitly destroying the xdg_popup object will also dismiss the popup and
313  * unmap the surface. Clients that want to dismiss the popup when another
314  * surface of their own is clicked should dismiss the popup using the destroy
315  * request.
316  *
317  * A newly created xdg_popup will be stacked on top of all previously created
318  * xdg_popup surfaces associated with the same xdg_toplevel.
319  *
320  * The parent of an xdg_popup must be mapped (see the xdg_surface
321  * description) before the xdg_popup itself.
322  *
323  * The x and y arguments passed when creating the popup object specify
324  * where the top left of the popup should be placed, relative to the
325  * local surface coordinates of the parent surface. See
326  * xdg_surface.get_popup. An xdg_popup must intersect with or be at least
327  * partially adjacent to its parent surface.
328  *
329  * The client must call wl_surface.commit on the corresponding wl_surface
330  * for the xdg_popup state to take effect.
331  */
332 extern const struct wl_interface xdg_popup_interface;
333 
334 #ifndef XDG_WM_BASE_ERROR_ENUM
335 #define XDG_WM_BASE_ERROR_ENUM
336 enum xdg_wm_base_error {
337 	/**
338 	 * given wl_surface has another role
339 	 */
340 	XDG_WM_BASE_ERROR_ROLE = 0,
341 	/**
342 	 * xdg_wm_base was destroyed before children
343 	 */
344 	XDG_WM_BASE_ERROR_DEFUNCT_SURFACES = 1,
345 	/**
346 	 * the client tried to map or destroy a non-topmost popup
347 	 */
348 	XDG_WM_BASE_ERROR_NOT_THE_TOPMOST_POPUP = 2,
349 	/**
350 	 * the client specified an invalid popup parent surface
351 	 */
352 	XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT = 3,
353 	/**
354 	 * the client provided an invalid surface state
355 	 */
356 	XDG_WM_BASE_ERROR_INVALID_SURFACE_STATE = 4,
357 	/**
358 	 * the client provided an invalid positioner
359 	 */
360 	XDG_WM_BASE_ERROR_INVALID_POSITIONER = 5,
361 };
362 #endif /* XDG_WM_BASE_ERROR_ENUM */
363 
364 /**
365  * @ingroup iface_xdg_wm_base
366  * @struct xdg_wm_base_listener
367  */
368 struct xdg_wm_base_listener {
369 	/**
370 	 * check if the client is alive
371 	 *
372 	 * The ping event asks the client if it's still alive. Pass the
373 	 * serial specified in the event back to the compositor by sending
374 	 * a "pong" request back with the specified serial. See
375 	 * xdg_wm_base.pong.
376 	 *
377 	 * Compositors can use this to determine if the client is still
378 	 * alive. It's unspecified what will happen if the client doesn't
379 	 * respond to the ping request, or in what timeframe. Clients
380 	 * should try to respond in a reasonable amount of time.
381 	 *
382 	 * A compositor is free to ping in any way it wants, but a client
383 	 * must always respond to any xdg_wm_base object it created.
384 	 * @param serial pass this to the pong request
385 	 */
386 	void (*ping)(void *data,
387 		     struct xdg_wm_base *xdg_wm_base,
388 		     uint32_t serial);
389 };
390 
391 /**
392  * @ingroup iface_xdg_wm_base
393  */
394 static inline int
xdg_wm_base_add_listener(struct xdg_wm_base * xdg_wm_base,const struct xdg_wm_base_listener * listener,void * data)395 xdg_wm_base_add_listener(struct xdg_wm_base *xdg_wm_base,
396 			 const struct xdg_wm_base_listener *listener, void *data)
397 {
398 	return wl_proxy_add_listener((struct wl_proxy *) xdg_wm_base,
399 				     (void (**)(void)) listener, data);
400 }
401 
402 #define XDG_WM_BASE_DESTROY 0
403 #define XDG_WM_BASE_CREATE_POSITIONER 1
404 #define XDG_WM_BASE_GET_XDG_SURFACE 2
405 #define XDG_WM_BASE_PONG 3
406 
407 /**
408  * @ingroup iface_xdg_wm_base
409  */
410 #define XDG_WM_BASE_PING_SINCE_VERSION 1
411 
412 /**
413  * @ingroup iface_xdg_wm_base
414  */
415 #define XDG_WM_BASE_DESTROY_SINCE_VERSION 1
416 /**
417  * @ingroup iface_xdg_wm_base
418  */
419 #define XDG_WM_BASE_CREATE_POSITIONER_SINCE_VERSION 1
420 /**
421  * @ingroup iface_xdg_wm_base
422  */
423 #define XDG_WM_BASE_GET_XDG_SURFACE_SINCE_VERSION 1
424 /**
425  * @ingroup iface_xdg_wm_base
426  */
427 #define XDG_WM_BASE_PONG_SINCE_VERSION 1
428 
429 /** @ingroup iface_xdg_wm_base */
430 static inline void
xdg_wm_base_set_user_data(struct xdg_wm_base * xdg_wm_base,void * user_data)431 xdg_wm_base_set_user_data(struct xdg_wm_base *xdg_wm_base, void *user_data)
432 {
433 	wl_proxy_set_user_data((struct wl_proxy *) xdg_wm_base, user_data);
434 }
435 
436 /** @ingroup iface_xdg_wm_base */
437 static inline void *
xdg_wm_base_get_user_data(struct xdg_wm_base * xdg_wm_base)438 xdg_wm_base_get_user_data(struct xdg_wm_base *xdg_wm_base)
439 {
440 	return wl_proxy_get_user_data((struct wl_proxy *) xdg_wm_base);
441 }
442 
443 static inline uint32_t
xdg_wm_base_get_version(struct xdg_wm_base * xdg_wm_base)444 xdg_wm_base_get_version(struct xdg_wm_base *xdg_wm_base)
445 {
446 	return wl_proxy_get_version((struct wl_proxy *) xdg_wm_base);
447 }
448 
449 /**
450  * @ingroup iface_xdg_wm_base
451  *
452  * Destroy this xdg_wm_base object.
453  *
454  * Destroying a bound xdg_wm_base object while there are surfaces
455  * still alive created by this xdg_wm_base object instance is illegal
456  * and will result in a protocol error.
457  */
458 static inline void
xdg_wm_base_destroy(struct xdg_wm_base * xdg_wm_base)459 xdg_wm_base_destroy(struct xdg_wm_base *xdg_wm_base)
460 {
461 	wl_proxy_marshal((struct wl_proxy *) xdg_wm_base,
462 			 XDG_WM_BASE_DESTROY);
463 
464 	wl_proxy_destroy((struct wl_proxy *) xdg_wm_base);
465 }
466 
467 /**
468  * @ingroup iface_xdg_wm_base
469  *
470  * Create a positioner object. A positioner object is used to position
471  * surfaces relative to some parent surface. See the interface description
472  * and xdg_surface.get_popup for details.
473  */
474 static inline struct xdg_positioner *
xdg_wm_base_create_positioner(struct xdg_wm_base * xdg_wm_base)475 xdg_wm_base_create_positioner(struct xdg_wm_base *xdg_wm_base)
476 {
477 	struct wl_proxy *id;
478 
479 	id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_wm_base,
480 			 XDG_WM_BASE_CREATE_POSITIONER, &xdg_positioner_interface, NULL);
481 
482 	return (struct xdg_positioner *) id;
483 }
484 
485 /**
486  * @ingroup iface_xdg_wm_base
487  *
488  * This creates an xdg_surface for the given surface. While xdg_surface
489  * itself is not a role, the corresponding surface may only be assigned
490  * a role extending xdg_surface, such as xdg_toplevel or xdg_popup.
491  *
492  * This creates an xdg_surface for the given surface. An xdg_surface is
493  * used as basis to define a role to a given surface, such as xdg_toplevel
494  * or xdg_popup. It also manages functionality shared between xdg_surface
495  * based surface roles.
496  *
497  * See the documentation of xdg_surface for more details about what an
498  * xdg_surface is and how it is used.
499  */
500 static inline struct xdg_surface *
xdg_wm_base_get_xdg_surface(struct xdg_wm_base * xdg_wm_base,struct wl_surface * surface)501 xdg_wm_base_get_xdg_surface(struct xdg_wm_base *xdg_wm_base, struct wl_surface *surface)
502 {
503 	struct wl_proxy *id;
504 
505 	id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_wm_base,
506 			 XDG_WM_BASE_GET_XDG_SURFACE, &xdg_surface_interface, NULL, surface);
507 
508 	return (struct xdg_surface *) id;
509 }
510 
511 /**
512  * @ingroup iface_xdg_wm_base
513  *
514  * A client must respond to a ping event with a pong request or
515  * the client may be deemed unresponsive. See xdg_wm_base.ping.
516  */
517 static inline void
xdg_wm_base_pong(struct xdg_wm_base * xdg_wm_base,uint32_t serial)518 xdg_wm_base_pong(struct xdg_wm_base *xdg_wm_base, uint32_t serial)
519 {
520 	wl_proxy_marshal((struct wl_proxy *) xdg_wm_base,
521 			 XDG_WM_BASE_PONG, serial);
522 }
523 
524 #ifndef XDG_POSITIONER_ERROR_ENUM
525 #define XDG_POSITIONER_ERROR_ENUM
526 enum xdg_positioner_error {
527 	/**
528 	 * invalid input provided
529 	 */
530 	XDG_POSITIONER_ERROR_INVALID_INPUT = 0,
531 };
532 #endif /* XDG_POSITIONER_ERROR_ENUM */
533 
534 #ifndef XDG_POSITIONER_ANCHOR_ENUM
535 #define XDG_POSITIONER_ANCHOR_ENUM
536 enum xdg_positioner_anchor {
537 	XDG_POSITIONER_ANCHOR_NONE = 0,
538 	XDG_POSITIONER_ANCHOR_TOP = 1,
539 	XDG_POSITIONER_ANCHOR_BOTTOM = 2,
540 	XDG_POSITIONER_ANCHOR_LEFT = 3,
541 	XDG_POSITIONER_ANCHOR_RIGHT = 4,
542 	XDG_POSITIONER_ANCHOR_TOP_LEFT = 5,
543 	XDG_POSITIONER_ANCHOR_BOTTOM_LEFT = 6,
544 	XDG_POSITIONER_ANCHOR_TOP_RIGHT = 7,
545 	XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT = 8,
546 };
547 #endif /* XDG_POSITIONER_ANCHOR_ENUM */
548 
549 #ifndef XDG_POSITIONER_GRAVITY_ENUM
550 #define XDG_POSITIONER_GRAVITY_ENUM
551 enum xdg_positioner_gravity {
552 	XDG_POSITIONER_GRAVITY_NONE = 0,
553 	XDG_POSITIONER_GRAVITY_TOP = 1,
554 	XDG_POSITIONER_GRAVITY_BOTTOM = 2,
555 	XDG_POSITIONER_GRAVITY_LEFT = 3,
556 	XDG_POSITIONER_GRAVITY_RIGHT = 4,
557 	XDG_POSITIONER_GRAVITY_TOP_LEFT = 5,
558 	XDG_POSITIONER_GRAVITY_BOTTOM_LEFT = 6,
559 	XDG_POSITIONER_GRAVITY_TOP_RIGHT = 7,
560 	XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT = 8,
561 };
562 #endif /* XDG_POSITIONER_GRAVITY_ENUM */
563 
564 #ifndef XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM
565 #define XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM
566 /**
567  * @ingroup iface_xdg_positioner
568  * vertically resize the surface
569  *
570  * Resize the surface vertically so that it is completely unconstrained.
571  */
572 enum xdg_positioner_constraint_adjustment {
573 	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE = 0,
574 	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X = 1,
575 	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y = 2,
576 	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X = 4,
577 	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y = 8,
578 	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X = 16,
579 	XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32,
580 };
581 #endif /* XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM */
582 
583 #define XDG_POSITIONER_DESTROY 0
584 #define XDG_POSITIONER_SET_SIZE 1
585 #define XDG_POSITIONER_SET_ANCHOR_RECT 2
586 #define XDG_POSITIONER_SET_ANCHOR 3
587 #define XDG_POSITIONER_SET_GRAVITY 4
588 #define XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT 5
589 #define XDG_POSITIONER_SET_OFFSET 6
590 
591 
592 /**
593  * @ingroup iface_xdg_positioner
594  */
595 #define XDG_POSITIONER_DESTROY_SINCE_VERSION 1
596 /**
597  * @ingroup iface_xdg_positioner
598  */
599 #define XDG_POSITIONER_SET_SIZE_SINCE_VERSION 1
600 /**
601  * @ingroup iface_xdg_positioner
602  */
603 #define XDG_POSITIONER_SET_ANCHOR_RECT_SINCE_VERSION 1
604 /**
605  * @ingroup iface_xdg_positioner
606  */
607 #define XDG_POSITIONER_SET_ANCHOR_SINCE_VERSION 1
608 /**
609  * @ingroup iface_xdg_positioner
610  */
611 #define XDG_POSITIONER_SET_GRAVITY_SINCE_VERSION 1
612 /**
613  * @ingroup iface_xdg_positioner
614  */
615 #define XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT_SINCE_VERSION 1
616 /**
617  * @ingroup iface_xdg_positioner
618  */
619 #define XDG_POSITIONER_SET_OFFSET_SINCE_VERSION 1
620 
621 /** @ingroup iface_xdg_positioner */
622 static inline void
xdg_positioner_set_user_data(struct xdg_positioner * xdg_positioner,void * user_data)623 xdg_positioner_set_user_data(struct xdg_positioner *xdg_positioner, void *user_data)
624 {
625 	wl_proxy_set_user_data((struct wl_proxy *) xdg_positioner, user_data);
626 }
627 
628 /** @ingroup iface_xdg_positioner */
629 static inline void *
xdg_positioner_get_user_data(struct xdg_positioner * xdg_positioner)630 xdg_positioner_get_user_data(struct xdg_positioner *xdg_positioner)
631 {
632 	return wl_proxy_get_user_data((struct wl_proxy *) xdg_positioner);
633 }
634 
635 static inline uint32_t
xdg_positioner_get_version(struct xdg_positioner * xdg_positioner)636 xdg_positioner_get_version(struct xdg_positioner *xdg_positioner)
637 {
638 	return wl_proxy_get_version((struct wl_proxy *) xdg_positioner);
639 }
640 
641 /**
642  * @ingroup iface_xdg_positioner
643  *
644  * Notify the compositor that the xdg_positioner will no longer be used.
645  */
646 static inline void
xdg_positioner_destroy(struct xdg_positioner * xdg_positioner)647 xdg_positioner_destroy(struct xdg_positioner *xdg_positioner)
648 {
649 	wl_proxy_marshal((struct wl_proxy *) xdg_positioner,
650 			 XDG_POSITIONER_DESTROY);
651 
652 	wl_proxy_destroy((struct wl_proxy *) xdg_positioner);
653 }
654 
655 /**
656  * @ingroup iface_xdg_positioner
657  *
658  * Set the size of the surface that is to be positioned with the positioner
659  * object. The size is in surface-local coordinates and corresponds to the
660  * window geometry. See xdg_surface.set_window_geometry.
661  *
662  * If a zero or negative size is set the invalid_input error is raised.
663  */
664 static inline void
xdg_positioner_set_size(struct xdg_positioner * xdg_positioner,int32_t width,int32_t height)665 xdg_positioner_set_size(struct xdg_positioner *xdg_positioner, int32_t width, int32_t height)
666 {
667 	wl_proxy_marshal((struct wl_proxy *) xdg_positioner,
668 			 XDG_POSITIONER_SET_SIZE, width, height);
669 }
670 
671 /**
672  * @ingroup iface_xdg_positioner
673  *
674  * Specify the anchor rectangle within the parent surface that the child
675  * surface will be placed relative to. The rectangle is relative to the
676  * window geometry as defined by xdg_surface.set_window_geometry of the
677  * parent surface.
678  *
679  * When the xdg_positioner object is used to position a child surface, the
680  * anchor rectangle may not extend outside the window geometry of the
681  * positioned child's parent surface.
682  *
683  * If a negative size is set the invalid_input error is raised.
684  */
685 static inline void
xdg_positioner_set_anchor_rect(struct xdg_positioner * xdg_positioner,int32_t x,int32_t y,int32_t width,int32_t height)686 xdg_positioner_set_anchor_rect(struct xdg_positioner *xdg_positioner, int32_t x, int32_t y, int32_t width, int32_t height)
687 {
688 	wl_proxy_marshal((struct wl_proxy *) xdg_positioner,
689 			 XDG_POSITIONER_SET_ANCHOR_RECT, x, y, width, height);
690 }
691 
692 /**
693  * @ingroup iface_xdg_positioner
694  *
695  * Defines the anchor point for the anchor rectangle. The specified anchor
696  * is used derive an anchor point that the child surface will be
697  * positioned relative to. If a corner anchor is set (e.g. 'top_left' or
698  * 'bottom_right'), the anchor point will be at the specified corner;
699  * otherwise, the derived anchor point will be centered on the specified
700  * edge, or in the center of the anchor rectangle if no edge is specified.
701  */
702 static inline void
xdg_positioner_set_anchor(struct xdg_positioner * xdg_positioner,uint32_t anchor)703 xdg_positioner_set_anchor(struct xdg_positioner *xdg_positioner, uint32_t anchor)
704 {
705 	wl_proxy_marshal((struct wl_proxy *) xdg_positioner,
706 			 XDG_POSITIONER_SET_ANCHOR, anchor);
707 }
708 
709 /**
710  * @ingroup iface_xdg_positioner
711  *
712  * Defines in what direction a surface should be positioned, relative to
713  * the anchor point of the parent surface. If a corner gravity is
714  * specified (e.g. 'bottom_right' or 'top_left'), then the child surface
715  * will be placed towards the specified gravity; otherwise, the child
716  * surface will be centered over the anchor point on any axis that had no
717  * gravity specified.
718  */
719 static inline void
xdg_positioner_set_gravity(struct xdg_positioner * xdg_positioner,uint32_t gravity)720 xdg_positioner_set_gravity(struct xdg_positioner *xdg_positioner, uint32_t gravity)
721 {
722 	wl_proxy_marshal((struct wl_proxy *) xdg_positioner,
723 			 XDG_POSITIONER_SET_GRAVITY, gravity);
724 }
725 
726 /**
727  * @ingroup iface_xdg_positioner
728  *
729  * Specify how the window should be positioned if the originally intended
730  * position caused the surface to be constrained, meaning at least
731  * partially outside positioning boundaries set by the compositor. The
732  * adjustment is set by constructing a bitmask describing the adjustment to
733  * be made when the surface is constrained on that axis.
734  *
735  * If no bit for one axis is set, the compositor will assume that the child
736  * surface should not change its position on that axis when constrained.
737  *
738  * If more than one bit for one axis is set, the order of how adjustments
739  * are applied is specified in the corresponding adjustment descriptions.
740  *
741  * The default adjustment is none.
742  */
743 static inline void
xdg_positioner_set_constraint_adjustment(struct xdg_positioner * xdg_positioner,uint32_t constraint_adjustment)744 xdg_positioner_set_constraint_adjustment(struct xdg_positioner *xdg_positioner, uint32_t constraint_adjustment)
745 {
746 	wl_proxy_marshal((struct wl_proxy *) xdg_positioner,
747 			 XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT, constraint_adjustment);
748 }
749 
750 /**
751  * @ingroup iface_xdg_positioner
752  *
753  * Specify the surface position offset relative to the position of the
754  * anchor on the anchor rectangle and the anchor on the surface. For
755  * example if the anchor of the anchor rectangle is at (x, y), the surface
756  * has the gravity bottom|right, and the offset is (ox, oy), the calculated
757  * surface position will be (x + ox, y + oy). The offset position of the
758  * surface is the one used for constraint testing. See
759  * set_constraint_adjustment.
760  *
761  * An example use case is placing a popup menu on top of a user interface
762  * element, while aligning the user interface element of the parent surface
763  * with some user interface element placed somewhere in the popup surface.
764  */
765 static inline void
xdg_positioner_set_offset(struct xdg_positioner * xdg_positioner,int32_t x,int32_t y)766 xdg_positioner_set_offset(struct xdg_positioner *xdg_positioner, int32_t x, int32_t y)
767 {
768 	wl_proxy_marshal((struct wl_proxy *) xdg_positioner,
769 			 XDG_POSITIONER_SET_OFFSET, x, y);
770 }
771 
772 #ifndef XDG_SURFACE_ERROR_ENUM
773 #define XDG_SURFACE_ERROR_ENUM
774 enum xdg_surface_error {
775 	XDG_SURFACE_ERROR_NOT_CONSTRUCTED = 1,
776 	XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED = 2,
777 	XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER = 3,
778 };
779 #endif /* XDG_SURFACE_ERROR_ENUM */
780 
781 /**
782  * @ingroup iface_xdg_surface
783  * @struct xdg_surface_listener
784  */
785 struct xdg_surface_listener {
786 	/**
787 	 * suggest a surface change
788 	 *
789 	 * The configure event marks the end of a configure sequence. A
790 	 * configure sequence is a set of one or more events configuring
791 	 * the state of the xdg_surface, including the final
792 	 * xdg_surface.configure event.
793 	 *
794 	 * Where applicable, xdg_surface surface roles will during a
795 	 * configure sequence extend this event as a latched state sent as
796 	 * events before the xdg_surface.configure event. Such events
797 	 * should be considered to make up a set of atomically applied
798 	 * configuration states, where the xdg_surface.configure commits
799 	 * the accumulated state.
800 	 *
801 	 * Clients should arrange their surface for the new states, and
802 	 * then send an ack_configure request with the serial sent in this
803 	 * configure event at some point before committing the new surface.
804 	 *
805 	 * If the client receives multiple configure events before it can
806 	 * respond to one, it is free to discard all but the last event it
807 	 * received.
808 	 * @param serial serial of the configure event
809 	 */
810 	void (*configure)(void *data,
811 			  struct xdg_surface *xdg_surface,
812 			  uint32_t serial);
813 };
814 
815 /**
816  * @ingroup iface_xdg_surface
817  */
818 static inline int
xdg_surface_add_listener(struct xdg_surface * xdg_surface,const struct xdg_surface_listener * listener,void * data)819 xdg_surface_add_listener(struct xdg_surface *xdg_surface,
820 			 const struct xdg_surface_listener *listener, void *data)
821 {
822 	return wl_proxy_add_listener((struct wl_proxy *) xdg_surface,
823 				     (void (**)(void)) listener, data);
824 }
825 
826 #define XDG_SURFACE_DESTROY 0
827 #define XDG_SURFACE_GET_TOPLEVEL 1
828 #define XDG_SURFACE_GET_POPUP 2
829 #define XDG_SURFACE_SET_WINDOW_GEOMETRY 3
830 #define XDG_SURFACE_ACK_CONFIGURE 4
831 
832 /**
833  * @ingroup iface_xdg_surface
834  */
835 #define XDG_SURFACE_CONFIGURE_SINCE_VERSION 1
836 
837 /**
838  * @ingroup iface_xdg_surface
839  */
840 #define XDG_SURFACE_DESTROY_SINCE_VERSION 1
841 /**
842  * @ingroup iface_xdg_surface
843  */
844 #define XDG_SURFACE_GET_TOPLEVEL_SINCE_VERSION 1
845 /**
846  * @ingroup iface_xdg_surface
847  */
848 #define XDG_SURFACE_GET_POPUP_SINCE_VERSION 1
849 /**
850  * @ingroup iface_xdg_surface
851  */
852 #define XDG_SURFACE_SET_WINDOW_GEOMETRY_SINCE_VERSION 1
853 /**
854  * @ingroup iface_xdg_surface
855  */
856 #define XDG_SURFACE_ACK_CONFIGURE_SINCE_VERSION 1
857 
858 /** @ingroup iface_xdg_surface */
859 static inline void
xdg_surface_set_user_data(struct xdg_surface * xdg_surface,void * user_data)860 xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data)
861 {
862 	wl_proxy_set_user_data((struct wl_proxy *) xdg_surface, user_data);
863 }
864 
865 /** @ingroup iface_xdg_surface */
866 static inline void *
xdg_surface_get_user_data(struct xdg_surface * xdg_surface)867 xdg_surface_get_user_data(struct xdg_surface *xdg_surface)
868 {
869 	return wl_proxy_get_user_data((struct wl_proxy *) xdg_surface);
870 }
871 
872 static inline uint32_t
xdg_surface_get_version(struct xdg_surface * xdg_surface)873 xdg_surface_get_version(struct xdg_surface *xdg_surface)
874 {
875 	return wl_proxy_get_version((struct wl_proxy *) xdg_surface);
876 }
877 
878 /**
879  * @ingroup iface_xdg_surface
880  *
881  * Destroy the xdg_surface object. An xdg_surface must only be destroyed
882  * after its role object has been destroyed.
883  */
884 static inline void
xdg_surface_destroy(struct xdg_surface * xdg_surface)885 xdg_surface_destroy(struct xdg_surface *xdg_surface)
886 {
887 	wl_proxy_marshal((struct wl_proxy *) xdg_surface,
888 			 XDG_SURFACE_DESTROY);
889 
890 	wl_proxy_destroy((struct wl_proxy *) xdg_surface);
891 }
892 
893 /**
894  * @ingroup iface_xdg_surface
895  *
896  * This creates an xdg_toplevel object for the given xdg_surface and gives
897  * the associated wl_surface the xdg_toplevel role.
898  *
899  * See the documentation of xdg_toplevel for more details about what an
900  * xdg_toplevel is and how it is used.
901  */
902 static inline struct xdg_toplevel *
xdg_surface_get_toplevel(struct xdg_surface * xdg_surface)903 xdg_surface_get_toplevel(struct xdg_surface *xdg_surface)
904 {
905 	struct wl_proxy *id;
906 
907 	id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_surface,
908 			 XDG_SURFACE_GET_TOPLEVEL, &xdg_toplevel_interface, NULL);
909 
910 	return (struct xdg_toplevel *) id;
911 }
912 
913 /**
914  * @ingroup iface_xdg_surface
915  *
916  * This creates an xdg_popup object for the given xdg_surface and gives
917  * the associated wl_surface the xdg_popup role.
918  *
919  * If null is passed as a parent, a parent surface must be specified using
920  * some other protocol, before committing the initial state.
921  *
922  * See the documentation of xdg_popup for more details about what an
923  * xdg_popup is and how it is used.
924  */
925 static inline struct xdg_popup *
xdg_surface_get_popup(struct xdg_surface * xdg_surface,struct xdg_surface * parent,struct xdg_positioner * positioner)926 xdg_surface_get_popup(struct xdg_surface *xdg_surface, struct xdg_surface *parent, struct xdg_positioner *positioner)
927 {
928 	struct wl_proxy *id;
929 
930 	id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_surface,
931 			 XDG_SURFACE_GET_POPUP, &xdg_popup_interface, NULL, parent, positioner);
932 
933 	return (struct xdg_popup *) id;
934 }
935 
936 /**
937  * @ingroup iface_xdg_surface
938  *
939  * The window geometry of a surface is its "visible bounds" from the
940  * user's perspective. Client-side decorations often have invisible
941  * portions like drop-shadows which should be ignored for the
942  * purposes of aligning, placing and constraining windows.
943  *
944  * The window geometry is double buffered, and will be applied at the
945  * time wl_surface.commit of the corresponding wl_surface is called.
946  *
947  * When maintaining a position, the compositor should treat the (x, y)
948  * coordinate of the window geometry as the top left corner of the window.
949  * A client changing the (x, y) window geometry coordinate should in
950  * general not alter the position of the window.
951  *
952  * Once the window geometry of the surface is set, it is not possible to
953  * unset it, and it will remain the same until set_window_geometry is
954  * called again, even if a new subsurface or buffer is attached.
955  *
956  * If never set, the value is the full bounds of the surface,
957  * including any subsurfaces. This updates dynamically on every
958  * commit. This unset is meant for extremely simple clients.
959  *
960  * The arguments are given in the surface-local coordinate space of
961  * the wl_surface associated with this xdg_surface.
962  *
963  * The width and height must be greater than zero. Setting an invalid size
964  * will raise an error. When applied, the effective window geometry will be
965  * the set window geometry clamped to the bounding rectangle of the
966  * combined geometry of the surface of the xdg_surface and the associated
967  * subsurfaces.
968  */
969 static inline void
xdg_surface_set_window_geometry(struct xdg_surface * xdg_surface,int32_t x,int32_t y,int32_t width,int32_t height)970 xdg_surface_set_window_geometry(struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height)
971 {
972 	wl_proxy_marshal((struct wl_proxy *) xdg_surface,
973 			 XDG_SURFACE_SET_WINDOW_GEOMETRY, x, y, width, height);
974 }
975 
976 /**
977  * @ingroup iface_xdg_surface
978  *
979  * When a configure event is received, if a client commits the
980  * surface in response to the configure event, then the client
981  * must make an ack_configure request sometime before the commit
982  * request, passing along the serial of the configure event.
983  *
984  * For instance, for toplevel surfaces the compositor might use this
985  * information to move a surface to the top left only when the client has
986  * drawn itself for the maximized or fullscreen state.
987  *
988  * If the client receives multiple configure events before it
989  * can respond to one, it only has to ack the last configure event.
990  *
991  * A client is not required to commit immediately after sending
992  * an ack_configure request - it may even ack_configure several times
993  * before its next surface commit.
994  *
995  * A client may send multiple ack_configure requests before committing, but
996  * only the last request sent before a commit indicates which configure
997  * event the client really is responding to.
998  */
999 static inline void
xdg_surface_ack_configure(struct xdg_surface * xdg_surface,uint32_t serial)1000 xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial)
1001 {
1002 	wl_proxy_marshal((struct wl_proxy *) xdg_surface,
1003 			 XDG_SURFACE_ACK_CONFIGURE, serial);
1004 }
1005 
1006 #ifndef XDG_TOPLEVEL_RESIZE_EDGE_ENUM
1007 #define XDG_TOPLEVEL_RESIZE_EDGE_ENUM
1008 /**
1009  * @ingroup iface_xdg_toplevel
1010  * edge values for resizing
1011  *
1012  * These values are used to indicate which edge of a surface
1013  * is being dragged in a resize operation.
1014  */
1015 enum xdg_toplevel_resize_edge {
1016 	XDG_TOPLEVEL_RESIZE_EDGE_NONE = 0,
1017 	XDG_TOPLEVEL_RESIZE_EDGE_TOP = 1,
1018 	XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM = 2,
1019 	XDG_TOPLEVEL_RESIZE_EDGE_LEFT = 4,
1020 	XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT = 5,
1021 	XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT = 6,
1022 	XDG_TOPLEVEL_RESIZE_EDGE_RIGHT = 8,
1023 	XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT = 9,
1024 	XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT = 10,
1025 };
1026 #endif /* XDG_TOPLEVEL_RESIZE_EDGE_ENUM */
1027 
1028 #ifndef XDG_TOPLEVEL_STATE_ENUM
1029 #define XDG_TOPLEVEL_STATE_ENUM
1030 /**
1031  * @ingroup iface_xdg_toplevel
1032  * the surface is tiled
1033  *
1034  * The window is currently in a tiled layout and the bottom edge is
1035  * considered to be adjacent to another part of the tiling grid.
1036  */
1037 enum xdg_toplevel_state {
1038 	/**
1039 	 * the surface is maximized
1040 	 */
1041 	XDG_TOPLEVEL_STATE_MAXIMIZED = 1,
1042 	/**
1043 	 * the surface is fullscreen
1044 	 */
1045 	XDG_TOPLEVEL_STATE_FULLSCREEN = 2,
1046 	/**
1047 	 * the surface is being resized
1048 	 */
1049 	XDG_TOPLEVEL_STATE_RESIZING = 3,
1050 	/**
1051 	 * the surface is now activated
1052 	 */
1053 	XDG_TOPLEVEL_STATE_ACTIVATED = 4,
1054 	/**
1055 	 * @since 2
1056 	 */
1057 	XDG_TOPLEVEL_STATE_TILED_LEFT = 5,
1058 	/**
1059 	 * @since 2
1060 	 */
1061 	XDG_TOPLEVEL_STATE_TILED_RIGHT = 6,
1062 	/**
1063 	 * @since 2
1064 	 */
1065 	XDG_TOPLEVEL_STATE_TILED_TOP = 7,
1066 	/**
1067 	 * @since 2
1068 	 */
1069 	XDG_TOPLEVEL_STATE_TILED_BOTTOM = 8,
1070 };
1071 /**
1072  * @ingroup iface_xdg_toplevel
1073  */
1074 #define XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION 2
1075 /**
1076  * @ingroup iface_xdg_toplevel
1077  */
1078 #define XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION 2
1079 /**
1080  * @ingroup iface_xdg_toplevel
1081  */
1082 #define XDG_TOPLEVEL_STATE_TILED_TOP_SINCE_VERSION 2
1083 /**
1084  * @ingroup iface_xdg_toplevel
1085  */
1086 #define XDG_TOPLEVEL_STATE_TILED_BOTTOM_SINCE_VERSION 2
1087 #endif /* XDG_TOPLEVEL_STATE_ENUM */
1088 
1089 /**
1090  * @ingroup iface_xdg_toplevel
1091  * @struct xdg_toplevel_listener
1092  */
1093 struct xdg_toplevel_listener {
1094 	/**
1095 	 * suggest a surface change
1096 	 *
1097 	 * This configure event asks the client to resize its toplevel
1098 	 * surface or to change its state. The configured state should not
1099 	 * be applied immediately. See xdg_surface.configure for details.
1100 	 *
1101 	 * The width and height arguments specify a hint to the window
1102 	 * about how its surface should be resized in window geometry
1103 	 * coordinates. See set_window_geometry.
1104 	 *
1105 	 * If the width or height arguments are zero, it means the client
1106 	 * should decide its own window dimension. This may happen when the
1107 	 * compositor needs to configure the state of the surface but
1108 	 * doesn't have any information about any previous or expected
1109 	 * dimension.
1110 	 *
1111 	 * The states listed in the event specify how the width/height
1112 	 * arguments should be interpreted, and possibly how it should be
1113 	 * drawn.
1114 	 *
1115 	 * Clients must send an ack_configure in response to this event.
1116 	 * See xdg_surface.configure and xdg_surface.ack_configure for
1117 	 * details.
1118 	 */
1119 	void (*configure)(void *data,
1120 			  struct xdg_toplevel *xdg_toplevel,
1121 			  int32_t width,
1122 			  int32_t height,
1123 			  struct wl_array *states);
1124 	/**
1125 	 * surface wants to be closed
1126 	 *
1127 	 * The close event is sent by the compositor when the user wants
1128 	 * the surface to be closed. This should be equivalent to the user
1129 	 * clicking the close button in client-side decorations, if your
1130 	 * application has any.
1131 	 *
1132 	 * This is only a request that the user intends to close the
1133 	 * window. The client may choose to ignore this request, or show a
1134 	 * dialog to ask the user to save their data, etc.
1135 	 */
1136 	void (*close)(void *data,
1137 		      struct xdg_toplevel *xdg_toplevel);
1138 };
1139 
1140 /**
1141  * @ingroup iface_xdg_toplevel
1142  */
1143 static inline int
xdg_toplevel_add_listener(struct xdg_toplevel * xdg_toplevel,const struct xdg_toplevel_listener * listener,void * data)1144 xdg_toplevel_add_listener(struct xdg_toplevel *xdg_toplevel,
1145 			  const struct xdg_toplevel_listener *listener, void *data)
1146 {
1147 	return wl_proxy_add_listener((struct wl_proxy *) xdg_toplevel,
1148 				     (void (**)(void)) listener, data);
1149 }
1150 
1151 #define XDG_TOPLEVEL_DESTROY 0
1152 #define XDG_TOPLEVEL_SET_PARENT 1
1153 #define XDG_TOPLEVEL_SET_TITLE 2
1154 #define XDG_TOPLEVEL_SET_APP_ID 3
1155 #define XDG_TOPLEVEL_SHOW_WINDOW_MENU 4
1156 #define XDG_TOPLEVEL_MOVE 5
1157 #define XDG_TOPLEVEL_RESIZE 6
1158 #define XDG_TOPLEVEL_SET_MAX_SIZE 7
1159 #define XDG_TOPLEVEL_SET_MIN_SIZE 8
1160 #define XDG_TOPLEVEL_SET_MAXIMIZED 9
1161 #define XDG_TOPLEVEL_UNSET_MAXIMIZED 10
1162 #define XDG_TOPLEVEL_SET_FULLSCREEN 11
1163 #define XDG_TOPLEVEL_UNSET_FULLSCREEN 12
1164 #define XDG_TOPLEVEL_SET_MINIMIZED 13
1165 
1166 /**
1167  * @ingroup iface_xdg_toplevel
1168  */
1169 #define XDG_TOPLEVEL_CONFIGURE_SINCE_VERSION 1
1170 /**
1171  * @ingroup iface_xdg_toplevel
1172  */
1173 #define XDG_TOPLEVEL_CLOSE_SINCE_VERSION 1
1174 
1175 /**
1176  * @ingroup iface_xdg_toplevel
1177  */
1178 #define XDG_TOPLEVEL_DESTROY_SINCE_VERSION 1
1179 /**
1180  * @ingroup iface_xdg_toplevel
1181  */
1182 #define XDG_TOPLEVEL_SET_PARENT_SINCE_VERSION 1
1183 /**
1184  * @ingroup iface_xdg_toplevel
1185  */
1186 #define XDG_TOPLEVEL_SET_TITLE_SINCE_VERSION 1
1187 /**
1188  * @ingroup iface_xdg_toplevel
1189  */
1190 #define XDG_TOPLEVEL_SET_APP_ID_SINCE_VERSION 1
1191 /**
1192  * @ingroup iface_xdg_toplevel
1193  */
1194 #define XDG_TOPLEVEL_SHOW_WINDOW_MENU_SINCE_VERSION 1
1195 /**
1196  * @ingroup iface_xdg_toplevel
1197  */
1198 #define XDG_TOPLEVEL_MOVE_SINCE_VERSION 1
1199 /**
1200  * @ingroup iface_xdg_toplevel
1201  */
1202 #define XDG_TOPLEVEL_RESIZE_SINCE_VERSION 1
1203 /**
1204  * @ingroup iface_xdg_toplevel
1205  */
1206 #define XDG_TOPLEVEL_SET_MAX_SIZE_SINCE_VERSION 1
1207 /**
1208  * @ingroup iface_xdg_toplevel
1209  */
1210 #define XDG_TOPLEVEL_SET_MIN_SIZE_SINCE_VERSION 1
1211 /**
1212  * @ingroup iface_xdg_toplevel
1213  */
1214 #define XDG_TOPLEVEL_SET_MAXIMIZED_SINCE_VERSION 1
1215 /**
1216  * @ingroup iface_xdg_toplevel
1217  */
1218 #define XDG_TOPLEVEL_UNSET_MAXIMIZED_SINCE_VERSION 1
1219 /**
1220  * @ingroup iface_xdg_toplevel
1221  */
1222 #define XDG_TOPLEVEL_SET_FULLSCREEN_SINCE_VERSION 1
1223 /**
1224  * @ingroup iface_xdg_toplevel
1225  */
1226 #define XDG_TOPLEVEL_UNSET_FULLSCREEN_SINCE_VERSION 1
1227 /**
1228  * @ingroup iface_xdg_toplevel
1229  */
1230 #define XDG_TOPLEVEL_SET_MINIMIZED_SINCE_VERSION 1
1231 
1232 /** @ingroup iface_xdg_toplevel */
1233 static inline void
xdg_toplevel_set_user_data(struct xdg_toplevel * xdg_toplevel,void * user_data)1234 xdg_toplevel_set_user_data(struct xdg_toplevel *xdg_toplevel, void *user_data)
1235 {
1236 	wl_proxy_set_user_data((struct wl_proxy *) xdg_toplevel, user_data);
1237 }
1238 
1239 /** @ingroup iface_xdg_toplevel */
1240 static inline void *
xdg_toplevel_get_user_data(struct xdg_toplevel * xdg_toplevel)1241 xdg_toplevel_get_user_data(struct xdg_toplevel *xdg_toplevel)
1242 {
1243 	return wl_proxy_get_user_data((struct wl_proxy *) xdg_toplevel);
1244 }
1245 
1246 static inline uint32_t
xdg_toplevel_get_version(struct xdg_toplevel * xdg_toplevel)1247 xdg_toplevel_get_version(struct xdg_toplevel *xdg_toplevel)
1248 {
1249 	return wl_proxy_get_version((struct wl_proxy *) xdg_toplevel);
1250 }
1251 
1252 /**
1253  * @ingroup iface_xdg_toplevel
1254  *
1255  * This request destroys the role surface and unmaps the surface;
1256  * see "Unmapping" behavior in interface section for details.
1257  */
1258 static inline void
xdg_toplevel_destroy(struct xdg_toplevel * xdg_toplevel)1259 xdg_toplevel_destroy(struct xdg_toplevel *xdg_toplevel)
1260 {
1261 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1262 			 XDG_TOPLEVEL_DESTROY);
1263 
1264 	wl_proxy_destroy((struct wl_proxy *) xdg_toplevel);
1265 }
1266 
1267 /**
1268  * @ingroup iface_xdg_toplevel
1269  *
1270  * Set the "parent" of this surface. This surface should be stacked
1271  * above the parent surface and all other ancestor surfaces.
1272  *
1273  * Parent windows should be set on dialogs, toolboxes, or other
1274  * "auxiliary" surfaces, so that the parent is raised when the dialog
1275  * is raised.
1276  *
1277  * Setting a null parent for a child window removes any parent-child
1278  * relationship for the child. Setting a null parent for a window which
1279  * currently has no parent is a no-op.
1280  *
1281  * If the parent is unmapped then its children are managed as
1282  * though the parent of the now-unmapped parent has become the
1283  * parent of this surface. If no parent exists for the now-unmapped
1284  * parent then the children are managed as though they have no
1285  * parent surface.
1286  */
1287 static inline void
xdg_toplevel_set_parent(struct xdg_toplevel * xdg_toplevel,struct xdg_toplevel * parent)1288 xdg_toplevel_set_parent(struct xdg_toplevel *xdg_toplevel, struct xdg_toplevel *parent)
1289 {
1290 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1291 			 XDG_TOPLEVEL_SET_PARENT, parent);
1292 }
1293 
1294 /**
1295  * @ingroup iface_xdg_toplevel
1296  *
1297  * Set a short title for the surface.
1298  *
1299  * This string may be used to identify the surface in a task bar,
1300  * window list, or other user interface elements provided by the
1301  * compositor.
1302  *
1303  * The string must be encoded in UTF-8.
1304  */
1305 static inline void
xdg_toplevel_set_title(struct xdg_toplevel * xdg_toplevel,const char * title)1306 xdg_toplevel_set_title(struct xdg_toplevel *xdg_toplevel, const char *title)
1307 {
1308 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1309 			 XDG_TOPLEVEL_SET_TITLE, title);
1310 }
1311 
1312 /**
1313  * @ingroup iface_xdg_toplevel
1314  *
1315  * Set an application identifier for the surface.
1316  *
1317  * The app ID identifies the general class of applications to which
1318  * the surface belongs. The compositor can use this to group multiple
1319  * surfaces together, or to determine how to launch a new application.
1320  *
1321  * For D-Bus activatable applications, the app ID is used as the D-Bus
1322  * service name.
1323  *
1324  * The compositor shell will try to group application surfaces together
1325  * by their app ID. As a best practice, it is suggested to select app
1326  * ID's that match the basename of the application's .desktop file.
1327  * For example, "org.freedesktop.FooViewer" where the .desktop file is
1328  * "org.freedesktop.FooViewer.desktop".
1329  *
1330  * Like other properties, a set_app_id request can be sent after the
1331  * xdg_toplevel has been mapped to update the property.
1332  *
1333  * See the desktop-entry specification [0] for more details on
1334  * application identifiers and how they relate to well-known D-Bus
1335  * names and .desktop files.
1336  *
1337  * [0] http://standards.freedesktop.org/desktop-entry-spec/
1338  */
1339 static inline void
xdg_toplevel_set_app_id(struct xdg_toplevel * xdg_toplevel,const char * app_id)1340 xdg_toplevel_set_app_id(struct xdg_toplevel *xdg_toplevel, const char *app_id)
1341 {
1342 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1343 			 XDG_TOPLEVEL_SET_APP_ID, app_id);
1344 }
1345 
1346 /**
1347  * @ingroup iface_xdg_toplevel
1348  *
1349  * Clients implementing client-side decorations might want to show
1350  * a context menu when right-clicking on the decorations, giving the
1351  * user a menu that they can use to maximize or minimize the window.
1352  *
1353  * This request asks the compositor to pop up such a window menu at
1354  * the given position, relative to the local surface coordinates of
1355  * the parent surface. There are no guarantees as to what menu items
1356  * the window menu contains.
1357  *
1358  * This request must be used in response to some sort of user action
1359  * like a button press, key press, or touch down event.
1360  */
1361 static inline void
xdg_toplevel_show_window_menu(struct xdg_toplevel * xdg_toplevel,struct wl_seat * seat,uint32_t serial,int32_t x,int32_t y)1362 xdg_toplevel_show_window_menu(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
1363 {
1364 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1365 			 XDG_TOPLEVEL_SHOW_WINDOW_MENU, seat, serial, x, y);
1366 }
1367 
1368 /**
1369  * @ingroup iface_xdg_toplevel
1370  *
1371  * Start an interactive, user-driven move of the surface.
1372  *
1373  * This request must be used in response to some sort of user action
1374  * like a button press, key press, or touch down event. The passed
1375  * serial is used to determine the type of interactive move (touch,
1376  * pointer, etc).
1377  *
1378  * The server may ignore move requests depending on the state of
1379  * the surface (e.g. fullscreen or maximized), or if the passed serial
1380  * is no longer valid.
1381  *
1382  * If triggered, the surface will lose the focus of the device
1383  * (wl_pointer, wl_touch, etc) used for the move. It is up to the
1384  * compositor to visually indicate that the move is taking place, such as
1385  * updating a pointer cursor, during the move. There is no guarantee
1386  * that the device focus will return when the move is completed.
1387  */
1388 static inline void
xdg_toplevel_move(struct xdg_toplevel * xdg_toplevel,struct wl_seat * seat,uint32_t serial)1389 xdg_toplevel_move(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial)
1390 {
1391 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1392 			 XDG_TOPLEVEL_MOVE, seat, serial);
1393 }
1394 
1395 /**
1396  * @ingroup iface_xdg_toplevel
1397  *
1398  * Start a user-driven, interactive resize of the surface.
1399  *
1400  * This request must be used in response to some sort of user action
1401  * like a button press, key press, or touch down event. The passed
1402  * serial is used to determine the type of interactive resize (touch,
1403  * pointer, etc).
1404  *
1405  * The server may ignore resize requests depending on the state of
1406  * the surface (e.g. fullscreen or maximized).
1407  *
1408  * If triggered, the client will receive configure events with the
1409  * "resize" state enum value and the expected sizes. See the "resize"
1410  * enum value for more details about what is required. The client
1411  * must also acknowledge configure events using "ack_configure". After
1412  * the resize is completed, the client will receive another "configure"
1413  * event without the resize state.
1414  *
1415  * If triggered, the surface also will lose the focus of the device
1416  * (wl_pointer, wl_touch, etc) used for the resize. It is up to the
1417  * compositor to visually indicate that the resize is taking place,
1418  * such as updating a pointer cursor, during the resize. There is no
1419  * guarantee that the device focus will return when the resize is
1420  * completed.
1421  *
1422  * The edges parameter specifies how the surface should be resized,
1423  * and is one of the values of the resize_edge enum. The compositor
1424  * may use this information to update the surface position for
1425  * example when dragging the top left corner. The compositor may also
1426  * use this information to adapt its behavior, e.g. choose an
1427  * appropriate cursor image.
1428  */
1429 static inline void
xdg_toplevel_resize(struct xdg_toplevel * xdg_toplevel,struct wl_seat * seat,uint32_t serial,uint32_t edges)1430 xdg_toplevel_resize(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial, uint32_t edges)
1431 {
1432 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1433 			 XDG_TOPLEVEL_RESIZE, seat, serial, edges);
1434 }
1435 
1436 /**
1437  * @ingroup iface_xdg_toplevel
1438  *
1439  * Set a maximum size for the window.
1440  *
1441  * The client can specify a maximum size so that the compositor does
1442  * not try to configure the window beyond this size.
1443  *
1444  * The width and height arguments are in window geometry coordinates.
1445  * See xdg_surface.set_window_geometry.
1446  *
1447  * Values set in this way are double-buffered. They will get applied
1448  * on the next commit.
1449  *
1450  * The compositor can use this information to allow or disallow
1451  * different states like maximize or fullscreen and draw accurate
1452  * animations.
1453  *
1454  * Similarly, a tiling window manager may use this information to
1455  * place and resize client windows in a more effective way.
1456  *
1457  * The client should not rely on the compositor to obey the maximum
1458  * size. The compositor may decide to ignore the values set by the
1459  * client and request a larger size.
1460  *
1461  * If never set, or a value of zero in the request, means that the
1462  * client has no expected maximum size in the given dimension.
1463  * As a result, a client wishing to reset the maximum size
1464  * to an unspecified state can use zero for width and height in the
1465  * request.
1466  *
1467  * Requesting a maximum size to be smaller than the minimum size of
1468  * a surface is illegal and will result in a protocol error.
1469  *
1470  * The width and height must be greater than or equal to zero. Using
1471  * strictly negative values for width and height will result in a
1472  * protocol error.
1473  */
1474 static inline void
xdg_toplevel_set_max_size(struct xdg_toplevel * xdg_toplevel,int32_t width,int32_t height)1475 xdg_toplevel_set_max_size(struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height)
1476 {
1477 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1478 			 XDG_TOPLEVEL_SET_MAX_SIZE, width, height);
1479 }
1480 
1481 /**
1482  * @ingroup iface_xdg_toplevel
1483  *
1484  * Set a minimum size for the window.
1485  *
1486  * The client can specify a minimum size so that the compositor does
1487  * not try to configure the window below this size.
1488  *
1489  * The width and height arguments are in window geometry coordinates.
1490  * See xdg_surface.set_window_geometry.
1491  *
1492  * Values set in this way are double-buffered. They will get applied
1493  * on the next commit.
1494  *
1495  * The compositor can use this information to allow or disallow
1496  * different states like maximize or fullscreen and draw accurate
1497  * animations.
1498  *
1499  * Similarly, a tiling window manager may use this information to
1500  * place and resize client windows in a more effective way.
1501  *
1502  * The client should not rely on the compositor to obey the minimum
1503  * size. The compositor may decide to ignore the values set by the
1504  * client and request a smaller size.
1505  *
1506  * If never set, or a value of zero in the request, means that the
1507  * client has no expected minimum size in the given dimension.
1508  * As a result, a client wishing to reset the minimum size
1509  * to an unspecified state can use zero for width and height in the
1510  * request.
1511  *
1512  * Requesting a minimum size to be larger than the maximum size of
1513  * a surface is illegal and will result in a protocol error.
1514  *
1515  * The width and height must be greater than or equal to zero. Using
1516  * strictly negative values for width and height will result in a
1517  * protocol error.
1518  */
1519 static inline void
xdg_toplevel_set_min_size(struct xdg_toplevel * xdg_toplevel,int32_t width,int32_t height)1520 xdg_toplevel_set_min_size(struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height)
1521 {
1522 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1523 			 XDG_TOPLEVEL_SET_MIN_SIZE, width, height);
1524 }
1525 
1526 /**
1527  * @ingroup iface_xdg_toplevel
1528  *
1529  * Maximize the surface.
1530  *
1531  * After requesting that the surface should be maximized, the compositor
1532  * will respond by emitting a configure event. Whether this configure
1533  * actually sets the window maximized is subject to compositor policies.
1534  * The client must then update its content, drawing in the configured
1535  * state. The client must also acknowledge the configure when committing
1536  * the new content (see ack_configure).
1537  *
1538  * It is up to the compositor to decide how and where to maximize the
1539  * surface, for example which output and what region of the screen should
1540  * be used.
1541  *
1542  * If the surface was already maximized, the compositor will still emit
1543  * a configure event with the "maximized" state.
1544  *
1545  * If the surface is in a fullscreen state, this request has no direct
1546  * effect. It may alter the state the surface is returned to when
1547  * unmaximized unless overridden by the compositor.
1548  */
1549 static inline void
xdg_toplevel_set_maximized(struct xdg_toplevel * xdg_toplevel)1550 xdg_toplevel_set_maximized(struct xdg_toplevel *xdg_toplevel)
1551 {
1552 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1553 			 XDG_TOPLEVEL_SET_MAXIMIZED);
1554 }
1555 
1556 /**
1557  * @ingroup iface_xdg_toplevel
1558  *
1559  * Unmaximize the surface.
1560  *
1561  * After requesting that the surface should be unmaximized, the compositor
1562  * will respond by emitting a configure event. Whether this actually
1563  * un-maximizes the window is subject to compositor policies.
1564  * If available and applicable, the compositor will include the window
1565  * geometry dimensions the window had prior to being maximized in the
1566  * configure event. The client must then update its content, drawing it in
1567  * the configured state. The client must also acknowledge the configure
1568  * when committing the new content (see ack_configure).
1569  *
1570  * It is up to the compositor to position the surface after it was
1571  * unmaximized; usually the position the surface had before maximizing, if
1572  * applicable.
1573  *
1574  * If the surface was already not maximized, the compositor will still
1575  * emit a configure event without the "maximized" state.
1576  *
1577  * If the surface is in a fullscreen state, this request has no direct
1578  * effect. It may alter the state the surface is returned to when
1579  * unmaximized unless overridden by the compositor.
1580  */
1581 static inline void
xdg_toplevel_unset_maximized(struct xdg_toplevel * xdg_toplevel)1582 xdg_toplevel_unset_maximized(struct xdg_toplevel *xdg_toplevel)
1583 {
1584 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1585 			 XDG_TOPLEVEL_UNSET_MAXIMIZED);
1586 }
1587 
1588 /**
1589  * @ingroup iface_xdg_toplevel
1590  *
1591  * Make the surface fullscreen.
1592  *
1593  * After requesting that the surface should be fullscreened, the
1594  * compositor will respond by emitting a configure event. Whether the
1595  * client is actually put into a fullscreen state is subject to compositor
1596  * policies. The client must also acknowledge the configure when
1597  * committing the new content (see ack_configure).
1598  *
1599  * The output passed by the request indicates the client's preference as
1600  * to which display it should be set fullscreen on. If this value is NULL,
1601  * it's up to the compositor to choose which display will be used to map
1602  * this surface.
1603  *
1604  * If the surface doesn't cover the whole output, the compositor will
1605  * position the surface in the center of the output and compensate with
1606  * with border fill covering the rest of the output. The content of the
1607  * border fill is undefined, but should be assumed to be in some way that
1608  * attempts to blend into the surrounding area (e.g. solid black).
1609  *
1610  * If the fullscreened surface is not opaque, the compositor must make
1611  * sure that other screen content not part of the same surface tree (made
1612  * up of subsurfaces, popups or similarly coupled surfaces) are not
1613  * visible below the fullscreened surface.
1614  */
1615 static inline void
xdg_toplevel_set_fullscreen(struct xdg_toplevel * xdg_toplevel,struct wl_output * output)1616 xdg_toplevel_set_fullscreen(struct xdg_toplevel *xdg_toplevel, struct wl_output *output)
1617 {
1618 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1619 			 XDG_TOPLEVEL_SET_FULLSCREEN, output);
1620 }
1621 
1622 /**
1623  * @ingroup iface_xdg_toplevel
1624  *
1625  * Make the surface no longer fullscreen.
1626  *
1627  * After requesting that the surface should be unfullscreened, the
1628  * compositor will respond by emitting a configure event.
1629  * Whether this actually removes the fullscreen state of the client is
1630  * subject to compositor policies.
1631  *
1632  * Making a surface unfullscreen sets states for the surface based on the following:
1633  * * the state(s) it may have had before becoming fullscreen
1634  * * any state(s) decided by the compositor
1635  * * any state(s) requested by the client while the surface was fullscreen
1636  *
1637  * The compositor may include the previous window geometry dimensions in
1638  * the configure event, if applicable.
1639  *
1640  * The client must also acknowledge the configure when committing the new
1641  * content (see ack_configure).
1642  */
1643 static inline void
xdg_toplevel_unset_fullscreen(struct xdg_toplevel * xdg_toplevel)1644 xdg_toplevel_unset_fullscreen(struct xdg_toplevel *xdg_toplevel)
1645 {
1646 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1647 			 XDG_TOPLEVEL_UNSET_FULLSCREEN);
1648 }
1649 
1650 /**
1651  * @ingroup iface_xdg_toplevel
1652  *
1653  * Request that the compositor minimize your surface. There is no
1654  * way to know if the surface is currently minimized, nor is there
1655  * any way to unset minimization on this surface.
1656  *
1657  * If you are looking to throttle redrawing when minimized, please
1658  * instead use the wl_surface.frame event for this, as this will
1659  * also work with live previews on windows in Alt-Tab, Expose or
1660  * similar compositor features.
1661  */
1662 static inline void
xdg_toplevel_set_minimized(struct xdg_toplevel * xdg_toplevel)1663 xdg_toplevel_set_minimized(struct xdg_toplevel *xdg_toplevel)
1664 {
1665 	wl_proxy_marshal((struct wl_proxy *) xdg_toplevel,
1666 			 XDG_TOPLEVEL_SET_MINIMIZED);
1667 }
1668 
1669 #ifndef XDG_POPUP_ERROR_ENUM
1670 #define XDG_POPUP_ERROR_ENUM
1671 enum xdg_popup_error {
1672 	/**
1673 	 * tried to grab after being mapped
1674 	 */
1675 	XDG_POPUP_ERROR_INVALID_GRAB = 0,
1676 };
1677 #endif /* XDG_POPUP_ERROR_ENUM */
1678 
1679 /**
1680  * @ingroup iface_xdg_popup
1681  * @struct xdg_popup_listener
1682  */
1683 struct xdg_popup_listener {
1684 	/**
1685 	 * configure the popup surface
1686 	 *
1687 	 * This event asks the popup surface to configure itself given
1688 	 * the configuration. The configured state should not be applied
1689 	 * immediately. See xdg_surface.configure for details.
1690 	 *
1691 	 * The x and y arguments represent the position the popup was
1692 	 * placed at given the xdg_positioner rule, relative to the upper
1693 	 * left corner of the window geometry of the parent surface.
1694 	 * @param x x position relative to parent surface window geometry
1695 	 * @param y y position relative to parent surface window geometry
1696 	 * @param width window geometry width
1697 	 * @param height window geometry height
1698 	 */
1699 	void (*configure)(void *data,
1700 			  struct xdg_popup *xdg_popup,
1701 			  int32_t x,
1702 			  int32_t y,
1703 			  int32_t width,
1704 			  int32_t height);
1705 	/**
1706 	 * popup interaction is done
1707 	 *
1708 	 * The popup_done event is sent out when a popup is dismissed by
1709 	 * the compositor. The client should destroy the xdg_popup object
1710 	 * at this point.
1711 	 */
1712 	void (*popup_done)(void *data,
1713 			   struct xdg_popup *xdg_popup);
1714 };
1715 
1716 /**
1717  * @ingroup iface_xdg_popup
1718  */
1719 static inline int
xdg_popup_add_listener(struct xdg_popup * xdg_popup,const struct xdg_popup_listener * listener,void * data)1720 xdg_popup_add_listener(struct xdg_popup *xdg_popup,
1721 		       const struct xdg_popup_listener *listener, void *data)
1722 {
1723 	return wl_proxy_add_listener((struct wl_proxy *) xdg_popup,
1724 				     (void (**)(void)) listener, data);
1725 }
1726 
1727 #define XDG_POPUP_DESTROY 0
1728 #define XDG_POPUP_GRAB 1
1729 
1730 /**
1731  * @ingroup iface_xdg_popup
1732  */
1733 #define XDG_POPUP_CONFIGURE_SINCE_VERSION 1
1734 /**
1735  * @ingroup iface_xdg_popup
1736  */
1737 #define XDG_POPUP_POPUP_DONE_SINCE_VERSION 1
1738 
1739 /**
1740  * @ingroup iface_xdg_popup
1741  */
1742 #define XDG_POPUP_DESTROY_SINCE_VERSION 1
1743 /**
1744  * @ingroup iface_xdg_popup
1745  */
1746 #define XDG_POPUP_GRAB_SINCE_VERSION 1
1747 
1748 /** @ingroup iface_xdg_popup */
1749 static inline void
xdg_popup_set_user_data(struct xdg_popup * xdg_popup,void * user_data)1750 xdg_popup_set_user_data(struct xdg_popup *xdg_popup, void *user_data)
1751 {
1752 	wl_proxy_set_user_data((struct wl_proxy *) xdg_popup, user_data);
1753 }
1754 
1755 /** @ingroup iface_xdg_popup */
1756 static inline void *
xdg_popup_get_user_data(struct xdg_popup * xdg_popup)1757 xdg_popup_get_user_data(struct xdg_popup *xdg_popup)
1758 {
1759 	return wl_proxy_get_user_data((struct wl_proxy *) xdg_popup);
1760 }
1761 
1762 static inline uint32_t
xdg_popup_get_version(struct xdg_popup * xdg_popup)1763 xdg_popup_get_version(struct xdg_popup *xdg_popup)
1764 {
1765 	return wl_proxy_get_version((struct wl_proxy *) xdg_popup);
1766 }
1767 
1768 /**
1769  * @ingroup iface_xdg_popup
1770  *
1771  * This destroys the popup. Explicitly destroying the xdg_popup
1772  * object will also dismiss the popup, and unmap the surface.
1773  *
1774  * If this xdg_popup is not the "topmost" popup, a protocol error
1775  * will be sent.
1776  */
1777 static inline void
xdg_popup_destroy(struct xdg_popup * xdg_popup)1778 xdg_popup_destroy(struct xdg_popup *xdg_popup)
1779 {
1780 	wl_proxy_marshal((struct wl_proxy *) xdg_popup,
1781 			 XDG_POPUP_DESTROY);
1782 
1783 	wl_proxy_destroy((struct wl_proxy *) xdg_popup);
1784 }
1785 
1786 /**
1787  * @ingroup iface_xdg_popup
1788  *
1789  * This request makes the created popup take an explicit grab. An explicit
1790  * grab will be dismissed when the user dismisses the popup, or when the
1791  * client destroys the xdg_popup. This can be done by the user clicking
1792  * outside the surface, using the keyboard, or even locking the screen
1793  * through closing the lid or a timeout.
1794  *
1795  * If the compositor denies the grab, the popup will be immediately
1796  * dismissed.
1797  *
1798  * This request must be used in response to some sort of user action like a
1799  * button press, key press, or touch down event. The serial number of the
1800  * event should be passed as 'serial'.
1801  *
1802  * The parent of a grabbing popup must either be an xdg_toplevel surface or
1803  * another xdg_popup with an explicit grab. If the parent is another
1804  * xdg_popup it means that the popups are nested, with this popup now being
1805  * the topmost popup.
1806  *
1807  * Nested popups must be destroyed in the reverse order they were created
1808  * in, e.g. the only popup you are allowed to destroy at all times is the
1809  * topmost one.
1810  *
1811  * When compositors choose to dismiss a popup, they may dismiss every
1812  * nested grabbing popup as well. When a compositor dismisses popups, it
1813  * will follow the same dismissing order as required from the client.
1814  *
1815  * The parent of a grabbing popup must either be another xdg_popup with an
1816  * active explicit grab, or an xdg_popup or xdg_toplevel, if there are no
1817  * explicit grabs already taken.
1818  *
1819  * If the topmost grabbing popup is destroyed, the grab will be returned to
1820  * the parent of the popup, if that parent previously had an explicit grab.
1821  *
1822  * If the parent is a grabbing popup which has already been dismissed, this
1823  * popup will be immediately dismissed. If the parent is a popup that did
1824  * not take an explicit grab, an error will be raised.
1825  *
1826  * During a popup grab, the client owning the grab will receive pointer
1827  * and touch events for all their surfaces as normal (similar to an
1828  * "owner-events" grab in X11 parlance), while the top most grabbing popup
1829  * will always have keyboard focus.
1830  */
1831 static inline void
xdg_popup_grab(struct xdg_popup * xdg_popup,struct wl_seat * seat,uint32_t serial)1832 xdg_popup_grab(struct xdg_popup *xdg_popup, struct wl_seat *seat, uint32_t serial)
1833 {
1834 	wl_proxy_marshal((struct wl_proxy *) xdg_popup,
1835 			 XDG_POPUP_GRAB, seat, serial);
1836 }
1837 
1838 #ifdef  __cplusplus
1839 }
1840 #endif
1841 
1842 #endif
1843