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