• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SCANNER TEST */
2 
3 #ifndef WAYLAND_CLIENT_PROTOCOL_H
4 #define WAYLAND_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_wayland The wayland protocol
16  * @section page_ifaces_wayland Interfaces
17  * - @subpage page_iface_wl_display - core global object
18  * - @subpage page_iface_wl_registry - global registry object
19  * - @subpage page_iface_wl_callback - callback object
20  * - @subpage page_iface_wl_compositor - the compositor singleton
21  * - @subpage page_iface_wl_shm_pool - a shared memory pool
22  * - @subpage page_iface_wl_shm - shared memory support
23  * - @subpage page_iface_wl_buffer - content for a wl_surface
24  * - @subpage page_iface_wl_data_offer - offer to transfer data
25  * - @subpage page_iface_wl_data_source - offer to transfer data
26  * - @subpage page_iface_wl_data_device - data transfer device
27  * - @subpage page_iface_wl_data_device_manager - data transfer interface
28  * - @subpage page_iface_wl_shell - create desktop-style surfaces
29  * - @subpage page_iface_wl_shell_surface - desktop-style metadata interface
30  * - @subpage page_iface_wl_surface - an onscreen surface
31  * - @subpage page_iface_wl_seat - group of input devices
32  * - @subpage page_iface_wl_pointer - pointer input device
33  * - @subpage page_iface_wl_keyboard - keyboard input device
34  * - @subpage page_iface_wl_touch - touchscreen input device
35  * - @subpage page_iface_wl_output - compositor output region
36  * - @subpage page_iface_wl_region - region interface
37  * - @subpage page_iface_wl_subcompositor - sub-surface compositing
38  * - @subpage page_iface_wl_subsurface - sub-surface interface to a wl_surface
39  * @section page_copyright_wayland Copyright
40  * <pre>
41  *
42  * Copyright © 2008-2011 Kristian Høgsberg
43  * Copyright © 2010-2011 Intel Corporation
44  * Copyright © 2012-2013 Collabora, Ltd.
45  *
46  * Permission is hereby granted, free of charge, to any person
47  * obtaining a copy of this software and associated documentation files
48  * (the "Software"), to deal in the Software without restriction,
49  * including without limitation the rights to use, copy, modify, merge,
50  * publish, distribute, sublicense, and/or sell copies of the Software,
51  * and to permit persons to whom the Software is furnished to do so,
52  * subject to the following conditions:
53  *
54  * The above copyright notice and this permission notice (including the
55  * next paragraph) shall be included in all copies or substantial
56  * portions of the Software.
57  *
58  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
59  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
60  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
61  * NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
62  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
63  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
64  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
65  * SOFTWARE.
66  * </pre>
67  */
68 struct wl_buffer;
69 struct wl_callback;
70 struct wl_compositor;
71 struct wl_data_device;
72 struct wl_data_device_manager;
73 struct wl_data_offer;
74 struct wl_data_source;
75 struct wl_display;
76 struct wl_keyboard;
77 struct wl_output;
78 struct wl_pointer;
79 struct wl_region;
80 struct wl_registry;
81 struct wl_seat;
82 struct wl_shell;
83 struct wl_shell_surface;
84 struct wl_shm;
85 struct wl_shm_pool;
86 struct wl_subcompositor;
87 struct wl_subsurface;
88 struct wl_surface;
89 struct wl_touch;
90 
91 #ifndef WL_DISPLAY_INTERFACE
92 #define WL_DISPLAY_INTERFACE
93 /**
94  * @page page_iface_wl_display wl_display
95  * @section page_iface_wl_display_desc Description
96  *
97  * The core global object.  This is a special singleton object.  It
98  * is used for internal Wayland protocol features.
99  * @section page_iface_wl_display_api API
100  * See @ref iface_wl_display.
101  */
102 /**
103  * @defgroup iface_wl_display The wl_display interface
104  *
105  * The core global object.  This is a special singleton object.  It
106  * is used for internal Wayland protocol features.
107  */
108 extern const struct wl_interface wl_display_interface;
109 #endif
110 #ifndef WL_REGISTRY_INTERFACE
111 #define WL_REGISTRY_INTERFACE
112 /**
113  * @page page_iface_wl_registry wl_registry
114  * @section page_iface_wl_registry_desc Description
115  *
116  * The singleton global registry object.  The server has a number of
117  * global objects that are available to all clients.  These objects
118  * typically represent an actual object in the server (for example,
119  * an input device) or they are singleton objects that provide
120  * extension functionality.
121  *
122  * When a client creates a registry object, the registry object
123  * will emit a global event for each global currently in the
124  * registry.  Globals come and go as a result of device or
125  * monitor hotplugs, reconfiguration or other events, and the
126  * registry will send out global and global_remove events to
127  * keep the client up to date with the changes.  To mark the end
128  * of the initial burst of events, the client can use the
129  * wl_display.sync request immediately after calling
130  * wl_display.get_registry.
131  *
132  * A client can bind to a global object by using the bind
133  * request.  This creates a client-side handle that lets the object
134  * emit events to the client and lets the client invoke requests on
135  * the object.
136  * @section page_iface_wl_registry_api API
137  * See @ref iface_wl_registry.
138  */
139 /**
140  * @defgroup iface_wl_registry The wl_registry interface
141  *
142  * The singleton global registry object.  The server has a number of
143  * global objects that are available to all clients.  These objects
144  * typically represent an actual object in the server (for example,
145  * an input device) or they are singleton objects that provide
146  * extension functionality.
147  *
148  * When a client creates a registry object, the registry object
149  * will emit a global event for each global currently in the
150  * registry.  Globals come and go as a result of device or
151  * monitor hotplugs, reconfiguration or other events, and the
152  * registry will send out global and global_remove events to
153  * keep the client up to date with the changes.  To mark the end
154  * of the initial burst of events, the client can use the
155  * wl_display.sync request immediately after calling
156  * wl_display.get_registry.
157  *
158  * A client can bind to a global object by using the bind
159  * request.  This creates a client-side handle that lets the object
160  * emit events to the client and lets the client invoke requests on
161  * the object.
162  */
163 extern const struct wl_interface wl_registry_interface;
164 #endif
165 #ifndef WL_CALLBACK_INTERFACE
166 #define WL_CALLBACK_INTERFACE
167 /**
168  * @page page_iface_wl_callback wl_callback
169  * @section page_iface_wl_callback_desc Description
170  *
171  * Clients can handle the 'done' event to get notified when
172  * the related request is done.
173  * @section page_iface_wl_callback_api API
174  * See @ref iface_wl_callback.
175  */
176 /**
177  * @defgroup iface_wl_callback The wl_callback interface
178  *
179  * Clients can handle the 'done' event to get notified when
180  * the related request is done.
181  */
182 extern const struct wl_interface wl_callback_interface;
183 #endif
184 #ifndef WL_COMPOSITOR_INTERFACE
185 #define WL_COMPOSITOR_INTERFACE
186 /**
187  * @page page_iface_wl_compositor wl_compositor
188  * @section page_iface_wl_compositor_desc Description
189  *
190  * A compositor.  This object is a singleton global.  The
191  * compositor is in charge of combining the contents of multiple
192  * surfaces into one displayable output.
193  * @section page_iface_wl_compositor_api API
194  * See @ref iface_wl_compositor.
195  */
196 /**
197  * @defgroup iface_wl_compositor The wl_compositor interface
198  *
199  * A compositor.  This object is a singleton global.  The
200  * compositor is in charge of combining the contents of multiple
201  * surfaces into one displayable output.
202  */
203 extern const struct wl_interface wl_compositor_interface;
204 #endif
205 #ifndef WL_SHM_POOL_INTERFACE
206 #define WL_SHM_POOL_INTERFACE
207 /**
208  * @page page_iface_wl_shm_pool wl_shm_pool
209  * @section page_iface_wl_shm_pool_desc Description
210  *
211  * The wl_shm_pool object encapsulates a piece of memory shared
212  * between the compositor and client.  Through the wl_shm_pool
213  * object, the client can allocate shared memory wl_buffer objects.
214  * All objects created through the same pool share the same
215  * underlying mapped memory. Reusing the mapped memory avoids the
216  * setup/teardown overhead and is useful when interactively resizing
217  * a surface or for many small buffers.
218  * @section page_iface_wl_shm_pool_api API
219  * See @ref iface_wl_shm_pool.
220  */
221 /**
222  * @defgroup iface_wl_shm_pool The wl_shm_pool interface
223  *
224  * The wl_shm_pool object encapsulates a piece of memory shared
225  * between the compositor and client.  Through the wl_shm_pool
226  * object, the client can allocate shared memory wl_buffer objects.
227  * All objects created through the same pool share the same
228  * underlying mapped memory. Reusing the mapped memory avoids the
229  * setup/teardown overhead and is useful when interactively resizing
230  * a surface or for many small buffers.
231  */
232 extern const struct wl_interface wl_shm_pool_interface;
233 #endif
234 #ifndef WL_SHM_INTERFACE
235 #define WL_SHM_INTERFACE
236 /**
237  * @page page_iface_wl_shm wl_shm
238  * @section page_iface_wl_shm_desc Description
239  *
240  * A singleton global object that provides support for shared
241  * memory.
242  *
243  * Clients can create wl_shm_pool objects using the create_pool
244  * request.
245  *
246  * At connection setup time, the wl_shm object emits one or more
247  * format events to inform clients about the valid pixel formats
248  * that can be used for buffers.
249  * @section page_iface_wl_shm_api API
250  * See @ref iface_wl_shm.
251  */
252 /**
253  * @defgroup iface_wl_shm The wl_shm interface
254  *
255  * A singleton global object that provides support for shared
256  * memory.
257  *
258  * Clients can create wl_shm_pool objects using the create_pool
259  * request.
260  *
261  * At connection setup time, the wl_shm object emits one or more
262  * format events to inform clients about the valid pixel formats
263  * that can be used for buffers.
264  */
265 extern const struct wl_interface wl_shm_interface;
266 #endif
267 #ifndef WL_BUFFER_INTERFACE
268 #define WL_BUFFER_INTERFACE
269 /**
270  * @page page_iface_wl_buffer wl_buffer
271  * @section page_iface_wl_buffer_desc Description
272  *
273  * A buffer provides the content for a wl_surface. Buffers are
274  * created through factory interfaces such as wl_drm, wl_shm or
275  * similar. It has a width and a height and can be attached to a
276  * wl_surface, but the mechanism by which a client provides and
277  * updates the contents is defined by the buffer factory interface.
278  * @section page_iface_wl_buffer_api API
279  * See @ref iface_wl_buffer.
280  */
281 /**
282  * @defgroup iface_wl_buffer The wl_buffer interface
283  *
284  * A buffer provides the content for a wl_surface. Buffers are
285  * created through factory interfaces such as wl_drm, wl_shm or
286  * similar. It has a width and a height and can be attached to a
287  * wl_surface, but the mechanism by which a client provides and
288  * updates the contents is defined by the buffer factory interface.
289  */
290 extern const struct wl_interface wl_buffer_interface;
291 #endif
292 #ifndef WL_DATA_OFFER_INTERFACE
293 #define WL_DATA_OFFER_INTERFACE
294 /**
295  * @page page_iface_wl_data_offer wl_data_offer
296  * @section page_iface_wl_data_offer_desc Description
297  *
298  * A wl_data_offer represents a piece of data offered for transfer
299  * by another client (the source client).  It is used by the
300  * copy-and-paste and drag-and-drop mechanisms.  The offer
301  * describes the different mime types that the data can be
302  * converted to and provides the mechanism for transferring the
303  * data directly from the source client.
304  * @section page_iface_wl_data_offer_api API
305  * See @ref iface_wl_data_offer.
306  */
307 /**
308  * @defgroup iface_wl_data_offer The wl_data_offer interface
309  *
310  * A wl_data_offer represents a piece of data offered for transfer
311  * by another client (the source client).  It is used by the
312  * copy-and-paste and drag-and-drop mechanisms.  The offer
313  * describes the different mime types that the data can be
314  * converted to and provides the mechanism for transferring the
315  * data directly from the source client.
316  */
317 extern const struct wl_interface wl_data_offer_interface;
318 #endif
319 #ifndef WL_DATA_SOURCE_INTERFACE
320 #define WL_DATA_SOURCE_INTERFACE
321 /**
322  * @page page_iface_wl_data_source wl_data_source
323  * @section page_iface_wl_data_source_desc Description
324  *
325  * The wl_data_source object is the source side of a wl_data_offer.
326  * It is created by the source client in a data transfer and
327  * provides a way to describe the offered data and a way to respond
328  * to requests to transfer the data.
329  * @section page_iface_wl_data_source_api API
330  * See @ref iface_wl_data_source.
331  */
332 /**
333  * @defgroup iface_wl_data_source The wl_data_source interface
334  *
335  * The wl_data_source object is the source side of a wl_data_offer.
336  * It is created by the source client in a data transfer and
337  * provides a way to describe the offered data and a way to respond
338  * to requests to transfer the data.
339  */
340 extern const struct wl_interface wl_data_source_interface;
341 #endif
342 #ifndef WL_DATA_DEVICE_INTERFACE
343 #define WL_DATA_DEVICE_INTERFACE
344 /**
345  * @page page_iface_wl_data_device wl_data_device
346  * @section page_iface_wl_data_device_desc Description
347  *
348  * There is one wl_data_device per seat which can be obtained
349  * from the global wl_data_device_manager singleton.
350  *
351  * A wl_data_device provides access to inter-client data transfer
352  * mechanisms such as copy-and-paste and drag-and-drop.
353  * @section page_iface_wl_data_device_api API
354  * See @ref iface_wl_data_device.
355  */
356 /**
357  * @defgroup iface_wl_data_device The wl_data_device interface
358  *
359  * There is one wl_data_device per seat which can be obtained
360  * from the global wl_data_device_manager singleton.
361  *
362  * A wl_data_device provides access to inter-client data transfer
363  * mechanisms such as copy-and-paste and drag-and-drop.
364  */
365 extern const struct wl_interface wl_data_device_interface;
366 #endif
367 #ifndef WL_DATA_DEVICE_MANAGER_INTERFACE
368 #define WL_DATA_DEVICE_MANAGER_INTERFACE
369 /**
370  * @page page_iface_wl_data_device_manager wl_data_device_manager
371  * @section page_iface_wl_data_device_manager_desc Description
372  *
373  * The wl_data_device_manager is a singleton global object that
374  * provides access to inter-client data transfer mechanisms such as
375  * copy-and-paste and drag-and-drop.  These mechanisms are tied to
376  * a wl_seat and this interface lets a client get a wl_data_device
377  * corresponding to a wl_seat.
378  *
379  * Depending on the version bound, the objects created from the bound
380  * wl_data_device_manager object will have different requirements for
381  * functioning properly. See wl_data_source.set_actions,
382  * wl_data_offer.accept and wl_data_offer.finish for details.
383  * @section page_iface_wl_data_device_manager_api API
384  * See @ref iface_wl_data_device_manager.
385  */
386 /**
387  * @defgroup iface_wl_data_device_manager The wl_data_device_manager interface
388  *
389  * The wl_data_device_manager is a singleton global object that
390  * provides access to inter-client data transfer mechanisms such as
391  * copy-and-paste and drag-and-drop.  These mechanisms are tied to
392  * a wl_seat and this interface lets a client get a wl_data_device
393  * corresponding to a wl_seat.
394  *
395  * Depending on the version bound, the objects created from the bound
396  * wl_data_device_manager object will have different requirements for
397  * functioning properly. See wl_data_source.set_actions,
398  * wl_data_offer.accept and wl_data_offer.finish for details.
399  */
400 extern const struct wl_interface wl_data_device_manager_interface;
401 #endif
402 #ifndef WL_SHELL_INTERFACE
403 #define WL_SHELL_INTERFACE
404 /**
405  * @page page_iface_wl_shell wl_shell
406  * @section page_iface_wl_shell_desc Description
407  *
408  * This interface is implemented by servers that provide
409  * desktop-style user interfaces.
410  *
411  * It allows clients to associate a wl_shell_surface with
412  * a basic surface.
413  * @section page_iface_wl_shell_api API
414  * See @ref iface_wl_shell.
415  */
416 /**
417  * @defgroup iface_wl_shell The wl_shell interface
418  *
419  * This interface is implemented by servers that provide
420  * desktop-style user interfaces.
421  *
422  * It allows clients to associate a wl_shell_surface with
423  * a basic surface.
424  */
425 extern const struct wl_interface wl_shell_interface;
426 #endif
427 #ifndef WL_SHELL_SURFACE_INTERFACE
428 #define WL_SHELL_SURFACE_INTERFACE
429 /**
430  * @page page_iface_wl_shell_surface wl_shell_surface
431  * @section page_iface_wl_shell_surface_desc Description
432  *
433  * An interface that may be implemented by a wl_surface, for
434  * implementations that provide a desktop-style user interface.
435  *
436  * It provides requests to treat surfaces like toplevel, fullscreen
437  * or popup windows, move, resize or maximize them, associate
438  * metadata like title and class, etc.
439  *
440  * On the server side the object is automatically destroyed when
441  * the related wl_surface is destroyed. On the client side,
442  * wl_shell_surface_destroy() must be called before destroying
443  * the wl_surface object.
444  * @section page_iface_wl_shell_surface_api API
445  * See @ref iface_wl_shell_surface.
446  */
447 /**
448  * @defgroup iface_wl_shell_surface The wl_shell_surface interface
449  *
450  * An interface that may be implemented by a wl_surface, for
451  * implementations that provide a desktop-style user interface.
452  *
453  * It provides requests to treat surfaces like toplevel, fullscreen
454  * or popup windows, move, resize or maximize them, associate
455  * metadata like title and class, etc.
456  *
457  * On the server side the object is automatically destroyed when
458  * the related wl_surface is destroyed. On the client side,
459  * wl_shell_surface_destroy() must be called before destroying
460  * the wl_surface object.
461  */
462 extern const struct wl_interface wl_shell_surface_interface;
463 #endif
464 #ifndef WL_SURFACE_INTERFACE
465 #define WL_SURFACE_INTERFACE
466 /**
467  * @page page_iface_wl_surface wl_surface
468  * @section page_iface_wl_surface_desc Description
469  *
470  * A surface is a rectangular area that is displayed on the screen.
471  * It has a location, size and pixel contents.
472  *
473  * The size of a surface (and relative positions on it) is described
474  * in surface-local coordinates, which may differ from the buffer
475  * coordinates of the pixel content, in case a buffer_transform
476  * or a buffer_scale is used.
477  *
478  * A surface without a "role" is fairly useless: a compositor does
479  * not know where, when or how to present it. The role is the
480  * purpose of a wl_surface. Examples of roles are a cursor for a
481  * pointer (as set by wl_pointer.set_cursor), a drag icon
482  * (wl_data_device.start_drag), a sub-surface
483  * (wl_subcompositor.get_subsurface), and a window as defined by a
484  * shell protocol (e.g. wl_shell.get_shell_surface).
485  *
486  * A surface can have only one role at a time. Initially a
487  * wl_surface does not have a role. Once a wl_surface is given a
488  * role, it is set permanently for the whole lifetime of the
489  * wl_surface object. Giving the current role again is allowed,
490  * unless explicitly forbidden by the relevant interface
491  * specification.
492  *
493  * Surface roles are given by requests in other interfaces such as
494  * wl_pointer.set_cursor. The request should explicitly mention
495  * that this request gives a role to a wl_surface. Often, this
496  * request also creates a new protocol object that represents the
497  * role and adds additional functionality to wl_surface. When a
498  * client wants to destroy a wl_surface, they must destroy this 'role
499  * object' before the wl_surface.
500  *
501  * Destroying the role object does not remove the role from the
502  * wl_surface, but it may stop the wl_surface from "playing the role".
503  * For instance, if a wl_subsurface object is destroyed, the wl_surface
504  * it was created for will be unmapped and forget its position and
505  * z-order. It is allowed to create a wl_subsurface for the same
506  * wl_surface again, but it is not allowed to use the wl_surface as
507  * a cursor (cursor is a different role than sub-surface, and role
508  * switching is not allowed).
509  * @section page_iface_wl_surface_api API
510  * See @ref iface_wl_surface.
511  */
512 /**
513  * @defgroup iface_wl_surface The wl_surface interface
514  *
515  * A surface is a rectangular area that is displayed on the screen.
516  * It has a location, size and pixel contents.
517  *
518  * The size of a surface (and relative positions on it) is described
519  * in surface-local coordinates, which may differ from the buffer
520  * coordinates of the pixel content, in case a buffer_transform
521  * or a buffer_scale is used.
522  *
523  * A surface without a "role" is fairly useless: a compositor does
524  * not know where, when or how to present it. The role is the
525  * purpose of a wl_surface. Examples of roles are a cursor for a
526  * pointer (as set by wl_pointer.set_cursor), a drag icon
527  * (wl_data_device.start_drag), a sub-surface
528  * (wl_subcompositor.get_subsurface), and a window as defined by a
529  * shell protocol (e.g. wl_shell.get_shell_surface).
530  *
531  * A surface can have only one role at a time. Initially a
532  * wl_surface does not have a role. Once a wl_surface is given a
533  * role, it is set permanently for the whole lifetime of the
534  * wl_surface object. Giving the current role again is allowed,
535  * unless explicitly forbidden by the relevant interface
536  * specification.
537  *
538  * Surface roles are given by requests in other interfaces such as
539  * wl_pointer.set_cursor. The request should explicitly mention
540  * that this request gives a role to a wl_surface. Often, this
541  * request also creates a new protocol object that represents the
542  * role and adds additional functionality to wl_surface. When a
543  * client wants to destroy a wl_surface, they must destroy this 'role
544  * object' before the wl_surface.
545  *
546  * Destroying the role object does not remove the role from the
547  * wl_surface, but it may stop the wl_surface from "playing the role".
548  * For instance, if a wl_subsurface object is destroyed, the wl_surface
549  * it was created for will be unmapped and forget its position and
550  * z-order. It is allowed to create a wl_subsurface for the same
551  * wl_surface again, but it is not allowed to use the wl_surface as
552  * a cursor (cursor is a different role than sub-surface, and role
553  * switching is not allowed).
554  */
555 extern const struct wl_interface wl_surface_interface;
556 #endif
557 #ifndef WL_SEAT_INTERFACE
558 #define WL_SEAT_INTERFACE
559 /**
560  * @page page_iface_wl_seat wl_seat
561  * @section page_iface_wl_seat_desc Description
562  *
563  * A seat is a group of keyboards, pointer and touch devices. This
564  * object is published as a global during start up, or when such a
565  * device is hot plugged.  A seat typically has a pointer and
566  * maintains a keyboard focus and a pointer focus.
567  * @section page_iface_wl_seat_api API
568  * See @ref iface_wl_seat.
569  */
570 /**
571  * @defgroup iface_wl_seat The wl_seat interface
572  *
573  * A seat is a group of keyboards, pointer and touch devices. This
574  * object is published as a global during start up, or when such a
575  * device is hot plugged.  A seat typically has a pointer and
576  * maintains a keyboard focus and a pointer focus.
577  */
578 extern const struct wl_interface wl_seat_interface;
579 #endif
580 #ifndef WL_POINTER_INTERFACE
581 #define WL_POINTER_INTERFACE
582 /**
583  * @page page_iface_wl_pointer wl_pointer
584  * @section page_iface_wl_pointer_desc Description
585  *
586  * The wl_pointer interface represents one or more input devices,
587  * such as mice, which control the pointer location and pointer_focus
588  * of a seat.
589  *
590  * The wl_pointer interface generates motion, enter and leave
591  * events for the surfaces that the pointer is located over,
592  * and button and axis events for button presses, button releases
593  * and scrolling.
594  * @section page_iface_wl_pointer_api API
595  * See @ref iface_wl_pointer.
596  */
597 /**
598  * @defgroup iface_wl_pointer The wl_pointer interface
599  *
600  * The wl_pointer interface represents one or more input devices,
601  * such as mice, which control the pointer location and pointer_focus
602  * of a seat.
603  *
604  * The wl_pointer interface generates motion, enter and leave
605  * events for the surfaces that the pointer is located over,
606  * and button and axis events for button presses, button releases
607  * and scrolling.
608  */
609 extern const struct wl_interface wl_pointer_interface;
610 #endif
611 #ifndef WL_KEYBOARD_INTERFACE
612 #define WL_KEYBOARD_INTERFACE
613 /**
614  * @page page_iface_wl_keyboard wl_keyboard
615  * @section page_iface_wl_keyboard_desc Description
616  *
617  * The wl_keyboard interface represents one or more keyboards
618  * associated with a seat.
619  * @section page_iface_wl_keyboard_api API
620  * See @ref iface_wl_keyboard.
621  */
622 /**
623  * @defgroup iface_wl_keyboard The wl_keyboard interface
624  *
625  * The wl_keyboard interface represents one or more keyboards
626  * associated with a seat.
627  */
628 extern const struct wl_interface wl_keyboard_interface;
629 #endif
630 #ifndef WL_TOUCH_INTERFACE
631 #define WL_TOUCH_INTERFACE
632 /**
633  * @page page_iface_wl_touch wl_touch
634  * @section page_iface_wl_touch_desc Description
635  *
636  * The wl_touch interface represents a touchscreen
637  * associated with a seat.
638  *
639  * Touch interactions can consist of one or more contacts.
640  * For each contact, a series of events is generated, starting
641  * with a down event, followed by zero or more motion events,
642  * and ending with an up event. Events relating to the same
643  * contact point can be identified by the ID of the sequence.
644  * @section page_iface_wl_touch_api API
645  * See @ref iface_wl_touch.
646  */
647 /**
648  * @defgroup iface_wl_touch The wl_touch interface
649  *
650  * The wl_touch interface represents a touchscreen
651  * associated with a seat.
652  *
653  * Touch interactions can consist of one or more contacts.
654  * For each contact, a series of events is generated, starting
655  * with a down event, followed by zero or more motion events,
656  * and ending with an up event. Events relating to the same
657  * contact point can be identified by the ID of the sequence.
658  */
659 extern const struct wl_interface wl_touch_interface;
660 #endif
661 #ifndef WL_OUTPUT_INTERFACE
662 #define WL_OUTPUT_INTERFACE
663 /**
664  * @page page_iface_wl_output wl_output
665  * @section page_iface_wl_output_desc Description
666  *
667  * An output describes part of the compositor geometry.  The
668  * compositor works in the 'compositor coordinate system' and an
669  * output corresponds to a rectangular area in that space that is
670  * actually visible.  This typically corresponds to a monitor that
671  * displays part of the compositor space.  This object is published
672  * as global during start up, or when a monitor is hotplugged.
673  * @section page_iface_wl_output_api API
674  * See @ref iface_wl_output.
675  */
676 /**
677  * @defgroup iface_wl_output The wl_output interface
678  *
679  * An output describes part of the compositor geometry.  The
680  * compositor works in the 'compositor coordinate system' and an
681  * output corresponds to a rectangular area in that space that is
682  * actually visible.  This typically corresponds to a monitor that
683  * displays part of the compositor space.  This object is published
684  * as global during start up, or when a monitor is hotplugged.
685  */
686 extern const struct wl_interface wl_output_interface;
687 #endif
688 #ifndef WL_REGION_INTERFACE
689 #define WL_REGION_INTERFACE
690 /**
691  * @page page_iface_wl_region wl_region
692  * @section page_iface_wl_region_desc Description
693  *
694  * A region object describes an area.
695  *
696  * Region objects are used to describe the opaque and input
697  * regions of a surface.
698  * @section page_iface_wl_region_api API
699  * See @ref iface_wl_region.
700  */
701 /**
702  * @defgroup iface_wl_region The wl_region interface
703  *
704  * A region object describes an area.
705  *
706  * Region objects are used to describe the opaque and input
707  * regions of a surface.
708  */
709 extern const struct wl_interface wl_region_interface;
710 #endif
711 #ifndef WL_SUBCOMPOSITOR_INTERFACE
712 #define WL_SUBCOMPOSITOR_INTERFACE
713 /**
714  * @page page_iface_wl_subcompositor wl_subcompositor
715  * @section page_iface_wl_subcompositor_desc Description
716  *
717  * The global interface exposing sub-surface compositing capabilities.
718  * A wl_surface, that has sub-surfaces associated, is called the
719  * parent surface. Sub-surfaces can be arbitrarily nested and create
720  * a tree of sub-surfaces.
721  *
722  * The root surface in a tree of sub-surfaces is the main
723  * surface. The main surface cannot be a sub-surface, because
724  * sub-surfaces must always have a parent.
725  *
726  * A main surface with its sub-surfaces forms a (compound) window.
727  * For window management purposes, this set of wl_surface objects is
728  * to be considered as a single window, and it should also behave as
729  * such.
730  *
731  * The aim of sub-surfaces is to offload some of the compositing work
732  * within a window from clients to the compositor. A prime example is
733  * a video player with decorations and video in separate wl_surface
734  * objects. This should allow the compositor to pass YUV video buffer
735  * processing to dedicated overlay hardware when possible.
736  * @section page_iface_wl_subcompositor_api API
737  * See @ref iface_wl_subcompositor.
738  */
739 /**
740  * @defgroup iface_wl_subcompositor The wl_subcompositor interface
741  *
742  * The global interface exposing sub-surface compositing capabilities.
743  * A wl_surface, that has sub-surfaces associated, is called the
744  * parent surface. Sub-surfaces can be arbitrarily nested and create
745  * a tree of sub-surfaces.
746  *
747  * The root surface in a tree of sub-surfaces is the main
748  * surface. The main surface cannot be a sub-surface, because
749  * sub-surfaces must always have a parent.
750  *
751  * A main surface with its sub-surfaces forms a (compound) window.
752  * For window management purposes, this set of wl_surface objects is
753  * to be considered as a single window, and it should also behave as
754  * such.
755  *
756  * The aim of sub-surfaces is to offload some of the compositing work
757  * within a window from clients to the compositor. A prime example is
758  * a video player with decorations and video in separate wl_surface
759  * objects. This should allow the compositor to pass YUV video buffer
760  * processing to dedicated overlay hardware when possible.
761  */
762 extern const struct wl_interface wl_subcompositor_interface;
763 #endif
764 #ifndef WL_SUBSURFACE_INTERFACE
765 #define WL_SUBSURFACE_INTERFACE
766 /**
767  * @page page_iface_wl_subsurface wl_subsurface
768  * @section page_iface_wl_subsurface_desc Description
769  *
770  * An additional interface to a wl_surface object, which has been
771  * made a sub-surface. A sub-surface has one parent surface. A
772  * sub-surface's size and position are not limited to that of the parent.
773  * Particularly, a sub-surface is not automatically clipped to its
774  * parent's area.
775  *
776  * A sub-surface becomes mapped, when a non-NULL wl_buffer is applied
777  * and the parent surface is mapped. The order of which one happens
778  * first is irrelevant. A sub-surface is hidden if the parent becomes
779  * hidden, or if a NULL wl_buffer is applied. These rules apply
780  * recursively through the tree of surfaces.
781  *
782  * The behaviour of a wl_surface.commit request on a sub-surface
783  * depends on the sub-surface's mode. The possible modes are
784  * synchronized and desynchronized, see methods
785  * wl_subsurface.set_sync and wl_subsurface.set_desync. Synchronized
786  * mode caches the wl_surface state to be applied when the parent's
787  * state gets applied, and desynchronized mode applies the pending
788  * wl_surface state directly. A sub-surface is initially in the
789  * synchronized mode.
790  *
791  * Sub-surfaces have also other kind of state, which is managed by
792  * wl_subsurface requests, as opposed to wl_surface requests. This
793  * state includes the sub-surface position relative to the parent
794  * surface (wl_subsurface.set_position), and the stacking order of
795  * the parent and its sub-surfaces (wl_subsurface.place_above and
796  * .place_below). This state is applied when the parent surface's
797  * wl_surface state is applied, regardless of the sub-surface's mode.
798  * As the exception, set_sync and set_desync are effective immediately.
799  *
800  * The main surface can be thought to be always in desynchronized mode,
801  * since it does not have a parent in the sub-surfaces sense.
802  *
803  * Even if a sub-surface is in desynchronized mode, it will behave as
804  * in synchronized mode, if its parent surface behaves as in
805  * synchronized mode. This rule is applied recursively throughout the
806  * tree of surfaces. This means, that one can set a sub-surface into
807  * synchronized mode, and then assume that all its child and grand-child
808  * sub-surfaces are synchronized, too, without explicitly setting them.
809  *
810  * If the wl_surface associated with the wl_subsurface is destroyed, the
811  * wl_subsurface object becomes inert. Note, that destroying either object
812  * takes effect immediately. If you need to synchronize the removal
813  * of a sub-surface to the parent surface update, unmap the sub-surface
814  * first by attaching a NULL wl_buffer, update parent, and then destroy
815  * the sub-surface.
816  *
817  * If the parent wl_surface object is destroyed, the sub-surface is
818  * unmapped.
819  * @section page_iface_wl_subsurface_api API
820  * See @ref iface_wl_subsurface.
821  */
822 /**
823  * @defgroup iface_wl_subsurface The wl_subsurface interface
824  *
825  * An additional interface to a wl_surface object, which has been
826  * made a sub-surface. A sub-surface has one parent surface. A
827  * sub-surface's size and position are not limited to that of the parent.
828  * Particularly, a sub-surface is not automatically clipped to its
829  * parent's area.
830  *
831  * A sub-surface becomes mapped, when a non-NULL wl_buffer is applied
832  * and the parent surface is mapped. The order of which one happens
833  * first is irrelevant. A sub-surface is hidden if the parent becomes
834  * hidden, or if a NULL wl_buffer is applied. These rules apply
835  * recursively through the tree of surfaces.
836  *
837  * The behaviour of a wl_surface.commit request on a sub-surface
838  * depends on the sub-surface's mode. The possible modes are
839  * synchronized and desynchronized, see methods
840  * wl_subsurface.set_sync and wl_subsurface.set_desync. Synchronized
841  * mode caches the wl_surface state to be applied when the parent's
842  * state gets applied, and desynchronized mode applies the pending
843  * wl_surface state directly. A sub-surface is initially in the
844  * synchronized mode.
845  *
846  * Sub-surfaces have also other kind of state, which is managed by
847  * wl_subsurface requests, as opposed to wl_surface requests. This
848  * state includes the sub-surface position relative to the parent
849  * surface (wl_subsurface.set_position), and the stacking order of
850  * the parent and its sub-surfaces (wl_subsurface.place_above and
851  * .place_below). This state is applied when the parent surface's
852  * wl_surface state is applied, regardless of the sub-surface's mode.
853  * As the exception, set_sync and set_desync are effective immediately.
854  *
855  * The main surface can be thought to be always in desynchronized mode,
856  * since it does not have a parent in the sub-surfaces sense.
857  *
858  * Even if a sub-surface is in desynchronized mode, it will behave as
859  * in synchronized mode, if its parent surface behaves as in
860  * synchronized mode. This rule is applied recursively throughout the
861  * tree of surfaces. This means, that one can set a sub-surface into
862  * synchronized mode, and then assume that all its child and grand-child
863  * sub-surfaces are synchronized, too, without explicitly setting them.
864  *
865  * If the wl_surface associated with the wl_subsurface is destroyed, the
866  * wl_subsurface object becomes inert. Note, that destroying either object
867  * takes effect immediately. If you need to synchronize the removal
868  * of a sub-surface to the parent surface update, unmap the sub-surface
869  * first by attaching a NULL wl_buffer, update parent, and then destroy
870  * the sub-surface.
871  *
872  * If the parent wl_surface object is destroyed, the sub-surface is
873  * unmapped.
874  */
875 extern const struct wl_interface wl_subsurface_interface;
876 #endif
877 
878 #ifndef WL_DISPLAY_ERROR_ENUM
879 #define WL_DISPLAY_ERROR_ENUM
880 /**
881  * @ingroup iface_wl_display
882  * global error values
883  *
884  * These errors are global and can be emitted in response to any
885  * server request.
886  */
887 enum wl_display_error {
888 	/**
889 	 * server couldn't find object
890 	 */
891 	WL_DISPLAY_ERROR_INVALID_OBJECT = 0,
892 	/**
893 	 * method doesn't exist on the specified interface
894 	 */
895 	WL_DISPLAY_ERROR_INVALID_METHOD = 1,
896 	/**
897 	 * server is out of memory
898 	 */
899 	WL_DISPLAY_ERROR_NO_MEMORY = 2,
900 };
901 #endif /* WL_DISPLAY_ERROR_ENUM */
902 
903 /**
904  * @ingroup iface_wl_display
905  * @struct wl_display_listener
906  */
907 struct wl_display_listener {
908 	/**
909 	 * fatal error event
910 	 *
911 	 * The error event is sent out when a fatal (non-recoverable)
912 	 * error has occurred. The object_id argument is the object where
913 	 * the error occurred, most often in response to a request to that
914 	 * object. The code identifies the error and is defined by the
915 	 * object interface. As such, each interface defines its own set of
916 	 * error codes. The message is a brief description of the error,
917 	 * for (debugging) convenience.
918 	 * @param object_id object where the error occurred
919 	 * @param code error code
920 	 * @param message error description
921 	 */
922 	void (*error)(void *data,
923 		      struct wl_display *wl_display,
924 		      void *object_id,
925 		      uint32_t code,
926 		      const char *message);
927 	/**
928 	 * acknowledge object ID deletion
929 	 *
930 	 * This event is used internally by the object ID management
931 	 * logic. When a client deletes an object, the server will send
932 	 * this event to acknowledge that it has seen the delete request.
933 	 * When the client receives this event, it will know that it can
934 	 * safely reuse the object ID.
935 	 * @param id deleted object ID
936 	 */
937 	void (*delete_id)(void *data,
938 			  struct wl_display *wl_display,
939 			  uint32_t id);
940 };
941 
942 /**
943  * @ingroup iface_wl_display
944  */
945 static inline int
wl_display_add_listener(struct wl_display * wl_display,const struct wl_display_listener * listener,void * data)946 wl_display_add_listener(struct wl_display *wl_display,
947 			const struct wl_display_listener *listener, void *data)
948 {
949 	return wl_proxy_add_listener((struct wl_proxy *) wl_display,
950 				     (void (**)(void)) listener, data);
951 }
952 
953 #define WL_DISPLAY_SYNC 0
954 #define WL_DISPLAY_GET_REGISTRY 1
955 
956 /**
957  * @ingroup iface_wl_display
958  */
959 #define WL_DISPLAY_ERROR_SINCE_VERSION 1
960 /**
961  * @ingroup iface_wl_display
962  */
963 #define WL_DISPLAY_DELETE_ID_SINCE_VERSION 1
964 
965 /**
966  * @ingroup iface_wl_display
967  */
968 #define WL_DISPLAY_SYNC_SINCE_VERSION 1
969 /**
970  * @ingroup iface_wl_display
971  */
972 #define WL_DISPLAY_GET_REGISTRY_SINCE_VERSION 1
973 
974 /** @ingroup iface_wl_display */
975 static inline void
wl_display_set_user_data(struct wl_display * wl_display,void * user_data)976 wl_display_set_user_data(struct wl_display *wl_display, void *user_data)
977 {
978 	wl_proxy_set_user_data((struct wl_proxy *) wl_display, user_data);
979 }
980 
981 /** @ingroup iface_wl_display */
982 static inline void *
wl_display_get_user_data(struct wl_display * wl_display)983 wl_display_get_user_data(struct wl_display *wl_display)
984 {
985 	return wl_proxy_get_user_data((struct wl_proxy *) wl_display);
986 }
987 
988 static inline uint32_t
wl_display_get_version(struct wl_display * wl_display)989 wl_display_get_version(struct wl_display *wl_display)
990 {
991 	return wl_proxy_get_version((struct wl_proxy *) wl_display);
992 }
993 
994 /**
995  * @ingroup iface_wl_display
996  *
997  * The sync request asks the server to emit the 'done' event
998  * on the returned wl_callback object.  Since requests are
999  * handled in-order and events are delivered in-order, this can
1000  * be used as a barrier to ensure all previous requests and the
1001  * resulting events have been handled.
1002  *
1003  * The object returned by this request will be destroyed by the
1004  * compositor after the callback is fired and as such the client must not
1005  * attempt to use it after that point.
1006  *
1007  * The callback_data passed in the callback is the event serial.
1008  */
1009 static inline struct wl_callback *
wl_display_sync(struct wl_display * wl_display)1010 wl_display_sync(struct wl_display *wl_display)
1011 {
1012 	struct wl_proxy *callback;
1013 
1014 	callback = wl_proxy_marshal_constructor((struct wl_proxy *) wl_display,
1015 			 WL_DISPLAY_SYNC, &wl_callback_interface, NULL);
1016 
1017 	return (struct wl_callback *) callback;
1018 }
1019 
1020 /**
1021  * @ingroup iface_wl_display
1022  *
1023  * This request creates a registry object that allows the client
1024  * to list and bind the global objects available from the
1025  * compositor.
1026  */
1027 static inline struct wl_registry *
wl_display_get_registry(struct wl_display * wl_display)1028 wl_display_get_registry(struct wl_display *wl_display)
1029 {
1030 	struct wl_proxy *registry;
1031 
1032 	registry = wl_proxy_marshal_constructor((struct wl_proxy *) wl_display,
1033 			 WL_DISPLAY_GET_REGISTRY, &wl_registry_interface, NULL);
1034 
1035 	return (struct wl_registry *) registry;
1036 }
1037 
1038 /**
1039  * @ingroup iface_wl_registry
1040  * @struct wl_registry_listener
1041  */
1042 struct wl_registry_listener {
1043 	/**
1044 	 * announce global object
1045 	 *
1046 	 * Notify the client of global objects.
1047 	 *
1048 	 * The event notifies the client that a global object with the
1049 	 * given name is now available, and it implements the given version
1050 	 * of the given interface.
1051 	 * @param name numeric name of the global object
1052 	 * @param interface interface implemented by the object
1053 	 * @param version interface version
1054 	 */
1055 	void (*global)(void *data,
1056 		       struct wl_registry *wl_registry,
1057 		       uint32_t name,
1058 		       const char *interface,
1059 		       uint32_t version);
1060 	/**
1061 	 * announce removal of global object
1062 	 *
1063 	 * Notify the client of removed global objects.
1064 	 *
1065 	 * This event notifies the client that the global identified by
1066 	 * name is no longer available. If the client bound to the global
1067 	 * using the bind request, the client should now destroy that
1068 	 * object.
1069 	 *
1070 	 * The object remains valid and requests to the object will be
1071 	 * ignored until the client destroys it, to avoid races between the
1072 	 * global going away and a client sending a request to it.
1073 	 * @param name numeric name of the global object
1074 	 */
1075 	void (*global_remove)(void *data,
1076 			      struct wl_registry *wl_registry,
1077 			      uint32_t name);
1078 };
1079 
1080 /**
1081  * @ingroup iface_wl_registry
1082  */
1083 static inline int
wl_registry_add_listener(struct wl_registry * wl_registry,const struct wl_registry_listener * listener,void * data)1084 wl_registry_add_listener(struct wl_registry *wl_registry,
1085 			 const struct wl_registry_listener *listener, void *data)
1086 {
1087 	return wl_proxy_add_listener((struct wl_proxy *) wl_registry,
1088 				     (void (**)(void)) listener, data);
1089 }
1090 
1091 #define WL_REGISTRY_BIND 0
1092 
1093 /**
1094  * @ingroup iface_wl_registry
1095  */
1096 #define WL_REGISTRY_GLOBAL_SINCE_VERSION 1
1097 /**
1098  * @ingroup iface_wl_registry
1099  */
1100 #define WL_REGISTRY_GLOBAL_REMOVE_SINCE_VERSION 1
1101 
1102 /**
1103  * @ingroup iface_wl_registry
1104  */
1105 #define WL_REGISTRY_BIND_SINCE_VERSION 1
1106 
1107 /** @ingroup iface_wl_registry */
1108 static inline void
wl_registry_set_user_data(struct wl_registry * wl_registry,void * user_data)1109 wl_registry_set_user_data(struct wl_registry *wl_registry, void *user_data)
1110 {
1111 	wl_proxy_set_user_data((struct wl_proxy *) wl_registry, user_data);
1112 }
1113 
1114 /** @ingroup iface_wl_registry */
1115 static inline void *
wl_registry_get_user_data(struct wl_registry * wl_registry)1116 wl_registry_get_user_data(struct wl_registry *wl_registry)
1117 {
1118 	return wl_proxy_get_user_data((struct wl_proxy *) wl_registry);
1119 }
1120 
1121 static inline uint32_t
wl_registry_get_version(struct wl_registry * wl_registry)1122 wl_registry_get_version(struct wl_registry *wl_registry)
1123 {
1124 	return wl_proxy_get_version((struct wl_proxy *) wl_registry);
1125 }
1126 
1127 /** @ingroup iface_wl_registry */
1128 static inline void
wl_registry_destroy(struct wl_registry * wl_registry)1129 wl_registry_destroy(struct wl_registry *wl_registry)
1130 {
1131 	wl_proxy_destroy((struct wl_proxy *) wl_registry);
1132 }
1133 
1134 /**
1135  * @ingroup iface_wl_registry
1136  *
1137  * Binds a new, client-created object to the server using the
1138  * specified name as the identifier.
1139  */
1140 static inline void *
wl_registry_bind(struct wl_registry * wl_registry,uint32_t name,const struct wl_interface * interface,uint32_t version)1141 wl_registry_bind(struct wl_registry *wl_registry, uint32_t name, const struct wl_interface *interface, uint32_t version)
1142 {
1143 	struct wl_proxy *id;
1144 
1145 	id = wl_proxy_marshal_constructor_versioned((struct wl_proxy *) wl_registry,
1146 			 WL_REGISTRY_BIND, interface, version, name, interface->name, version, NULL);
1147 
1148 	return (void *) id;
1149 }
1150 
1151 /**
1152  * @ingroup iface_wl_callback
1153  * @struct wl_callback_listener
1154  */
1155 struct wl_callback_listener {
1156 	/**
1157 	 * done event
1158 	 *
1159 	 * Notify the client when the related request is done.
1160 	 * @param callback_data request-specific data for the callback
1161 	 */
1162 	void (*done)(void *data,
1163 		     struct wl_callback *wl_callback,
1164 		     uint32_t callback_data);
1165 };
1166 
1167 /**
1168  * @ingroup iface_wl_callback
1169  */
1170 static inline int
wl_callback_add_listener(struct wl_callback * wl_callback,const struct wl_callback_listener * listener,void * data)1171 wl_callback_add_listener(struct wl_callback *wl_callback,
1172 			 const struct wl_callback_listener *listener, void *data)
1173 {
1174 	return wl_proxy_add_listener((struct wl_proxy *) wl_callback,
1175 				     (void (**)(void)) listener, data);
1176 }
1177 
1178 /**
1179  * @ingroup iface_wl_callback
1180  */
1181 #define WL_CALLBACK_DONE_SINCE_VERSION 1
1182 
1183 
1184 /** @ingroup iface_wl_callback */
1185 static inline void
wl_callback_set_user_data(struct wl_callback * wl_callback,void * user_data)1186 wl_callback_set_user_data(struct wl_callback *wl_callback, void *user_data)
1187 {
1188 	wl_proxy_set_user_data((struct wl_proxy *) wl_callback, user_data);
1189 }
1190 
1191 /** @ingroup iface_wl_callback */
1192 static inline void *
wl_callback_get_user_data(struct wl_callback * wl_callback)1193 wl_callback_get_user_data(struct wl_callback *wl_callback)
1194 {
1195 	return wl_proxy_get_user_data((struct wl_proxy *) wl_callback);
1196 }
1197 
1198 static inline uint32_t
wl_callback_get_version(struct wl_callback * wl_callback)1199 wl_callback_get_version(struct wl_callback *wl_callback)
1200 {
1201 	return wl_proxy_get_version((struct wl_proxy *) wl_callback);
1202 }
1203 
1204 /** @ingroup iface_wl_callback */
1205 static inline void
wl_callback_destroy(struct wl_callback * wl_callback)1206 wl_callback_destroy(struct wl_callback *wl_callback)
1207 {
1208 	wl_proxy_destroy((struct wl_proxy *) wl_callback);
1209 }
1210 
1211 #define WL_COMPOSITOR_CREATE_SURFACE 0
1212 #define WL_COMPOSITOR_CREATE_REGION 1
1213 
1214 
1215 /**
1216  * @ingroup iface_wl_compositor
1217  */
1218 #define WL_COMPOSITOR_CREATE_SURFACE_SINCE_VERSION 1
1219 /**
1220  * @ingroup iface_wl_compositor
1221  */
1222 #define WL_COMPOSITOR_CREATE_REGION_SINCE_VERSION 1
1223 
1224 /** @ingroup iface_wl_compositor */
1225 static inline void
wl_compositor_set_user_data(struct wl_compositor * wl_compositor,void * user_data)1226 wl_compositor_set_user_data(struct wl_compositor *wl_compositor, void *user_data)
1227 {
1228 	wl_proxy_set_user_data((struct wl_proxy *) wl_compositor, user_data);
1229 }
1230 
1231 /** @ingroup iface_wl_compositor */
1232 static inline void *
wl_compositor_get_user_data(struct wl_compositor * wl_compositor)1233 wl_compositor_get_user_data(struct wl_compositor *wl_compositor)
1234 {
1235 	return wl_proxy_get_user_data((struct wl_proxy *) wl_compositor);
1236 }
1237 
1238 static inline uint32_t
wl_compositor_get_version(struct wl_compositor * wl_compositor)1239 wl_compositor_get_version(struct wl_compositor *wl_compositor)
1240 {
1241 	return wl_proxy_get_version((struct wl_proxy *) wl_compositor);
1242 }
1243 
1244 /** @ingroup iface_wl_compositor */
1245 static inline void
wl_compositor_destroy(struct wl_compositor * wl_compositor)1246 wl_compositor_destroy(struct wl_compositor *wl_compositor)
1247 {
1248 	wl_proxy_destroy((struct wl_proxy *) wl_compositor);
1249 }
1250 
1251 /**
1252  * @ingroup iface_wl_compositor
1253  *
1254  * Ask the compositor to create a new surface.
1255  */
1256 static inline struct wl_surface *
wl_compositor_create_surface(struct wl_compositor * wl_compositor)1257 wl_compositor_create_surface(struct wl_compositor *wl_compositor)
1258 {
1259 	struct wl_proxy *id;
1260 
1261 	id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_compositor,
1262 			 WL_COMPOSITOR_CREATE_SURFACE, &wl_surface_interface, NULL);
1263 
1264 	return (struct wl_surface *) id;
1265 }
1266 
1267 /**
1268  * @ingroup iface_wl_compositor
1269  *
1270  * Ask the compositor to create a new region.
1271  */
1272 static inline struct wl_region *
wl_compositor_create_region(struct wl_compositor * wl_compositor)1273 wl_compositor_create_region(struct wl_compositor *wl_compositor)
1274 {
1275 	struct wl_proxy *id;
1276 
1277 	id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_compositor,
1278 			 WL_COMPOSITOR_CREATE_REGION, &wl_region_interface, NULL);
1279 
1280 	return (struct wl_region *) id;
1281 }
1282 
1283 #define WL_SHM_POOL_CREATE_BUFFER 0
1284 #define WL_SHM_POOL_DESTROY 1
1285 #define WL_SHM_POOL_RESIZE 2
1286 
1287 
1288 /**
1289  * @ingroup iface_wl_shm_pool
1290  */
1291 #define WL_SHM_POOL_CREATE_BUFFER_SINCE_VERSION 1
1292 /**
1293  * @ingroup iface_wl_shm_pool
1294  */
1295 #define WL_SHM_POOL_DESTROY_SINCE_VERSION 1
1296 /**
1297  * @ingroup iface_wl_shm_pool
1298  */
1299 #define WL_SHM_POOL_RESIZE_SINCE_VERSION 1
1300 
1301 /** @ingroup iface_wl_shm_pool */
1302 static inline void
wl_shm_pool_set_user_data(struct wl_shm_pool * wl_shm_pool,void * user_data)1303 wl_shm_pool_set_user_data(struct wl_shm_pool *wl_shm_pool, void *user_data)
1304 {
1305 	wl_proxy_set_user_data((struct wl_proxy *) wl_shm_pool, user_data);
1306 }
1307 
1308 /** @ingroup iface_wl_shm_pool */
1309 static inline void *
wl_shm_pool_get_user_data(struct wl_shm_pool * wl_shm_pool)1310 wl_shm_pool_get_user_data(struct wl_shm_pool *wl_shm_pool)
1311 {
1312 	return wl_proxy_get_user_data((struct wl_proxy *) wl_shm_pool);
1313 }
1314 
1315 static inline uint32_t
wl_shm_pool_get_version(struct wl_shm_pool * wl_shm_pool)1316 wl_shm_pool_get_version(struct wl_shm_pool *wl_shm_pool)
1317 {
1318 	return wl_proxy_get_version((struct wl_proxy *) wl_shm_pool);
1319 }
1320 
1321 /**
1322  * @ingroup iface_wl_shm_pool
1323  *
1324  * Create a wl_buffer object from the pool.
1325  *
1326  * The buffer is created offset bytes into the pool and has
1327  * width and height as specified.  The stride argument specifies
1328  * the number of bytes from the beginning of one row to the beginning
1329  * of the next.  The format is the pixel format of the buffer and
1330  * must be one of those advertised through the wl_shm.format event.
1331  *
1332  * A buffer will keep a reference to the pool it was created from
1333  * so it is valid to destroy the pool immediately after creating
1334  * a buffer from it.
1335  */
1336 static inline struct wl_buffer *
wl_shm_pool_create_buffer(struct wl_shm_pool * wl_shm_pool,int32_t offset,int32_t width,int32_t height,int32_t stride,uint32_t format)1337 wl_shm_pool_create_buffer(struct wl_shm_pool *wl_shm_pool, int32_t offset, int32_t width, int32_t height, int32_t stride, uint32_t format)
1338 {
1339 	struct wl_proxy *id;
1340 
1341 	id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_shm_pool,
1342 			 WL_SHM_POOL_CREATE_BUFFER, &wl_buffer_interface, NULL, offset, width, height, stride, format);
1343 
1344 	return (struct wl_buffer *) id;
1345 }
1346 
1347 /**
1348  * @ingroup iface_wl_shm_pool
1349  *
1350  * Destroy the shared memory pool.
1351  *
1352  * The mmapped memory will be released when all
1353  * buffers that have been created from this pool
1354  * are gone.
1355  */
1356 static inline void
wl_shm_pool_destroy(struct wl_shm_pool * wl_shm_pool)1357 wl_shm_pool_destroy(struct wl_shm_pool *wl_shm_pool)
1358 {
1359 	wl_proxy_marshal((struct wl_proxy *) wl_shm_pool,
1360 			 WL_SHM_POOL_DESTROY);
1361 
1362 	wl_proxy_destroy((struct wl_proxy *) wl_shm_pool);
1363 }
1364 
1365 /**
1366  * @ingroup iface_wl_shm_pool
1367  *
1368  * This request will cause the server to remap the backing memory
1369  * for the pool from the file descriptor passed when the pool was
1370  * created, but using the new size.  This request can only be
1371  * used to make the pool bigger.
1372  */
1373 static inline void
wl_shm_pool_resize(struct wl_shm_pool * wl_shm_pool,int32_t size)1374 wl_shm_pool_resize(struct wl_shm_pool *wl_shm_pool, int32_t size)
1375 {
1376 	wl_proxy_marshal((struct wl_proxy *) wl_shm_pool,
1377 			 WL_SHM_POOL_RESIZE, size);
1378 }
1379 
1380 #ifndef WL_SHM_ERROR_ENUM
1381 #define WL_SHM_ERROR_ENUM
1382 /**
1383  * @ingroup iface_wl_shm
1384  * wl_shm error values
1385  *
1386  * These errors can be emitted in response to wl_shm requests.
1387  */
1388 enum wl_shm_error {
1389 	/**
1390 	 * buffer format is not known
1391 	 */
1392 	WL_SHM_ERROR_INVALID_FORMAT = 0,
1393 	/**
1394 	 * invalid size or stride during pool or buffer creation
1395 	 */
1396 	WL_SHM_ERROR_INVALID_STRIDE = 1,
1397 	/**
1398 	 * mmapping the file descriptor failed
1399 	 */
1400 	WL_SHM_ERROR_INVALID_FD = 2,
1401 };
1402 #endif /* WL_SHM_ERROR_ENUM */
1403 
1404 #ifndef WL_SHM_FORMAT_ENUM
1405 #define WL_SHM_FORMAT_ENUM
1406 /**
1407  * @ingroup iface_wl_shm
1408  * pixel formats
1409  *
1410  * This describes the memory layout of an individual pixel.
1411  *
1412  * All renderers should support argb8888 and xrgb8888 but any other
1413  * formats are optional and may not be supported by the particular
1414  * renderer in use.
1415  *
1416  * The drm format codes match the macros defined in drm_fourcc.h.
1417  * The formats actually supported by the compositor will be
1418  * reported by the format event.
1419  */
1420 enum wl_shm_format {
1421 	/**
1422 	 * 32-bit ARGB format, [31:0] A:R:G:B 8:8:8:8 little endian
1423 	 */
1424 	WL_SHM_FORMAT_ARGB8888 = 0,
1425 	/**
1426 	 * 32-bit RGB format, [31:0] x:R:G:B 8:8:8:8 little endian
1427 	 */
1428 	WL_SHM_FORMAT_XRGB8888 = 1,
1429 	/**
1430 	 * 8-bit color index format, [7:0] C
1431 	 */
1432 	WL_SHM_FORMAT_C8 = 0x20203843,
1433 	/**
1434 	 * 8-bit RGB format, [7:0] R:G:B 3:3:2
1435 	 */
1436 	WL_SHM_FORMAT_RGB332 = 0x38424752,
1437 	/**
1438 	 * 8-bit BGR format, [7:0] B:G:R 2:3:3
1439 	 */
1440 	WL_SHM_FORMAT_BGR233 = 0x38524742,
1441 	/**
1442 	 * 16-bit xRGB format, [15:0] x:R:G:B 4:4:4:4 little endian
1443 	 */
1444 	WL_SHM_FORMAT_XRGB4444 = 0x32315258,
1445 	/**
1446 	 * 16-bit xBGR format, [15:0] x:B:G:R 4:4:4:4 little endian
1447 	 */
1448 	WL_SHM_FORMAT_XBGR4444 = 0x32314258,
1449 	/**
1450 	 * 16-bit RGBx format, [15:0] R:G:B:x 4:4:4:4 little endian
1451 	 */
1452 	WL_SHM_FORMAT_RGBX4444 = 0x32315852,
1453 	/**
1454 	 * 16-bit BGRx format, [15:0] B:G:R:x 4:4:4:4 little endian
1455 	 */
1456 	WL_SHM_FORMAT_BGRX4444 = 0x32315842,
1457 	/**
1458 	 * 16-bit ARGB format, [15:0] A:R:G:B 4:4:4:4 little endian
1459 	 */
1460 	WL_SHM_FORMAT_ARGB4444 = 0x32315241,
1461 	/**
1462 	 * 16-bit ABGR format, [15:0] A:B:G:R 4:4:4:4 little endian
1463 	 */
1464 	WL_SHM_FORMAT_ABGR4444 = 0x32314241,
1465 	/**
1466 	 * 16-bit RBGA format, [15:0] R:G:B:A 4:4:4:4 little endian
1467 	 */
1468 	WL_SHM_FORMAT_RGBA4444 = 0x32314152,
1469 	/**
1470 	 * 16-bit BGRA format, [15:0] B:G:R:A 4:4:4:4 little endian
1471 	 */
1472 	WL_SHM_FORMAT_BGRA4444 = 0x32314142,
1473 	/**
1474 	 * 16-bit xRGB format, [15:0] x:R:G:B 1:5:5:5 little endian
1475 	 */
1476 	WL_SHM_FORMAT_XRGB1555 = 0x35315258,
1477 	/**
1478 	 * 16-bit xBGR 1555 format, [15:0] x:B:G:R 1:5:5:5 little endian
1479 	 */
1480 	WL_SHM_FORMAT_XBGR1555 = 0x35314258,
1481 	/**
1482 	 * 16-bit RGBx 5551 format, [15:0] R:G:B:x 5:5:5:1 little endian
1483 	 */
1484 	WL_SHM_FORMAT_RGBX5551 = 0x35315852,
1485 	/**
1486 	 * 16-bit BGRx 5551 format, [15:0] B:G:R:x 5:5:5:1 little endian
1487 	 */
1488 	WL_SHM_FORMAT_BGRX5551 = 0x35315842,
1489 	/**
1490 	 * 16-bit ARGB 1555 format, [15:0] A:R:G:B 1:5:5:5 little endian
1491 	 */
1492 	WL_SHM_FORMAT_ARGB1555 = 0x35315241,
1493 	/**
1494 	 * 16-bit ABGR 1555 format, [15:0] A:B:G:R 1:5:5:5 little endian
1495 	 */
1496 	WL_SHM_FORMAT_ABGR1555 = 0x35314241,
1497 	/**
1498 	 * 16-bit RGBA 5551 format, [15:0] R:G:B:A 5:5:5:1 little endian
1499 	 */
1500 	WL_SHM_FORMAT_RGBA5551 = 0x35314152,
1501 	/**
1502 	 * 16-bit BGRA 5551 format, [15:0] B:G:R:A 5:5:5:1 little endian
1503 	 */
1504 	WL_SHM_FORMAT_BGRA5551 = 0x35314142,
1505 	/**
1506 	 * 16-bit RGB 565 format, [15:0] R:G:B 5:6:5 little endian
1507 	 */
1508 	WL_SHM_FORMAT_RGB565 = 0x36314752,
1509 	/**
1510 	 * 16-bit BGR 565 format, [15:0] B:G:R 5:6:5 little endian
1511 	 */
1512 	WL_SHM_FORMAT_BGR565 = 0x36314742,
1513 	/**
1514 	 * 24-bit RGB format, [23:0] R:G:B little endian
1515 	 */
1516 	WL_SHM_FORMAT_RGB888 = 0x34324752,
1517 	/**
1518 	 * 24-bit BGR format, [23:0] B:G:R little endian
1519 	 */
1520 	WL_SHM_FORMAT_BGR888 = 0x34324742,
1521 	/**
1522 	 * 32-bit xBGR format, [31:0] x:B:G:R 8:8:8:8 little endian
1523 	 */
1524 	WL_SHM_FORMAT_XBGR8888 = 0x34324258,
1525 	/**
1526 	 * 32-bit RGBx format, [31:0] R:G:B:x 8:8:8:8 little endian
1527 	 */
1528 	WL_SHM_FORMAT_RGBX8888 = 0x34325852,
1529 	/**
1530 	 * 32-bit BGRx format, [31:0] B:G:R:x 8:8:8:8 little endian
1531 	 */
1532 	WL_SHM_FORMAT_BGRX8888 = 0x34325842,
1533 	/**
1534 	 * 32-bit ABGR format, [31:0] A:B:G:R 8:8:8:8 little endian
1535 	 */
1536 	WL_SHM_FORMAT_ABGR8888 = 0x34324241,
1537 	/**
1538 	 * 32-bit RGBA format, [31:0] R:G:B:A 8:8:8:8 little endian
1539 	 */
1540 	WL_SHM_FORMAT_RGBA8888 = 0x34324152,
1541 	/**
1542 	 * 32-bit BGRA format, [31:0] B:G:R:A 8:8:8:8 little endian
1543 	 */
1544 	WL_SHM_FORMAT_BGRA8888 = 0x34324142,
1545 	/**
1546 	 * 32-bit xRGB format, [31:0] x:R:G:B 2:10:10:10 little endian
1547 	 */
1548 	WL_SHM_FORMAT_XRGB2101010 = 0x30335258,
1549 	/**
1550 	 * 32-bit xBGR format, [31:0] x:B:G:R 2:10:10:10 little endian
1551 	 */
1552 	WL_SHM_FORMAT_XBGR2101010 = 0x30334258,
1553 	/**
1554 	 * 32-bit RGBx format, [31:0] R:G:B:x 10:10:10:2 little endian
1555 	 */
1556 	WL_SHM_FORMAT_RGBX1010102 = 0x30335852,
1557 	/**
1558 	 * 32-bit BGRx format, [31:0] B:G:R:x 10:10:10:2 little endian
1559 	 */
1560 	WL_SHM_FORMAT_BGRX1010102 = 0x30335842,
1561 	/**
1562 	 * 32-bit ARGB format, [31:0] A:R:G:B 2:10:10:10 little endian
1563 	 */
1564 	WL_SHM_FORMAT_ARGB2101010 = 0x30335241,
1565 	/**
1566 	 * 32-bit ABGR format, [31:0] A:B:G:R 2:10:10:10 little endian
1567 	 */
1568 	WL_SHM_FORMAT_ABGR2101010 = 0x30334241,
1569 	/**
1570 	 * 32-bit RGBA format, [31:0] R:G:B:A 10:10:10:2 little endian
1571 	 */
1572 	WL_SHM_FORMAT_RGBA1010102 = 0x30334152,
1573 	/**
1574 	 * 32-bit BGRA format, [31:0] B:G:R:A 10:10:10:2 little endian
1575 	 */
1576 	WL_SHM_FORMAT_BGRA1010102 = 0x30334142,
1577 	/**
1578 	 * packed YCbCr format, [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian
1579 	 */
1580 	WL_SHM_FORMAT_YUYV = 0x56595559,
1581 	/**
1582 	 * packed YCbCr format, [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian
1583 	 */
1584 	WL_SHM_FORMAT_YVYU = 0x55595659,
1585 	/**
1586 	 * packed YCbCr format, [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian
1587 	 */
1588 	WL_SHM_FORMAT_UYVY = 0x59565955,
1589 	/**
1590 	 * packed YCbCr format, [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian
1591 	 */
1592 	WL_SHM_FORMAT_VYUY = 0x59555956,
1593 	/**
1594 	 * packed AYCbCr format, [31:0] A:Y:Cb:Cr 8:8:8:8 little endian
1595 	 */
1596 	WL_SHM_FORMAT_AYUV = 0x56555941,
1597 	/**
1598 	 * 2 plane YCbCr Cr:Cb format, 2x2 subsampled Cr:Cb plane
1599 	 */
1600 	WL_SHM_FORMAT_NV12 = 0x3231564e,
1601 	/**
1602 	 * 2 plane YCbCr Cb:Cr format, 2x2 subsampled Cb:Cr plane
1603 	 */
1604 	WL_SHM_FORMAT_NV21 = 0x3132564e,
1605 	/**
1606 	 * 2 plane YCbCr Cr:Cb format, 2x1 subsampled Cr:Cb plane
1607 	 */
1608 	WL_SHM_FORMAT_NV16 = 0x3631564e,
1609 	/**
1610 	 * 2 plane YCbCr Cb:Cr format, 2x1 subsampled Cb:Cr plane
1611 	 */
1612 	WL_SHM_FORMAT_NV61 = 0x3136564e,
1613 	/**
1614 	 * 3 plane YCbCr format, 4x4 subsampled Cb (1) and Cr (2) planes
1615 	 */
1616 	WL_SHM_FORMAT_YUV410 = 0x39565559,
1617 	/**
1618 	 * 3 plane YCbCr format, 4x4 subsampled Cr (1) and Cb (2) planes
1619 	 */
1620 	WL_SHM_FORMAT_YVU410 = 0x39555659,
1621 	/**
1622 	 * 3 plane YCbCr format, 4x1 subsampled Cb (1) and Cr (2) planes
1623 	 */
1624 	WL_SHM_FORMAT_YUV411 = 0x31315559,
1625 	/**
1626 	 * 3 plane YCbCr format, 4x1 subsampled Cr (1) and Cb (2) planes
1627 	 */
1628 	WL_SHM_FORMAT_YVU411 = 0x31315659,
1629 	/**
1630 	 * 3 plane YCbCr format, 2x2 subsampled Cb (1) and Cr (2) planes
1631 	 */
1632 	WL_SHM_FORMAT_YUV420 = 0x32315559,
1633 	/**
1634 	 * 3 plane YCbCr format, 2x2 subsampled Cr (1) and Cb (2) planes
1635 	 */
1636 	WL_SHM_FORMAT_YVU420 = 0x32315659,
1637 	/**
1638 	 * 3 plane YCbCr format, 2x1 subsampled Cb (1) and Cr (2) planes
1639 	 */
1640 	WL_SHM_FORMAT_YUV422 = 0x36315559,
1641 	/**
1642 	 * 3 plane YCbCr format, 2x1 subsampled Cr (1) and Cb (2) planes
1643 	 */
1644 	WL_SHM_FORMAT_YVU422 = 0x36315659,
1645 	/**
1646 	 * 3 plane YCbCr format, non-subsampled Cb (1) and Cr (2) planes
1647 	 */
1648 	WL_SHM_FORMAT_YUV444 = 0x34325559,
1649 	/**
1650 	 * 3 plane YCbCr format, non-subsampled Cr (1) and Cb (2) planes
1651 	 */
1652 	WL_SHM_FORMAT_YVU444 = 0x34325659,
1653 };
1654 #endif /* WL_SHM_FORMAT_ENUM */
1655 
1656 /**
1657  * @ingroup iface_wl_shm
1658  * @struct wl_shm_listener
1659  */
1660 struct wl_shm_listener {
1661 	/**
1662 	 * pixel format description
1663 	 *
1664 	 * Informs the client about a valid pixel format that can be used
1665 	 * for buffers. Known formats include argb8888 and xrgb8888.
1666 	 * @param format buffer pixel format
1667 	 */
1668 	void (*format)(void *data,
1669 		       struct wl_shm *wl_shm,
1670 		       uint32_t format);
1671 };
1672 
1673 /**
1674  * @ingroup iface_wl_shm
1675  */
1676 static inline int
wl_shm_add_listener(struct wl_shm * wl_shm,const struct wl_shm_listener * listener,void * data)1677 wl_shm_add_listener(struct wl_shm *wl_shm,
1678 		    const struct wl_shm_listener *listener, void *data)
1679 {
1680 	return wl_proxy_add_listener((struct wl_proxy *) wl_shm,
1681 				     (void (**)(void)) listener, data);
1682 }
1683 
1684 #define WL_SHM_CREATE_POOL 0
1685 
1686 /**
1687  * @ingroup iface_wl_shm
1688  */
1689 #define WL_SHM_FORMAT_SINCE_VERSION 1
1690 
1691 /**
1692  * @ingroup iface_wl_shm
1693  */
1694 #define WL_SHM_CREATE_POOL_SINCE_VERSION 1
1695 
1696 /** @ingroup iface_wl_shm */
1697 static inline void
wl_shm_set_user_data(struct wl_shm * wl_shm,void * user_data)1698 wl_shm_set_user_data(struct wl_shm *wl_shm, void *user_data)
1699 {
1700 	wl_proxy_set_user_data((struct wl_proxy *) wl_shm, user_data);
1701 }
1702 
1703 /** @ingroup iface_wl_shm */
1704 static inline void *
wl_shm_get_user_data(struct wl_shm * wl_shm)1705 wl_shm_get_user_data(struct wl_shm *wl_shm)
1706 {
1707 	return wl_proxy_get_user_data((struct wl_proxy *) wl_shm);
1708 }
1709 
1710 static inline uint32_t
wl_shm_get_version(struct wl_shm * wl_shm)1711 wl_shm_get_version(struct wl_shm *wl_shm)
1712 {
1713 	return wl_proxy_get_version((struct wl_proxy *) wl_shm);
1714 }
1715 
1716 /** @ingroup iface_wl_shm */
1717 static inline void
wl_shm_destroy(struct wl_shm * wl_shm)1718 wl_shm_destroy(struct wl_shm *wl_shm)
1719 {
1720 	wl_proxy_destroy((struct wl_proxy *) wl_shm);
1721 }
1722 
1723 /**
1724  * @ingroup iface_wl_shm
1725  *
1726  * Create a new wl_shm_pool object.
1727  *
1728  * The pool can be used to create shared memory based buffer
1729  * objects.  The server will mmap size bytes of the passed file
1730  * descriptor, to use as backing memory for the pool.
1731  */
1732 static inline struct wl_shm_pool *
wl_shm_create_pool(struct wl_shm * wl_shm,int32_t fd,int32_t size)1733 wl_shm_create_pool(struct wl_shm *wl_shm, int32_t fd, int32_t size)
1734 {
1735 	struct wl_proxy *id;
1736 
1737 	id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_shm,
1738 			 WL_SHM_CREATE_POOL, &wl_shm_pool_interface, NULL, fd, size);
1739 
1740 	return (struct wl_shm_pool *) id;
1741 }
1742 
1743 /**
1744  * @ingroup iface_wl_buffer
1745  * @struct wl_buffer_listener
1746  */
1747 struct wl_buffer_listener {
1748 	/**
1749 	 * compositor releases buffer
1750 	 *
1751 	 * Sent when this wl_buffer is no longer used by the compositor.
1752 	 * The client is now free to reuse or destroy this buffer and its
1753 	 * backing storage.
1754 	 *
1755 	 * If a client receives a release event before the frame callback
1756 	 * requested in the same wl_surface.commit that attaches this
1757 	 * wl_buffer to a surface, then the client is immediately free to
1758 	 * reuse the buffer and its backing storage, and does not need a
1759 	 * second buffer for the next surface content update. Typically
1760 	 * this is possible, when the compositor maintains a copy of the
1761 	 * wl_surface contents, e.g. as a GL texture. This is an important
1762 	 * optimization for GL(ES) compositors with wl_shm clients.
1763 	 */
1764 	void (*release)(void *data,
1765 			struct wl_buffer *wl_buffer);
1766 };
1767 
1768 /**
1769  * @ingroup iface_wl_buffer
1770  */
1771 static inline int
wl_buffer_add_listener(struct wl_buffer * wl_buffer,const struct wl_buffer_listener * listener,void * data)1772 wl_buffer_add_listener(struct wl_buffer *wl_buffer,
1773 		       const struct wl_buffer_listener *listener, void *data)
1774 {
1775 	return wl_proxy_add_listener((struct wl_proxy *) wl_buffer,
1776 				     (void (**)(void)) listener, data);
1777 }
1778 
1779 #define WL_BUFFER_DESTROY 0
1780 
1781 /**
1782  * @ingroup iface_wl_buffer
1783  */
1784 #define WL_BUFFER_RELEASE_SINCE_VERSION 1
1785 
1786 /**
1787  * @ingroup iface_wl_buffer
1788  */
1789 #define WL_BUFFER_DESTROY_SINCE_VERSION 1
1790 
1791 /** @ingroup iface_wl_buffer */
1792 static inline void
wl_buffer_set_user_data(struct wl_buffer * wl_buffer,void * user_data)1793 wl_buffer_set_user_data(struct wl_buffer *wl_buffer, void *user_data)
1794 {
1795 	wl_proxy_set_user_data((struct wl_proxy *) wl_buffer, user_data);
1796 }
1797 
1798 /** @ingroup iface_wl_buffer */
1799 static inline void *
wl_buffer_get_user_data(struct wl_buffer * wl_buffer)1800 wl_buffer_get_user_data(struct wl_buffer *wl_buffer)
1801 {
1802 	return wl_proxy_get_user_data((struct wl_proxy *) wl_buffer);
1803 }
1804 
1805 static inline uint32_t
wl_buffer_get_version(struct wl_buffer * wl_buffer)1806 wl_buffer_get_version(struct wl_buffer *wl_buffer)
1807 {
1808 	return wl_proxy_get_version((struct wl_proxy *) wl_buffer);
1809 }
1810 
1811 /**
1812  * @ingroup iface_wl_buffer
1813  *
1814  * Destroy a buffer. If and how you need to release the backing
1815  * storage is defined by the buffer factory interface.
1816  *
1817  * For possible side-effects to a surface, see wl_surface.attach.
1818  */
1819 static inline void
wl_buffer_destroy(struct wl_buffer * wl_buffer)1820 wl_buffer_destroy(struct wl_buffer *wl_buffer)
1821 {
1822 	wl_proxy_marshal((struct wl_proxy *) wl_buffer,
1823 			 WL_BUFFER_DESTROY);
1824 
1825 	wl_proxy_destroy((struct wl_proxy *) wl_buffer);
1826 }
1827 
1828 #ifndef WL_DATA_OFFER_ERROR_ENUM
1829 #define WL_DATA_OFFER_ERROR_ENUM
1830 enum wl_data_offer_error {
1831 	/**
1832 	 * finish request was called untimely
1833 	 */
1834 	WL_DATA_OFFER_ERROR_INVALID_FINISH = 0,
1835 	/**
1836 	 * action mask contains invalid values
1837 	 */
1838 	WL_DATA_OFFER_ERROR_INVALID_ACTION_MASK = 1,
1839 	/**
1840 	 * action argument has an invalid value
1841 	 */
1842 	WL_DATA_OFFER_ERROR_INVALID_ACTION = 2,
1843 	/**
1844 	 * offer doesn't accept this request
1845 	 */
1846 	WL_DATA_OFFER_ERROR_INVALID_OFFER = 3,
1847 };
1848 #endif /* WL_DATA_OFFER_ERROR_ENUM */
1849 
1850 /**
1851  * @ingroup iface_wl_data_offer
1852  * @struct wl_data_offer_listener
1853  */
1854 struct wl_data_offer_listener {
1855 	/**
1856 	 * advertise offered mime type
1857 	 *
1858 	 * Sent immediately after creating the wl_data_offer object. One
1859 	 * event per offered mime type.
1860 	 * @param mime_type offered mime type
1861 	 */
1862 	void (*offer)(void *data,
1863 		      struct wl_data_offer *wl_data_offer,
1864 		      const char *mime_type);
1865 	/**
1866 	 * notify the source-side available actions
1867 	 *
1868 	 * This event indicates the actions offered by the data source.
1869 	 * It will be sent right after wl_data_device.enter, or anytime the
1870 	 * source side changes its offered actions through
1871 	 * wl_data_source.set_actions.
1872 	 * @param source_actions actions offered by the data source
1873 	 * @since 3
1874 	 */
1875 	void (*source_actions)(void *data,
1876 			       struct wl_data_offer *wl_data_offer,
1877 			       uint32_t source_actions);
1878 	/**
1879 	 * notify the selected action
1880 	 *
1881 	 * This event indicates the action selected by the compositor
1882 	 * after matching the source/destination side actions. Only one
1883 	 * action (or none) will be offered here.
1884 	 *
1885 	 * This event can be emitted multiple times during the
1886 	 * drag-and-drop operation in response to destination side action
1887 	 * changes through wl_data_offer.set_actions.
1888 	 *
1889 	 * This event will no longer be emitted after wl_data_device.drop
1890 	 * happened on the drag-and-drop destination, the client must honor
1891 	 * the last action received, or the last preferred one set through
1892 	 * wl_data_offer.set_actions when handling an "ask" action.
1893 	 *
1894 	 * Compositors may also change the selected action on the fly,
1895 	 * mainly in response to keyboard modifier changes during the
1896 	 * drag-and-drop operation.
1897 	 *
1898 	 * The most recent action received is always the valid one. Prior
1899 	 * to receiving wl_data_device.drop, the chosen action may change
1900 	 * (e.g. due to keyboard modifiers being pressed). At the time of
1901 	 * receiving wl_data_device.drop the drag-and-drop destination must
1902 	 * honor the last action received.
1903 	 *
1904 	 * Action changes may still happen after wl_data_device.drop,
1905 	 * especially on "ask" actions, where the drag-and-drop destination
1906 	 * may choose another action afterwards. Action changes happening
1907 	 * at this stage are always the result of inter-client negotiation,
1908 	 * the compositor shall no longer be able to induce a different
1909 	 * action.
1910 	 *
1911 	 * Upon "ask" actions, it is expected that the drag-and-drop
1912 	 * destination may potentially choose a different action and/or
1913 	 * mime type, based on wl_data_offer.source_actions and finally
1914 	 * chosen by the user (e.g. popping up a menu with the available
1915 	 * options). The final wl_data_offer.set_actions and
1916 	 * wl_data_offer.accept requests must happen before the call to
1917 	 * wl_data_offer.finish.
1918 	 * @param dnd_action action selected by the compositor
1919 	 * @since 3
1920 	 */
1921 	void (*action)(void *data,
1922 		       struct wl_data_offer *wl_data_offer,
1923 		       uint32_t dnd_action);
1924 };
1925 
1926 /**
1927  * @ingroup iface_wl_data_offer
1928  */
1929 static inline int
wl_data_offer_add_listener(struct wl_data_offer * wl_data_offer,const struct wl_data_offer_listener * listener,void * data)1930 wl_data_offer_add_listener(struct wl_data_offer *wl_data_offer,
1931 			   const struct wl_data_offer_listener *listener, void *data)
1932 {
1933 	return wl_proxy_add_listener((struct wl_proxy *) wl_data_offer,
1934 				     (void (**)(void)) listener, data);
1935 }
1936 
1937 #define WL_DATA_OFFER_ACCEPT 0
1938 #define WL_DATA_OFFER_RECEIVE 1
1939 #define WL_DATA_OFFER_DESTROY 2
1940 #define WL_DATA_OFFER_FINISH 3
1941 #define WL_DATA_OFFER_SET_ACTIONS 4
1942 
1943 /**
1944  * @ingroup iface_wl_data_offer
1945  */
1946 #define WL_DATA_OFFER_OFFER_SINCE_VERSION 1
1947 /**
1948  * @ingroup iface_wl_data_offer
1949  */
1950 #define WL_DATA_OFFER_SOURCE_ACTIONS_SINCE_VERSION 3
1951 /**
1952  * @ingroup iface_wl_data_offer
1953  */
1954 #define WL_DATA_OFFER_ACTION_SINCE_VERSION 3
1955 
1956 /**
1957  * @ingroup iface_wl_data_offer
1958  */
1959 #define WL_DATA_OFFER_ACCEPT_SINCE_VERSION 1
1960 /**
1961  * @ingroup iface_wl_data_offer
1962  */
1963 #define WL_DATA_OFFER_RECEIVE_SINCE_VERSION 1
1964 /**
1965  * @ingroup iface_wl_data_offer
1966  */
1967 #define WL_DATA_OFFER_DESTROY_SINCE_VERSION 1
1968 /**
1969  * @ingroup iface_wl_data_offer
1970  */
1971 #define WL_DATA_OFFER_FINISH_SINCE_VERSION 3
1972 /**
1973  * @ingroup iface_wl_data_offer
1974  */
1975 #define WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION 3
1976 
1977 /** @ingroup iface_wl_data_offer */
1978 static inline void
wl_data_offer_set_user_data(struct wl_data_offer * wl_data_offer,void * user_data)1979 wl_data_offer_set_user_data(struct wl_data_offer *wl_data_offer, void *user_data)
1980 {
1981 	wl_proxy_set_user_data((struct wl_proxy *) wl_data_offer, user_data);
1982 }
1983 
1984 /** @ingroup iface_wl_data_offer */
1985 static inline void *
wl_data_offer_get_user_data(struct wl_data_offer * wl_data_offer)1986 wl_data_offer_get_user_data(struct wl_data_offer *wl_data_offer)
1987 {
1988 	return wl_proxy_get_user_data((struct wl_proxy *) wl_data_offer);
1989 }
1990 
1991 static inline uint32_t
wl_data_offer_get_version(struct wl_data_offer * wl_data_offer)1992 wl_data_offer_get_version(struct wl_data_offer *wl_data_offer)
1993 {
1994 	return wl_proxy_get_version((struct wl_proxy *) wl_data_offer);
1995 }
1996 
1997 /**
1998  * @ingroup iface_wl_data_offer
1999  *
2000  * Indicate that the client can accept the given mime type, or
2001  * NULL for not accepted.
2002  *
2003  * For objects of version 2 or older, this request is used by the
2004  * client to give feedback whether the client can receive the given
2005  * mime type, or NULL if none is accepted; the feedback does not
2006  * determine whether the drag-and-drop operation succeeds or not.
2007  *
2008  * For objects of version 3 or newer, this request determines the
2009  * final result of the drag-and-drop operation. If the end result
2010  * is that no mime types were accepted, the drag-and-drop operation
2011  * will be cancelled and the corresponding drag source will receive
2012  * wl_data_source.cancelled. Clients may still use this event in
2013  * conjunction with wl_data_source.action for feedback.
2014  */
2015 static inline void
wl_data_offer_accept(struct wl_data_offer * wl_data_offer,uint32_t serial,const char * mime_type)2016 wl_data_offer_accept(struct wl_data_offer *wl_data_offer, uint32_t serial, const char *mime_type)
2017 {
2018 	wl_proxy_marshal((struct wl_proxy *) wl_data_offer,
2019 			 WL_DATA_OFFER_ACCEPT, serial, mime_type);
2020 }
2021 
2022 /**
2023  * @ingroup iface_wl_data_offer
2024  *
2025  * To transfer the offered data, the client issues this request
2026  * and indicates the mime type it wants to receive.  The transfer
2027  * happens through the passed file descriptor (typically created
2028  * with the pipe system call).  The source client writes the data
2029  * in the mime type representation requested and then closes the
2030  * file descriptor.
2031  *
2032  * The receiving client reads from the read end of the pipe until
2033  * EOF and then closes its end, at which point the transfer is
2034  * complete.
2035  *
2036  * This request may happen multiple times for different mime types,
2037  * both before and after wl_data_device.drop. Drag-and-drop destination
2038  * clients may preemptively fetch data or examine it more closely to
2039  * determine acceptance.
2040  */
2041 static inline void
wl_data_offer_receive(struct wl_data_offer * wl_data_offer,const char * mime_type,int32_t fd)2042 wl_data_offer_receive(struct wl_data_offer *wl_data_offer, const char *mime_type, int32_t fd)
2043 {
2044 	wl_proxy_marshal((struct wl_proxy *) wl_data_offer,
2045 			 WL_DATA_OFFER_RECEIVE, mime_type, fd);
2046 }
2047 
2048 /**
2049  * @ingroup iface_wl_data_offer
2050  *
2051  * Destroy the data offer.
2052  */
2053 static inline void
wl_data_offer_destroy(struct wl_data_offer * wl_data_offer)2054 wl_data_offer_destroy(struct wl_data_offer *wl_data_offer)
2055 {
2056 	wl_proxy_marshal((struct wl_proxy *) wl_data_offer,
2057 			 WL_DATA_OFFER_DESTROY);
2058 
2059 	wl_proxy_destroy((struct wl_proxy *) wl_data_offer);
2060 }
2061 
2062 /**
2063  * @ingroup iface_wl_data_offer
2064  *
2065  * Notifies the compositor that the drag destination successfully
2066  * finished the drag-and-drop operation.
2067  *
2068  * Upon receiving this request, the compositor will emit
2069  * wl_data_source.dnd_finished on the drag source client.
2070  *
2071  * It is a client error to perform other requests than
2072  * wl_data_offer.destroy after this one. It is also an error to perform
2073  * this request after a NULL mime type has been set in
2074  * wl_data_offer.accept or no action was received through
2075  * wl_data_offer.action.
2076  */
2077 static inline void
wl_data_offer_finish(struct wl_data_offer * wl_data_offer)2078 wl_data_offer_finish(struct wl_data_offer *wl_data_offer)
2079 {
2080 	wl_proxy_marshal((struct wl_proxy *) wl_data_offer,
2081 			 WL_DATA_OFFER_FINISH);
2082 }
2083 
2084 /**
2085  * @ingroup iface_wl_data_offer
2086  *
2087  * Sets the actions that the destination side client supports for
2088  * this operation. This request may trigger the emission of
2089  * wl_data_source.action and wl_data_offer.action events if the compositor
2090  * needs to change the selected action.
2091  *
2092  * This request can be called multiple times throughout the
2093  * drag-and-drop operation, typically in response to wl_data_device.enter
2094  * or wl_data_device.motion events.
2095  *
2096  * This request determines the final result of the drag-and-drop
2097  * operation. If the end result is that no action is accepted,
2098  * the drag source will receive wl_drag_source.cancelled.
2099  *
2100  * The dnd_actions argument must contain only values expressed in the
2101  * wl_data_device_manager.dnd_actions enum, and the preferred_action
2102  * argument must only contain one of those values set, otherwise it
2103  * will result in a protocol error.
2104  *
2105  * While managing an "ask" action, the destination drag-and-drop client
2106  * may perform further wl_data_offer.receive requests, and is expected
2107  * to perform one last wl_data_offer.set_actions request with a preferred
2108  * action other than "ask" (and optionally wl_data_offer.accept) before
2109  * requesting wl_data_offer.finish, in order to convey the action selected
2110  * by the user. If the preferred action is not in the
2111  * wl_data_offer.source_actions mask, an error will be raised.
2112  *
2113  * If the "ask" action is dismissed (e.g. user cancellation), the client
2114  * is expected to perform wl_data_offer.destroy right away.
2115  *
2116  * This request can only be made on drag-and-drop offers, a protocol error
2117  * will be raised otherwise.
2118  */
2119 static inline void
wl_data_offer_set_actions(struct wl_data_offer * wl_data_offer,uint32_t dnd_actions,uint32_t preferred_action)2120 wl_data_offer_set_actions(struct wl_data_offer *wl_data_offer, uint32_t dnd_actions, uint32_t preferred_action)
2121 {
2122 	wl_proxy_marshal((struct wl_proxy *) wl_data_offer,
2123 			 WL_DATA_OFFER_SET_ACTIONS, dnd_actions, preferred_action);
2124 }
2125 
2126 #ifndef WL_DATA_SOURCE_ERROR_ENUM
2127 #define WL_DATA_SOURCE_ERROR_ENUM
2128 enum wl_data_source_error {
2129 	/**
2130 	 * action mask contains invalid values
2131 	 */
2132 	WL_DATA_SOURCE_ERROR_INVALID_ACTION_MASK = 0,
2133 	/**
2134 	 * source doesn't accept this request
2135 	 */
2136 	WL_DATA_SOURCE_ERROR_INVALID_SOURCE = 1,
2137 };
2138 #endif /* WL_DATA_SOURCE_ERROR_ENUM */
2139 
2140 /**
2141  * @ingroup iface_wl_data_source
2142  * @struct wl_data_source_listener
2143  */
2144 struct wl_data_source_listener {
2145 	/**
2146 	 * a target accepts an offered mime type
2147 	 *
2148 	 * Sent when a target accepts pointer_focus or motion events. If
2149 	 * a target does not accept any of the offered types, type is NULL.
2150 	 *
2151 	 * Used for feedback during drag-and-drop.
2152 	 * @param mime_type mime type accepted by the target
2153 	 */
2154 	void (*target)(void *data,
2155 		       struct wl_data_source *wl_data_source,
2156 		       const char *mime_type);
2157 	/**
2158 	 * send the data
2159 	 *
2160 	 * Request for data from the client. Send the data as the
2161 	 * specified mime type over the passed file descriptor, then close
2162 	 * it.
2163 	 * @param mime_type mime type for the data
2164 	 * @param fd file descriptor for the data
2165 	 */
2166 	void (*send)(void *data,
2167 		     struct wl_data_source *wl_data_source,
2168 		     const char *mime_type,
2169 		     int32_t fd);
2170 	/**
2171 	 * selection was cancelled
2172 	 *
2173 	 * This data source is no longer valid. There are several reasons
2174 	 * why this could happen:
2175 	 *
2176 	 * - The data source has been replaced by another data source. -
2177 	 * The drag-and-drop operation was performed, but the drop
2178 	 * destination did not accept any of the mime types offered through
2179 	 * wl_data_source.target. - The drag-and-drop operation was
2180 	 * performed, but the drop destination did not select any of the
2181 	 * actions present in the mask offered through
2182 	 * wl_data_source.action. - The drag-and-drop operation was
2183 	 * performed but didn't happen over a surface. - The compositor
2184 	 * cancelled the drag-and-drop operation (e.g. compositor dependent
2185 	 * timeouts to avoid stale drag-and-drop transfers).
2186 	 *
2187 	 * The client should clean up and destroy this data source.
2188 	 *
2189 	 * For objects of version 2 or older, wl_data_source.cancelled will
2190 	 * only be emitted if the data source was replaced by another data
2191 	 * source.
2192 	 */
2193 	void (*cancelled)(void *data,
2194 			  struct wl_data_source *wl_data_source);
2195 	/**
2196 	 * the drag-and-drop operation physically finished
2197 	 *
2198 	 * The user performed the drop action. This event does not
2199 	 * indicate acceptance, wl_data_source.cancelled may still be
2200 	 * emitted afterwards if the drop destination does not accept any
2201 	 * mime type.
2202 	 *
2203 	 * However, this event might however not be received if the
2204 	 * compositor cancelled the drag-and-drop operation before this
2205 	 * event could happen.
2206 	 *
2207 	 * Note that the data_source may still be used in the future and
2208 	 * should not be destroyed here.
2209 	 * @since 3
2210 	 */
2211 	void (*dnd_drop_performed)(void *data,
2212 				   struct wl_data_source *wl_data_source);
2213 	/**
2214 	 * the drag-and-drop operation concluded
2215 	 *
2216 	 * The drop destination finished interoperating with this data
2217 	 * source, so the client is now free to destroy this data source
2218 	 * and free all associated data.
2219 	 *
2220 	 * If the action used to perform the operation was "move", the
2221 	 * source can now delete the transferred data.
2222 	 * @since 3
2223 	 */
2224 	void (*dnd_finished)(void *data,
2225 			     struct wl_data_source *wl_data_source);
2226 	/**
2227 	 * notify the selected action
2228 	 *
2229 	 * This event indicates the action selected by the compositor
2230 	 * after matching the source/destination side actions. Only one
2231 	 * action (or none) will be offered here.
2232 	 *
2233 	 * This event can be emitted multiple times during the
2234 	 * drag-and-drop operation, mainly in response to destination side
2235 	 * changes through wl_data_offer.set_actions, and as the data
2236 	 * device enters/leaves surfaces.
2237 	 *
2238 	 * It is only possible to receive this event after
2239 	 * wl_data_source.dnd_drop_performed if the drag-and-drop operation
2240 	 * ended in an "ask" action, in which case the final
2241 	 * wl_data_source.action event will happen immediately before
2242 	 * wl_data_source.dnd_finished.
2243 	 *
2244 	 * Compositors may also change the selected action on the fly,
2245 	 * mainly in response to keyboard modifier changes during the
2246 	 * drag-and-drop operation.
2247 	 *
2248 	 * The most recent action received is always the valid one. The
2249 	 * chosen action may change alongside negotiation (e.g. an "ask"
2250 	 * action can turn into a "move" operation), so the effects of the
2251 	 * final action must always be applied in
2252 	 * wl_data_offer.dnd_finished.
2253 	 *
2254 	 * Clients can trigger cursor surface changes from this point, so
2255 	 * they reflect the current action.
2256 	 * @param dnd_action action selected by the compositor
2257 	 * @since 3
2258 	 */
2259 	void (*action)(void *data,
2260 		       struct wl_data_source *wl_data_source,
2261 		       uint32_t dnd_action);
2262 };
2263 
2264 /**
2265  * @ingroup iface_wl_data_source
2266  */
2267 static inline int
wl_data_source_add_listener(struct wl_data_source * wl_data_source,const struct wl_data_source_listener * listener,void * data)2268 wl_data_source_add_listener(struct wl_data_source *wl_data_source,
2269 			    const struct wl_data_source_listener *listener, void *data)
2270 {
2271 	return wl_proxy_add_listener((struct wl_proxy *) wl_data_source,
2272 				     (void (**)(void)) listener, data);
2273 }
2274 
2275 #define WL_DATA_SOURCE_OFFER 0
2276 #define WL_DATA_SOURCE_DESTROY 1
2277 #define WL_DATA_SOURCE_SET_ACTIONS 2
2278 
2279 /**
2280  * @ingroup iface_wl_data_source
2281  */
2282 #define WL_DATA_SOURCE_TARGET_SINCE_VERSION 1
2283 /**
2284  * @ingroup iface_wl_data_source
2285  */
2286 #define WL_DATA_SOURCE_SEND_SINCE_VERSION 1
2287 /**
2288  * @ingroup iface_wl_data_source
2289  */
2290 #define WL_DATA_SOURCE_CANCELLED_SINCE_VERSION 1
2291 /**
2292  * @ingroup iface_wl_data_source
2293  */
2294 #define WL_DATA_SOURCE_DND_DROP_PERFORMED_SINCE_VERSION 3
2295 /**
2296  * @ingroup iface_wl_data_source
2297  */
2298 #define WL_DATA_SOURCE_DND_FINISHED_SINCE_VERSION 3
2299 /**
2300  * @ingroup iface_wl_data_source
2301  */
2302 #define WL_DATA_SOURCE_ACTION_SINCE_VERSION 3
2303 
2304 /**
2305  * @ingroup iface_wl_data_source
2306  */
2307 #define WL_DATA_SOURCE_OFFER_SINCE_VERSION 1
2308 /**
2309  * @ingroup iface_wl_data_source
2310  */
2311 #define WL_DATA_SOURCE_DESTROY_SINCE_VERSION 1
2312 /**
2313  * @ingroup iface_wl_data_source
2314  */
2315 #define WL_DATA_SOURCE_SET_ACTIONS_SINCE_VERSION 3
2316 
2317 /** @ingroup iface_wl_data_source */
2318 static inline void
wl_data_source_set_user_data(struct wl_data_source * wl_data_source,void * user_data)2319 wl_data_source_set_user_data(struct wl_data_source *wl_data_source, void *user_data)
2320 {
2321 	wl_proxy_set_user_data((struct wl_proxy *) wl_data_source, user_data);
2322 }
2323 
2324 /** @ingroup iface_wl_data_source */
2325 static inline void *
wl_data_source_get_user_data(struct wl_data_source * wl_data_source)2326 wl_data_source_get_user_data(struct wl_data_source *wl_data_source)
2327 {
2328 	return wl_proxy_get_user_data((struct wl_proxy *) wl_data_source);
2329 }
2330 
2331 static inline uint32_t
wl_data_source_get_version(struct wl_data_source * wl_data_source)2332 wl_data_source_get_version(struct wl_data_source *wl_data_source)
2333 {
2334 	return wl_proxy_get_version((struct wl_proxy *) wl_data_source);
2335 }
2336 
2337 /**
2338  * @ingroup iface_wl_data_source
2339  *
2340  * This request adds a mime type to the set of mime types
2341  * advertised to targets.  Can be called several times to offer
2342  * multiple types.
2343  */
2344 static inline void
wl_data_source_offer(struct wl_data_source * wl_data_source,const char * mime_type)2345 wl_data_source_offer(struct wl_data_source *wl_data_source, const char *mime_type)
2346 {
2347 	wl_proxy_marshal((struct wl_proxy *) wl_data_source,
2348 			 WL_DATA_SOURCE_OFFER, mime_type);
2349 }
2350 
2351 /**
2352  * @ingroup iface_wl_data_source
2353  *
2354  * Destroy the data source.
2355  */
2356 static inline void
wl_data_source_destroy(struct wl_data_source * wl_data_source)2357 wl_data_source_destroy(struct wl_data_source *wl_data_source)
2358 {
2359 	wl_proxy_marshal((struct wl_proxy *) wl_data_source,
2360 			 WL_DATA_SOURCE_DESTROY);
2361 
2362 	wl_proxy_destroy((struct wl_proxy *) wl_data_source);
2363 }
2364 
2365 /**
2366  * @ingroup iface_wl_data_source
2367  *
2368  * Sets the actions that the source side client supports for this
2369  * operation. This request may trigger wl_data_source.action and
2370  * wl_data_offer.action events if the compositor needs to change the
2371  * selected action.
2372  *
2373  * The dnd_actions argument must contain only values expressed in the
2374  * wl_data_device_manager.dnd_actions enum, otherwise it will result
2375  * in a protocol error.
2376  *
2377  * This request must be made once only, and can only be made on sources
2378  * used in drag-and-drop, so it must be performed before
2379  * wl_data_device.start_drag. Attempting to use the source other than
2380  * for drag-and-drop will raise a protocol error.
2381  */
2382 static inline void
wl_data_source_set_actions(struct wl_data_source * wl_data_source,uint32_t dnd_actions)2383 wl_data_source_set_actions(struct wl_data_source *wl_data_source, uint32_t dnd_actions)
2384 {
2385 	wl_proxy_marshal((struct wl_proxy *) wl_data_source,
2386 			 WL_DATA_SOURCE_SET_ACTIONS, dnd_actions);
2387 }
2388 
2389 #ifndef WL_DATA_DEVICE_ERROR_ENUM
2390 #define WL_DATA_DEVICE_ERROR_ENUM
2391 enum wl_data_device_error {
2392 	/**
2393 	 * given wl_surface has another role
2394 	 */
2395 	WL_DATA_DEVICE_ERROR_ROLE = 0,
2396 };
2397 #endif /* WL_DATA_DEVICE_ERROR_ENUM */
2398 
2399 /**
2400  * @ingroup iface_wl_data_device
2401  * @struct wl_data_device_listener
2402  */
2403 struct wl_data_device_listener {
2404 	/**
2405 	 * introduce a new wl_data_offer
2406 	 *
2407 	 * The data_offer event introduces a new wl_data_offer object,
2408 	 * which will subsequently be used in either the data_device.enter
2409 	 * event (for drag-and-drop) or the data_device.selection event
2410 	 * (for selections). Immediately following the
2411 	 * data_device_data_offer event, the new data_offer object will
2412 	 * send out data_offer.offer events to describe the mime types it
2413 	 * offers.
2414 	 * @param id the new data_offer object
2415 	 */
2416 	void (*data_offer)(void *data,
2417 			   struct wl_data_device *wl_data_device,
2418 			   struct wl_data_offer *id);
2419 	/**
2420 	 * initiate drag-and-drop session
2421 	 *
2422 	 * This event is sent when an active drag-and-drop pointer enters
2423 	 * a surface owned by the client. The position of the pointer at
2424 	 * enter time is provided by the x and y arguments, in
2425 	 * surface-local coordinates.
2426 	 * @param serial serial number of the enter event
2427 	 * @param surface client surface entered
2428 	 * @param x surface-local x coordinate
2429 	 * @param y surface-local y coordinate
2430 	 * @param id source data_offer object
2431 	 */
2432 	void (*enter)(void *data,
2433 		      struct wl_data_device *wl_data_device,
2434 		      uint32_t serial,
2435 		      struct wl_surface *surface,
2436 		      wl_fixed_t x,
2437 		      wl_fixed_t y,
2438 		      struct wl_data_offer *id);
2439 	/**
2440 	 * end drag-and-drop session
2441 	 *
2442 	 * This event is sent when the drag-and-drop pointer leaves the
2443 	 * surface and the session ends. The client must destroy the
2444 	 * wl_data_offer introduced at enter time at this point.
2445 	 */
2446 	void (*leave)(void *data,
2447 		      struct wl_data_device *wl_data_device);
2448 	/**
2449 	 * drag-and-drop session motion
2450 	 *
2451 	 * This event is sent when the drag-and-drop pointer moves within
2452 	 * the currently focused surface. The new position of the pointer
2453 	 * is provided by the x and y arguments, in surface-local
2454 	 * coordinates.
2455 	 * @param time timestamp with millisecond granularity
2456 	 * @param x surface-local x coordinate
2457 	 * @param y surface-local y coordinate
2458 	 */
2459 	void (*motion)(void *data,
2460 		       struct wl_data_device *wl_data_device,
2461 		       uint32_t time,
2462 		       wl_fixed_t x,
2463 		       wl_fixed_t y);
2464 	/**
2465 	 * end drag-and-drop session successfully
2466 	 *
2467 	 * The event is sent when a drag-and-drop operation is ended
2468 	 * because the implicit grab is removed.
2469 	 *
2470 	 * The drag-and-drop destination is expected to honor the last
2471 	 * action received through wl_data_offer.action, if the resulting
2472 	 * action is "copy" or "move", the destination can still perform
2473 	 * wl_data_offer.receive requests, and is expected to end all
2474 	 * transfers with a wl_data_offer.finish request.
2475 	 *
2476 	 * If the resulting action is "ask", the action will not be
2477 	 * considered final. The drag-and-drop destination is expected to
2478 	 * perform one last wl_data_offer.set_actions request, or
2479 	 * wl_data_offer.destroy in order to cancel the operation.
2480 	 */
2481 	void (*drop)(void *data,
2482 		     struct wl_data_device *wl_data_device);
2483 	/**
2484 	 * advertise new selection
2485 	 *
2486 	 * The selection event is sent out to notify the client of a new
2487 	 * wl_data_offer for the selection for this device. The
2488 	 * data_device.data_offer and the data_offer.offer events are sent
2489 	 * out immediately before this event to introduce the data offer
2490 	 * object. The selection event is sent to a client immediately
2491 	 * before receiving keyboard focus and when a new selection is set
2492 	 * while the client has keyboard focus. The data_offer is valid
2493 	 * until a new data_offer or NULL is received or until the client
2494 	 * loses keyboard focus. The client must destroy the previous
2495 	 * selection data_offer, if any, upon receiving this event.
2496 	 * @param id selection data_offer object
2497 	 */
2498 	void (*selection)(void *data,
2499 			  struct wl_data_device *wl_data_device,
2500 			  struct wl_data_offer *id);
2501 };
2502 
2503 /**
2504  * @ingroup iface_wl_data_device
2505  */
2506 static inline int
wl_data_device_add_listener(struct wl_data_device * wl_data_device,const struct wl_data_device_listener * listener,void * data)2507 wl_data_device_add_listener(struct wl_data_device *wl_data_device,
2508 			    const struct wl_data_device_listener *listener, void *data)
2509 {
2510 	return wl_proxy_add_listener((struct wl_proxy *) wl_data_device,
2511 				     (void (**)(void)) listener, data);
2512 }
2513 
2514 #define WL_DATA_DEVICE_START_DRAG 0
2515 #define WL_DATA_DEVICE_SET_SELECTION 1
2516 #define WL_DATA_DEVICE_RELEASE 2
2517 
2518 /**
2519  * @ingroup iface_wl_data_device
2520  */
2521 #define WL_DATA_DEVICE_DATA_OFFER_SINCE_VERSION 1
2522 /**
2523  * @ingroup iface_wl_data_device
2524  */
2525 #define WL_DATA_DEVICE_ENTER_SINCE_VERSION 1
2526 /**
2527  * @ingroup iface_wl_data_device
2528  */
2529 #define WL_DATA_DEVICE_LEAVE_SINCE_VERSION 1
2530 /**
2531  * @ingroup iface_wl_data_device
2532  */
2533 #define WL_DATA_DEVICE_MOTION_SINCE_VERSION 1
2534 /**
2535  * @ingroup iface_wl_data_device
2536  */
2537 #define WL_DATA_DEVICE_DROP_SINCE_VERSION 1
2538 /**
2539  * @ingroup iface_wl_data_device
2540  */
2541 #define WL_DATA_DEVICE_SELECTION_SINCE_VERSION 1
2542 
2543 /**
2544  * @ingroup iface_wl_data_device
2545  */
2546 #define WL_DATA_DEVICE_START_DRAG_SINCE_VERSION 1
2547 /**
2548  * @ingroup iface_wl_data_device
2549  */
2550 #define WL_DATA_DEVICE_SET_SELECTION_SINCE_VERSION 1
2551 /**
2552  * @ingroup iface_wl_data_device
2553  */
2554 #define WL_DATA_DEVICE_RELEASE_SINCE_VERSION 2
2555 
2556 /** @ingroup iface_wl_data_device */
2557 static inline void
wl_data_device_set_user_data(struct wl_data_device * wl_data_device,void * user_data)2558 wl_data_device_set_user_data(struct wl_data_device *wl_data_device, void *user_data)
2559 {
2560 	wl_proxy_set_user_data((struct wl_proxy *) wl_data_device, user_data);
2561 }
2562 
2563 /** @ingroup iface_wl_data_device */
2564 static inline void *
wl_data_device_get_user_data(struct wl_data_device * wl_data_device)2565 wl_data_device_get_user_data(struct wl_data_device *wl_data_device)
2566 {
2567 	return wl_proxy_get_user_data((struct wl_proxy *) wl_data_device);
2568 }
2569 
2570 static inline uint32_t
wl_data_device_get_version(struct wl_data_device * wl_data_device)2571 wl_data_device_get_version(struct wl_data_device *wl_data_device)
2572 {
2573 	return wl_proxy_get_version((struct wl_proxy *) wl_data_device);
2574 }
2575 
2576 /** @ingroup iface_wl_data_device */
2577 static inline void
wl_data_device_destroy(struct wl_data_device * wl_data_device)2578 wl_data_device_destroy(struct wl_data_device *wl_data_device)
2579 {
2580 	wl_proxy_destroy((struct wl_proxy *) wl_data_device);
2581 }
2582 
2583 /**
2584  * @ingroup iface_wl_data_device
2585  *
2586  * This request asks the compositor to start a drag-and-drop
2587  * operation on behalf of the client.
2588  *
2589  * The source argument is the data source that provides the data
2590  * for the eventual data transfer. If source is NULL, enter, leave
2591  * and motion events are sent only to the client that initiated the
2592  * drag and the client is expected to handle the data passing
2593  * internally.
2594  *
2595  * The origin surface is the surface where the drag originates and
2596  * the client must have an active implicit grab that matches the
2597  * serial.
2598  *
2599  * The icon surface is an optional (can be NULL) surface that
2600  * provides an icon to be moved around with the cursor.  Initially,
2601  * the top-left corner of the icon surface is placed at the cursor
2602  * hotspot, but subsequent wl_surface.attach request can move the
2603  * relative position. Attach requests must be confirmed with
2604  * wl_surface.commit as usual. The icon surface is given the role of
2605  * a drag-and-drop icon. If the icon surface already has another role,
2606  * it raises a protocol error.
2607  *
2608  * The current and pending input regions of the icon wl_surface are
2609  * cleared, and wl_surface.set_input_region is ignored until the
2610  * wl_surface is no longer used as the icon surface. When the use
2611  * as an icon ends, the current and pending input regions become
2612  * undefined, and the wl_surface is unmapped.
2613  */
2614 static inline void
wl_data_device_start_drag(struct wl_data_device * wl_data_device,struct wl_data_source * source,struct wl_surface * origin,struct wl_surface * icon,uint32_t serial)2615 wl_data_device_start_drag(struct wl_data_device *wl_data_device, struct wl_data_source *source, struct wl_surface *origin, struct wl_surface *icon, uint32_t serial)
2616 {
2617 	wl_proxy_marshal((struct wl_proxy *) wl_data_device,
2618 			 WL_DATA_DEVICE_START_DRAG, source, origin, icon, serial);
2619 }
2620 
2621 /**
2622  * @ingroup iface_wl_data_device
2623  *
2624  * This request asks the compositor to set the selection
2625  * to the data from the source on behalf of the client.
2626  *
2627  * To unset the selection, set the source to NULL.
2628  */
2629 static inline void
wl_data_device_set_selection(struct wl_data_device * wl_data_device,struct wl_data_source * source,uint32_t serial)2630 wl_data_device_set_selection(struct wl_data_device *wl_data_device, struct wl_data_source *source, uint32_t serial)
2631 {
2632 	wl_proxy_marshal((struct wl_proxy *) wl_data_device,
2633 			 WL_DATA_DEVICE_SET_SELECTION, source, serial);
2634 }
2635 
2636 /**
2637  * @ingroup iface_wl_data_device
2638  *
2639  * This request destroys the data device.
2640  */
2641 static inline void
wl_data_device_release(struct wl_data_device * wl_data_device)2642 wl_data_device_release(struct wl_data_device *wl_data_device)
2643 {
2644 	wl_proxy_marshal((struct wl_proxy *) wl_data_device,
2645 			 WL_DATA_DEVICE_RELEASE);
2646 
2647 	wl_proxy_destroy((struct wl_proxy *) wl_data_device);
2648 }
2649 
2650 #ifndef WL_DATA_DEVICE_MANAGER_DND_ACTION_ENUM
2651 #define WL_DATA_DEVICE_MANAGER_DND_ACTION_ENUM
2652 /**
2653  * @ingroup iface_wl_data_device_manager
2654  * drag and drop actions
2655  *
2656  * This is a bitmask of the available/preferred actions in a
2657  * drag-and-drop operation.
2658  *
2659  * In the compositor, the selected action is a result of matching the
2660  * actions offered by the source and destination sides.  "action" events
2661  * with a "none" action will be sent to both source and destination if
2662  * there is no match. All further checks will effectively happen on
2663  * (source actions ∩ destination actions).
2664  *
2665  * In addition, compositors may also pick different actions in
2666  * reaction to key modifiers being pressed. One common design that
2667  * is used in major toolkits (and the behavior recommended for
2668  * compositors) is:
2669  *
2670  * - If no modifiers are pressed, the first match (in bit order)
2671  * will be used.
2672  * - Pressing Shift selects "move", if enabled in the mask.
2673  * - Pressing Control selects "copy", if enabled in the mask.
2674  *
2675  * Behavior beyond that is considered implementation-dependent.
2676  * Compositors may for example bind other modifiers (like Alt/Meta)
2677  * or drags initiated with other buttons than BTN_LEFT to specific
2678  * actions (e.g. "ask").
2679  */
2680 enum wl_data_device_manager_dnd_action {
2681 	/**
2682 	 * no action
2683 	 */
2684 	WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE = 0,
2685 	/**
2686 	 * copy action
2687 	 */
2688 	WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY = 1,
2689 	/**
2690 	 * move action
2691 	 */
2692 	WL_DATA_DEVICE_MANAGER_DND_ACTION_MOVE = 2,
2693 	/**
2694 	 * ask action
2695 	 */
2696 	WL_DATA_DEVICE_MANAGER_DND_ACTION_ASK = 4,
2697 };
2698 #endif /* WL_DATA_DEVICE_MANAGER_DND_ACTION_ENUM */
2699 
2700 #define WL_DATA_DEVICE_MANAGER_CREATE_DATA_SOURCE 0
2701 #define WL_DATA_DEVICE_MANAGER_GET_DATA_DEVICE 1
2702 
2703 
2704 /**
2705  * @ingroup iface_wl_data_device_manager
2706  */
2707 #define WL_DATA_DEVICE_MANAGER_CREATE_DATA_SOURCE_SINCE_VERSION 1
2708 /**
2709  * @ingroup iface_wl_data_device_manager
2710  */
2711 #define WL_DATA_DEVICE_MANAGER_GET_DATA_DEVICE_SINCE_VERSION 1
2712 
2713 /** @ingroup iface_wl_data_device_manager */
2714 static inline void
wl_data_device_manager_set_user_data(struct wl_data_device_manager * wl_data_device_manager,void * user_data)2715 wl_data_device_manager_set_user_data(struct wl_data_device_manager *wl_data_device_manager, void *user_data)
2716 {
2717 	wl_proxy_set_user_data((struct wl_proxy *) wl_data_device_manager, user_data);
2718 }
2719 
2720 /** @ingroup iface_wl_data_device_manager */
2721 static inline void *
wl_data_device_manager_get_user_data(struct wl_data_device_manager * wl_data_device_manager)2722 wl_data_device_manager_get_user_data(struct wl_data_device_manager *wl_data_device_manager)
2723 {
2724 	return wl_proxy_get_user_data((struct wl_proxy *) wl_data_device_manager);
2725 }
2726 
2727 static inline uint32_t
wl_data_device_manager_get_version(struct wl_data_device_manager * wl_data_device_manager)2728 wl_data_device_manager_get_version(struct wl_data_device_manager *wl_data_device_manager)
2729 {
2730 	return wl_proxy_get_version((struct wl_proxy *) wl_data_device_manager);
2731 }
2732 
2733 /** @ingroup iface_wl_data_device_manager */
2734 static inline void
wl_data_device_manager_destroy(struct wl_data_device_manager * wl_data_device_manager)2735 wl_data_device_manager_destroy(struct wl_data_device_manager *wl_data_device_manager)
2736 {
2737 	wl_proxy_destroy((struct wl_proxy *) wl_data_device_manager);
2738 }
2739 
2740 /**
2741  * @ingroup iface_wl_data_device_manager
2742  *
2743  * Create a new data source.
2744  */
2745 static inline struct wl_data_source *
wl_data_device_manager_create_data_source(struct wl_data_device_manager * wl_data_device_manager)2746 wl_data_device_manager_create_data_source(struct wl_data_device_manager *wl_data_device_manager)
2747 {
2748 	struct wl_proxy *id;
2749 
2750 	id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_data_device_manager,
2751 			 WL_DATA_DEVICE_MANAGER_CREATE_DATA_SOURCE, &wl_data_source_interface, NULL);
2752 
2753 	return (struct wl_data_source *) id;
2754 }
2755 
2756 /**
2757  * @ingroup iface_wl_data_device_manager
2758  *
2759  * Create a new data device for a given seat.
2760  */
2761 static inline struct wl_data_device *
wl_data_device_manager_get_data_device(struct wl_data_device_manager * wl_data_device_manager,struct wl_seat * seat)2762 wl_data_device_manager_get_data_device(struct wl_data_device_manager *wl_data_device_manager, struct wl_seat *seat)
2763 {
2764 	struct wl_proxy *id;
2765 
2766 	id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_data_device_manager,
2767 			 WL_DATA_DEVICE_MANAGER_GET_DATA_DEVICE, &wl_data_device_interface, NULL, seat);
2768 
2769 	return (struct wl_data_device *) id;
2770 }
2771 
2772 #ifndef WL_SHELL_ERROR_ENUM
2773 #define WL_SHELL_ERROR_ENUM
2774 enum wl_shell_error {
2775 	/**
2776 	 * given wl_surface has another role
2777 	 */
2778 	WL_SHELL_ERROR_ROLE = 0,
2779 };
2780 #endif /* WL_SHELL_ERROR_ENUM */
2781 
2782 #define WL_SHELL_GET_SHELL_SURFACE 0
2783 
2784 
2785 /**
2786  * @ingroup iface_wl_shell
2787  */
2788 #define WL_SHELL_GET_SHELL_SURFACE_SINCE_VERSION 1
2789 
2790 /** @ingroup iface_wl_shell */
2791 static inline void
wl_shell_set_user_data(struct wl_shell * wl_shell,void * user_data)2792 wl_shell_set_user_data(struct wl_shell *wl_shell, void *user_data)
2793 {
2794 	wl_proxy_set_user_data((struct wl_proxy *) wl_shell, user_data);
2795 }
2796 
2797 /** @ingroup iface_wl_shell */
2798 static inline void *
wl_shell_get_user_data(struct wl_shell * wl_shell)2799 wl_shell_get_user_data(struct wl_shell *wl_shell)
2800 {
2801 	return wl_proxy_get_user_data((struct wl_proxy *) wl_shell);
2802 }
2803 
2804 static inline uint32_t
wl_shell_get_version(struct wl_shell * wl_shell)2805 wl_shell_get_version(struct wl_shell *wl_shell)
2806 {
2807 	return wl_proxy_get_version((struct wl_proxy *) wl_shell);
2808 }
2809 
2810 /** @ingroup iface_wl_shell */
2811 static inline void
wl_shell_destroy(struct wl_shell * wl_shell)2812 wl_shell_destroy(struct wl_shell *wl_shell)
2813 {
2814 	wl_proxy_destroy((struct wl_proxy *) wl_shell);
2815 }
2816 
2817 /**
2818  * @ingroup iface_wl_shell
2819  *
2820  * Create a shell surface for an existing surface. This gives
2821  * the wl_surface the role of a shell surface. If the wl_surface
2822  * already has another role, it raises a protocol error.
2823  *
2824  * Only one shell surface can be associated with a given surface.
2825  */
2826 static inline struct wl_shell_surface *
wl_shell_get_shell_surface(struct wl_shell * wl_shell,struct wl_surface * surface)2827 wl_shell_get_shell_surface(struct wl_shell *wl_shell, struct wl_surface *surface)
2828 {
2829 	struct wl_proxy *id;
2830 
2831 	id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_shell,
2832 			 WL_SHELL_GET_SHELL_SURFACE, &wl_shell_surface_interface, NULL, surface);
2833 
2834 	return (struct wl_shell_surface *) id;
2835 }
2836 
2837 #ifndef WL_SHELL_SURFACE_RESIZE_ENUM
2838 #define WL_SHELL_SURFACE_RESIZE_ENUM
2839 /**
2840  * @ingroup iface_wl_shell_surface
2841  * edge values for resizing
2842  *
2843  * These values are used to indicate which edge of a surface
2844  * is being dragged in a resize operation. The server may
2845  * use this information to adapt its behavior, e.g. choose
2846  * an appropriate cursor image.
2847  */
2848 enum wl_shell_surface_resize {
2849 	/**
2850 	 * no edge
2851 	 */
2852 	WL_SHELL_SURFACE_RESIZE_NONE = 0,
2853 	/**
2854 	 * top edge
2855 	 */
2856 	WL_SHELL_SURFACE_RESIZE_TOP = 1,
2857 	/**
2858 	 * bottom edge
2859 	 */
2860 	WL_SHELL_SURFACE_RESIZE_BOTTOM = 2,
2861 	/**
2862 	 * left edge
2863 	 */
2864 	WL_SHELL_SURFACE_RESIZE_LEFT = 4,
2865 	/**
2866 	 * top and left edges
2867 	 */
2868 	WL_SHELL_SURFACE_RESIZE_TOP_LEFT = 5,
2869 	/**
2870 	 * bottom and left edges
2871 	 */
2872 	WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT = 6,
2873 	/**
2874 	 * right edge
2875 	 */
2876 	WL_SHELL_SURFACE_RESIZE_RIGHT = 8,
2877 	/**
2878 	 * top and right edges
2879 	 */
2880 	WL_SHELL_SURFACE_RESIZE_TOP_RIGHT = 9,
2881 	/**
2882 	 * bottom and right edges
2883 	 */
2884 	WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT = 10,
2885 };
2886 #endif /* WL_SHELL_SURFACE_RESIZE_ENUM */
2887 
2888 #ifndef WL_SHELL_SURFACE_TRANSIENT_ENUM
2889 #define WL_SHELL_SURFACE_TRANSIENT_ENUM
2890 /**
2891  * @ingroup iface_wl_shell_surface
2892  * details of transient behaviour
2893  *
2894  * These flags specify details of the expected behaviour
2895  * of transient surfaces. Used in the set_transient request.
2896  */
2897 enum wl_shell_surface_transient {
2898 	/**
2899 	 * do not set keyboard focus
2900 	 */
2901 	WL_SHELL_SURFACE_TRANSIENT_INACTIVE = 0x1,
2902 };
2903 #endif /* WL_SHELL_SURFACE_TRANSIENT_ENUM */
2904 
2905 #ifndef WL_SHELL_SURFACE_FULLSCREEN_METHOD_ENUM
2906 #define WL_SHELL_SURFACE_FULLSCREEN_METHOD_ENUM
2907 /**
2908  * @ingroup iface_wl_shell_surface
2909  * different method to set the surface fullscreen
2910  *
2911  * Hints to indicate to the compositor how to deal with a conflict
2912  * between the dimensions of the surface and the dimensions of the
2913  * output. The compositor is free to ignore this parameter.
2914  */
2915 enum wl_shell_surface_fullscreen_method {
2916 	/**
2917 	 * no preference, apply default policy
2918 	 */
2919 	WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT = 0,
2920 	/**
2921 	 * scale, preserve the surface's aspect ratio and center on output
2922 	 */
2923 	WL_SHELL_SURFACE_FULLSCREEN_METHOD_SCALE = 1,
2924 	/**
2925 	 * switch output mode to the smallest mode that can fit the surface, add black borders to compensate size mismatch
2926 	 */
2927 	WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER = 2,
2928 	/**
2929 	 * no upscaling, center on output and add black borders to compensate size mismatch
2930 	 */
2931 	WL_SHELL_SURFACE_FULLSCREEN_METHOD_FILL = 3,
2932 };
2933 #endif /* WL_SHELL_SURFACE_FULLSCREEN_METHOD_ENUM */
2934 
2935 /**
2936  * @ingroup iface_wl_shell_surface
2937  * @struct wl_shell_surface_listener
2938  */
2939 struct wl_shell_surface_listener {
2940 	/**
2941 	 * ping client
2942 	 *
2943 	 * Ping a client to check if it is receiving events and sending
2944 	 * requests. A client is expected to reply with a pong request.
2945 	 * @param serial serial number of the ping
2946 	 */
2947 	void (*ping)(void *data,
2948 		     struct wl_shell_surface *wl_shell_surface,
2949 		     uint32_t serial);
2950 	/**
2951 	 * suggest resize
2952 	 *
2953 	 * The configure event asks the client to resize its surface.
2954 	 *
2955 	 * The size is a hint, in the sense that the client is free to
2956 	 * ignore it if it doesn't resize, pick a smaller size (to satisfy
2957 	 * aspect ratio or resize in steps of NxM pixels).
2958 	 *
2959 	 * The edges parameter provides a hint about how the surface was
2960 	 * resized. The client may use this information to decide how to
2961 	 * adjust its content to the new size (e.g. a scrolling area might
2962 	 * adjust its content position to leave the viewable content
2963 	 * unmoved).
2964 	 *
2965 	 * The client is free to dismiss all but the last configure event
2966 	 * it received.
2967 	 *
2968 	 * The width and height arguments specify the size of the window in
2969 	 * surface-local coordinates.
2970 	 * @param edges how the surface was resized
2971 	 * @param width new width of the surface
2972 	 * @param height new height of the surface
2973 	 */
2974 	void (*configure)(void *data,
2975 			  struct wl_shell_surface *wl_shell_surface,
2976 			  uint32_t edges,
2977 			  int32_t width,
2978 			  int32_t height);
2979 	/**
2980 	 * popup interaction is done
2981 	 *
2982 	 * The popup_done event is sent out when a popup grab is broken,
2983 	 * that is, when the user clicks a surface that doesn't belong to
2984 	 * the client owning the popup surface.
2985 	 */
2986 	void (*popup_done)(void *data,
2987 			   struct wl_shell_surface *wl_shell_surface);
2988 };
2989 
2990 /**
2991  * @ingroup iface_wl_shell_surface
2992  */
2993 static inline int
wl_shell_surface_add_listener(struct wl_shell_surface * wl_shell_surface,const struct wl_shell_surface_listener * listener,void * data)2994 wl_shell_surface_add_listener(struct wl_shell_surface *wl_shell_surface,
2995 			      const struct wl_shell_surface_listener *listener, void *data)
2996 {
2997 	return wl_proxy_add_listener((struct wl_proxy *) wl_shell_surface,
2998 				     (void (**)(void)) listener, data);
2999 }
3000 
3001 #define WL_SHELL_SURFACE_PONG 0
3002 #define WL_SHELL_SURFACE_MOVE 1
3003 #define WL_SHELL_SURFACE_RESIZE 2
3004 #define WL_SHELL_SURFACE_SET_TOPLEVEL 3
3005 #define WL_SHELL_SURFACE_SET_TRANSIENT 4
3006 #define WL_SHELL_SURFACE_SET_FULLSCREEN 5
3007 #define WL_SHELL_SURFACE_SET_POPUP 6
3008 #define WL_SHELL_SURFACE_SET_MAXIMIZED 7
3009 #define WL_SHELL_SURFACE_SET_TITLE 8
3010 #define WL_SHELL_SURFACE_SET_CLASS 9
3011 
3012 /**
3013  * @ingroup iface_wl_shell_surface
3014  */
3015 #define WL_SHELL_SURFACE_PING_SINCE_VERSION 1
3016 /**
3017  * @ingroup iface_wl_shell_surface
3018  */
3019 #define WL_SHELL_SURFACE_CONFIGURE_SINCE_VERSION 1
3020 /**
3021  * @ingroup iface_wl_shell_surface
3022  */
3023 #define WL_SHELL_SURFACE_POPUP_DONE_SINCE_VERSION 1
3024 
3025 /**
3026  * @ingroup iface_wl_shell_surface
3027  */
3028 #define WL_SHELL_SURFACE_PONG_SINCE_VERSION 1
3029 /**
3030  * @ingroup iface_wl_shell_surface
3031  */
3032 #define WL_SHELL_SURFACE_MOVE_SINCE_VERSION 1
3033 /**
3034  * @ingroup iface_wl_shell_surface
3035  */
3036 #define WL_SHELL_SURFACE_RESIZE_SINCE_VERSION 1
3037 /**
3038  * @ingroup iface_wl_shell_surface
3039  */
3040 #define WL_SHELL_SURFACE_SET_TOPLEVEL_SINCE_VERSION 1
3041 /**
3042  * @ingroup iface_wl_shell_surface
3043  */
3044 #define WL_SHELL_SURFACE_SET_TRANSIENT_SINCE_VERSION 1
3045 /**
3046  * @ingroup iface_wl_shell_surface
3047  */
3048 #define WL_SHELL_SURFACE_SET_FULLSCREEN_SINCE_VERSION 1
3049 /**
3050  * @ingroup iface_wl_shell_surface
3051  */
3052 #define WL_SHELL_SURFACE_SET_POPUP_SINCE_VERSION 1
3053 /**
3054  * @ingroup iface_wl_shell_surface
3055  */
3056 #define WL_SHELL_SURFACE_SET_MAXIMIZED_SINCE_VERSION 1
3057 /**
3058  * @ingroup iface_wl_shell_surface
3059  */
3060 #define WL_SHELL_SURFACE_SET_TITLE_SINCE_VERSION 1
3061 /**
3062  * @ingroup iface_wl_shell_surface
3063  */
3064 #define WL_SHELL_SURFACE_SET_CLASS_SINCE_VERSION 1
3065 
3066 /** @ingroup iface_wl_shell_surface */
3067 static inline void
wl_shell_surface_set_user_data(struct wl_shell_surface * wl_shell_surface,void * user_data)3068 wl_shell_surface_set_user_data(struct wl_shell_surface *wl_shell_surface, void *user_data)
3069 {
3070 	wl_proxy_set_user_data((struct wl_proxy *) wl_shell_surface, user_data);
3071 }
3072 
3073 /** @ingroup iface_wl_shell_surface */
3074 static inline void *
wl_shell_surface_get_user_data(struct wl_shell_surface * wl_shell_surface)3075 wl_shell_surface_get_user_data(struct wl_shell_surface *wl_shell_surface)
3076 {
3077 	return wl_proxy_get_user_data((struct wl_proxy *) wl_shell_surface);
3078 }
3079 
3080 static inline uint32_t
wl_shell_surface_get_version(struct wl_shell_surface * wl_shell_surface)3081 wl_shell_surface_get_version(struct wl_shell_surface *wl_shell_surface)
3082 {
3083 	return wl_proxy_get_version((struct wl_proxy *) wl_shell_surface);
3084 }
3085 
3086 /** @ingroup iface_wl_shell_surface */
3087 static inline void
wl_shell_surface_destroy(struct wl_shell_surface * wl_shell_surface)3088 wl_shell_surface_destroy(struct wl_shell_surface *wl_shell_surface)
3089 {
3090 	wl_proxy_destroy((struct wl_proxy *) wl_shell_surface);
3091 }
3092 
3093 /**
3094  * @ingroup iface_wl_shell_surface
3095  *
3096  * A client must respond to a ping event with a pong request or
3097  * the client may be deemed unresponsive.
3098  */
3099 static inline void
wl_shell_surface_pong(struct wl_shell_surface * wl_shell_surface,uint32_t serial)3100 wl_shell_surface_pong(struct wl_shell_surface *wl_shell_surface, uint32_t serial)
3101 {
3102 	wl_proxy_marshal((struct wl_proxy *) wl_shell_surface,
3103 			 WL_SHELL_SURFACE_PONG, serial);
3104 }
3105 
3106 /**
3107  * @ingroup iface_wl_shell_surface
3108  *
3109  * Start a pointer-driven move of the surface.
3110  *
3111  * This request must be used in response to a button press event.
3112  * The server may ignore move requests depending on the state of
3113  * the surface (e.g. fullscreen or maximized).
3114  */
3115 static inline void
wl_shell_surface_move(struct wl_shell_surface * wl_shell_surface,struct wl_seat * seat,uint32_t serial)3116 wl_shell_surface_move(struct wl_shell_surface *wl_shell_surface, struct wl_seat *seat, uint32_t serial)
3117 {
3118 	wl_proxy_marshal((struct wl_proxy *) wl_shell_surface,
3119 			 WL_SHELL_SURFACE_MOVE, seat, serial);
3120 }
3121 
3122 /**
3123  * @ingroup iface_wl_shell_surface
3124  *
3125  * Start a pointer-driven resizing of the surface.
3126  *
3127  * This request must be used in response to a button press event.
3128  * The server may ignore resize requests depending on the state of
3129  * the surface (e.g. fullscreen or maximized).
3130  */
3131 static inline void
wl_shell_surface_resize(struct wl_shell_surface * wl_shell_surface,struct wl_seat * seat,uint32_t serial,uint32_t edges)3132 wl_shell_surface_resize(struct wl_shell_surface *wl_shell_surface, struct wl_seat *seat, uint32_t serial, uint32_t edges)
3133 {
3134 	wl_proxy_marshal((struct wl_proxy *) wl_shell_surface,
3135 			 WL_SHELL_SURFACE_RESIZE, seat, serial, edges);
3136 }
3137 
3138 /**
3139  * @ingroup iface_wl_shell_surface
3140  *
3141  * Map the surface as a toplevel surface.
3142  *
3143  * A toplevel surface is not fullscreen, maximized or transient.
3144  */
3145 static inline void
wl_shell_surface_set_toplevel(struct wl_shell_surface * wl_shell_surface)3146 wl_shell_surface_set_toplevel(struct wl_shell_surface *wl_shell_surface)
3147 {
3148 	wl_proxy_marshal((struct wl_proxy *) wl_shell_surface,
3149 			 WL_SHELL_SURFACE_SET_TOPLEVEL);
3150 }
3151 
3152 /**
3153  * @ingroup iface_wl_shell_surface
3154  *
3155  * Map the surface relative to an existing surface.
3156  *
3157  * The x and y arguments specify the location of the upper left
3158  * corner of the surface relative to the upper left corner of the
3159  * parent surface, in surface-local coordinates.
3160  *
3161  * The flags argument controls details of the transient behaviour.
3162  */
3163 static inline void
wl_shell_surface_set_transient(struct wl_shell_surface * wl_shell_surface,struct wl_surface * parent,int32_t x,int32_t y,uint32_t flags)3164 wl_shell_surface_set_transient(struct wl_shell_surface *wl_shell_surface, struct wl_surface *parent, int32_t x, int32_t y, uint32_t flags)
3165 {
3166 	wl_proxy_marshal((struct wl_proxy *) wl_shell_surface,
3167 			 WL_SHELL_SURFACE_SET_TRANSIENT, parent, x, y, flags);
3168 }
3169 
3170 /**
3171  * @ingroup iface_wl_shell_surface
3172  *
3173  * Map the surface as a fullscreen surface.
3174  *
3175  * If an output parameter is given then the surface will be made
3176  * fullscreen on that output. If the client does not specify the
3177  * output then the compositor will apply its policy - usually
3178  * choosing the output on which the surface has the biggest surface
3179  * area.
3180  *
3181  * The client may specify a method to resolve a size conflict
3182  * between the output size and the surface size - this is provided
3183  * through the method parameter.
3184  *
3185  * The framerate parameter is used only when the method is set
3186  * to "driver", to indicate the preferred framerate. A value of 0
3187  * indicates that the client does not care about framerate.  The
3188  * framerate is specified in mHz, that is framerate of 60000 is 60Hz.
3189  *
3190  * A method of "scale" or "driver" implies a scaling operation of
3191  * the surface, either via a direct scaling operation or a change of
3192  * the output mode. This will override any kind of output scaling, so
3193  * that mapping a surface with a buffer size equal to the mode can
3194  * fill the screen independent of buffer_scale.
3195  *
3196  * A method of "fill" means we don't scale up the buffer, however
3197  * any output scale is applied. This means that you may run into
3198  * an edge case where the application maps a buffer with the same
3199  * size of the output mode but buffer_scale 1 (thus making a
3200  * surface larger than the output). In this case it is allowed to
3201  * downscale the results to fit the screen.
3202  *
3203  * The compositor must reply to this request with a configure event
3204  * with the dimensions for the output on which the surface will
3205  * be made fullscreen.
3206  */
3207 static inline void
wl_shell_surface_set_fullscreen(struct wl_shell_surface * wl_shell_surface,uint32_t method,uint32_t framerate,struct wl_output * output)3208 wl_shell_surface_set_fullscreen(struct wl_shell_surface *wl_shell_surface, uint32_t method, uint32_t framerate, struct wl_output *output)
3209 {
3210 	wl_proxy_marshal((struct wl_proxy *) wl_shell_surface,
3211 			 WL_SHELL_SURFACE_SET_FULLSCREEN, method, framerate, output);
3212 }
3213 
3214 /**
3215  * @ingroup iface_wl_shell_surface
3216  *
3217  * Map the surface as a popup.
3218  *
3219  * A popup surface is a transient surface with an added pointer
3220  * grab.
3221  *
3222  * An existing implicit grab will be changed to owner-events mode,
3223  * and the popup grab will continue after the implicit grab ends
3224  * (i.e. releasing the mouse button does not cause the popup to
3225  * be unmapped).
3226  *
3227  * The popup grab continues until the window is destroyed or a
3228  * mouse button is pressed in any other client's window. A click
3229  * in any of the client's surfaces is reported as normal, however,
3230  * clicks in other clients' surfaces will be discarded and trigger
3231  * the callback.
3232  *
3233  * The x and y arguments specify the location of the upper left
3234  * corner of the surface relative to the upper left corner of the
3235  * parent surface, in surface-local coordinates.
3236  */
3237 static inline void
wl_shell_surface_set_popup(struct wl_shell_surface * wl_shell_surface,struct wl_seat * seat,uint32_t serial,struct wl_surface * parent,int32_t x,int32_t y,uint32_t flags)3238 wl_shell_surface_set_popup(struct wl_shell_surface *wl_shell_surface, struct wl_seat *seat, uint32_t serial, struct wl_surface *parent, int32_t x, int32_t y, uint32_t flags)
3239 {
3240 	wl_proxy_marshal((struct wl_proxy *) wl_shell_surface,
3241 			 WL_SHELL_SURFACE_SET_POPUP, seat, serial, parent, x, y, flags);
3242 }
3243 
3244 /**
3245  * @ingroup iface_wl_shell_surface
3246  *
3247  * Map the surface as a maximized surface.
3248  *
3249  * If an output parameter is given then the surface will be
3250  * maximized on that output. If the client does not specify the
3251  * output then the compositor will apply its policy - usually
3252  * choosing the output on which the surface has the biggest surface
3253  * area.
3254  *
3255  * The compositor will reply with a configure event telling
3256  * the expected new surface size. The operation is completed
3257  * on the next buffer attach to this surface.
3258  *
3259  * A maximized surface typically fills the entire output it is
3260  * bound to, except for desktop elements such as panels. This is
3261  * the main difference between a maximized shell surface and a
3262  * fullscreen shell surface.
3263  *
3264  * The details depend on the compositor implementation.
3265  */
3266 static inline void
wl_shell_surface_set_maximized(struct wl_shell_surface * wl_shell_surface,struct wl_output * output)3267 wl_shell_surface_set_maximized(struct wl_shell_surface *wl_shell_surface, struct wl_output *output)
3268 {
3269 	wl_proxy_marshal((struct wl_proxy *) wl_shell_surface,
3270 			 WL_SHELL_SURFACE_SET_MAXIMIZED, output);
3271 }
3272 
3273 /**
3274  * @ingroup iface_wl_shell_surface
3275  *
3276  * Set a short title for the surface.
3277  *
3278  * This string may be used to identify the surface in a task bar,
3279  * window list, or other user interface elements provided by the
3280  * compositor.
3281  *
3282  * The string must be encoded in UTF-8.
3283  */
3284 static inline void
wl_shell_surface_set_title(struct wl_shell_surface * wl_shell_surface,const char * title)3285 wl_shell_surface_set_title(struct wl_shell_surface *wl_shell_surface, const char *title)
3286 {
3287 	wl_proxy_marshal((struct wl_proxy *) wl_shell_surface,
3288 			 WL_SHELL_SURFACE_SET_TITLE, title);
3289 }
3290 
3291 /**
3292  * @ingroup iface_wl_shell_surface
3293  *
3294  * Set a class for the surface.
3295  *
3296  * The surface class identifies the general class of applications
3297  * to which the surface belongs. A common convention is to use the
3298  * file name (or the full path if it is a non-standard location) of
3299  * the application's .desktop file as the class.
3300  */
3301 static inline void
wl_shell_surface_set_class(struct wl_shell_surface * wl_shell_surface,const char * class_)3302 wl_shell_surface_set_class(struct wl_shell_surface *wl_shell_surface, const char *class_)
3303 {
3304 	wl_proxy_marshal((struct wl_proxy *) wl_shell_surface,
3305 			 WL_SHELL_SURFACE_SET_CLASS, class_);
3306 }
3307 
3308 #ifndef WL_SURFACE_ERROR_ENUM
3309 #define WL_SURFACE_ERROR_ENUM
3310 /**
3311  * @ingroup iface_wl_surface
3312  * wl_surface error values
3313  *
3314  * These errors can be emitted in response to wl_surface requests.
3315  */
3316 enum wl_surface_error {
3317 	/**
3318 	 * buffer scale value is invalid
3319 	 */
3320 	WL_SURFACE_ERROR_INVALID_SCALE = 0,
3321 	/**
3322 	 * buffer transform value is invalid
3323 	 */
3324 	WL_SURFACE_ERROR_INVALID_TRANSFORM = 1,
3325 };
3326 #endif /* WL_SURFACE_ERROR_ENUM */
3327 
3328 /**
3329  * @ingroup iface_wl_surface
3330  * @struct wl_surface_listener
3331  */
3332 struct wl_surface_listener {
3333 	/**
3334 	 * surface enters an output
3335 	 *
3336 	 * This is emitted whenever a surface's creation, movement, or
3337 	 * resizing results in some part of it being within the scanout
3338 	 * region of an output.
3339 	 *
3340 	 * Note that a surface may be overlapping with zero or more
3341 	 * outputs.
3342 	 * @param output output entered by the surface
3343 	 */
3344 	void (*enter)(void *data,
3345 		      struct wl_surface *wl_surface,
3346 		      struct wl_output *output);
3347 	/**
3348 	 * surface leaves an output
3349 	 *
3350 	 * This is emitted whenever a surface's creation, movement, or
3351 	 * resizing results in it no longer having any part of it within
3352 	 * the scanout region of an output.
3353 	 * @param output output left by the surface
3354 	 */
3355 	void (*leave)(void *data,
3356 		      struct wl_surface *wl_surface,
3357 		      struct wl_output *output);
3358 };
3359 
3360 /**
3361  * @ingroup iface_wl_surface
3362  */
3363 static inline int
wl_surface_add_listener(struct wl_surface * wl_surface,const struct wl_surface_listener * listener,void * data)3364 wl_surface_add_listener(struct wl_surface *wl_surface,
3365 			const struct wl_surface_listener *listener, void *data)
3366 {
3367 	return wl_proxy_add_listener((struct wl_proxy *) wl_surface,
3368 				     (void (**)(void)) listener, data);
3369 }
3370 
3371 #define WL_SURFACE_DESTROY 0
3372 #define WL_SURFACE_ATTACH 1
3373 #define WL_SURFACE_DAMAGE 2
3374 #define WL_SURFACE_FRAME 3
3375 #define WL_SURFACE_SET_OPAQUE_REGION 4
3376 #define WL_SURFACE_SET_INPUT_REGION 5
3377 #define WL_SURFACE_COMMIT 6
3378 #define WL_SURFACE_SET_BUFFER_TRANSFORM 7
3379 #define WL_SURFACE_SET_BUFFER_SCALE 8
3380 #define WL_SURFACE_DAMAGE_BUFFER 9
3381 
3382 /**
3383  * @ingroup iface_wl_surface
3384  */
3385 #define WL_SURFACE_ENTER_SINCE_VERSION 1
3386 /**
3387  * @ingroup iface_wl_surface
3388  */
3389 #define WL_SURFACE_LEAVE_SINCE_VERSION 1
3390 
3391 /**
3392  * @ingroup iface_wl_surface
3393  */
3394 #define WL_SURFACE_DESTROY_SINCE_VERSION 1
3395 /**
3396  * @ingroup iface_wl_surface
3397  */
3398 #define WL_SURFACE_ATTACH_SINCE_VERSION 1
3399 /**
3400  * @ingroup iface_wl_surface
3401  */
3402 #define WL_SURFACE_DAMAGE_SINCE_VERSION 1
3403 /**
3404  * @ingroup iface_wl_surface
3405  */
3406 #define WL_SURFACE_FRAME_SINCE_VERSION 1
3407 /**
3408  * @ingroup iface_wl_surface
3409  */
3410 #define WL_SURFACE_SET_OPAQUE_REGION_SINCE_VERSION 1
3411 /**
3412  * @ingroup iface_wl_surface
3413  */
3414 #define WL_SURFACE_SET_INPUT_REGION_SINCE_VERSION 1
3415 /**
3416  * @ingroup iface_wl_surface
3417  */
3418 #define WL_SURFACE_COMMIT_SINCE_VERSION 1
3419 /**
3420  * @ingroup iface_wl_surface
3421  */
3422 #define WL_SURFACE_SET_BUFFER_TRANSFORM_SINCE_VERSION 2
3423 /**
3424  * @ingroup iface_wl_surface
3425  */
3426 #define WL_SURFACE_SET_BUFFER_SCALE_SINCE_VERSION 3
3427 /**
3428  * @ingroup iface_wl_surface
3429  */
3430 #define WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION 4
3431 
3432 /** @ingroup iface_wl_surface */
3433 static inline void
wl_surface_set_user_data(struct wl_surface * wl_surface,void * user_data)3434 wl_surface_set_user_data(struct wl_surface *wl_surface, void *user_data)
3435 {
3436 	wl_proxy_set_user_data((struct wl_proxy *) wl_surface, user_data);
3437 }
3438 
3439 /** @ingroup iface_wl_surface */
3440 static inline void *
wl_surface_get_user_data(struct wl_surface * wl_surface)3441 wl_surface_get_user_data(struct wl_surface *wl_surface)
3442 {
3443 	return wl_proxy_get_user_data((struct wl_proxy *) wl_surface);
3444 }
3445 
3446 static inline uint32_t
wl_surface_get_version(struct wl_surface * wl_surface)3447 wl_surface_get_version(struct wl_surface *wl_surface)
3448 {
3449 	return wl_proxy_get_version((struct wl_proxy *) wl_surface);
3450 }
3451 
3452 /**
3453  * @ingroup iface_wl_surface
3454  *
3455  * Deletes the surface and invalidates its object ID.
3456  */
3457 static inline void
wl_surface_destroy(struct wl_surface * wl_surface)3458 wl_surface_destroy(struct wl_surface *wl_surface)
3459 {
3460 	wl_proxy_marshal((struct wl_proxy *) wl_surface,
3461 			 WL_SURFACE_DESTROY);
3462 
3463 	wl_proxy_destroy((struct wl_proxy *) wl_surface);
3464 }
3465 
3466 /**
3467  * @ingroup iface_wl_surface
3468  *
3469  * Set a buffer as the content of this surface.
3470  *
3471  * The new size of the surface is calculated based on the buffer
3472  * size transformed by the inverse buffer_transform and the
3473  * inverse buffer_scale. This means that the supplied buffer
3474  * must be an integer multiple of the buffer_scale.
3475  *
3476  * The x and y arguments specify the location of the new pending
3477  * buffer's upper left corner, relative to the current buffer's upper
3478  * left corner, in surface-local coordinates. In other words, the
3479  * x and y, combined with the new surface size define in which
3480  * directions the surface's size changes.
3481  *
3482  * Surface contents are double-buffered state, see wl_surface.commit.
3483  *
3484  * The initial surface contents are void; there is no content.
3485  * wl_surface.attach assigns the given wl_buffer as the pending
3486  * wl_buffer. wl_surface.commit makes the pending wl_buffer the new
3487  * surface contents, and the size of the surface becomes the size
3488  * calculated from the wl_buffer, as described above. After commit,
3489  * there is no pending buffer until the next attach.
3490  *
3491  * Committing a pending wl_buffer allows the compositor to read the
3492  * pixels in the wl_buffer. The compositor may access the pixels at
3493  * any time after the wl_surface.commit request. When the compositor
3494  * will not access the pixels anymore, it will send the
3495  * wl_buffer.release event. Only after receiving wl_buffer.release,
3496  * the client may reuse the wl_buffer. A wl_buffer that has been
3497  * attached and then replaced by another attach instead of committed
3498  * will not receive a release event, and is not used by the
3499  * compositor.
3500  *
3501  * Destroying the wl_buffer after wl_buffer.release does not change
3502  * the surface contents. However, if the client destroys the
3503  * wl_buffer before receiving the wl_buffer.release event, the surface
3504  * contents become undefined immediately.
3505  *
3506  * If wl_surface.attach is sent with a NULL wl_buffer, the
3507  * following wl_surface.commit will remove the surface content.
3508  */
3509 static inline void
wl_surface_attach(struct wl_surface * wl_surface,struct wl_buffer * buffer,int32_t x,int32_t y)3510 wl_surface_attach(struct wl_surface *wl_surface, struct wl_buffer *buffer, int32_t x, int32_t y)
3511 {
3512 	wl_proxy_marshal((struct wl_proxy *) wl_surface,
3513 			 WL_SURFACE_ATTACH, buffer, x, y);
3514 }
3515 
3516 /**
3517  * @ingroup iface_wl_surface
3518  *
3519  * This request is used to describe the regions where the pending
3520  * buffer is different from the current surface contents, and where
3521  * the surface therefore needs to be repainted. The compositor
3522  * ignores the parts of the damage that fall outside of the surface.
3523  *
3524  * Damage is double-buffered state, see wl_surface.commit.
3525  *
3526  * The damage rectangle is specified in surface-local coordinates,
3527  * where x and y specify the upper left corner of the damage rectangle.
3528  *
3529  * The initial value for pending damage is empty: no damage.
3530  * wl_surface.damage adds pending damage: the new pending damage
3531  * is the union of old pending damage and the given rectangle.
3532  *
3533  * wl_surface.commit assigns pending damage as the current damage,
3534  * and clears pending damage. The server will clear the current
3535  * damage as it repaints the surface.
3536  *
3537  * Alternatively, damage can be posted with wl_surface.damage_buffer
3538  * which uses buffer coordinates instead of surface coordinates,
3539  * and is probably the preferred and intuitive way of doing this.
3540  */
3541 static inline void
wl_surface_damage(struct wl_surface * wl_surface,int32_t x,int32_t y,int32_t width,int32_t height)3542 wl_surface_damage(struct wl_surface *wl_surface, int32_t x, int32_t y, int32_t width, int32_t height)
3543 {
3544 	wl_proxy_marshal((struct wl_proxy *) wl_surface,
3545 			 WL_SURFACE_DAMAGE, x, y, width, height);
3546 }
3547 
3548 /**
3549  * @ingroup iface_wl_surface
3550  *
3551  * Request a notification when it is a good time to start drawing a new
3552  * frame, by creating a frame callback. This is useful for throttling
3553  * redrawing operations, and driving animations.
3554  *
3555  * When a client is animating on a wl_surface, it can use the 'frame'
3556  * request to get notified when it is a good time to draw and commit the
3557  * next frame of animation. If the client commits an update earlier than
3558  * that, it is likely that some updates will not make it to the display,
3559  * and the client is wasting resources by drawing too often.
3560  *
3561  * The frame request will take effect on the next wl_surface.commit.
3562  * The notification will only be posted for one frame unless
3563  * requested again. For a wl_surface, the notifications are posted in
3564  * the order the frame requests were committed.
3565  *
3566  * The server must send the notifications so that a client
3567  * will not send excessive updates, while still allowing
3568  * the highest possible update rate for clients that wait for the reply
3569  * before drawing again. The server should give some time for the client
3570  * to draw and commit after sending the frame callback events to let it
3571  * hit the next output refresh.
3572  *
3573  * A server should avoid signaling the frame callbacks if the
3574  * surface is not visible in any way, e.g. the surface is off-screen,
3575  * or completely obscured by other opaque surfaces.
3576  *
3577  * The object returned by this request will be destroyed by the
3578  * compositor after the callback is fired and as such the client must not
3579  * attempt to use it after that point.
3580  *
3581  * The callback_data passed in the callback is the current time, in
3582  * milliseconds, with an undefined base.
3583  */
3584 static inline struct wl_callback *
wl_surface_frame(struct wl_surface * wl_surface)3585 wl_surface_frame(struct wl_surface *wl_surface)
3586 {
3587 	struct wl_proxy *callback;
3588 
3589 	callback = wl_proxy_marshal_constructor((struct wl_proxy *) wl_surface,
3590 			 WL_SURFACE_FRAME, &wl_callback_interface, NULL);
3591 
3592 	return (struct wl_callback *) callback;
3593 }
3594 
3595 /**
3596  * @ingroup iface_wl_surface
3597  *
3598  * This request sets the region of the surface that contains
3599  * opaque content.
3600  *
3601  * The opaque region is an optimization hint for the compositor
3602  * that lets it optimize the redrawing of content behind opaque
3603  * regions.  Setting an opaque region is not required for correct
3604  * behaviour, but marking transparent content as opaque will result
3605  * in repaint artifacts.
3606  *
3607  * The opaque region is specified in surface-local coordinates.
3608  *
3609  * The compositor ignores the parts of the opaque region that fall
3610  * outside of the surface.
3611  *
3612  * Opaque region is double-buffered state, see wl_surface.commit.
3613  *
3614  * wl_surface.set_opaque_region changes the pending opaque region.
3615  * wl_surface.commit copies the pending region to the current region.
3616  * Otherwise, the pending and current regions are never changed.
3617  *
3618  * The initial value for an opaque region is empty. Setting the pending
3619  * opaque region has copy semantics, and the wl_region object can be
3620  * destroyed immediately. A NULL wl_region causes the pending opaque
3621  * region to be set to empty.
3622  */
3623 static inline void
wl_surface_set_opaque_region(struct wl_surface * wl_surface,struct wl_region * region)3624 wl_surface_set_opaque_region(struct wl_surface *wl_surface, struct wl_region *region)
3625 {
3626 	wl_proxy_marshal((struct wl_proxy *) wl_surface,
3627 			 WL_SURFACE_SET_OPAQUE_REGION, region);
3628 }
3629 
3630 /**
3631  * @ingroup iface_wl_surface
3632  *
3633  * This request sets the region of the surface that can receive
3634  * pointer and touch events.
3635  *
3636  * Input events happening outside of this region will try the next
3637  * surface in the server surface stack. The compositor ignores the
3638  * parts of the input region that fall outside of the surface.
3639  *
3640  * The input region is specified in surface-local coordinates.
3641  *
3642  * Input region is double-buffered state, see wl_surface.commit.
3643  *
3644  * wl_surface.set_input_region changes the pending input region.
3645  * wl_surface.commit copies the pending region to the current region.
3646  * Otherwise the pending and current regions are never changed,
3647  * except cursor and icon surfaces are special cases, see
3648  * wl_pointer.set_cursor and wl_data_device.start_drag.
3649  *
3650  * The initial value for an input region is infinite. That means the
3651  * whole surface will accept input. Setting the pending input region
3652  * has copy semantics, and the wl_region object can be destroyed
3653  * immediately. A NULL wl_region causes the input region to be set
3654  * to infinite.
3655  */
3656 static inline void
wl_surface_set_input_region(struct wl_surface * wl_surface,struct wl_region * region)3657 wl_surface_set_input_region(struct wl_surface *wl_surface, struct wl_region *region)
3658 {
3659 	wl_proxy_marshal((struct wl_proxy *) wl_surface,
3660 			 WL_SURFACE_SET_INPUT_REGION, region);
3661 }
3662 
3663 /**
3664  * @ingroup iface_wl_surface
3665  *
3666  * Surface state (input, opaque, and damage regions, attached buffers,
3667  * etc.) is double-buffered. Protocol requests modify the pending state,
3668  * as opposed to the current state in use by the compositor. A commit
3669  * request atomically applies all pending state, replacing the current
3670  * state. After commit, the new pending state is as documented for each
3671  * related request.
3672  *
3673  * On commit, a pending wl_buffer is applied first, and all other state
3674  * second. This means that all coordinates in double-buffered state are
3675  * relative to the new wl_buffer coming into use, except for
3676  * wl_surface.attach itself. If there is no pending wl_buffer, the
3677  * coordinates are relative to the current surface contents.
3678  *
3679  * All requests that need a commit to become effective are documented
3680  * to affect double-buffered state.
3681  *
3682  * Other interfaces may add further double-buffered surface state.
3683  */
3684 static inline void
wl_surface_commit(struct wl_surface * wl_surface)3685 wl_surface_commit(struct wl_surface *wl_surface)
3686 {
3687 	wl_proxy_marshal((struct wl_proxy *) wl_surface,
3688 			 WL_SURFACE_COMMIT);
3689 }
3690 
3691 /**
3692  * @ingroup iface_wl_surface
3693  *
3694  * This request sets an optional transformation on how the compositor
3695  * interprets the contents of the buffer attached to the surface. The
3696  * accepted values for the transform parameter are the values for
3697  * wl_output.transform.
3698  *
3699  * Buffer transform is double-buffered state, see wl_surface.commit.
3700  *
3701  * A newly created surface has its buffer transformation set to normal.
3702  *
3703  * wl_surface.set_buffer_transform changes the pending buffer
3704  * transformation. wl_surface.commit copies the pending buffer
3705  * transformation to the current one. Otherwise, the pending and current
3706  * values are never changed.
3707  *
3708  * The purpose of this request is to allow clients to render content
3709  * according to the output transform, thus permitting the compositor to
3710  * use certain optimizations even if the display is rotated. Using
3711  * hardware overlays and scanning out a client buffer for fullscreen
3712  * surfaces are examples of such optimizations. Those optimizations are
3713  * highly dependent on the compositor implementation, so the use of this
3714  * request should be considered on a case-by-case basis.
3715  *
3716  * Note that if the transform value includes 90 or 270 degree rotation,
3717  * the width of the buffer will become the surface height and the height
3718  * of the buffer will become the surface width.
3719  *
3720  * If transform is not one of the values from the
3721  * wl_output.transform enum the invalid_transform protocol error
3722  * is raised.
3723  */
3724 static inline void
wl_surface_set_buffer_transform(struct wl_surface * wl_surface,int32_t transform)3725 wl_surface_set_buffer_transform(struct wl_surface *wl_surface, int32_t transform)
3726 {
3727 	wl_proxy_marshal((struct wl_proxy *) wl_surface,
3728 			 WL_SURFACE_SET_BUFFER_TRANSFORM, transform);
3729 }
3730 
3731 /**
3732  * @ingroup iface_wl_surface
3733  *
3734  * This request sets an optional scaling factor on how the compositor
3735  * interprets the contents of the buffer attached to the window.
3736  *
3737  * Buffer scale is double-buffered state, see wl_surface.commit.
3738  *
3739  * A newly created surface has its buffer scale set to 1.
3740  *
3741  * wl_surface.set_buffer_scale changes the pending buffer scale.
3742  * wl_surface.commit copies the pending buffer scale to the current one.
3743  * Otherwise, the pending and current values are never changed.
3744  *
3745  * The purpose of this request is to allow clients to supply higher
3746  * resolution buffer data for use on high resolution outputs. It is
3747  * intended that you pick the same buffer scale as the scale of the
3748  * output that the surface is displayed on. This means the compositor
3749  * can avoid scaling when rendering the surface on that output.
3750  *
3751  * Note that if the scale is larger than 1, then you have to attach
3752  * a buffer that is larger (by a factor of scale in each dimension)
3753  * than the desired surface size.
3754  *
3755  * If scale is not positive the invalid_scale protocol error is
3756  * raised.
3757  */
3758 static inline void
wl_surface_set_buffer_scale(struct wl_surface * wl_surface,int32_t scale)3759 wl_surface_set_buffer_scale(struct wl_surface *wl_surface, int32_t scale)
3760 {
3761 	wl_proxy_marshal((struct wl_proxy *) wl_surface,
3762 			 WL_SURFACE_SET_BUFFER_SCALE, scale);
3763 }
3764 
3765 /**
3766  * @ingroup iface_wl_surface
3767  *
3768  * This request is used to describe the regions where the pending
3769  * buffer is different from the current surface contents, and where
3770  * the surface therefore needs to be repainted. The compositor
3771  * ignores the parts of the damage that fall outside of the surface.
3772  *
3773  * Damage is double-buffered state, see wl_surface.commit.
3774  *
3775  * The damage rectangle is specified in buffer coordinates,
3776  * where x and y specify the upper left corner of the damage rectangle.
3777  *
3778  * The initial value for pending damage is empty: no damage.
3779  * wl_surface.damage_buffer adds pending damage: the new pending
3780  * damage is the union of old pending damage and the given rectangle.
3781  *
3782  * wl_surface.commit assigns pending damage as the current damage,
3783  * and clears pending damage. The server will clear the current
3784  * damage as it repaints the surface.
3785  *
3786  * This request differs from wl_surface.damage in only one way - it
3787  * takes damage in buffer coordinates instead of surface-local
3788  * coordinates. While this generally is more intuitive than surface
3789  * coordinates, it is especially desirable when using wp_viewport
3790  * or when a drawing library (like EGL) is unaware of buffer scale
3791  * and buffer transform.
3792  *
3793  * Note: Because buffer transformation changes and damage requests may
3794  * be interleaved in the protocol stream, it is impossible to determine
3795  * the actual mapping between surface and buffer damage until
3796  * wl_surface.commit time. Therefore, compositors wishing to take both
3797  * kinds of damage into account will have to accumulate damage from the
3798  * two requests separately and only transform from one to the other
3799  * after receiving the wl_surface.commit.
3800  */
3801 static inline void
wl_surface_damage_buffer(struct wl_surface * wl_surface,int32_t x,int32_t y,int32_t width,int32_t height)3802 wl_surface_damage_buffer(struct wl_surface *wl_surface, int32_t x, int32_t y, int32_t width, int32_t height)
3803 {
3804 	wl_proxy_marshal((struct wl_proxy *) wl_surface,
3805 			 WL_SURFACE_DAMAGE_BUFFER, x, y, width, height);
3806 }
3807 
3808 #ifndef WL_SEAT_CAPABILITY_ENUM
3809 #define WL_SEAT_CAPABILITY_ENUM
3810 /**
3811  * @ingroup iface_wl_seat
3812  * seat capability bitmask
3813  *
3814  * This is a bitmask of capabilities this seat has; if a member is
3815  * set, then it is present on the seat.
3816  */
3817 enum wl_seat_capability {
3818 	/**
3819 	 * the seat has pointer devices
3820 	 */
3821 	WL_SEAT_CAPABILITY_POINTER = 1,
3822 	/**
3823 	 * the seat has one or more keyboards
3824 	 */
3825 	WL_SEAT_CAPABILITY_KEYBOARD = 2,
3826 	/**
3827 	 * the seat has touch devices
3828 	 */
3829 	WL_SEAT_CAPABILITY_TOUCH = 4,
3830 };
3831 #endif /* WL_SEAT_CAPABILITY_ENUM */
3832 
3833 /**
3834  * @ingroup iface_wl_seat
3835  * @struct wl_seat_listener
3836  */
3837 struct wl_seat_listener {
3838 	/**
3839 	 * seat capabilities changed
3840 	 *
3841 	 * This is emitted whenever a seat gains or loses the pointer,
3842 	 * keyboard or touch capabilities. The argument is a capability
3843 	 * enum containing the complete set of capabilities this seat has.
3844 	 *
3845 	 * When the pointer capability is added, a client may create a
3846 	 * wl_pointer object using the wl_seat.get_pointer request. This
3847 	 * object will receive pointer events until the capability is
3848 	 * removed in the future.
3849 	 *
3850 	 * When the pointer capability is removed, a client should destroy
3851 	 * the wl_pointer objects associated with the seat where the
3852 	 * capability was removed, using the wl_pointer.release request. No
3853 	 * further pointer events will be received on these objects.
3854 	 *
3855 	 * In some compositors, if a seat regains the pointer capability
3856 	 * and a client has a previously obtained wl_pointer object of
3857 	 * version 4 or less, that object may start sending pointer events
3858 	 * again. This behavior is considered a misinterpretation of the
3859 	 * intended behavior and must not be relied upon by the client.
3860 	 * wl_pointer objects of version 5 or later must not send events if
3861 	 * created before the most recent event notifying the client of an
3862 	 * added pointer capability.
3863 	 *
3864 	 * The above behavior also applies to wl_keyboard and wl_touch with
3865 	 * the keyboard and touch capabilities, respectively.
3866 	 * @param capabilities capabilities of the seat
3867 	 */
3868 	void (*capabilities)(void *data,
3869 			     struct wl_seat *wl_seat,
3870 			     uint32_t capabilities);
3871 	/**
3872 	 * unique identifier for this seat
3873 	 *
3874 	 * In a multiseat configuration this can be used by the client to
3875 	 * help identify which physical devices the seat represents. Based
3876 	 * on the seat configuration used by the compositor.
3877 	 * @param name seat identifier
3878 	 * @since 2
3879 	 */
3880 	void (*name)(void *data,
3881 		     struct wl_seat *wl_seat,
3882 		     const char *name);
3883 };
3884 
3885 /**
3886  * @ingroup iface_wl_seat
3887  */
3888 static inline int
wl_seat_add_listener(struct wl_seat * wl_seat,const struct wl_seat_listener * listener,void * data)3889 wl_seat_add_listener(struct wl_seat *wl_seat,
3890 		     const struct wl_seat_listener *listener, void *data)
3891 {
3892 	return wl_proxy_add_listener((struct wl_proxy *) wl_seat,
3893 				     (void (**)(void)) listener, data);
3894 }
3895 
3896 #define WL_SEAT_GET_POINTER 0
3897 #define WL_SEAT_GET_KEYBOARD 1
3898 #define WL_SEAT_GET_TOUCH 2
3899 #define WL_SEAT_RELEASE 3
3900 
3901 /**
3902  * @ingroup iface_wl_seat
3903  */
3904 #define WL_SEAT_CAPABILITIES_SINCE_VERSION 1
3905 /**
3906  * @ingroup iface_wl_seat
3907  */
3908 #define WL_SEAT_NAME_SINCE_VERSION 2
3909 
3910 /**
3911  * @ingroup iface_wl_seat
3912  */
3913 #define WL_SEAT_GET_POINTER_SINCE_VERSION 1
3914 /**
3915  * @ingroup iface_wl_seat
3916  */
3917 #define WL_SEAT_GET_KEYBOARD_SINCE_VERSION 1
3918 /**
3919  * @ingroup iface_wl_seat
3920  */
3921 #define WL_SEAT_GET_TOUCH_SINCE_VERSION 1
3922 /**
3923  * @ingroup iface_wl_seat
3924  */
3925 #define WL_SEAT_RELEASE_SINCE_VERSION 5
3926 
3927 /** @ingroup iface_wl_seat */
3928 static inline void
wl_seat_set_user_data(struct wl_seat * wl_seat,void * user_data)3929 wl_seat_set_user_data(struct wl_seat *wl_seat, void *user_data)
3930 {
3931 	wl_proxy_set_user_data((struct wl_proxy *) wl_seat, user_data);
3932 }
3933 
3934 /** @ingroup iface_wl_seat */
3935 static inline void *
wl_seat_get_user_data(struct wl_seat * wl_seat)3936 wl_seat_get_user_data(struct wl_seat *wl_seat)
3937 {
3938 	return wl_proxy_get_user_data((struct wl_proxy *) wl_seat);
3939 }
3940 
3941 static inline uint32_t
wl_seat_get_version(struct wl_seat * wl_seat)3942 wl_seat_get_version(struct wl_seat *wl_seat)
3943 {
3944 	return wl_proxy_get_version((struct wl_proxy *) wl_seat);
3945 }
3946 
3947 /** @ingroup iface_wl_seat */
3948 static inline void
wl_seat_destroy(struct wl_seat * wl_seat)3949 wl_seat_destroy(struct wl_seat *wl_seat)
3950 {
3951 	wl_proxy_destroy((struct wl_proxy *) wl_seat);
3952 }
3953 
3954 /**
3955  * @ingroup iface_wl_seat
3956  *
3957  * The ID provided will be initialized to the wl_pointer interface
3958  * for this seat.
3959  *
3960  * This request only takes effect if the seat has the pointer
3961  * capability, or has had the pointer capability in the past.
3962  * It is a protocol violation to issue this request on a seat that has
3963  * never had the pointer capability.
3964  */
3965 static inline struct wl_pointer *
wl_seat_get_pointer(struct wl_seat * wl_seat)3966 wl_seat_get_pointer(struct wl_seat *wl_seat)
3967 {
3968 	struct wl_proxy *id;
3969 
3970 	id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_seat,
3971 			 WL_SEAT_GET_POINTER, &wl_pointer_interface, NULL);
3972 
3973 	return (struct wl_pointer *) id;
3974 }
3975 
3976 /**
3977  * @ingroup iface_wl_seat
3978  *
3979  * The ID provided will be initialized to the wl_keyboard interface
3980  * for this seat.
3981  *
3982  * This request only takes effect if the seat has the keyboard
3983  * capability, or has had the keyboard capability in the past.
3984  * It is a protocol violation to issue this request on a seat that has
3985  * never had the keyboard capability.
3986  */
3987 static inline struct wl_keyboard *
wl_seat_get_keyboard(struct wl_seat * wl_seat)3988 wl_seat_get_keyboard(struct wl_seat *wl_seat)
3989 {
3990 	struct wl_proxy *id;
3991 
3992 	id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_seat,
3993 			 WL_SEAT_GET_KEYBOARD, &wl_keyboard_interface, NULL);
3994 
3995 	return (struct wl_keyboard *) id;
3996 }
3997 
3998 /**
3999  * @ingroup iface_wl_seat
4000  *
4001  * The ID provided will be initialized to the wl_touch interface
4002  * for this seat.
4003  *
4004  * This request only takes effect if the seat has the touch
4005  * capability, or has had the touch capability in the past.
4006  * It is a protocol violation to issue this request on a seat that has
4007  * never had the touch capability.
4008  */
4009 static inline struct wl_touch *
wl_seat_get_touch(struct wl_seat * wl_seat)4010 wl_seat_get_touch(struct wl_seat *wl_seat)
4011 {
4012 	struct wl_proxy *id;
4013 
4014 	id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_seat,
4015 			 WL_SEAT_GET_TOUCH, &wl_touch_interface, NULL);
4016 
4017 	return (struct wl_touch *) id;
4018 }
4019 
4020 /**
4021  * @ingroup iface_wl_seat
4022  *
4023  * Using this request a client can tell the server that it is not going to
4024  * use the seat object anymore.
4025  */
4026 static inline void
wl_seat_release(struct wl_seat * wl_seat)4027 wl_seat_release(struct wl_seat *wl_seat)
4028 {
4029 	wl_proxy_marshal((struct wl_proxy *) wl_seat,
4030 			 WL_SEAT_RELEASE);
4031 
4032 	wl_proxy_destroy((struct wl_proxy *) wl_seat);
4033 }
4034 
4035 #ifndef WL_POINTER_ERROR_ENUM
4036 #define WL_POINTER_ERROR_ENUM
4037 enum wl_pointer_error {
4038 	/**
4039 	 * given wl_surface has another role
4040 	 */
4041 	WL_POINTER_ERROR_ROLE = 0,
4042 };
4043 #endif /* WL_POINTER_ERROR_ENUM */
4044 
4045 #ifndef WL_POINTER_BUTTON_STATE_ENUM
4046 #define WL_POINTER_BUTTON_STATE_ENUM
4047 /**
4048  * @ingroup iface_wl_pointer
4049  * physical button state
4050  *
4051  * Describes the physical state of a button that produced the button
4052  * event.
4053  */
4054 enum wl_pointer_button_state {
4055 	/**
4056 	 * the button is not pressed
4057 	 */
4058 	WL_POINTER_BUTTON_STATE_RELEASED = 0,
4059 	/**
4060 	 * the button is pressed
4061 	 */
4062 	WL_POINTER_BUTTON_STATE_PRESSED = 1,
4063 };
4064 #endif /* WL_POINTER_BUTTON_STATE_ENUM */
4065 
4066 #ifndef WL_POINTER_AXIS_ENUM
4067 #define WL_POINTER_AXIS_ENUM
4068 /**
4069  * @ingroup iface_wl_pointer
4070  * axis types
4071  *
4072  * Describes the axis types of scroll events.
4073  */
4074 enum wl_pointer_axis {
4075 	/**
4076 	 * vertical axis
4077 	 */
4078 	WL_POINTER_AXIS_VERTICAL_SCROLL = 0,
4079 	/**
4080 	 * horizontal axis
4081 	 */
4082 	WL_POINTER_AXIS_HORIZONTAL_SCROLL = 1,
4083 };
4084 #endif /* WL_POINTER_AXIS_ENUM */
4085 
4086 #ifndef WL_POINTER_AXIS_SOURCE_ENUM
4087 #define WL_POINTER_AXIS_SOURCE_ENUM
4088 /**
4089  * @ingroup iface_wl_pointer
4090  * axis source types
4091  *
4092  * Describes the source types for axis events. This indicates to the
4093  * client how an axis event was physically generated; a client may
4094  * adjust the user interface accordingly. For example, scroll events
4095  * from a "finger" source may be in a smooth coordinate space with
4096  * kinetic scrolling whereas a "wheel" source may be in discrete steps
4097  * of a number of lines.
4098  *
4099  * The "continuous" axis source is a device generating events in a
4100  * continuous coordinate space, but using something other than a
4101  * finger. One example for this source is button-based scrolling where
4102  * the vertical motion of a device is converted to scroll events while
4103  * a button is held down.
4104  *
4105  * The "wheel tilt" axis source indicates that the actual device is a
4106  * wheel but the scroll event is not caused by a rotation but a
4107  * (usually sideways) tilt of the wheel.
4108  */
4109 enum wl_pointer_axis_source {
4110 	/**
4111 	 * a physical wheel rotation
4112 	 */
4113 	WL_POINTER_AXIS_SOURCE_WHEEL = 0,
4114 	/**
4115 	 * finger on a touch surface
4116 	 */
4117 	WL_POINTER_AXIS_SOURCE_FINGER = 1,
4118 	/**
4119 	 * continuous coordinate space
4120 	 */
4121 	WL_POINTER_AXIS_SOURCE_CONTINUOUS = 2,
4122 	/**
4123 	 * a physical wheel tilt
4124 	 * @since 6
4125 	 */
4126 	WL_POINTER_AXIS_SOURCE_WHEEL_TILT = 3,
4127 };
4128 /**
4129  * @ingroup iface_wl_pointer
4130  */
4131 #define WL_POINTER_AXIS_SOURCE_WHEEL_TILT_SINCE_VERSION 6
4132 #endif /* WL_POINTER_AXIS_SOURCE_ENUM */
4133 
4134 /**
4135  * @ingroup iface_wl_pointer
4136  * @struct wl_pointer_listener
4137  */
4138 struct wl_pointer_listener {
4139 	/**
4140 	 * enter event
4141 	 *
4142 	 * Notification that this seat's pointer is focused on a certain
4143 	 * surface.
4144 	 *
4145 	 * When a seat's focus enters a surface, the pointer image is
4146 	 * undefined and a client should respond to this event by setting
4147 	 * an appropriate pointer image with the set_cursor request.
4148 	 * @param serial serial number of the enter event
4149 	 * @param surface surface entered by the pointer
4150 	 * @param surface_x surface-local x coordinate
4151 	 * @param surface_y surface-local y coordinate
4152 	 */
4153 	void (*enter)(void *data,
4154 		      struct wl_pointer *wl_pointer,
4155 		      uint32_t serial,
4156 		      struct wl_surface *surface,
4157 		      wl_fixed_t surface_x,
4158 		      wl_fixed_t surface_y);
4159 	/**
4160 	 * leave event
4161 	 *
4162 	 * Notification that this seat's pointer is no longer focused on
4163 	 * a certain surface.
4164 	 *
4165 	 * The leave notification is sent before the enter notification for
4166 	 * the new focus.
4167 	 * @param serial serial number of the leave event
4168 	 * @param surface surface left by the pointer
4169 	 */
4170 	void (*leave)(void *data,
4171 		      struct wl_pointer *wl_pointer,
4172 		      uint32_t serial,
4173 		      struct wl_surface *surface);
4174 	/**
4175 	 * pointer motion event
4176 	 *
4177 	 * Notification of pointer location change. The arguments
4178 	 * surface_x and surface_y are the location relative to the focused
4179 	 * surface.
4180 	 * @param time timestamp with millisecond granularity
4181 	 * @param surface_x surface-local x coordinate
4182 	 * @param surface_y surface-local y coordinate
4183 	 */
4184 	void (*motion)(void *data,
4185 		       struct wl_pointer *wl_pointer,
4186 		       uint32_t time,
4187 		       wl_fixed_t surface_x,
4188 		       wl_fixed_t surface_y);
4189 	/**
4190 	 * pointer button event
4191 	 *
4192 	 * Mouse button click and release notifications.
4193 	 *
4194 	 * The location of the click is given by the last motion or enter
4195 	 * event. The time argument is a timestamp with millisecond
4196 	 * granularity, with an undefined base.
4197 	 *
4198 	 * The button is a button code as defined in the Linux kernel's
4199 	 * linux/input-event-codes.h header file, e.g. BTN_LEFT.
4200 	 *
4201 	 * Any 16-bit button code value is reserved for future additions to
4202 	 * the kernel's event code list. All other button codes above
4203 	 * 0xFFFF are currently undefined but may be used in future
4204 	 * versions of this protocol.
4205 	 * @param serial serial number of the button event
4206 	 * @param time timestamp with millisecond granularity
4207 	 * @param button button that produced the event
4208 	 * @param state physical state of the button
4209 	 */
4210 	void (*button)(void *data,
4211 		       struct wl_pointer *wl_pointer,
4212 		       uint32_t serial,
4213 		       uint32_t time,
4214 		       uint32_t button,
4215 		       uint32_t state);
4216 	/**
4217 	 * axis event
4218 	 *
4219 	 * Scroll and other axis notifications.
4220 	 *
4221 	 * For scroll events (vertical and horizontal scroll axes), the
4222 	 * value parameter is the length of a vector along the specified
4223 	 * axis in a coordinate space identical to those of motion events,
4224 	 * representing a relative movement along the specified axis.
4225 	 *
4226 	 * For devices that support movements non-parallel to axes multiple
4227 	 * axis events will be emitted.
4228 	 *
4229 	 * When applicable, for example for touch pads, the server can
4230 	 * choose to emit scroll events where the motion vector is
4231 	 * equivalent to a motion event vector.
4232 	 *
4233 	 * When applicable, a client can transform its content relative to
4234 	 * the scroll distance.
4235 	 * @param time timestamp with millisecond granularity
4236 	 * @param axis axis type
4237 	 * @param value length of vector in surface-local coordinate space
4238 	 */
4239 	void (*axis)(void *data,
4240 		     struct wl_pointer *wl_pointer,
4241 		     uint32_t time,
4242 		     uint32_t axis,
4243 		     wl_fixed_t value);
4244 	/**
4245 	 * end of a pointer event sequence
4246 	 *
4247 	 * Indicates the end of a set of events that logically belong
4248 	 * together. A client is expected to accumulate the data in all
4249 	 * events within the frame before proceeding.
4250 	 *
4251 	 * All wl_pointer events before a wl_pointer.frame event belong
4252 	 * logically together. For example, in a diagonal scroll motion the
4253 	 * compositor will send an optional wl_pointer.axis_source event,
4254 	 * two wl_pointer.axis events (horizontal and vertical) and finally
4255 	 * a wl_pointer.frame event. The client may use this information to
4256 	 * calculate a diagonal vector for scrolling.
4257 	 *
4258 	 * When multiple wl_pointer.axis events occur within the same
4259 	 * frame, the motion vector is the combined motion of all events.
4260 	 * When a wl_pointer.axis and a wl_pointer.axis_stop event occur
4261 	 * within the same frame, this indicates that axis movement in one
4262 	 * axis has stopped but continues in the other axis. When multiple
4263 	 * wl_pointer.axis_stop events occur within the same frame, this
4264 	 * indicates that these axes stopped in the same instance.
4265 	 *
4266 	 * A wl_pointer.frame event is sent for every logical event group,
4267 	 * even if the group only contains a single wl_pointer event.
4268 	 * Specifically, a client may get a sequence: motion, frame,
4269 	 * button, frame, axis, frame, axis_stop, frame.
4270 	 *
4271 	 * The wl_pointer.enter and wl_pointer.leave events are logical
4272 	 * events generated by the compositor and not the hardware. These
4273 	 * events are also grouped by a wl_pointer.frame. When a pointer
4274 	 * moves from one surface to another, a compositor should group the
4275 	 * wl_pointer.leave event within the same wl_pointer.frame.
4276 	 * However, a client must not rely on wl_pointer.leave and
4277 	 * wl_pointer.enter being in the same wl_pointer.frame.
4278 	 * Compositor-specific policies may require the wl_pointer.leave
4279 	 * and wl_pointer.enter event being split across multiple
4280 	 * wl_pointer.frame groups.
4281 	 * @since 5
4282 	 */
4283 	void (*frame)(void *data,
4284 		      struct wl_pointer *wl_pointer);
4285 	/**
4286 	 * axis source event
4287 	 *
4288 	 * Source information for scroll and other axes.
4289 	 *
4290 	 * This event does not occur on its own. It is sent before a
4291 	 * wl_pointer.frame event and carries the source information for
4292 	 * all events within that frame.
4293 	 *
4294 	 * The source specifies how this event was generated. If the source
4295 	 * is wl_pointer.axis_source.finger, a wl_pointer.axis_stop event
4296 	 * will be sent when the user lifts the finger off the device.
4297 	 *
4298 	 * If the source is wl_pointer.axis_source.wheel,
4299 	 * wl_pointer.axis_source.wheel_tilt or
4300 	 * wl_pointer.axis_source.continuous, a wl_pointer.axis_stop event
4301 	 * may or may not be sent. Whether a compositor sends an axis_stop
4302 	 * event for these sources is hardware-specific and
4303 	 * implementation-dependent; clients must not rely on receiving an
4304 	 * axis_stop event for these scroll sources and should treat scroll
4305 	 * sequences from these scroll sources as unterminated by default.
4306 	 *
4307 	 * This event is optional. If the source is unknown for a
4308 	 * particular axis event sequence, no event is sent. Only one
4309 	 * wl_pointer.axis_source event is permitted per frame.
4310 	 *
4311 	 * The order of wl_pointer.axis_discrete and wl_pointer.axis_source
4312 	 * is not guaranteed.
4313 	 * @param axis_source source of the axis event
4314 	 * @since 5
4315 	 */
4316 	void (*axis_source)(void *data,
4317 			    struct wl_pointer *wl_pointer,
4318 			    uint32_t axis_source);
4319 	/**
4320 	 * axis stop event
4321 	 *
4322 	 * Stop notification for scroll and other axes.
4323 	 *
4324 	 * For some wl_pointer.axis_source types, a wl_pointer.axis_stop
4325 	 * event is sent to notify a client that the axis sequence has
4326 	 * terminated. This enables the client to implement kinetic
4327 	 * scrolling. See the wl_pointer.axis_source documentation for
4328 	 * information on when this event may be generated.
4329 	 *
4330 	 * Any wl_pointer.axis events with the same axis_source after this
4331 	 * event should be considered as the start of a new axis motion.
4332 	 *
4333 	 * The timestamp is to be interpreted identical to the timestamp in
4334 	 * the wl_pointer.axis event. The timestamp value may be the same
4335 	 * as a preceding wl_pointer.axis event.
4336 	 * @param time timestamp with millisecond granularity
4337 	 * @param axis the axis stopped with this event
4338 	 * @since 5
4339 	 */
4340 	void (*axis_stop)(void *data,
4341 			  struct wl_pointer *wl_pointer,
4342 			  uint32_t time,
4343 			  uint32_t axis);
4344 	/**
4345 	 * axis click event
4346 	 *
4347 	 * Discrete step information for scroll and other axes.
4348 	 *
4349 	 * This event carries the axis value of the wl_pointer.axis event
4350 	 * in discrete steps (e.g. mouse wheel clicks).
4351 	 *
4352 	 * This event does not occur on its own, it is coupled with a
4353 	 * wl_pointer.axis event that represents this axis value on a
4354 	 * continuous scale. The protocol guarantees that each
4355 	 * axis_discrete event is always followed by exactly one axis event
4356 	 * with the same axis number within the same wl_pointer.frame. Note
4357 	 * that the protocol allows for other events to occur between the
4358 	 * axis_discrete and its coupled axis event, including other
4359 	 * axis_discrete or axis events.
4360 	 *
4361 	 * This event is optional; continuous scrolling devices like
4362 	 * two-finger scrolling on touchpads do not have discrete steps and
4363 	 * do not generate this event.
4364 	 *
4365 	 * The discrete value carries the directional information. e.g. a
4366 	 * value of -2 is two steps towards the negative direction of this
4367 	 * axis.
4368 	 *
4369 	 * The axis number is identical to the axis number in the
4370 	 * associated axis event.
4371 	 *
4372 	 * The order of wl_pointer.axis_discrete and wl_pointer.axis_source
4373 	 * is not guaranteed.
4374 	 * @param axis axis type
4375 	 * @param discrete number of steps
4376 	 * @since 5
4377 	 */
4378 	void (*axis_discrete)(void *data,
4379 			      struct wl_pointer *wl_pointer,
4380 			      uint32_t axis,
4381 			      int32_t discrete);
4382 };
4383 
4384 /**
4385  * @ingroup iface_wl_pointer
4386  */
4387 static inline int
wl_pointer_add_listener(struct wl_pointer * wl_pointer,const struct wl_pointer_listener * listener,void * data)4388 wl_pointer_add_listener(struct wl_pointer *wl_pointer,
4389 			const struct wl_pointer_listener *listener, void *data)
4390 {
4391 	return wl_proxy_add_listener((struct wl_proxy *) wl_pointer,
4392 				     (void (**)(void)) listener, data);
4393 }
4394 
4395 #define WL_POINTER_SET_CURSOR 0
4396 #define WL_POINTER_RELEASE 1
4397 
4398 /**
4399  * @ingroup iface_wl_pointer
4400  */
4401 #define WL_POINTER_ENTER_SINCE_VERSION 1
4402 /**
4403  * @ingroup iface_wl_pointer
4404  */
4405 #define WL_POINTER_LEAVE_SINCE_VERSION 1
4406 /**
4407  * @ingroup iface_wl_pointer
4408  */
4409 #define WL_POINTER_MOTION_SINCE_VERSION 1
4410 /**
4411  * @ingroup iface_wl_pointer
4412  */
4413 #define WL_POINTER_BUTTON_SINCE_VERSION 1
4414 /**
4415  * @ingroup iface_wl_pointer
4416  */
4417 #define WL_POINTER_AXIS_SINCE_VERSION 1
4418 /**
4419  * @ingroup iface_wl_pointer
4420  */
4421 #define WL_POINTER_FRAME_SINCE_VERSION 5
4422 /**
4423  * @ingroup iface_wl_pointer
4424  */
4425 #define WL_POINTER_AXIS_SOURCE_SINCE_VERSION 5
4426 /**
4427  * @ingroup iface_wl_pointer
4428  */
4429 #define WL_POINTER_AXIS_STOP_SINCE_VERSION 5
4430 /**
4431  * @ingroup iface_wl_pointer
4432  */
4433 #define WL_POINTER_AXIS_DISCRETE_SINCE_VERSION 5
4434 
4435 /**
4436  * @ingroup iface_wl_pointer
4437  */
4438 #define WL_POINTER_SET_CURSOR_SINCE_VERSION 1
4439 /**
4440  * @ingroup iface_wl_pointer
4441  */
4442 #define WL_POINTER_RELEASE_SINCE_VERSION 3
4443 
4444 /** @ingroup iface_wl_pointer */
4445 static inline void
wl_pointer_set_user_data(struct wl_pointer * wl_pointer,void * user_data)4446 wl_pointer_set_user_data(struct wl_pointer *wl_pointer, void *user_data)
4447 {
4448 	wl_proxy_set_user_data((struct wl_proxy *) wl_pointer, user_data);
4449 }
4450 
4451 /** @ingroup iface_wl_pointer */
4452 static inline void *
wl_pointer_get_user_data(struct wl_pointer * wl_pointer)4453 wl_pointer_get_user_data(struct wl_pointer *wl_pointer)
4454 {
4455 	return wl_proxy_get_user_data((struct wl_proxy *) wl_pointer);
4456 }
4457 
4458 static inline uint32_t
wl_pointer_get_version(struct wl_pointer * wl_pointer)4459 wl_pointer_get_version(struct wl_pointer *wl_pointer)
4460 {
4461 	return wl_proxy_get_version((struct wl_proxy *) wl_pointer);
4462 }
4463 
4464 /** @ingroup iface_wl_pointer */
4465 static inline void
wl_pointer_destroy(struct wl_pointer * wl_pointer)4466 wl_pointer_destroy(struct wl_pointer *wl_pointer)
4467 {
4468 	wl_proxy_destroy((struct wl_proxy *) wl_pointer);
4469 }
4470 
4471 /**
4472  * @ingroup iface_wl_pointer
4473  *
4474  * Set the pointer surface, i.e., the surface that contains the
4475  * pointer image (cursor). This request gives the surface the role
4476  * of a cursor. If the surface already has another role, it raises
4477  * a protocol error.
4478  *
4479  * The cursor actually changes only if the pointer
4480  * focus for this device is one of the requesting client's surfaces
4481  * or the surface parameter is the current pointer surface. If
4482  * there was a previous surface set with this request it is
4483  * replaced. If surface is NULL, the pointer image is hidden.
4484  *
4485  * The parameters hotspot_x and hotspot_y define the position of
4486  * the pointer surface relative to the pointer location. Its
4487  * top-left corner is always at (x, y) - (hotspot_x, hotspot_y),
4488  * where (x, y) are the coordinates of the pointer location, in
4489  * surface-local coordinates.
4490  *
4491  * On surface.attach requests to the pointer surface, hotspot_x
4492  * and hotspot_y are decremented by the x and y parameters
4493  * passed to the request. Attach must be confirmed by
4494  * wl_surface.commit as usual.
4495  *
4496  * The hotspot can also be updated by passing the currently set
4497  * pointer surface to this request with new values for hotspot_x
4498  * and hotspot_y.
4499  *
4500  * The current and pending input regions of the wl_surface are
4501  * cleared, and wl_surface.set_input_region is ignored until the
4502  * wl_surface is no longer used as the cursor. When the use as a
4503  * cursor ends, the current and pending input regions become
4504  * undefined, and the wl_surface is unmapped.
4505  */
4506 static inline void
wl_pointer_set_cursor(struct wl_pointer * wl_pointer,uint32_t serial,struct wl_surface * surface,int32_t hotspot_x,int32_t hotspot_y)4507 wl_pointer_set_cursor(struct wl_pointer *wl_pointer, uint32_t serial, struct wl_surface *surface, int32_t hotspot_x, int32_t hotspot_y)
4508 {
4509 	wl_proxy_marshal((struct wl_proxy *) wl_pointer,
4510 			 WL_POINTER_SET_CURSOR, serial, surface, hotspot_x, hotspot_y);
4511 }
4512 
4513 /**
4514  * @ingroup iface_wl_pointer
4515  *
4516  * Using this request a client can tell the server that it is not going to
4517  * use the pointer object anymore.
4518  *
4519  * This request destroys the pointer proxy object, so clients must not call
4520  * wl_pointer_destroy() after using this request.
4521  */
4522 static inline void
wl_pointer_release(struct wl_pointer * wl_pointer)4523 wl_pointer_release(struct wl_pointer *wl_pointer)
4524 {
4525 	wl_proxy_marshal((struct wl_proxy *) wl_pointer,
4526 			 WL_POINTER_RELEASE);
4527 
4528 	wl_proxy_destroy((struct wl_proxy *) wl_pointer);
4529 }
4530 
4531 #ifndef WL_KEYBOARD_KEYMAP_FORMAT_ENUM
4532 #define WL_KEYBOARD_KEYMAP_FORMAT_ENUM
4533 /**
4534  * @ingroup iface_wl_keyboard
4535  * keyboard mapping format
4536  *
4537  * This specifies the format of the keymap provided to the
4538  * client with the wl_keyboard.keymap event.
4539  */
4540 enum wl_keyboard_keymap_format {
4541 	/**
4542 	 * no keymap; client must understand how to interpret the raw keycode
4543 	 */
4544 	WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP = 0,
4545 	/**
4546 	 * libxkbcommon compatible; to determine the xkb keycode, clients must add 8 to the key event keycode
4547 	 */
4548 	WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1 = 1,
4549 };
4550 #endif /* WL_KEYBOARD_KEYMAP_FORMAT_ENUM */
4551 
4552 #ifndef WL_KEYBOARD_KEY_STATE_ENUM
4553 #define WL_KEYBOARD_KEY_STATE_ENUM
4554 /**
4555  * @ingroup iface_wl_keyboard
4556  * physical key state
4557  *
4558  * Describes the physical state of a key that produced the key event.
4559  */
4560 enum wl_keyboard_key_state {
4561 	/**
4562 	 * key is not pressed
4563 	 */
4564 	WL_KEYBOARD_KEY_STATE_RELEASED = 0,
4565 	/**
4566 	 * key is pressed
4567 	 */
4568 	WL_KEYBOARD_KEY_STATE_PRESSED = 1,
4569 };
4570 #endif /* WL_KEYBOARD_KEY_STATE_ENUM */
4571 
4572 /**
4573  * @ingroup iface_wl_keyboard
4574  * @struct wl_keyboard_listener
4575  */
4576 struct wl_keyboard_listener {
4577 	/**
4578 	 * keyboard mapping
4579 	 *
4580 	 * This event provides a file descriptor to the client which can
4581 	 * be memory-mapped to provide a keyboard mapping description.
4582 	 * @param format keymap format
4583 	 * @param fd keymap file descriptor
4584 	 * @param size keymap size, in bytes
4585 	 */
4586 	void (*keymap)(void *data,
4587 		       struct wl_keyboard *wl_keyboard,
4588 		       uint32_t format,
4589 		       int32_t fd,
4590 		       uint32_t size);
4591 	/**
4592 	 * enter event
4593 	 *
4594 	 * Notification that this seat's keyboard focus is on a certain
4595 	 * surface.
4596 	 * @param serial serial number of the enter event
4597 	 * @param surface surface gaining keyboard focus
4598 	 * @param keys the currently pressed keys
4599 	 */
4600 	void (*enter)(void *data,
4601 		      struct wl_keyboard *wl_keyboard,
4602 		      uint32_t serial,
4603 		      struct wl_surface *surface,
4604 		      struct wl_array *keys);
4605 	/**
4606 	 * leave event
4607 	 *
4608 	 * Notification that this seat's keyboard focus is no longer on a
4609 	 * certain surface.
4610 	 *
4611 	 * The leave notification is sent before the enter notification for
4612 	 * the new focus.
4613 	 * @param serial serial number of the leave event
4614 	 * @param surface surface that lost keyboard focus
4615 	 */
4616 	void (*leave)(void *data,
4617 		      struct wl_keyboard *wl_keyboard,
4618 		      uint32_t serial,
4619 		      struct wl_surface *surface);
4620 	/**
4621 	 * key event
4622 	 *
4623 	 * A key was pressed or released. The time argument is a
4624 	 * timestamp with millisecond granularity, with an undefined base.
4625 	 * @param serial serial number of the key event
4626 	 * @param time timestamp with millisecond granularity
4627 	 * @param key key that produced the event
4628 	 * @param state physical state of the key
4629 	 */
4630 	void (*key)(void *data,
4631 		    struct wl_keyboard *wl_keyboard,
4632 		    uint32_t serial,
4633 		    uint32_t time,
4634 		    uint32_t key,
4635 		    uint32_t state);
4636 	/**
4637 	 * modifier and group state
4638 	 *
4639 	 * Notifies clients that the modifier and/or group state has
4640 	 * changed, and it should update its local state.
4641 	 * @param serial serial number of the modifiers event
4642 	 * @param mods_depressed depressed modifiers
4643 	 * @param mods_latched latched modifiers
4644 	 * @param mods_locked locked modifiers
4645 	 * @param group keyboard layout
4646 	 */
4647 	void (*modifiers)(void *data,
4648 			  struct wl_keyboard *wl_keyboard,
4649 			  uint32_t serial,
4650 			  uint32_t mods_depressed,
4651 			  uint32_t mods_latched,
4652 			  uint32_t mods_locked,
4653 			  uint32_t group);
4654 	/**
4655 	 * repeat rate and delay
4656 	 *
4657 	 * Informs the client about the keyboard's repeat rate and delay.
4658 	 *
4659 	 * This event is sent as soon as the wl_keyboard object has been
4660 	 * created, and is guaranteed to be received by the client before
4661 	 * any key press event.
4662 	 *
4663 	 * Negative values for either rate or delay are illegal. A rate of
4664 	 * zero will disable any repeating (regardless of the value of
4665 	 * delay).
4666 	 *
4667 	 * This event can be sent later on as well with a new value if
4668 	 * necessary, so clients should continue listening for the event
4669 	 * past the creation of wl_keyboard.
4670 	 * @param rate the rate of repeating keys in characters per second
4671 	 * @param delay delay in milliseconds since key down until repeating starts
4672 	 * @since 4
4673 	 */
4674 	void (*repeat_info)(void *data,
4675 			    struct wl_keyboard *wl_keyboard,
4676 			    int32_t rate,
4677 			    int32_t delay);
4678 };
4679 
4680 /**
4681  * @ingroup iface_wl_keyboard
4682  */
4683 static inline int
wl_keyboard_add_listener(struct wl_keyboard * wl_keyboard,const struct wl_keyboard_listener * listener,void * data)4684 wl_keyboard_add_listener(struct wl_keyboard *wl_keyboard,
4685 			 const struct wl_keyboard_listener *listener, void *data)
4686 {
4687 	return wl_proxy_add_listener((struct wl_proxy *) wl_keyboard,
4688 				     (void (**)(void)) listener, data);
4689 }
4690 
4691 #define WL_KEYBOARD_RELEASE 0
4692 
4693 /**
4694  * @ingroup iface_wl_keyboard
4695  */
4696 #define WL_KEYBOARD_KEYMAP_SINCE_VERSION 1
4697 /**
4698  * @ingroup iface_wl_keyboard
4699  */
4700 #define WL_KEYBOARD_ENTER_SINCE_VERSION 1
4701 /**
4702  * @ingroup iface_wl_keyboard
4703  */
4704 #define WL_KEYBOARD_LEAVE_SINCE_VERSION 1
4705 /**
4706  * @ingroup iface_wl_keyboard
4707  */
4708 #define WL_KEYBOARD_KEY_SINCE_VERSION 1
4709 /**
4710  * @ingroup iface_wl_keyboard
4711  */
4712 #define WL_KEYBOARD_MODIFIERS_SINCE_VERSION 1
4713 /**
4714  * @ingroup iface_wl_keyboard
4715  */
4716 #define WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION 4
4717 
4718 /**
4719  * @ingroup iface_wl_keyboard
4720  */
4721 #define WL_KEYBOARD_RELEASE_SINCE_VERSION 3
4722 
4723 /** @ingroup iface_wl_keyboard */
4724 static inline void
wl_keyboard_set_user_data(struct wl_keyboard * wl_keyboard,void * user_data)4725 wl_keyboard_set_user_data(struct wl_keyboard *wl_keyboard, void *user_data)
4726 {
4727 	wl_proxy_set_user_data((struct wl_proxy *) wl_keyboard, user_data);
4728 }
4729 
4730 /** @ingroup iface_wl_keyboard */
4731 static inline void *
wl_keyboard_get_user_data(struct wl_keyboard * wl_keyboard)4732 wl_keyboard_get_user_data(struct wl_keyboard *wl_keyboard)
4733 {
4734 	return wl_proxy_get_user_data((struct wl_proxy *) wl_keyboard);
4735 }
4736 
4737 static inline uint32_t
wl_keyboard_get_version(struct wl_keyboard * wl_keyboard)4738 wl_keyboard_get_version(struct wl_keyboard *wl_keyboard)
4739 {
4740 	return wl_proxy_get_version((struct wl_proxy *) wl_keyboard);
4741 }
4742 
4743 /** @ingroup iface_wl_keyboard */
4744 static inline void
wl_keyboard_destroy(struct wl_keyboard * wl_keyboard)4745 wl_keyboard_destroy(struct wl_keyboard *wl_keyboard)
4746 {
4747 	wl_proxy_destroy((struct wl_proxy *) wl_keyboard);
4748 }
4749 
4750 /**
4751  * @ingroup iface_wl_keyboard
4752  */
4753 static inline void
wl_keyboard_release(struct wl_keyboard * wl_keyboard)4754 wl_keyboard_release(struct wl_keyboard *wl_keyboard)
4755 {
4756 	wl_proxy_marshal((struct wl_proxy *) wl_keyboard,
4757 			 WL_KEYBOARD_RELEASE);
4758 
4759 	wl_proxy_destroy((struct wl_proxy *) wl_keyboard);
4760 }
4761 
4762 /**
4763  * @ingroup iface_wl_touch
4764  * @struct wl_touch_listener
4765  */
4766 struct wl_touch_listener {
4767 	/**
4768 	 * touch down event and beginning of a touch sequence
4769 	 *
4770 	 * A new touch point has appeared on the surface. This touch
4771 	 * point is assigned a unique ID. Future events from this touch
4772 	 * point reference this ID. The ID ceases to be valid after a touch
4773 	 * up event and may be reused in the future.
4774 	 * @param serial serial number of the touch down event
4775 	 * @param time timestamp with millisecond granularity
4776 	 * @param surface surface touched
4777 	 * @param id the unique ID of this touch point
4778 	 * @param x surface-local x coordinate
4779 	 * @param y surface-local y coordinate
4780 	 */
4781 	void (*down)(void *data,
4782 		     struct wl_touch *wl_touch,
4783 		     uint32_t serial,
4784 		     uint32_t time,
4785 		     struct wl_surface *surface,
4786 		     int32_t id,
4787 		     wl_fixed_t x,
4788 		     wl_fixed_t y);
4789 	/**
4790 	 * end of a touch event sequence
4791 	 *
4792 	 * The touch point has disappeared. No further events will be
4793 	 * sent for this touch point and the touch point's ID is released
4794 	 * and may be reused in a future touch down event.
4795 	 * @param serial serial number of the touch up event
4796 	 * @param time timestamp with millisecond granularity
4797 	 * @param id the unique ID of this touch point
4798 	 */
4799 	void (*up)(void *data,
4800 		   struct wl_touch *wl_touch,
4801 		   uint32_t serial,
4802 		   uint32_t time,
4803 		   int32_t id);
4804 	/**
4805 	 * update of touch point coordinates
4806 	 *
4807 	 * A touch point has changed coordinates.
4808 	 * @param time timestamp with millisecond granularity
4809 	 * @param id the unique ID of this touch point
4810 	 * @param x surface-local x coordinate
4811 	 * @param y surface-local y coordinate
4812 	 */
4813 	void (*motion)(void *data,
4814 		       struct wl_touch *wl_touch,
4815 		       uint32_t time,
4816 		       int32_t id,
4817 		       wl_fixed_t x,
4818 		       wl_fixed_t y);
4819 	/**
4820 	 * end of touch frame event
4821 	 *
4822 	 * Indicates the end of a set of events that logically belong
4823 	 * together. A client is expected to accumulate the data in all
4824 	 * events within the frame before proceeding.
4825 	 *
4826 	 * A wl_touch.frame terminates at least one event but otherwise no
4827 	 * guarantee is provided about the set of events within a frame. A
4828 	 * client must assume that any state not updated in a frame is
4829 	 * unchanged from the previously known state.
4830 	 */
4831 	void (*frame)(void *data,
4832 		      struct wl_touch *wl_touch);
4833 	/**
4834 	 * touch session cancelled
4835 	 *
4836 	 * Sent if the compositor decides the touch stream is a global
4837 	 * gesture. No further events are sent to the clients from that
4838 	 * particular gesture. Touch cancellation applies to all touch
4839 	 * points currently active on this client's surface. The client is
4840 	 * responsible for finalizing the touch points, future touch points
4841 	 * on this surface may reuse the touch point ID.
4842 	 */
4843 	void (*cancel)(void *data,
4844 		       struct wl_touch *wl_touch);
4845 	/**
4846 	 * update shape of touch point
4847 	 *
4848 	 * Sent when a touchpoint has changed its shape.
4849 	 *
4850 	 * This event does not occur on its own. It is sent before a
4851 	 * wl_touch.frame event and carries the new shape information for
4852 	 * any previously reported, or new touch points of that frame.
4853 	 *
4854 	 * Other events describing the touch point such as wl_touch.down,
4855 	 * wl_touch.motion or wl_touch.orientation may be sent within the
4856 	 * same wl_touch.frame. A client should treat these events as a
4857 	 * single logical touch point update. The order of wl_touch.shape,
4858 	 * wl_touch.orientation and wl_touch.motion is not guaranteed. A
4859 	 * wl_touch.down event is guaranteed to occur before the first
4860 	 * wl_touch.shape event for this touch ID but both events may occur
4861 	 * within the same wl_touch.frame.
4862 	 *
4863 	 * A touchpoint shape is approximated by an ellipse through the
4864 	 * major and minor axis length. The major axis length describes the
4865 	 * longer diameter of the ellipse, while the minor axis length
4866 	 * describes the shorter diameter. Major and minor are orthogonal
4867 	 * and both are specified in surface-local coordinates. The center
4868 	 * of the ellipse is always at the touchpoint location as reported
4869 	 * by wl_touch.down or wl_touch.move.
4870 	 *
4871 	 * This event is only sent by the compositor if the touch device
4872 	 * supports shape reports. The client has to make reasonable
4873 	 * assumptions about the shape if it did not receive this event.
4874 	 * @param id the unique ID of this touch point
4875 	 * @param major length of the major axis in surface-local coordinates
4876 	 * @param minor length of the minor axis in surface-local coordinates
4877 	 * @since 6
4878 	 */
4879 	void (*shape)(void *data,
4880 		      struct wl_touch *wl_touch,
4881 		      int32_t id,
4882 		      wl_fixed_t major,
4883 		      wl_fixed_t minor);
4884 	/**
4885 	 * update orientation of touch point
4886 	 *
4887 	 * Sent when a touchpoint has changed its orientation.
4888 	 *
4889 	 * This event does not occur on its own. It is sent before a
4890 	 * wl_touch.frame event and carries the new shape information for
4891 	 * any previously reported, or new touch points of that frame.
4892 	 *
4893 	 * Other events describing the touch point such as wl_touch.down,
4894 	 * wl_touch.motion or wl_touch.shape may be sent within the same
4895 	 * wl_touch.frame. A client should treat these events as a single
4896 	 * logical touch point update. The order of wl_touch.shape,
4897 	 * wl_touch.orientation and wl_touch.motion is not guaranteed. A
4898 	 * wl_touch.down event is guaranteed to occur before the first
4899 	 * wl_touch.orientation event for this touch ID but both events may
4900 	 * occur within the same wl_touch.frame.
4901 	 *
4902 	 * The orientation describes the clockwise angle of a touchpoint's
4903 	 * major axis to the positive surface y-axis and is normalized to
4904 	 * the -180 to +180 degree range. The granularity of orientation
4905 	 * depends on the touch device, some devices only support binary
4906 	 * rotation values between 0 and 90 degrees.
4907 	 *
4908 	 * This event is only sent by the compositor if the touch device
4909 	 * supports orientation reports.
4910 	 * @param id the unique ID of this touch point
4911 	 * @param orientation angle between major axis and positive surface y-axis in degrees
4912 	 * @since 6
4913 	 */
4914 	void (*orientation)(void *data,
4915 			    struct wl_touch *wl_touch,
4916 			    int32_t id,
4917 			    wl_fixed_t orientation);
4918 };
4919 
4920 /**
4921  * @ingroup iface_wl_touch
4922  */
4923 static inline int
wl_touch_add_listener(struct wl_touch * wl_touch,const struct wl_touch_listener * listener,void * data)4924 wl_touch_add_listener(struct wl_touch *wl_touch,
4925 		      const struct wl_touch_listener *listener, void *data)
4926 {
4927 	return wl_proxy_add_listener((struct wl_proxy *) wl_touch,
4928 				     (void (**)(void)) listener, data);
4929 }
4930 
4931 #define WL_TOUCH_RELEASE 0
4932 
4933 /**
4934  * @ingroup iface_wl_touch
4935  */
4936 #define WL_TOUCH_DOWN_SINCE_VERSION 1
4937 /**
4938  * @ingroup iface_wl_touch
4939  */
4940 #define WL_TOUCH_UP_SINCE_VERSION 1
4941 /**
4942  * @ingroup iface_wl_touch
4943  */
4944 #define WL_TOUCH_MOTION_SINCE_VERSION 1
4945 /**
4946  * @ingroup iface_wl_touch
4947  */
4948 #define WL_TOUCH_FRAME_SINCE_VERSION 1
4949 /**
4950  * @ingroup iface_wl_touch
4951  */
4952 #define WL_TOUCH_CANCEL_SINCE_VERSION 1
4953 /**
4954  * @ingroup iface_wl_touch
4955  */
4956 #define WL_TOUCH_SHAPE_SINCE_VERSION 6
4957 /**
4958  * @ingroup iface_wl_touch
4959  */
4960 #define WL_TOUCH_ORIENTATION_SINCE_VERSION 6
4961 
4962 /**
4963  * @ingroup iface_wl_touch
4964  */
4965 #define WL_TOUCH_RELEASE_SINCE_VERSION 3
4966 
4967 /** @ingroup iface_wl_touch */
4968 static inline void
wl_touch_set_user_data(struct wl_touch * wl_touch,void * user_data)4969 wl_touch_set_user_data(struct wl_touch *wl_touch, void *user_data)
4970 {
4971 	wl_proxy_set_user_data((struct wl_proxy *) wl_touch, user_data);
4972 }
4973 
4974 /** @ingroup iface_wl_touch */
4975 static inline void *
wl_touch_get_user_data(struct wl_touch * wl_touch)4976 wl_touch_get_user_data(struct wl_touch *wl_touch)
4977 {
4978 	return wl_proxy_get_user_data((struct wl_proxy *) wl_touch);
4979 }
4980 
4981 static inline uint32_t
wl_touch_get_version(struct wl_touch * wl_touch)4982 wl_touch_get_version(struct wl_touch *wl_touch)
4983 {
4984 	return wl_proxy_get_version((struct wl_proxy *) wl_touch);
4985 }
4986 
4987 /** @ingroup iface_wl_touch */
4988 static inline void
wl_touch_destroy(struct wl_touch * wl_touch)4989 wl_touch_destroy(struct wl_touch *wl_touch)
4990 {
4991 	wl_proxy_destroy((struct wl_proxy *) wl_touch);
4992 }
4993 
4994 /**
4995  * @ingroup iface_wl_touch
4996  */
4997 static inline void
wl_touch_release(struct wl_touch * wl_touch)4998 wl_touch_release(struct wl_touch *wl_touch)
4999 {
5000 	wl_proxy_marshal((struct wl_proxy *) wl_touch,
5001 			 WL_TOUCH_RELEASE);
5002 
5003 	wl_proxy_destroy((struct wl_proxy *) wl_touch);
5004 }
5005 
5006 #ifndef WL_OUTPUT_SUBPIXEL_ENUM
5007 #define WL_OUTPUT_SUBPIXEL_ENUM
5008 /**
5009  * @ingroup iface_wl_output
5010  * subpixel geometry information
5011  *
5012  * This enumeration describes how the physical
5013  * pixels on an output are laid out.
5014  */
5015 enum wl_output_subpixel {
5016 	/**
5017 	 * unknown geometry
5018 	 */
5019 	WL_OUTPUT_SUBPIXEL_UNKNOWN = 0,
5020 	/**
5021 	 * no geometry
5022 	 */
5023 	WL_OUTPUT_SUBPIXEL_NONE = 1,
5024 	/**
5025 	 * horizontal RGB
5026 	 */
5027 	WL_OUTPUT_SUBPIXEL_HORIZONTAL_RGB = 2,
5028 	/**
5029 	 * horizontal BGR
5030 	 */
5031 	WL_OUTPUT_SUBPIXEL_HORIZONTAL_BGR = 3,
5032 	/**
5033 	 * vertical RGB
5034 	 */
5035 	WL_OUTPUT_SUBPIXEL_VERTICAL_RGB = 4,
5036 	/**
5037 	 * vertical BGR
5038 	 */
5039 	WL_OUTPUT_SUBPIXEL_VERTICAL_BGR = 5,
5040 };
5041 #endif /* WL_OUTPUT_SUBPIXEL_ENUM */
5042 
5043 #ifndef WL_OUTPUT_TRANSFORM_ENUM
5044 #define WL_OUTPUT_TRANSFORM_ENUM
5045 /**
5046  * @ingroup iface_wl_output
5047  * transform from framebuffer to output
5048  *
5049  * This describes the transform that a compositor will apply to a
5050  * surface to compensate for the rotation or mirroring of an
5051  * output device.
5052  *
5053  * The flipped values correspond to an initial flip around a
5054  * vertical axis followed by rotation.
5055  *
5056  * The purpose is mainly to allow clients to render accordingly and
5057  * tell the compositor, so that for fullscreen surfaces, the
5058  * compositor will still be able to scan out directly from client
5059  * surfaces.
5060  */
5061 enum wl_output_transform {
5062 	/**
5063 	 * no transform
5064 	 */
5065 	WL_OUTPUT_TRANSFORM_NORMAL = 0,
5066 	/**
5067 	 * 90 degrees counter-clockwise
5068 	 */
5069 	WL_OUTPUT_TRANSFORM_90 = 1,
5070 	/**
5071 	 * 180 degrees counter-clockwise
5072 	 */
5073 	WL_OUTPUT_TRANSFORM_180 = 2,
5074 	/**
5075 	 * 270 degrees counter-clockwise
5076 	 */
5077 	WL_OUTPUT_TRANSFORM_270 = 3,
5078 	/**
5079 	 * 180 degree flip around a vertical axis
5080 	 */
5081 	WL_OUTPUT_TRANSFORM_FLIPPED = 4,
5082 	/**
5083 	 * flip and rotate 90 degrees counter-clockwise
5084 	 */
5085 	WL_OUTPUT_TRANSFORM_FLIPPED_90 = 5,
5086 	/**
5087 	 * flip and rotate 180 degrees counter-clockwise
5088 	 */
5089 	WL_OUTPUT_TRANSFORM_FLIPPED_180 = 6,
5090 	/**
5091 	 * flip and rotate 270 degrees counter-clockwise
5092 	 */
5093 	WL_OUTPUT_TRANSFORM_FLIPPED_270 = 7,
5094 };
5095 #endif /* WL_OUTPUT_TRANSFORM_ENUM */
5096 
5097 #ifndef WL_OUTPUT_MODE_ENUM
5098 #define WL_OUTPUT_MODE_ENUM
5099 /**
5100  * @ingroup iface_wl_output
5101  * mode information
5102  *
5103  * These flags describe properties of an output mode.
5104  * They are used in the flags bitfield of the mode event.
5105  */
5106 enum wl_output_mode {
5107 	/**
5108 	 * indicates this is the current mode
5109 	 */
5110 	WL_OUTPUT_MODE_CURRENT = 0x1,
5111 	/**
5112 	 * indicates this is the preferred mode
5113 	 */
5114 	WL_OUTPUT_MODE_PREFERRED = 0x2,
5115 };
5116 #endif /* WL_OUTPUT_MODE_ENUM */
5117 
5118 /**
5119  * @ingroup iface_wl_output
5120  * @struct wl_output_listener
5121  */
5122 struct wl_output_listener {
5123 	/**
5124 	 * properties of the output
5125 	 *
5126 	 * The geometry event describes geometric properties of the
5127 	 * output. The event is sent when binding to the output object and
5128 	 * whenever any of the properties change.
5129 	 * @param x x position within the global compositor space
5130 	 * @param y y position within the global compositor space
5131 	 * @param physical_width width in millimeters of the output
5132 	 * @param physical_height height in millimeters of the output
5133 	 * @param subpixel subpixel orientation of the output
5134 	 * @param make textual description of the manufacturer
5135 	 * @param model textual description of the model
5136 	 * @param transform transform that maps framebuffer to output
5137 	 */
5138 	void (*geometry)(void *data,
5139 			 struct wl_output *wl_output,
5140 			 int32_t x,
5141 			 int32_t y,
5142 			 int32_t physical_width,
5143 			 int32_t physical_height,
5144 			 int32_t subpixel,
5145 			 const char *make,
5146 			 const char *model,
5147 			 int32_t transform);
5148 	/**
5149 	 * advertise available modes for the output
5150 	 *
5151 	 * The mode event describes an available mode for the output.
5152 	 *
5153 	 * The event is sent when binding to the output object and there
5154 	 * will always be one mode, the current mode. The event is sent
5155 	 * again if an output changes mode, for the mode that is now
5156 	 * current. In other words, the current mode is always the last
5157 	 * mode that was received with the current flag set.
5158 	 *
5159 	 * The size of a mode is given in physical hardware units of the
5160 	 * output device. This is not necessarily the same as the output
5161 	 * size in the global compositor space. For instance, the output
5162 	 * may be scaled, as described in wl_output.scale, or transformed,
5163 	 * as described in wl_output.transform.
5164 	 * @param flags bitfield of mode flags
5165 	 * @param width width of the mode in hardware units
5166 	 * @param height height of the mode in hardware units
5167 	 * @param refresh vertical refresh rate in mHz
5168 	 */
5169 	void (*mode)(void *data,
5170 		     struct wl_output *wl_output,
5171 		     uint32_t flags,
5172 		     int32_t width,
5173 		     int32_t height,
5174 		     int32_t refresh);
5175 	/**
5176 	 * sent all information about output
5177 	 *
5178 	 * This event is sent after all other properties have been sent
5179 	 * after binding to the output object and after any other property
5180 	 * changes done after that. This allows changes to the output
5181 	 * properties to be seen as atomic, even if they happen via
5182 	 * multiple events.
5183 	 * @since 2
5184 	 */
5185 	void (*done)(void *data,
5186 		     struct wl_output *wl_output);
5187 	/**
5188 	 * output scaling properties
5189 	 *
5190 	 * This event contains scaling geometry information that is not
5191 	 * in the geometry event. It may be sent after binding the output
5192 	 * object or if the output scale changes later. If it is not sent,
5193 	 * the client should assume a scale of 1.
5194 	 *
5195 	 * A scale larger than 1 means that the compositor will
5196 	 * automatically scale surface buffers by this amount when
5197 	 * rendering. This is used for very high resolution displays where
5198 	 * applications rendering at the native resolution would be too
5199 	 * small to be legible.
5200 	 *
5201 	 * It is intended that scaling aware clients track the current
5202 	 * output of a surface, and if it is on a scaled output it should
5203 	 * use wl_surface.set_buffer_scale with the scale of the output.
5204 	 * That way the compositor can avoid scaling the surface, and the
5205 	 * client can supply a higher detail image.
5206 	 * @param factor scaling factor of output
5207 	 * @since 2
5208 	 */
5209 	void (*scale)(void *data,
5210 		      struct wl_output *wl_output,
5211 		      int32_t factor);
5212 };
5213 
5214 /**
5215  * @ingroup iface_wl_output
5216  */
5217 static inline int
wl_output_add_listener(struct wl_output * wl_output,const struct wl_output_listener * listener,void * data)5218 wl_output_add_listener(struct wl_output *wl_output,
5219 		       const struct wl_output_listener *listener, void *data)
5220 {
5221 	return wl_proxy_add_listener((struct wl_proxy *) wl_output,
5222 				     (void (**)(void)) listener, data);
5223 }
5224 
5225 #define WL_OUTPUT_RELEASE 0
5226 
5227 /**
5228  * @ingroup iface_wl_output
5229  */
5230 #define WL_OUTPUT_GEOMETRY_SINCE_VERSION 1
5231 /**
5232  * @ingroup iface_wl_output
5233  */
5234 #define WL_OUTPUT_MODE_SINCE_VERSION 1
5235 /**
5236  * @ingroup iface_wl_output
5237  */
5238 #define WL_OUTPUT_DONE_SINCE_VERSION 2
5239 /**
5240  * @ingroup iface_wl_output
5241  */
5242 #define WL_OUTPUT_SCALE_SINCE_VERSION 2
5243 
5244 /**
5245  * @ingroup iface_wl_output
5246  */
5247 #define WL_OUTPUT_RELEASE_SINCE_VERSION 3
5248 
5249 /** @ingroup iface_wl_output */
5250 static inline void
wl_output_set_user_data(struct wl_output * wl_output,void * user_data)5251 wl_output_set_user_data(struct wl_output *wl_output, void *user_data)
5252 {
5253 	wl_proxy_set_user_data((struct wl_proxy *) wl_output, user_data);
5254 }
5255 
5256 /** @ingroup iface_wl_output */
5257 static inline void *
wl_output_get_user_data(struct wl_output * wl_output)5258 wl_output_get_user_data(struct wl_output *wl_output)
5259 {
5260 	return wl_proxy_get_user_data((struct wl_proxy *) wl_output);
5261 }
5262 
5263 static inline uint32_t
wl_output_get_version(struct wl_output * wl_output)5264 wl_output_get_version(struct wl_output *wl_output)
5265 {
5266 	return wl_proxy_get_version((struct wl_proxy *) wl_output);
5267 }
5268 
5269 /** @ingroup iface_wl_output */
5270 static inline void
wl_output_destroy(struct wl_output * wl_output)5271 wl_output_destroy(struct wl_output *wl_output)
5272 {
5273 	wl_proxy_destroy((struct wl_proxy *) wl_output);
5274 }
5275 
5276 /**
5277  * @ingroup iface_wl_output
5278  *
5279  * Using this request a client can tell the server that it is not going to
5280  * use the output object anymore.
5281  */
5282 static inline void
wl_output_release(struct wl_output * wl_output)5283 wl_output_release(struct wl_output *wl_output)
5284 {
5285 	wl_proxy_marshal((struct wl_proxy *) wl_output,
5286 			 WL_OUTPUT_RELEASE);
5287 
5288 	wl_proxy_destroy((struct wl_proxy *) wl_output);
5289 }
5290 
5291 #define WL_REGION_DESTROY 0
5292 #define WL_REGION_ADD 1
5293 #define WL_REGION_SUBTRACT 2
5294 
5295 
5296 /**
5297  * @ingroup iface_wl_region
5298  */
5299 #define WL_REGION_DESTROY_SINCE_VERSION 1
5300 /**
5301  * @ingroup iface_wl_region
5302  */
5303 #define WL_REGION_ADD_SINCE_VERSION 1
5304 /**
5305  * @ingroup iface_wl_region
5306  */
5307 #define WL_REGION_SUBTRACT_SINCE_VERSION 1
5308 
5309 /** @ingroup iface_wl_region */
5310 static inline void
wl_region_set_user_data(struct wl_region * wl_region,void * user_data)5311 wl_region_set_user_data(struct wl_region *wl_region, void *user_data)
5312 {
5313 	wl_proxy_set_user_data((struct wl_proxy *) wl_region, user_data);
5314 }
5315 
5316 /** @ingroup iface_wl_region */
5317 static inline void *
wl_region_get_user_data(struct wl_region * wl_region)5318 wl_region_get_user_data(struct wl_region *wl_region)
5319 {
5320 	return wl_proxy_get_user_data((struct wl_proxy *) wl_region);
5321 }
5322 
5323 static inline uint32_t
wl_region_get_version(struct wl_region * wl_region)5324 wl_region_get_version(struct wl_region *wl_region)
5325 {
5326 	return wl_proxy_get_version((struct wl_proxy *) wl_region);
5327 }
5328 
5329 /**
5330  * @ingroup iface_wl_region
5331  *
5332  * Destroy the region.  This will invalidate the object ID.
5333  */
5334 static inline void
wl_region_destroy(struct wl_region * wl_region)5335 wl_region_destroy(struct wl_region *wl_region)
5336 {
5337 	wl_proxy_marshal((struct wl_proxy *) wl_region,
5338 			 WL_REGION_DESTROY);
5339 
5340 	wl_proxy_destroy((struct wl_proxy *) wl_region);
5341 }
5342 
5343 /**
5344  * @ingroup iface_wl_region
5345  *
5346  * Add the specified rectangle to the region.
5347  */
5348 static inline void
wl_region_add(struct wl_region * wl_region,int32_t x,int32_t y,int32_t width,int32_t height)5349 wl_region_add(struct wl_region *wl_region, int32_t x, int32_t y, int32_t width, int32_t height)
5350 {
5351 	wl_proxy_marshal((struct wl_proxy *) wl_region,
5352 			 WL_REGION_ADD, x, y, width, height);
5353 }
5354 
5355 /**
5356  * @ingroup iface_wl_region
5357  *
5358  * Subtract the specified rectangle from the region.
5359  */
5360 static inline void
wl_region_subtract(struct wl_region * wl_region,int32_t x,int32_t y,int32_t width,int32_t height)5361 wl_region_subtract(struct wl_region *wl_region, int32_t x, int32_t y, int32_t width, int32_t height)
5362 {
5363 	wl_proxy_marshal((struct wl_proxy *) wl_region,
5364 			 WL_REGION_SUBTRACT, x, y, width, height);
5365 }
5366 
5367 #ifndef WL_SUBCOMPOSITOR_ERROR_ENUM
5368 #define WL_SUBCOMPOSITOR_ERROR_ENUM
5369 enum wl_subcompositor_error {
5370 	/**
5371 	 * the to-be sub-surface is invalid
5372 	 */
5373 	WL_SUBCOMPOSITOR_ERROR_BAD_SURFACE = 0,
5374 };
5375 #endif /* WL_SUBCOMPOSITOR_ERROR_ENUM */
5376 
5377 #define WL_SUBCOMPOSITOR_DESTROY 0
5378 #define WL_SUBCOMPOSITOR_GET_SUBSURFACE 1
5379 
5380 
5381 /**
5382  * @ingroup iface_wl_subcompositor
5383  */
5384 #define WL_SUBCOMPOSITOR_DESTROY_SINCE_VERSION 1
5385 /**
5386  * @ingroup iface_wl_subcompositor
5387  */
5388 #define WL_SUBCOMPOSITOR_GET_SUBSURFACE_SINCE_VERSION 1
5389 
5390 /** @ingroup iface_wl_subcompositor */
5391 static inline void
wl_subcompositor_set_user_data(struct wl_subcompositor * wl_subcompositor,void * user_data)5392 wl_subcompositor_set_user_data(struct wl_subcompositor *wl_subcompositor, void *user_data)
5393 {
5394 	wl_proxy_set_user_data((struct wl_proxy *) wl_subcompositor, user_data);
5395 }
5396 
5397 /** @ingroup iface_wl_subcompositor */
5398 static inline void *
wl_subcompositor_get_user_data(struct wl_subcompositor * wl_subcompositor)5399 wl_subcompositor_get_user_data(struct wl_subcompositor *wl_subcompositor)
5400 {
5401 	return wl_proxy_get_user_data((struct wl_proxy *) wl_subcompositor);
5402 }
5403 
5404 static inline uint32_t
wl_subcompositor_get_version(struct wl_subcompositor * wl_subcompositor)5405 wl_subcompositor_get_version(struct wl_subcompositor *wl_subcompositor)
5406 {
5407 	return wl_proxy_get_version((struct wl_proxy *) wl_subcompositor);
5408 }
5409 
5410 /**
5411  * @ingroup iface_wl_subcompositor
5412  *
5413  * Informs the server that the client will not be using this
5414  * protocol object anymore. This does not affect any other
5415  * objects, wl_subsurface objects included.
5416  */
5417 static inline void
wl_subcompositor_destroy(struct wl_subcompositor * wl_subcompositor)5418 wl_subcompositor_destroy(struct wl_subcompositor *wl_subcompositor)
5419 {
5420 	wl_proxy_marshal((struct wl_proxy *) wl_subcompositor,
5421 			 WL_SUBCOMPOSITOR_DESTROY);
5422 
5423 	wl_proxy_destroy((struct wl_proxy *) wl_subcompositor);
5424 }
5425 
5426 /**
5427  * @ingroup iface_wl_subcompositor
5428  *
5429  * Create a sub-surface interface for the given surface, and
5430  * associate it with the given parent surface. This turns a
5431  * plain wl_surface into a sub-surface.
5432  *
5433  * The to-be sub-surface must not already have another role, and it
5434  * must not have an existing wl_subsurface object. Otherwise a protocol
5435  * error is raised.
5436  */
5437 static inline struct wl_subsurface *
wl_subcompositor_get_subsurface(struct wl_subcompositor * wl_subcompositor,struct wl_surface * surface,struct wl_surface * parent)5438 wl_subcompositor_get_subsurface(struct wl_subcompositor *wl_subcompositor, struct wl_surface *surface, struct wl_surface *parent)
5439 {
5440 	struct wl_proxy *id;
5441 
5442 	id = wl_proxy_marshal_constructor((struct wl_proxy *) wl_subcompositor,
5443 			 WL_SUBCOMPOSITOR_GET_SUBSURFACE, &wl_subsurface_interface, NULL, surface, parent);
5444 
5445 	return (struct wl_subsurface *) id;
5446 }
5447 
5448 #ifndef WL_SUBSURFACE_ERROR_ENUM
5449 #define WL_SUBSURFACE_ERROR_ENUM
5450 enum wl_subsurface_error {
5451 	/**
5452 	 * wl_surface is not a sibling or the parent
5453 	 */
5454 	WL_SUBSURFACE_ERROR_BAD_SURFACE = 0,
5455 };
5456 #endif /* WL_SUBSURFACE_ERROR_ENUM */
5457 
5458 #define WL_SUBSURFACE_DESTROY 0
5459 #define WL_SUBSURFACE_SET_POSITION 1
5460 #define WL_SUBSURFACE_PLACE_ABOVE 2
5461 #define WL_SUBSURFACE_PLACE_BELOW 3
5462 #define WL_SUBSURFACE_SET_SYNC 4
5463 #define WL_SUBSURFACE_SET_DESYNC 5
5464 
5465 
5466 /**
5467  * @ingroup iface_wl_subsurface
5468  */
5469 #define WL_SUBSURFACE_DESTROY_SINCE_VERSION 1
5470 /**
5471  * @ingroup iface_wl_subsurface
5472  */
5473 #define WL_SUBSURFACE_SET_POSITION_SINCE_VERSION 1
5474 /**
5475  * @ingroup iface_wl_subsurface
5476  */
5477 #define WL_SUBSURFACE_PLACE_ABOVE_SINCE_VERSION 1
5478 /**
5479  * @ingroup iface_wl_subsurface
5480  */
5481 #define WL_SUBSURFACE_PLACE_BELOW_SINCE_VERSION 1
5482 /**
5483  * @ingroup iface_wl_subsurface
5484  */
5485 #define WL_SUBSURFACE_SET_SYNC_SINCE_VERSION 1
5486 /**
5487  * @ingroup iface_wl_subsurface
5488  */
5489 #define WL_SUBSURFACE_SET_DESYNC_SINCE_VERSION 1
5490 
5491 /** @ingroup iface_wl_subsurface */
5492 static inline void
wl_subsurface_set_user_data(struct wl_subsurface * wl_subsurface,void * user_data)5493 wl_subsurface_set_user_data(struct wl_subsurface *wl_subsurface, void *user_data)
5494 {
5495 	wl_proxy_set_user_data((struct wl_proxy *) wl_subsurface, user_data);
5496 }
5497 
5498 /** @ingroup iface_wl_subsurface */
5499 static inline void *
wl_subsurface_get_user_data(struct wl_subsurface * wl_subsurface)5500 wl_subsurface_get_user_data(struct wl_subsurface *wl_subsurface)
5501 {
5502 	return wl_proxy_get_user_data((struct wl_proxy *) wl_subsurface);
5503 }
5504 
5505 static inline uint32_t
wl_subsurface_get_version(struct wl_subsurface * wl_subsurface)5506 wl_subsurface_get_version(struct wl_subsurface *wl_subsurface)
5507 {
5508 	return wl_proxy_get_version((struct wl_proxy *) wl_subsurface);
5509 }
5510 
5511 /**
5512  * @ingroup iface_wl_subsurface
5513  *
5514  * The sub-surface interface is removed from the wl_surface object
5515  * that was turned into a sub-surface with a
5516  * wl_subcompositor.get_subsurface request. The wl_surface's association
5517  * to the parent is deleted, and the wl_surface loses its role as
5518  * a sub-surface. The wl_surface is unmapped.
5519  */
5520 static inline void
wl_subsurface_destroy(struct wl_subsurface * wl_subsurface)5521 wl_subsurface_destroy(struct wl_subsurface *wl_subsurface)
5522 {
5523 	wl_proxy_marshal((struct wl_proxy *) wl_subsurface,
5524 			 WL_SUBSURFACE_DESTROY);
5525 
5526 	wl_proxy_destroy((struct wl_proxy *) wl_subsurface);
5527 }
5528 
5529 /**
5530  * @ingroup iface_wl_subsurface
5531  *
5532  * This schedules a sub-surface position change.
5533  * The sub-surface will be moved so that its origin (top left
5534  * corner pixel) will be at the location x, y of the parent surface
5535  * coordinate system. The coordinates are not restricted to the parent
5536  * surface area. Negative values are allowed.
5537  *
5538  * The scheduled coordinates will take effect whenever the state of the
5539  * parent surface is applied. When this happens depends on whether the
5540  * parent surface is in synchronized mode or not. See
5541  * wl_subsurface.set_sync and wl_subsurface.set_desync for details.
5542  *
5543  * If more than one set_position request is invoked by the client before
5544  * the commit of the parent surface, the position of a new request always
5545  * replaces the scheduled position from any previous request.
5546  *
5547  * The initial position is 0, 0.
5548  */
5549 static inline void
wl_subsurface_set_position(struct wl_subsurface * wl_subsurface,int32_t x,int32_t y)5550 wl_subsurface_set_position(struct wl_subsurface *wl_subsurface, int32_t x, int32_t y)
5551 {
5552 	wl_proxy_marshal((struct wl_proxy *) wl_subsurface,
5553 			 WL_SUBSURFACE_SET_POSITION, x, y);
5554 }
5555 
5556 /**
5557  * @ingroup iface_wl_subsurface
5558  *
5559  * This sub-surface is taken from the stack, and put back just
5560  * above the reference surface, changing the z-order of the sub-surfaces.
5561  * The reference surface must be one of the sibling surfaces, or the
5562  * parent surface. Using any other surface, including this sub-surface,
5563  * will cause a protocol error.
5564  *
5565  * The z-order is double-buffered. Requests are handled in order and
5566  * applied immediately to a pending state. The final pending state is
5567  * copied to the active state the next time the state of the parent
5568  * surface is applied. When this happens depends on whether the parent
5569  * surface is in synchronized mode or not. See wl_subsurface.set_sync and
5570  * wl_subsurface.set_desync for details.
5571  *
5572  * A new sub-surface is initially added as the top-most in the stack
5573  * of its siblings and parent.
5574  */
5575 static inline void
wl_subsurface_place_above(struct wl_subsurface * wl_subsurface,struct wl_surface * sibling)5576 wl_subsurface_place_above(struct wl_subsurface *wl_subsurface, struct wl_surface *sibling)
5577 {
5578 	wl_proxy_marshal((struct wl_proxy *) wl_subsurface,
5579 			 WL_SUBSURFACE_PLACE_ABOVE, sibling);
5580 }
5581 
5582 /**
5583  * @ingroup iface_wl_subsurface
5584  *
5585  * The sub-surface is placed just below the reference surface.
5586  * See wl_subsurface.place_above.
5587  */
5588 static inline void
wl_subsurface_place_below(struct wl_subsurface * wl_subsurface,struct wl_surface * sibling)5589 wl_subsurface_place_below(struct wl_subsurface *wl_subsurface, struct wl_surface *sibling)
5590 {
5591 	wl_proxy_marshal((struct wl_proxy *) wl_subsurface,
5592 			 WL_SUBSURFACE_PLACE_BELOW, sibling);
5593 }
5594 
5595 /**
5596  * @ingroup iface_wl_subsurface
5597  *
5598  * Change the commit behaviour of the sub-surface to synchronized
5599  * mode, also described as the parent dependent mode.
5600  *
5601  * In synchronized mode, wl_surface.commit on a sub-surface will
5602  * accumulate the committed state in a cache, but the state will
5603  * not be applied and hence will not change the compositor output.
5604  * The cached state is applied to the sub-surface immediately after
5605  * the parent surface's state is applied. This ensures atomic
5606  * updates of the parent and all its synchronized sub-surfaces.
5607  * Applying the cached state will invalidate the cache, so further
5608  * parent surface commits do not (re-)apply old state.
5609  *
5610  * See wl_subsurface for the recursive effect of this mode.
5611  */
5612 static inline void
wl_subsurface_set_sync(struct wl_subsurface * wl_subsurface)5613 wl_subsurface_set_sync(struct wl_subsurface *wl_subsurface)
5614 {
5615 	wl_proxy_marshal((struct wl_proxy *) wl_subsurface,
5616 			 WL_SUBSURFACE_SET_SYNC);
5617 }
5618 
5619 /**
5620  * @ingroup iface_wl_subsurface
5621  *
5622  * Change the commit behaviour of the sub-surface to desynchronized
5623  * mode, also described as independent or freely running mode.
5624  *
5625  * In desynchronized mode, wl_surface.commit on a sub-surface will
5626  * apply the pending state directly, without caching, as happens
5627  * normally with a wl_surface. Calling wl_surface.commit on the
5628  * parent surface has no effect on the sub-surface's wl_surface
5629  * state. This mode allows a sub-surface to be updated on its own.
5630  *
5631  * If cached state exists when wl_surface.commit is called in
5632  * desynchronized mode, the pending state is added to the cached
5633  * state, and applied as a whole. This invalidates the cache.
5634  *
5635  * Note: even if a sub-surface is set to desynchronized, a parent
5636  * sub-surface may override it to behave as synchronized. For details,
5637  * see wl_subsurface.
5638  *
5639  * If a surface's parent surface behaves as desynchronized, then
5640  * the cached state is applied on set_desync.
5641  */
5642 static inline void
wl_subsurface_set_desync(struct wl_subsurface * wl_subsurface)5643 wl_subsurface_set_desync(struct wl_subsurface *wl_subsurface)
5644 {
5645 	wl_proxy_marshal((struct wl_proxy *) wl_subsurface,
5646 			 WL_SUBSURFACE_SET_DESYNC);
5647 }
5648 
5649 #ifdef  __cplusplus
5650 }
5651 #endif
5652 
5653 #endif
5654