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