tizen 2.4 release
[framework/uifw/libeom.git] / src / wayland / protocol / xdg-shell-client-protocol.h
1 /*
2  * Copyright © 2008-2013 Kristian Høgsberg
3  * Copyright © 2013      Rafael Antognolli
4  * Copyright © 2013      Jasper St. Pierre
5  * Copyright © 2010-2013 Intel Corporation
6  *
7  * Permission to use, copy, modify, distribute, and sell this
8  * software and its documentation for any purpose is hereby granted
9  * without fee, provided that the above copyright notice appear in
10  * all copies and that both that copyright notice and this permission
11  * notice appear in supporting documentation, and that the name of
12  * the copyright holders not be used in advertising or publicity
13  * pertaining to distribution of the software without specific,
14  * written prior permission.  The copyright holders make no
15  * representations about the suitability of this software for any
16  * purpose.  It is provided "as is" without express or implied
17  * warranty.
18  *
19  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
20  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
22  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
23  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
24  * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
25  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
26  * THIS SOFTWARE.
27  */
28
29 #ifndef XDG_SHELL_CLIENT_PROTOCOL_H
30 #define XDG_SHELL_CLIENT_PROTOCOL_H
31
32 #ifdef  __cplusplus
33 extern "C" {
34 #endif
35
36 #include <stdint.h>
37 #include <stddef.h>
38 #include "wayland-client.h"
39
40 struct wl_client;
41 struct wl_resource;
42
43 struct xdg_shell;
44 struct xdg_surface;
45 struct xdg_popup;
46
47 extern const struct wl_interface xdg_shell_interface;
48 extern const struct wl_interface xdg_surface_interface;
49 extern const struct wl_interface xdg_popup_interface;
50
51 #ifndef XDG_SHELL_VERSION_ENUM
52 #define XDG_SHELL_VERSION_ENUM
53 /**
54  * xdg_shell_version - latest protocol version
55  * @XDG_SHELL_VERSION_CURRENT: Always the latest version
56  *
57  * The 'current' member of this enum gives the version of the protocol.
58  * Implementations can compare this to the version they implement using
59  * static_assert to ensure the protocol and implementation versions match.
60  */
61 enum xdg_shell_version {
62         XDG_SHELL_VERSION_CURRENT = 4,
63 };
64 #endif /* XDG_SHELL_VERSION_ENUM */
65
66 /**
67  * xdg_shell - create desktop-style surfaces
68  * @ping: check if the client is alive
69  *
70  * This interface is implemented by servers that provide desktop-style
71  * user interfaces.
72  *
73  * It allows clients to associate a xdg_surface with a basic surface.
74  */
75 struct xdg_shell_listener {
76         /**
77          * ping - check if the client is alive
78          * @serial: pass this to the callback
79          *
80          * The ping event asks the client if it's still alive. Pass the
81          * serial specified in the event back to the compositor by sending
82          * a "pong" request back with the specified serial.
83          *
84          * Compositors can use this to determine if the client is still
85          * alive. It's unspecified what will happen if the client doesn't
86          * respond to the ping request, or in what timeframe. Clients
87          * should try to respond in a reasonable amount of time.
88          */
89         void (*ping)(void *data,
90                      struct xdg_shell *xdg_shell,
91                      uint32_t serial);
92 };
93
94 static inline int
95 xdg_shell_add_listener(struct xdg_shell *xdg_shell,
96                        const struct xdg_shell_listener *listener, void *data)
97 {
98         return wl_proxy_add_listener((struct wl_proxy *) xdg_shell,
99                                      (void (**)(void)) listener, data);
100 }
101
102 #define XDG_SHELL_USE_UNSTABLE_VERSION  0
103 #define XDG_SHELL_GET_XDG_SURFACE       1
104 #define XDG_SHELL_GET_XDG_POPUP 2
105 #define XDG_SHELL_PONG  3
106
107 static inline void
108 xdg_shell_set_user_data(struct xdg_shell *xdg_shell, void *user_data)
109 {
110         wl_proxy_set_user_data((struct wl_proxy *) xdg_shell, user_data);
111 }
112
113 static inline void *
114 xdg_shell_get_user_data(struct xdg_shell *xdg_shell)
115 {
116         return wl_proxy_get_user_data((struct wl_proxy *) xdg_shell);
117 }
118
119 static inline void
120 xdg_shell_destroy(struct xdg_shell *xdg_shell)
121 {
122         wl_proxy_destroy((struct wl_proxy *) xdg_shell);
123 }
124
125 static inline void
126 xdg_shell_use_unstable_version(struct xdg_shell *xdg_shell, int32_t version)
127 {
128         wl_proxy_marshal((struct wl_proxy *) xdg_shell,
129                          XDG_SHELL_USE_UNSTABLE_VERSION, version);
130 }
131
132 static inline struct xdg_surface *
133 xdg_shell_get_xdg_surface(struct xdg_shell *xdg_shell, struct wl_surface *surface)
134 {
135         struct wl_proxy *id;
136
137         id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_shell,
138                          XDG_SHELL_GET_XDG_SURFACE, &xdg_surface_interface, NULL, surface);
139
140         return (struct xdg_surface *) id;
141 }
142
143 static inline struct xdg_popup *
144 xdg_shell_get_xdg_popup(struct xdg_shell *xdg_shell, struct wl_surface *surface, struct wl_surface *parent, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y, uint32_t flags)
145 {
146         struct wl_proxy *id;
147
148         id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_shell,
149                          XDG_SHELL_GET_XDG_POPUP, &xdg_popup_interface, NULL, surface, parent, seat, serial, x, y, flags);
150
151         return (struct xdg_popup *) id;
152 }
153
154 static inline void
155 xdg_shell_pong(struct xdg_shell *xdg_shell, uint32_t serial)
156 {
157         wl_proxy_marshal((struct wl_proxy *) xdg_shell,
158                          XDG_SHELL_PONG, serial);
159 }
160
161 #ifndef XDG_SURFACE_RESIZE_EDGE_ENUM
162 #define XDG_SURFACE_RESIZE_EDGE_ENUM
163 /**
164  * xdg_surface_resize_edge - edge values for resizing
165  * @XDG_SURFACE_RESIZE_EDGE_NONE: (none)
166  * @XDG_SURFACE_RESIZE_EDGE_TOP: (none)
167  * @XDG_SURFACE_RESIZE_EDGE_BOTTOM: (none)
168  * @XDG_SURFACE_RESIZE_EDGE_LEFT: (none)
169  * @XDG_SURFACE_RESIZE_EDGE_TOP_LEFT: (none)
170  * @XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT: (none)
171  * @XDG_SURFACE_RESIZE_EDGE_RIGHT: (none)
172  * @XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT: (none)
173  * @XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT: (none)
174  *
175  * These values are used to indicate which edge of a surface is being
176  * dragged in a resize operation. The server may use this information to
177  * adapt its behavior, e.g. choose an appropriate cursor image.
178  */
179 enum xdg_surface_resize_edge {
180         XDG_SURFACE_RESIZE_EDGE_NONE = 0,
181         XDG_SURFACE_RESIZE_EDGE_TOP = 1,
182         XDG_SURFACE_RESIZE_EDGE_BOTTOM = 2,
183         XDG_SURFACE_RESIZE_EDGE_LEFT = 4,
184         XDG_SURFACE_RESIZE_EDGE_TOP_LEFT = 5,
185         XDG_SURFACE_RESIZE_EDGE_BOTTOM_LEFT = 6,
186         XDG_SURFACE_RESIZE_EDGE_RIGHT = 8,
187         XDG_SURFACE_RESIZE_EDGE_TOP_RIGHT = 9,
188         XDG_SURFACE_RESIZE_EDGE_BOTTOM_RIGHT = 10,
189 };
190 #endif /* XDG_SURFACE_RESIZE_EDGE_ENUM */
191
192 #ifndef XDG_SURFACE_STATE_ENUM
193 #define XDG_SURFACE_STATE_ENUM
194 /**
195  * xdg_surface_state - types of state on the surface
196  * @XDG_SURFACE_STATE_MAXIMIZED: the surface is maximized
197  * @XDG_SURFACE_STATE_FULLSCREEN: the surface is fullscreen
198  * @XDG_SURFACE_STATE_RESIZING: (none)
199  * @XDG_SURFACE_STATE_ACTIVATED: (none)
200  *
201  * The different state values used on the surface. This is designed for
202  * state values like maximized, fullscreen. It is paired with the configure
203  * event to ensure that both the client and the compositor setting the
204  * state can be synchronized.
205  *
206  * States set in this way are double-buffered. They will get applied on the
207  * next commit.
208  *
209  * Desktop environments may extend this enum by taking up a range of values
210  * and documenting the range they chose in this description. They are not
211  * required to document the values for the range that they chose. Ideally,
212  * any good extensions from a desktop environment should make its way into
213  * standardization into this enum.
214  *
215  * The current reserved ranges are:
216  *
217  * 0x0000 - 0x0FFF: xdg-shell core values, documented below. 0x1000 -
218  * 0x1FFF: GNOME
219  */
220 enum xdg_surface_state {
221         XDG_SURFACE_STATE_MAXIMIZED = 1,
222         XDG_SURFACE_STATE_FULLSCREEN = 2,
223         XDG_SURFACE_STATE_RESIZING = 3,
224         XDG_SURFACE_STATE_ACTIVATED = 4,
225 };
226 #endif /* XDG_SURFACE_STATE_ENUM */
227
228 /**
229  * xdg_surface - desktop-style metadata interface
230  * @configure: suggest a surface change
231  * @close: surface wants to be closed
232  *
233  * An interface that may be implemented by a wl_surface, for
234  * implementations that provide a desktop-style user interface.
235  *
236  * It provides requests to treat surfaces like windows, allowing to set
237  * properties like maximized, fullscreen, minimized, and to move and resize
238  * them, and associate metadata like title and app id.
239  *
240  * On the server side the object is automatically destroyed when the
241  * related wl_surface is destroyed. On client side, xdg_surface.destroy()
242  * must be called before destroying the wl_surface object.
243  */
244 struct xdg_surface_listener {
245         /**
246          * configure - suggest a surface change
247          * @width: (none)
248          * @height: (none)
249          * @states: (none)
250          * @serial: (none)
251          *
252          * The configure event asks the client to resize its surface.
253          *
254          * The width and height arguments specify a hint to the window
255          * about how its surface should be resized in window geometry
256          * coordinates. The states listed in the event specify how the
257          * width/height arguments should be interpreted.
258          *
259          * A client should arrange a new surface, and then send a
260          * ack_configure request with the serial sent in this configure
261          * event before attaching a new surface.
262          *
263          * If the client receives multiple configure events before it can
264          * respond to one, it is free to discard all but the last event it
265          * received.
266          */
267         void (*configure)(void *data,
268                           struct xdg_surface *xdg_surface,
269                           int32_t width,
270                           int32_t height,
271                           struct wl_array *states,
272                           uint32_t serial);
273         /**
274          * close - surface wants to be closed
275          *
276          * The close event is sent by the compositor when the user wants
277          * the surface to be closed. This should be equivalent to the user
278          * clicking the close button in client-side decorations, if your
279          * application has any...
280          *
281          * This is only a request that the user intends to close your
282          * window. The client may choose to ignore this request, or show a
283          * dialog to ask the user to save their data...
284          */
285         void (*close)(void *data,
286                       struct xdg_surface *xdg_surface);
287 };
288
289 static inline int
290 xdg_surface_add_listener(struct xdg_surface *xdg_surface,
291                          const struct xdg_surface_listener *listener, void *data)
292 {
293         return wl_proxy_add_listener((struct wl_proxy *) xdg_surface,
294                                      (void (**)(void)) listener, data);
295 }
296
297 #define XDG_SURFACE_DESTROY     0
298 #define XDG_SURFACE_SET_PARENT  1
299 #define XDG_SURFACE_SET_TITLE   2
300 #define XDG_SURFACE_SET_APP_ID  3
301 #define XDG_SURFACE_SHOW_WINDOW_MENU    4
302 #define XDG_SURFACE_MOVE        5
303 #define XDG_SURFACE_RESIZE      6
304 #define XDG_SURFACE_ACK_CONFIGURE       7
305 #define XDG_SURFACE_SET_WINDOW_GEOMETRY 8
306 #define XDG_SURFACE_SET_MAXIMIZED       9
307 #define XDG_SURFACE_UNSET_MAXIMIZED     10
308 #define XDG_SURFACE_SET_FULLSCREEN      11
309 #define XDG_SURFACE_UNSET_FULLSCREEN    12
310 #define XDG_SURFACE_SET_MINIMIZED       13
311
312 static inline void
313 xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data)
314 {
315         wl_proxy_set_user_data((struct wl_proxy *) xdg_surface, user_data);
316 }
317
318 static inline void *
319 xdg_surface_get_user_data(struct xdg_surface *xdg_surface)
320 {
321         return wl_proxy_get_user_data((struct wl_proxy *) xdg_surface);
322 }
323
324 static inline void
325 xdg_surface_destroy(struct xdg_surface *xdg_surface)
326 {
327         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
328                          XDG_SURFACE_DESTROY);
329
330         wl_proxy_destroy((struct wl_proxy *) xdg_surface);
331 }
332
333 static inline void
334 xdg_surface_set_parent(struct xdg_surface *xdg_surface, struct wl_surface *parent)
335 {
336         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
337                          XDG_SURFACE_SET_PARENT, parent);
338 }
339
340 static inline void
341 xdg_surface_set_title(struct xdg_surface *xdg_surface, const char *title)
342 {
343         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
344                          XDG_SURFACE_SET_TITLE, title);
345 }
346
347 static inline void
348 xdg_surface_set_app_id(struct xdg_surface *xdg_surface, const char *app_id)
349 {
350         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
351                          XDG_SURFACE_SET_APP_ID, app_id);
352 }
353
354 static inline void
355 xdg_surface_show_window_menu(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
356 {
357         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
358                          XDG_SURFACE_SHOW_WINDOW_MENU, seat, serial, x, y);
359 }
360
361 static inline void
362 xdg_surface_move(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial)
363 {
364         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
365                          XDG_SURFACE_MOVE, seat, serial);
366 }
367
368 static inline void
369 xdg_surface_resize(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial, uint32_t edges)
370 {
371         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
372                          XDG_SURFACE_RESIZE, seat, serial, edges);
373 }
374
375 static inline void
376 xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial)
377 {
378         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
379                          XDG_SURFACE_ACK_CONFIGURE, serial);
380 }
381
382 static inline void
383 xdg_surface_set_window_geometry(struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height)
384 {
385         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
386                          XDG_SURFACE_SET_WINDOW_GEOMETRY, x, y, width, height);
387 }
388
389 static inline void
390 xdg_surface_set_maximized(struct xdg_surface *xdg_surface)
391 {
392         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
393                          XDG_SURFACE_SET_MAXIMIZED);
394 }
395
396 static inline void
397 xdg_surface_unset_maximized(struct xdg_surface *xdg_surface)
398 {
399         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
400                          XDG_SURFACE_UNSET_MAXIMIZED);
401 }
402
403 static inline void
404 xdg_surface_set_fullscreen(struct xdg_surface *xdg_surface, struct wl_output *output)
405 {
406         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
407                          XDG_SURFACE_SET_FULLSCREEN, output);
408 }
409
410 static inline void
411 xdg_surface_unset_fullscreen(struct xdg_surface *xdg_surface)
412 {
413         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
414                          XDG_SURFACE_UNSET_FULLSCREEN);
415 }
416
417 static inline void
418 xdg_surface_set_minimized(struct xdg_surface *xdg_surface)
419 {
420         wl_proxy_marshal((struct wl_proxy *) xdg_surface,
421                          XDG_SURFACE_SET_MINIMIZED);
422 }
423
424 /**
425  * xdg_popup - desktop-style metadata interface
426  * @popup_done: popup interaction is done
427  *
428  * An interface that may be implemented by a wl_surface, for
429  * implementations that provide a desktop-style popups/menus. A popup
430  * surface is a transient surface with an added pointer grab.
431  *
432  * An existing implicit grab will be changed to owner-events mode, and the
433  * popup grab will continue after the implicit grab ends (i.e. releasing
434  * the mouse button does not cause the popup to be unmapped).
435  *
436  * The popup grab continues until the window is destroyed or a mouse button
437  * is pressed in any other clients window. A click in any of the clients
438  * surfaces is reported as normal, however, clicks in other clients
439  * surfaces will be discarded and trigger the callback.
440  *
441  * The x and y arguments specify the locations of the upper left corner of
442  * the surface relative to the upper left corner of the parent surface, in
443  * surface local coordinates.
444  *
445  * xdg_popup surfaces are always transient for another surface.
446  */
447 struct xdg_popup_listener {
448         /**
449          * popup_done - popup interaction is done
450          * @serial: serial of the implicit grab on the pointer
451          *
452          * The popup_done event is sent out when a popup grab is broken,
453          * that is, when the users clicks a surface that doesn't belong to
454          * the client owning the popup surface.
455          */
456         void (*popup_done)(void *data,
457                            struct xdg_popup *xdg_popup,
458                            uint32_t serial);
459 };
460
461 static inline int
462 xdg_popup_add_listener(struct xdg_popup *xdg_popup,
463                        const struct xdg_popup_listener *listener, void *data)
464 {
465         return wl_proxy_add_listener((struct wl_proxy *) xdg_popup,
466                                      (void (**)(void)) listener, data);
467 }
468
469 #define XDG_POPUP_DESTROY       0
470
471 static inline void
472 xdg_popup_set_user_data(struct xdg_popup *xdg_popup, void *user_data)
473 {
474         wl_proxy_set_user_data((struct wl_proxy *) xdg_popup, user_data);
475 }
476
477 static inline void *
478 xdg_popup_get_user_data(struct xdg_popup *xdg_popup)
479 {
480         return wl_proxy_get_user_data((struct wl_proxy *) xdg_popup);
481 }
482
483 static inline void
484 xdg_popup_destroy(struct xdg_popup *xdg_popup)
485 {
486         wl_proxy_marshal((struct wl_proxy *) xdg_popup,
487                          XDG_POPUP_DESTROY);
488
489         wl_proxy_destroy((struct wl_proxy *) xdg_popup);
490 }
491
492 #ifdef  __cplusplus
493 }
494 #endif
495
496 #endif