2 * Copyright © 2008-2013 Kristian Høgsberg
3 * Copyright © 2013 Rafael Antognolli
4 * Copyright © 2013 Jasper St. Pierre
5 * Copyright © 2010-2013 Intel Corporation
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
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
29 #ifndef XDG_SHELL_CLIENT_PROTOCOL_H
30 #define XDG_SHELL_CLIENT_PROTOCOL_H
38 #include "wayland-client.h"
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;
51 #ifndef XDG_SHELL_VERSION_ENUM
52 #define XDG_SHELL_VERSION_ENUM
54 * xdg_shell_version - latest protocol version
55 * @XDG_SHELL_VERSION_CURRENT: Always the latest version
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.
61 enum xdg_shell_version {
62 XDG_SHELL_VERSION_CURRENT = 4,
64 #endif /* XDG_SHELL_VERSION_ENUM */
67 * xdg_shell - create desktop-style surfaces
68 * @ping: check if the client is alive
70 * This interface is implemented by servers that provide desktop-style
73 * It allows clients to associate a xdg_surface with a basic surface.
75 struct xdg_shell_listener {
77 * ping - check if the client is alive
78 * @serial: pass this to the callback
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.
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.
89 void (*ping)(void *data,
90 struct xdg_shell *xdg_shell,
95 xdg_shell_add_listener(struct xdg_shell *xdg_shell,
96 const struct xdg_shell_listener *listener, void *data)
98 return wl_proxy_add_listener((struct wl_proxy *) xdg_shell,
99 (void (**)(void)) listener, data);
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
108 xdg_shell_set_user_data(struct xdg_shell *xdg_shell, void *user_data)
110 wl_proxy_set_user_data((struct wl_proxy *) xdg_shell, user_data);
114 xdg_shell_get_user_data(struct xdg_shell *xdg_shell)
116 return wl_proxy_get_user_data((struct wl_proxy *) xdg_shell);
120 xdg_shell_destroy(struct xdg_shell *xdg_shell)
122 wl_proxy_destroy((struct wl_proxy *) xdg_shell);
126 xdg_shell_use_unstable_version(struct xdg_shell *xdg_shell, int32_t version)
128 wl_proxy_marshal((struct wl_proxy *) xdg_shell,
129 XDG_SHELL_USE_UNSTABLE_VERSION, version);
132 static inline struct xdg_surface *
133 xdg_shell_get_xdg_surface(struct xdg_shell *xdg_shell, struct wl_surface *surface)
137 id = wl_proxy_marshal_constructor((struct wl_proxy *) xdg_shell,
138 XDG_SHELL_GET_XDG_SURFACE, &xdg_surface_interface, NULL, surface);
140 return (struct xdg_surface *) id;
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)
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);
151 return (struct xdg_popup *) id;
155 xdg_shell_pong(struct xdg_shell *xdg_shell, uint32_t serial)
157 wl_proxy_marshal((struct wl_proxy *) xdg_shell,
158 XDG_SHELL_PONG, serial);
161 #ifndef XDG_SURFACE_RESIZE_EDGE_ENUM
162 #define XDG_SURFACE_RESIZE_EDGE_ENUM
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)
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.
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,
190 #endif /* XDG_SURFACE_RESIZE_EDGE_ENUM */
192 #ifndef XDG_SURFACE_STATE_ENUM
193 #define XDG_SURFACE_STATE_ENUM
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)
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.
206 * States set in this way are double-buffered. They will get applied on the
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.
215 * The current reserved ranges are:
217 * 0x0000 - 0x0FFF: xdg-shell core values, documented below. 0x1000 -
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,
226 #endif /* XDG_SURFACE_STATE_ENUM */
229 * xdg_surface - desktop-style metadata interface
230 * @configure: suggest a surface change
231 * @close: surface wants to be closed
233 * An interface that may be implemented by a wl_surface, for
234 * implementations that provide a desktop-style user interface.
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.
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.
244 struct xdg_surface_listener {
246 * configure - suggest a surface change
252 * The configure event asks the client to resize its surface.
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.
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.
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
267 void (*configure)(void *data,
268 struct xdg_surface *xdg_surface,
271 struct wl_array *states,
274 * close - surface wants to be closed
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...
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...
285 void (*close)(void *data,
286 struct xdg_surface *xdg_surface);
290 xdg_surface_add_listener(struct xdg_surface *xdg_surface,
291 const struct xdg_surface_listener *listener, void *data)
293 return wl_proxy_add_listener((struct wl_proxy *) xdg_surface,
294 (void (**)(void)) listener, data);
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
313 xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data)
315 wl_proxy_set_user_data((struct wl_proxy *) xdg_surface, user_data);
319 xdg_surface_get_user_data(struct xdg_surface *xdg_surface)
321 return wl_proxy_get_user_data((struct wl_proxy *) xdg_surface);
325 xdg_surface_destroy(struct xdg_surface *xdg_surface)
327 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
328 XDG_SURFACE_DESTROY);
330 wl_proxy_destroy((struct wl_proxy *) xdg_surface);
334 xdg_surface_set_parent(struct xdg_surface *xdg_surface, struct wl_surface *parent)
336 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
337 XDG_SURFACE_SET_PARENT, parent);
341 xdg_surface_set_title(struct xdg_surface *xdg_surface, const char *title)
343 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
344 XDG_SURFACE_SET_TITLE, title);
348 xdg_surface_set_app_id(struct xdg_surface *xdg_surface, const char *app_id)
350 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
351 XDG_SURFACE_SET_APP_ID, app_id);
355 xdg_surface_show_window_menu(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y)
357 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
358 XDG_SURFACE_SHOW_WINDOW_MENU, seat, serial, x, y);
362 xdg_surface_move(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial)
364 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
365 XDG_SURFACE_MOVE, seat, serial);
369 xdg_surface_resize(struct xdg_surface *xdg_surface, struct wl_seat *seat, uint32_t serial, uint32_t edges)
371 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
372 XDG_SURFACE_RESIZE, seat, serial, edges);
376 xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial)
378 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
379 XDG_SURFACE_ACK_CONFIGURE, serial);
383 xdg_surface_set_window_geometry(struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height)
385 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
386 XDG_SURFACE_SET_WINDOW_GEOMETRY, x, y, width, height);
390 xdg_surface_set_maximized(struct xdg_surface *xdg_surface)
392 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
393 XDG_SURFACE_SET_MAXIMIZED);
397 xdg_surface_unset_maximized(struct xdg_surface *xdg_surface)
399 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
400 XDG_SURFACE_UNSET_MAXIMIZED);
404 xdg_surface_set_fullscreen(struct xdg_surface *xdg_surface, struct wl_output *output)
406 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
407 XDG_SURFACE_SET_FULLSCREEN, output);
411 xdg_surface_unset_fullscreen(struct xdg_surface *xdg_surface)
413 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
414 XDG_SURFACE_UNSET_FULLSCREEN);
418 xdg_surface_set_minimized(struct xdg_surface *xdg_surface)
420 wl_proxy_marshal((struct wl_proxy *) xdg_surface,
421 XDG_SURFACE_SET_MINIMIZED);
425 * xdg_popup - desktop-style metadata interface
426 * @popup_done: popup interaction is done
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.
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).
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.
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.
445 * xdg_popup surfaces are always transient for another surface.
447 struct xdg_popup_listener {
449 * popup_done - popup interaction is done
450 * @serial: serial of the implicit grab on the pointer
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.
456 void (*popup_done)(void *data,
457 struct xdg_popup *xdg_popup,
462 xdg_popup_add_listener(struct xdg_popup *xdg_popup,
463 const struct xdg_popup_listener *listener, void *data)
465 return wl_proxy_add_listener((struct wl_proxy *) xdg_popup,
466 (void (**)(void)) listener, data);
469 #define XDG_POPUP_DESTROY 0
472 xdg_popup_set_user_data(struct xdg_popup *xdg_popup, void *user_data)
474 wl_proxy_set_user_data((struct wl_proxy *) xdg_popup, user_data);
478 xdg_popup_get_user_data(struct xdg_popup *xdg_popup)
480 return wl_proxy_get_user_data((struct wl_proxy *) xdg_popup);
484 xdg_popup_destroy(struct xdg_popup *xdg_popup)
486 wl_proxy_marshal((struct wl_proxy *) xdg_popup,
489 wl_proxy_destroy((struct wl_proxy *) xdg_popup);