diff options
| author | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 13:44:13 +0300 |
|---|---|---|
| committer | Berke Güzel <wenekar1@gmail.com> | 2026-10-13 13:44:13 +0300 |
| commit | c059e3aa7f93da470f052a5cd8ee0d8dc969e679 (patch) | |
| tree | 63ffa378287ed2c606eda2e940501b9edc3d2b8b /src/platform/wayland/protocols | |
| parent | 87d0bc50d53dc216efb2b04495f090616318bc5c (diff) | |
rename and simplification
Diffstat (limited to 'src/platform/wayland/protocols')
27 files changed, 11160 insertions, 0 deletions
diff --git a/src/platform/wayland/protocols/commit-timing-v1-client-protocol.h b/src/platform/wayland/protocols/commit-timing-v1-client-protocol.h new file mode 100644 index 0000000..20dc94c --- /dev/null +++ b/src/platform/wayland/protocols/commit-timing-v1-client-protocol.h @@ -0,0 +1,294 @@ +/* Generated by wayland-scanner 1.26.0 */ + +#ifndef COMMIT_TIMING_V1_CLIENT_PROTOCOL_H +#define COMMIT_TIMING_V1_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_commit_timing_v1 The commit_timing_v1 protocol + * @section page_ifaces_commit_timing_v1 Interfaces + * - @subpage page_iface_wp_commit_timing_manager_v1 - commit timing + * - @subpage page_iface_wp_commit_timer_v1 - Surface commit timer + * @section page_copyright_commit_timing_v1 Copyright + * <pre> + * + * Copyright © 2023 Valve Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * </pre> + */ +struct wl_surface; +struct wp_commit_timer_v1; +struct wp_commit_timing_manager_v1; + +#ifndef WP_COMMIT_TIMING_MANAGER_V1_INTERFACE +#define WP_COMMIT_TIMING_MANAGER_V1_INTERFACE +/** + * @page page_iface_wp_commit_timing_manager_v1 wp_commit_timing_manager_v1 + * @section page_iface_wp_commit_timing_manager_v1_desc Description + * + * When a compositor latches on to new content updates it will check for + * any number of requirements of the available content updates (such as + * fences of all buffers being signalled) to consider the update ready. + * + * This protocol provides a method for adding a time constraint to surface + * content. This constraint indicates to the compositor that a content + * update should be presented as closely as possible to, but not before, + * a specified time. + * + * This protocol does not change the Wayland property that content + * updates are applied in the order they are received, even when some + * content updates contain timestamps and others do not. + * + * To provide timestamps, this global factory interface must be used to + * acquire a wp_commit_timing_v1 object for a surface, which may then be + * used to provide timestamp information for commits. + * + * Warning! The protocol described in this file is currently in the testing + * phase. Backward compatible changes may be added together with the + * corresponding interface version bump. Backward incompatible changes can + * only be done by creating a new major version of the extension. + * @section page_iface_wp_commit_timing_manager_v1_api API + * See @ref iface_wp_commit_timing_manager_v1. + */ +/** + * @defgroup iface_wp_commit_timing_manager_v1 The wp_commit_timing_manager_v1 interface + * + * When a compositor latches on to new content updates it will check for + * any number of requirements of the available content updates (such as + * fences of all buffers being signalled) to consider the update ready. + * + * This protocol provides a method for adding a time constraint to surface + * content. This constraint indicates to the compositor that a content + * update should be presented as closely as possible to, but not before, + * a specified time. + * + * This protocol does not change the Wayland property that content + * updates are applied in the order they are received, even when some + * content updates contain timestamps and others do not. + * + * To provide timestamps, this global factory interface must be used to + * acquire a wp_commit_timing_v1 object for a surface, which may then be + * used to provide timestamp information for commits. + * + * Warning! The protocol described in this file is currently in the testing + * phase. Backward compatible changes may be added together with the + * corresponding interface version bump. Backward incompatible changes can + * only be done by creating a new major version of the extension. + */ +extern const struct wl_interface wp_commit_timing_manager_v1_interface; +#endif +#ifndef WP_COMMIT_TIMER_V1_INTERFACE +#define WP_COMMIT_TIMER_V1_INTERFACE +/** + * @page page_iface_wp_commit_timer_v1 wp_commit_timer_v1 + * @section page_iface_wp_commit_timer_v1_desc Description + * + * An object to set a time constraint for a content update on a surface. + * @section page_iface_wp_commit_timer_v1_api API + * See @ref iface_wp_commit_timer_v1. + */ +/** + * @defgroup iface_wp_commit_timer_v1 The wp_commit_timer_v1 interface + * + * An object to set a time constraint for a content update on a surface. + */ +extern const struct wl_interface wp_commit_timer_v1_interface; +#endif + +#ifndef WP_COMMIT_TIMING_MANAGER_V1_ERROR_ENUM +#define WP_COMMIT_TIMING_MANAGER_V1_ERROR_ENUM +enum wp_commit_timing_manager_v1_error { + /** + * commit timer already exists for surface + */ + WP_COMMIT_TIMING_MANAGER_V1_ERROR_COMMIT_TIMER_EXISTS = 0, +}; +#endif /* WP_COMMIT_TIMING_MANAGER_V1_ERROR_ENUM */ + +#define WP_COMMIT_TIMING_MANAGER_V1_DESTROY 0 +#define WP_COMMIT_TIMING_MANAGER_V1_GET_TIMER 1 + + +/** + * @ingroup iface_wp_commit_timing_manager_v1 + */ +#define WP_COMMIT_TIMING_MANAGER_V1_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_wp_commit_timing_manager_v1 + */ +#define WP_COMMIT_TIMING_MANAGER_V1_GET_TIMER_SINCE_VERSION 1 + +/** @ingroup iface_wp_commit_timing_manager_v1 */ +static inline void +wp_commit_timing_manager_v1_set_user_data(struct wp_commit_timing_manager_v1 *wp_commit_timing_manager_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_commit_timing_manager_v1, user_data); +} + +/** @ingroup iface_wp_commit_timing_manager_v1 */ +static inline void * +wp_commit_timing_manager_v1_get_user_data(struct wp_commit_timing_manager_v1 *wp_commit_timing_manager_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_commit_timing_manager_v1); +} + +static inline uint32_t +wp_commit_timing_manager_v1_get_version(struct wp_commit_timing_manager_v1 *wp_commit_timing_manager_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_commit_timing_manager_v1); +} + +/** + * @ingroup iface_wp_commit_timing_manager_v1 + * + * Informs the server that the client will no longer be using + * this protocol object. Existing objects created by this object + * are not affected. + */ +static inline void +wp_commit_timing_manager_v1_destroy(struct wp_commit_timing_manager_v1 *wp_commit_timing_manager_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_commit_timing_manager_v1, + WP_COMMIT_TIMING_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_commit_timing_manager_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_wp_commit_timing_manager_v1 + * + * Establish a timing controller for a surface. + * + * Only one commit timer can be created for a surface, or a + * commit_timer_exists protocol error will be generated. + */ +static inline struct wp_commit_timer_v1 * +wp_commit_timing_manager_v1_get_timer(struct wp_commit_timing_manager_v1 *wp_commit_timing_manager_v1, struct wl_surface *surface) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) wp_commit_timing_manager_v1, + WP_COMMIT_TIMING_MANAGER_V1_GET_TIMER, &wp_commit_timer_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_commit_timing_manager_v1), 0, NULL, surface); + + return (struct wp_commit_timer_v1 *) id; +} + +#ifndef WP_COMMIT_TIMER_V1_ERROR_ENUM +#define WP_COMMIT_TIMER_V1_ERROR_ENUM +enum wp_commit_timer_v1_error { + /** + * timestamp contains an invalid value + */ + WP_COMMIT_TIMER_V1_ERROR_INVALID_TIMESTAMP = 0, + /** + * timestamp exists + */ + WP_COMMIT_TIMER_V1_ERROR_TIMESTAMP_EXISTS = 1, + /** + * the associated surface no longer exists + */ + WP_COMMIT_TIMER_V1_ERROR_SURFACE_DESTROYED = 2, +}; +#endif /* WP_COMMIT_TIMER_V1_ERROR_ENUM */ + +#define WP_COMMIT_TIMER_V1_SET_TIMESTAMP 0 +#define WP_COMMIT_TIMER_V1_DESTROY 1 + + +/** + * @ingroup iface_wp_commit_timer_v1 + */ +#define WP_COMMIT_TIMER_V1_SET_TIMESTAMP_SINCE_VERSION 1 +/** + * @ingroup iface_wp_commit_timer_v1 + */ +#define WP_COMMIT_TIMER_V1_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_wp_commit_timer_v1 */ +static inline void +wp_commit_timer_v1_set_user_data(struct wp_commit_timer_v1 *wp_commit_timer_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_commit_timer_v1, user_data); +} + +/** @ingroup iface_wp_commit_timer_v1 */ +static inline void * +wp_commit_timer_v1_get_user_data(struct wp_commit_timer_v1 *wp_commit_timer_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_commit_timer_v1); +} + +static inline uint32_t +wp_commit_timer_v1_get_version(struct wp_commit_timer_v1 *wp_commit_timer_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_commit_timer_v1); +} + +/** + * @ingroup iface_wp_commit_timer_v1 + * + * Provide a timing constraint for a surface content update. + * + * A set_timestamp request may be made before a wl_surface.commit to + * tell the compositor that the content is intended to be presented + * as closely as possible to, but not before, the specified time. + * The time is in the domain of the compositor's presentation clock. + * + * An invalid_timestamp error will be generated for invalid tv_nsec. + * + * If a timestamp already exists on the surface, a timestamp_exists + * error is generated. + * + * Requesting set_timestamp after the commit_timer object's surface is + * destroyed will generate a "surface_destroyed" error. + */ +static inline void +wp_commit_timer_v1_set_timestamp(struct wp_commit_timer_v1 *wp_commit_timer_v1, uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_commit_timer_v1, + WP_COMMIT_TIMER_V1_SET_TIMESTAMP, NULL, wl_proxy_get_version((struct wl_proxy *) wp_commit_timer_v1), 0, tv_sec_hi, tv_sec_lo, tv_nsec); +} + +/** + * @ingroup iface_wp_commit_timer_v1 + * + * Informs the server that the client will no longer be using + * this protocol object. + * + * Existing timing constraints are not affected by the destruction. + */ +static inline void +wp_commit_timer_v1_destroy(struct wp_commit_timer_v1 *wp_commit_timer_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_commit_timer_v1, + WP_COMMIT_TIMER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_commit_timer_v1), WL_MARSHAL_FLAG_DESTROY); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/commit-timing-v1-protocol.c b/src/platform/wayland/protocols/commit-timing-v1-protocol.c new file mode 100644 index 0000000..6755745 --- /dev/null +++ b/src/platform/wayland/protocols/commit-timing-v1-protocol.c @@ -0,0 +1,73 @@ +/* Generated by wayland-scanner 1.26.0 */ + +/* + * Copyright © 2023 Valve Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface wp_commit_timer_v1_interface; + +static const struct wl_interface *commit_timing_v1_types[] = { + NULL, + NULL, + NULL, + &wp_commit_timer_v1_interface, + &wl_surface_interface, +}; + +static const struct wl_message wp_commit_timing_manager_v1_requests[] = { + { "destroy", "", commit_timing_v1_types + 0 }, + { "get_timer", "no", commit_timing_v1_types + 3 }, +}; + +WL_PRIVATE const struct wl_interface wp_commit_timing_manager_v1_interface = { + "wp_commit_timing_manager_v1", 1, + 2, wp_commit_timing_manager_v1_requests, + 0, NULL, +}; + +static const struct wl_message wp_commit_timer_v1_requests[] = { + { "set_timestamp", "uuu", commit_timing_v1_types + 0 }, + { "destroy", "", commit_timing_v1_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface wp_commit_timer_v1_interface = { + "wp_commit_timer_v1", 1, + 2, wp_commit_timer_v1_requests, + 0, NULL, +}; + diff --git a/src/platform/wayland/protocols/cursor-shape-v1-client-protocol.h b/src/platform/wayland/protocols/cursor-shape-v1-client-protocol.h new file mode 100644 index 0000000..ff60edd --- /dev/null +++ b/src/platform/wayland/protocols/cursor-shape-v1-client-protocol.h @@ -0,0 +1,452 @@ +/* Generated by wayland-scanner 1.26.0 */ + +#ifndef CURSOR_SHAPE_V1_CLIENT_PROTOCOL_H +#define CURSOR_SHAPE_V1_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_cursor_shape_v1 The cursor_shape_v1 protocol + * @section page_ifaces_cursor_shape_v1 Interfaces + * - @subpage page_iface_wp_cursor_shape_manager_v1 - cursor shape manager + * - @subpage page_iface_wp_cursor_shape_device_v1 - cursor shape for a device + * @section page_copyright_cursor_shape_v1 Copyright + * <pre> + * + * Copyright 2018 The Chromium Authors + * Copyright 2023 Simon Ser + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * </pre> + */ +struct wl_pointer; +struct wp_cursor_shape_device_v1; +struct wp_cursor_shape_manager_v1; +struct zwp_tablet_tool_v2; + +#ifndef WP_CURSOR_SHAPE_MANAGER_V1_INTERFACE +#define WP_CURSOR_SHAPE_MANAGER_V1_INTERFACE +/** + * @page page_iface_wp_cursor_shape_manager_v1 wp_cursor_shape_manager_v1 + * @section page_iface_wp_cursor_shape_manager_v1_desc Description + * + * This global offers an alternative, optional way to set cursor images. This + * new way uses enumerated cursors instead of a wl_surface like + * wl_pointer.set_cursor does. + * + * Warning! The protocol described in this file is currently in the testing + * phase. Backward compatible changes may be added together with the + * corresponding interface version bump. Backward incompatible changes can + * only be done by creating a new major version of the extension. + * @section page_iface_wp_cursor_shape_manager_v1_api API + * See @ref iface_wp_cursor_shape_manager_v1. + */ +/** + * @defgroup iface_wp_cursor_shape_manager_v1 The wp_cursor_shape_manager_v1 interface + * + * This global offers an alternative, optional way to set cursor images. This + * new way uses enumerated cursors instead of a wl_surface like + * wl_pointer.set_cursor does. + * + * Warning! The protocol described in this file is currently in the testing + * phase. Backward compatible changes may be added together with the + * corresponding interface version bump. Backward incompatible changes can + * only be done by creating a new major version of the extension. + */ +extern const struct wl_interface wp_cursor_shape_manager_v1_interface; +#endif +#ifndef WP_CURSOR_SHAPE_DEVICE_V1_INTERFACE +#define WP_CURSOR_SHAPE_DEVICE_V1_INTERFACE +/** + * @page page_iface_wp_cursor_shape_device_v1 wp_cursor_shape_device_v1 + * @section page_iface_wp_cursor_shape_device_v1_desc Description + * + * This interface allows clients to set the cursor shape. + * @section page_iface_wp_cursor_shape_device_v1_api API + * See @ref iface_wp_cursor_shape_device_v1. + */ +/** + * @defgroup iface_wp_cursor_shape_device_v1 The wp_cursor_shape_device_v1 interface + * + * This interface allows clients to set the cursor shape. + */ +extern const struct wl_interface wp_cursor_shape_device_v1_interface; +#endif + +#define WP_CURSOR_SHAPE_MANAGER_V1_DESTROY 0 +#define WP_CURSOR_SHAPE_MANAGER_V1_GET_POINTER 1 +#define WP_CURSOR_SHAPE_MANAGER_V1_GET_TABLET_TOOL_V2 2 + + +/** + * @ingroup iface_wp_cursor_shape_manager_v1 + */ +#define WP_CURSOR_SHAPE_MANAGER_V1_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_wp_cursor_shape_manager_v1 + */ +#define WP_CURSOR_SHAPE_MANAGER_V1_GET_POINTER_SINCE_VERSION 1 +/** + * @ingroup iface_wp_cursor_shape_manager_v1 + */ +#define WP_CURSOR_SHAPE_MANAGER_V1_GET_TABLET_TOOL_V2_SINCE_VERSION 1 + +/** @ingroup iface_wp_cursor_shape_manager_v1 */ +static inline void +wp_cursor_shape_manager_v1_set_user_data(struct wp_cursor_shape_manager_v1 *wp_cursor_shape_manager_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_cursor_shape_manager_v1, user_data); +} + +/** @ingroup iface_wp_cursor_shape_manager_v1 */ +static inline void * +wp_cursor_shape_manager_v1_get_user_data(struct wp_cursor_shape_manager_v1 *wp_cursor_shape_manager_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_cursor_shape_manager_v1); +} + +static inline uint32_t +wp_cursor_shape_manager_v1_get_version(struct wp_cursor_shape_manager_v1 *wp_cursor_shape_manager_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_manager_v1); +} + +/** + * @ingroup iface_wp_cursor_shape_manager_v1 + * + * Destroy the cursor shape manager. + */ +static inline void +wp_cursor_shape_manager_v1_destroy(struct wp_cursor_shape_manager_v1 *wp_cursor_shape_manager_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_cursor_shape_manager_v1, + WP_CURSOR_SHAPE_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_manager_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_wp_cursor_shape_manager_v1 + * + * Obtain a wp_cursor_shape_device_v1 for a wl_pointer object. + * + * When the pointer capability is removed from the wl_seat, the + * wp_cursor_shape_device_v1 object becomes inert. + */ +static inline struct wp_cursor_shape_device_v1 * +wp_cursor_shape_manager_v1_get_pointer(struct wp_cursor_shape_manager_v1 *wp_cursor_shape_manager_v1, struct wl_pointer *pointer) +{ + struct wl_proxy *cursor_shape_device; + + cursor_shape_device = wl_proxy_marshal_flags((struct wl_proxy *) wp_cursor_shape_manager_v1, + WP_CURSOR_SHAPE_MANAGER_V1_GET_POINTER, &wp_cursor_shape_device_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_manager_v1), 0, NULL, pointer); + + return (struct wp_cursor_shape_device_v1 *) cursor_shape_device; +} + +/** + * @ingroup iface_wp_cursor_shape_manager_v1 + * + * Obtain a wp_cursor_shape_device_v1 for a zwp_tablet_tool_v2 object. + * + * When the zwp_tablet_tool_v2 is removed, the wp_cursor_shape_device_v1 + * object becomes inert. + */ +static inline struct wp_cursor_shape_device_v1 * +wp_cursor_shape_manager_v1_get_tablet_tool_v2(struct wp_cursor_shape_manager_v1 *wp_cursor_shape_manager_v1, struct zwp_tablet_tool_v2 *tablet_tool) +{ + struct wl_proxy *cursor_shape_device; + + cursor_shape_device = wl_proxy_marshal_flags((struct wl_proxy *) wp_cursor_shape_manager_v1, + WP_CURSOR_SHAPE_MANAGER_V1_GET_TABLET_TOOL_V2, &wp_cursor_shape_device_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_manager_v1), 0, NULL, tablet_tool); + + return (struct wp_cursor_shape_device_v1 *) cursor_shape_device; +} + +#ifndef WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ENUM +#define WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ENUM +/** + * @ingroup iface_wp_cursor_shape_device_v1 + * cursor shapes + * + * This enum describes cursor shapes. + * + * The names are taken from the CSS W3C specification: + * https://w3c.github.io/csswg-drafts/css-ui/#cursor + * with a few additions. + * + * Note that there are some groups of cursor shapes that are related: + * The first group is drag-and-drop cursors which are used to indicate + * the selected action during dnd operations. The second group is resize + * cursors which are used to indicate resizing and moving possibilities + * on window borders. It is recommended that the shapes in these groups + * should use visually compatible images and metaphors. + */ +enum wp_cursor_shape_device_v1_shape { + /** + * default cursor + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT = 1, + /** + * a context menu is available for the object under the cursor + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CONTEXT_MENU = 2, + /** + * help is available for the object under the cursor + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_HELP = 3, + /** + * pointer that indicates a link or another interactive element + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_POINTER = 4, + /** + * progress indicator + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_PROGRESS = 5, + /** + * program is busy, user should wait + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_WAIT = 6, + /** + * a cell or set of cells may be selected + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CELL = 7, + /** + * simple crosshair + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CROSSHAIR = 8, + /** + * text may be selected + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_TEXT = 9, + /** + * vertical text may be selected + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_VERTICAL_TEXT = 10, + /** + * drag-and-drop: alias of/shortcut to something is to be created + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALIAS = 11, + /** + * drag-and-drop: something is to be copied + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_COPY = 12, + /** + * drag-and-drop: something is to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_MOVE = 13, + /** + * drag-and-drop: the dragged item cannot be dropped at the current cursor location + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NO_DROP = 14, + /** + * drag-and-drop: the requested action will not be carried out + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NOT_ALLOWED = 15, + /** + * drag-and-drop: something can be grabbed + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_GRAB = 16, + /** + * drag-and-drop: something is being grabbed + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_GRABBING = 17, + /** + * resizing: the east border is to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_E_RESIZE = 18, + /** + * resizing: the north border is to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_N_RESIZE = 19, + /** + * resizing: the north-east corner is to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NE_RESIZE = 20, + /** + * resizing: the north-west corner is to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NW_RESIZE = 21, + /** + * resizing: the south border is to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_S_RESIZE = 22, + /** + * resizing: the south-east corner is to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_SE_RESIZE = 23, + /** + * resizing: the south-west corner is to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_SW_RESIZE = 24, + /** + * resizing: the west border is to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_W_RESIZE = 25, + /** + * resizing: the east and west borders are to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_EW_RESIZE = 26, + /** + * resizing: the north and south borders are to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NS_RESIZE = 27, + /** + * resizing: the north-east and south-west corners are to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NESW_RESIZE = 28, + /** + * resizing: the north-west and south-east corners are to be moved + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NWSE_RESIZE = 29, + /** + * resizing: that the item/column can be resized horizontally + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_COL_RESIZE = 30, + /** + * resizing: that the item/row can be resized vertically + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ROW_RESIZE = 31, + /** + * something can be scrolled in any direction + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_SCROLL = 32, + /** + * something can be zoomed in + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ZOOM_IN = 33, + /** + * something can be zoomed out + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ZOOM_OUT = 34, + /** + * drag-and-drop: the user will select which action will be carried out (non-css value) + * @since 2 + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK = 35, + /** + * resizing: something can be moved or resized in any direction (non-css value) + * @since 2 + */ + WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE = 36, +}; +/** + * @ingroup iface_wp_cursor_shape_device_v1 + */ +#define WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DND_ASK_SINCE_VERSION 2 +/** + * @ingroup iface_wp_cursor_shape_device_v1 + */ +#define WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_RESIZE_SINCE_VERSION 2 +#endif /* WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ENUM */ + +#ifndef WP_CURSOR_SHAPE_DEVICE_V1_ERROR_ENUM +#define WP_CURSOR_SHAPE_DEVICE_V1_ERROR_ENUM +enum wp_cursor_shape_device_v1_error { + /** + * the specified shape value is invalid + */ + WP_CURSOR_SHAPE_DEVICE_V1_ERROR_INVALID_SHAPE = 1, +}; +#endif /* WP_CURSOR_SHAPE_DEVICE_V1_ERROR_ENUM */ + +#define WP_CURSOR_SHAPE_DEVICE_V1_DESTROY 0 +#define WP_CURSOR_SHAPE_DEVICE_V1_SET_SHAPE 1 + + +/** + * @ingroup iface_wp_cursor_shape_device_v1 + */ +#define WP_CURSOR_SHAPE_DEVICE_V1_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_wp_cursor_shape_device_v1 + */ +#define WP_CURSOR_SHAPE_DEVICE_V1_SET_SHAPE_SINCE_VERSION 1 + +/** @ingroup iface_wp_cursor_shape_device_v1 */ +static inline void +wp_cursor_shape_device_v1_set_user_data(struct wp_cursor_shape_device_v1 *wp_cursor_shape_device_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_cursor_shape_device_v1, user_data); +} + +/** @ingroup iface_wp_cursor_shape_device_v1 */ +static inline void * +wp_cursor_shape_device_v1_get_user_data(struct wp_cursor_shape_device_v1 *wp_cursor_shape_device_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_cursor_shape_device_v1); +} + +static inline uint32_t +wp_cursor_shape_device_v1_get_version(struct wp_cursor_shape_device_v1 *wp_cursor_shape_device_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_device_v1); +} + +/** + * @ingroup iface_wp_cursor_shape_device_v1 + * + * Destroy the cursor shape device. + * + * The device cursor shape remains unchanged. + */ +static inline void +wp_cursor_shape_device_v1_destroy(struct wp_cursor_shape_device_v1 *wp_cursor_shape_device_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_cursor_shape_device_v1, + WP_CURSOR_SHAPE_DEVICE_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_device_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_wp_cursor_shape_device_v1 + * + * Sets the device cursor to the specified shape. The compositor will + * change the cursor image based on the specified shape. + * + * The cursor actually changes only if the input device focus is one of + * the requesting client's surfaces. If any, the previous cursor image + * (surface or shape) is replaced. + * + * The "shape" argument must be a valid enum entry, otherwise the + * invalid_shape protocol error is raised. + * + * This is similar to the wl_pointer.set_cursor and + * zwp_tablet_tool_v2.set_cursor requests, but this request accepts a + * shape instead of contents in the form of a surface. Clients can mix + * set_cursor and set_shape requests. + * + * The serial parameter must match the latest wl_pointer.enter or + * zwp_tablet_tool_v2.proximity_in serial number sent to the client. + * Otherwise the request will be ignored. + */ +static inline void +wp_cursor_shape_device_v1_set_shape(struct wp_cursor_shape_device_v1 *wp_cursor_shape_device_v1, uint32_t serial, uint32_t shape) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_cursor_shape_device_v1, + WP_CURSOR_SHAPE_DEVICE_V1_SET_SHAPE, NULL, wl_proxy_get_version((struct wl_proxy *) wp_cursor_shape_device_v1), 0, serial, shape); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/cursor-shape-v1-protocol.c b/src/platform/wayland/protocols/cursor-shape-v1-protocol.c new file mode 100644 index 0000000..c76190d --- /dev/null +++ b/src/platform/wayland/protocols/cursor-shape-v1-protocol.c @@ -0,0 +1,75 @@ +/* Generated by wayland-scanner 1.26.0 */ + +/* + * Copyright 2018 The Chromium Authors + * Copyright 2023 Simon Ser + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_pointer_interface; +extern const struct wl_interface wp_cursor_shape_device_v1_interface; +extern const struct wl_interface zwp_tablet_tool_v2_interface; + +static const struct wl_interface *cursor_shape_v1_types[] = { + NULL, + NULL, + &wp_cursor_shape_device_v1_interface, + &wl_pointer_interface, + &wp_cursor_shape_device_v1_interface, + &zwp_tablet_tool_v2_interface, +}; + +static const struct wl_message wp_cursor_shape_manager_v1_requests[] = { + { "destroy", "", cursor_shape_v1_types + 0 }, + { "get_pointer", "no", cursor_shape_v1_types + 2 }, + { "get_tablet_tool_v2", "no", cursor_shape_v1_types + 4 }, +}; + +WL_PRIVATE const struct wl_interface wp_cursor_shape_manager_v1_interface = { + "wp_cursor_shape_manager_v1", 2, + 3, wp_cursor_shape_manager_v1_requests, + 0, NULL, +}; + +static const struct wl_message wp_cursor_shape_device_v1_requests[] = { + { "destroy", "", cursor_shape_v1_types + 0 }, + { "set_shape", "uu", cursor_shape_v1_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface wp_cursor_shape_device_v1_interface = { + "wp_cursor_shape_device_v1", 2, + 2, wp_cursor_shape_device_v1_requests, + 0, NULL, +}; + diff --git a/src/platform/wayland/protocols/fifo-v1-client-protocol.h b/src/platform/wayland/protocols/fifo-v1-client-protocol.h new file mode 100644 index 0000000..8c2eeec --- /dev/null +++ b/src/platform/wayland/protocols/fifo-v1-client-protocol.h @@ -0,0 +1,323 @@ +/* Generated by wayland-scanner 1.26.0 */ + +#ifndef FIFO_V1_CLIENT_PROTOCOL_H +#define FIFO_V1_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_fifo_v1 The fifo_v1 protocol + * @section page_ifaces_fifo_v1 Interfaces + * - @subpage page_iface_wp_fifo_manager_v1 - protocol for fifo constraints + * - @subpage page_iface_wp_fifo_v1 - fifo interface + * @section page_copyright_fifo_v1 Copyright + * <pre> + * + * Copyright © 2023 Valve Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * </pre> + */ +struct wl_surface; +struct wp_fifo_manager_v1; +struct wp_fifo_v1; + +#ifndef WP_FIFO_MANAGER_V1_INTERFACE +#define WP_FIFO_MANAGER_V1_INTERFACE +/** + * @page page_iface_wp_fifo_manager_v1 wp_fifo_manager_v1 + * @section page_iface_wp_fifo_manager_v1_desc Description + * + * When a Wayland compositor considers applying a content update, + * it must ensure all the update's readiness constraints (fences, etc) + * are met. + * + * This protocol provides a way to use the completion of a display refresh + * cycle as an additional readiness constraint. + * + * Warning! The protocol described in this file is currently in the testing + * phase. Backward compatible changes may be added together with the + * corresponding interface version bump. Backward incompatible changes can + * only be done by creating a new major version of the extension. + * @section page_iface_wp_fifo_manager_v1_api API + * See @ref iface_wp_fifo_manager_v1. + */ +/** + * @defgroup iface_wp_fifo_manager_v1 The wp_fifo_manager_v1 interface + * + * When a Wayland compositor considers applying a content update, + * it must ensure all the update's readiness constraints (fences, etc) + * are met. + * + * This protocol provides a way to use the completion of a display refresh + * cycle as an additional readiness constraint. + * + * Warning! The protocol described in this file is currently in the testing + * phase. Backward compatible changes may be added together with the + * corresponding interface version bump. Backward incompatible changes can + * only be done by creating a new major version of the extension. + */ +extern const struct wl_interface wp_fifo_manager_v1_interface; +#endif +#ifndef WP_FIFO_V1_INTERFACE +#define WP_FIFO_V1_INTERFACE +/** + * @page page_iface_wp_fifo_v1 wp_fifo_v1 + * @section page_iface_wp_fifo_v1_desc Description + * + * A fifo object for a surface that may be used to add + * display refresh constraints to content updates. + * @section page_iface_wp_fifo_v1_api API + * See @ref iface_wp_fifo_v1. + */ +/** + * @defgroup iface_wp_fifo_v1 The wp_fifo_v1 interface + * + * A fifo object for a surface that may be used to add + * display refresh constraints to content updates. + */ +extern const struct wl_interface wp_fifo_v1_interface; +#endif + +#ifndef WP_FIFO_MANAGER_V1_ERROR_ENUM +#define WP_FIFO_MANAGER_V1_ERROR_ENUM +/** + * @ingroup iface_wp_fifo_manager_v1 + * fatal presentation error + * + * These fatal protocol errors may be emitted in response to + * illegal requests. + */ +enum wp_fifo_manager_v1_error { + /** + * fifo manager already exists for surface + */ + WP_FIFO_MANAGER_V1_ERROR_ALREADY_EXISTS = 0, +}; +#endif /* WP_FIFO_MANAGER_V1_ERROR_ENUM */ + +#define WP_FIFO_MANAGER_V1_DESTROY 0 +#define WP_FIFO_MANAGER_V1_GET_FIFO 1 + + +/** + * @ingroup iface_wp_fifo_manager_v1 + */ +#define WP_FIFO_MANAGER_V1_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_wp_fifo_manager_v1 + */ +#define WP_FIFO_MANAGER_V1_GET_FIFO_SINCE_VERSION 1 + +/** @ingroup iface_wp_fifo_manager_v1 */ +static inline void +wp_fifo_manager_v1_set_user_data(struct wp_fifo_manager_v1 *wp_fifo_manager_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_fifo_manager_v1, user_data); +} + +/** @ingroup iface_wp_fifo_manager_v1 */ +static inline void * +wp_fifo_manager_v1_get_user_data(struct wp_fifo_manager_v1 *wp_fifo_manager_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_fifo_manager_v1); +} + +static inline uint32_t +wp_fifo_manager_v1_get_version(struct wp_fifo_manager_v1 *wp_fifo_manager_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_fifo_manager_v1); +} + +/** + * @ingroup iface_wp_fifo_manager_v1 + * + * Informs the server that the client will no longer be using + * this protocol object. Existing objects created by this object + * are not affected. + */ +static inline void +wp_fifo_manager_v1_destroy(struct wp_fifo_manager_v1 *wp_fifo_manager_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_fifo_manager_v1, + WP_FIFO_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_fifo_manager_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_wp_fifo_manager_v1 + * + * Establish a fifo object for a surface that may be used to add + * display refresh constraints to content updates. + * + * Only one such object may exist for a surface and attempting + * to create more than one will result in an already_exists + * protocol error. If a surface is acted on by multiple software + * components, general best practice is that only the component + * performing wl_surface.attach operations should use this protocol. + */ +static inline struct wp_fifo_v1 * +wp_fifo_manager_v1_get_fifo(struct wp_fifo_manager_v1 *wp_fifo_manager_v1, struct wl_surface *surface) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) wp_fifo_manager_v1, + WP_FIFO_MANAGER_V1_GET_FIFO, &wp_fifo_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_fifo_manager_v1), 0, NULL, surface); + + return (struct wp_fifo_v1 *) id; +} + +#ifndef WP_FIFO_V1_ERROR_ENUM +#define WP_FIFO_V1_ERROR_ENUM +/** + * @ingroup iface_wp_fifo_v1 + * fatal error + * + * These fatal protocol errors may be emitted in response to + * illegal requests. + */ +enum wp_fifo_v1_error { + /** + * the associated surface no longer exists + */ + WP_FIFO_V1_ERROR_SURFACE_DESTROYED = 0, +}; +#endif /* WP_FIFO_V1_ERROR_ENUM */ + +#define WP_FIFO_V1_SET_BARRIER 0 +#define WP_FIFO_V1_WAIT_BARRIER 1 +#define WP_FIFO_V1_DESTROY 2 + + +/** + * @ingroup iface_wp_fifo_v1 + */ +#define WP_FIFO_V1_SET_BARRIER_SINCE_VERSION 1 +/** + * @ingroup iface_wp_fifo_v1 + */ +#define WP_FIFO_V1_WAIT_BARRIER_SINCE_VERSION 1 +/** + * @ingroup iface_wp_fifo_v1 + */ +#define WP_FIFO_V1_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_wp_fifo_v1 */ +static inline void +wp_fifo_v1_set_user_data(struct wp_fifo_v1 *wp_fifo_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_fifo_v1, user_data); +} + +/** @ingroup iface_wp_fifo_v1 */ +static inline void * +wp_fifo_v1_get_user_data(struct wp_fifo_v1 *wp_fifo_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_fifo_v1); +} + +static inline uint32_t +wp_fifo_v1_get_version(struct wp_fifo_v1 *wp_fifo_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_fifo_v1); +} + +/** + * @ingroup iface_wp_fifo_v1 + * + * When the content update containing the "set_barrier" is applied, + * it sets a "fifo_barrier" condition on the surface associated with + * the fifo object. The condition is cleared immediately after the + * following latching deadline for non-tearing presentation. + * + * The compositor may clear the condition early if it must do so to + * ensure client forward progress assumptions. + * + * To wait for this condition to clear, use the "wait_barrier" request. + * + * "set_barrier" is double-buffered state, see wl_surface.commit. + * + * Requesting set_barrier after the fifo object's surface is + * destroyed will generate a "surface_destroyed" error. + */ +static inline void +wp_fifo_v1_set_barrier(struct wp_fifo_v1 *wp_fifo_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_fifo_v1, + WP_FIFO_V1_SET_BARRIER, NULL, wl_proxy_get_version((struct wl_proxy *) wp_fifo_v1), 0); +} + +/** + * @ingroup iface_wp_fifo_v1 + * + * Indicate that this content update is not ready while a + * "fifo_barrier" condition is present on the surface. + * + * This means that when the content update containing "set_barrier" + * was made active at a latching deadline, it will be active for + * at least one refresh cycle. A content update which is allowed to + * tear might become active after a latching deadline if no content + * update became active at the deadline. + * + * The constraint must be ignored if the surface is a subsurface in + * synchronized mode. If the surface is not being updated by the + * compositor (off-screen, occluded) the compositor may ignore the + * constraint. Clients must use an additional mechanism such as + * frame callbacks or timestamps to ensure throttling occurs under + * all conditions. + * + * "wait_barrier" is double-buffered state, see wl_surface.commit. + * + * Requesting "wait_barrier" after the fifo object's surface is + * destroyed will generate a "surface_destroyed" error. + */ +static inline void +wp_fifo_v1_wait_barrier(struct wp_fifo_v1 *wp_fifo_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_fifo_v1, + WP_FIFO_V1_WAIT_BARRIER, NULL, wl_proxy_get_version((struct wl_proxy *) wp_fifo_v1), 0); +} + +/** + * @ingroup iface_wp_fifo_v1 + * + * Informs the server that the client will no longer be using + * this protocol object. + * + * Surface state changes previously made by this protocol are + * unaffected by this object's destruction. + */ +static inline void +wp_fifo_v1_destroy(struct wp_fifo_v1 *wp_fifo_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_fifo_v1, + WP_FIFO_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_fifo_v1), WL_MARSHAL_FLAG_DESTROY); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/fifo-v1-protocol.c b/src/platform/wayland/protocols/fifo-v1-protocol.c new file mode 100644 index 0000000..5c31da3 --- /dev/null +++ b/src/platform/wayland/protocols/fifo-v1-protocol.c @@ -0,0 +1,71 @@ +/* Generated by wayland-scanner 1.26.0 */ + +/* + * Copyright © 2023 Valve Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface wp_fifo_v1_interface; + +static const struct wl_interface *fifo_v1_types[] = { + &wp_fifo_v1_interface, + &wl_surface_interface, +}; + +static const struct wl_message wp_fifo_manager_v1_requests[] = { + { "destroy", "", fifo_v1_types + 0 }, + { "get_fifo", "no", fifo_v1_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface wp_fifo_manager_v1_interface = { + "wp_fifo_manager_v1", 1, + 2, wp_fifo_manager_v1_requests, + 0, NULL, +}; + +static const struct wl_message wp_fifo_v1_requests[] = { + { "set_barrier", "", fifo_v1_types + 0 }, + { "wait_barrier", "", fifo_v1_types + 0 }, + { "destroy", "", fifo_v1_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface wp_fifo_v1_interface = { + "wp_fifo_v1", 1, + 3, wp_fifo_v1_requests, + 0, NULL, +}; + diff --git a/src/platform/wayland/protocols/fractional-scale-v1-client-protocol.h b/src/platform/wayland/protocols/fractional-scale-v1-client-protocol.h new file mode 100644 index 0000000..65adbd0 --- /dev/null +++ b/src/platform/wayland/protocols/fractional-scale-v1-client-protocol.h @@ -0,0 +1,264 @@ +/* Generated by wayland-scanner 1.26.0 */ + +#ifndef FRACTIONAL_SCALE_V1_CLIENT_PROTOCOL_H +#define FRACTIONAL_SCALE_V1_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_fractional_scale_v1 The fractional_scale_v1 protocol + * Protocol for requesting fractional surface scales + * + * @section page_desc_fractional_scale_v1 Description + * + * This protocol allows a compositor to suggest for surfaces to render at + * fractional scales. + * + * A client can submit scaled content by utilizing wp_viewport. This is done by + * creating a wp_viewport object for the surface and setting the destination + * rectangle to the surface size before the scale factor is applied. + * + * The buffer size is calculated by multiplying the surface size by the + * intended scale. + * + * The wl_surface buffer scale should remain set to 1. + * + * If a surface has a surface-local size of 100 px by 50 px and wishes to + * submit buffers with a scale of 1.5, then a buffer of 150px by 75 px should + * be used and the wp_viewport destination rectangle should be 100 px by 50 px. + * + * For toplevel surfaces, the size is rounded halfway away from zero. The + * rounding algorithm for subsurface position and size is not defined. + * + * @section page_ifaces_fractional_scale_v1 Interfaces + * - @subpage page_iface_wp_fractional_scale_manager_v1 - fractional surface scale information + * - @subpage page_iface_wp_fractional_scale_v1 - fractional scale interface to a wl_surface + * @section page_copyright_fractional_scale_v1 Copyright + * <pre> + * + * Copyright © 2022 Kenny Levinsen + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * </pre> + */ +struct wl_surface; +struct wp_fractional_scale_manager_v1; +struct wp_fractional_scale_v1; + +#ifndef WP_FRACTIONAL_SCALE_MANAGER_V1_INTERFACE +#define WP_FRACTIONAL_SCALE_MANAGER_V1_INTERFACE +/** + * @page page_iface_wp_fractional_scale_manager_v1 wp_fractional_scale_manager_v1 + * @section page_iface_wp_fractional_scale_manager_v1_desc Description + * + * A global interface for requesting surfaces to use fractional scales. + * @section page_iface_wp_fractional_scale_manager_v1_api API + * See @ref iface_wp_fractional_scale_manager_v1. + */ +/** + * @defgroup iface_wp_fractional_scale_manager_v1 The wp_fractional_scale_manager_v1 interface + * + * A global interface for requesting surfaces to use fractional scales. + */ +extern const struct wl_interface wp_fractional_scale_manager_v1_interface; +#endif +#ifndef WP_FRACTIONAL_SCALE_V1_INTERFACE +#define WP_FRACTIONAL_SCALE_V1_INTERFACE +/** + * @page page_iface_wp_fractional_scale_v1 wp_fractional_scale_v1 + * @section page_iface_wp_fractional_scale_v1_desc Description + * + * An additional interface to a wl_surface object which allows the compositor + * to inform the client of the preferred scale. + * @section page_iface_wp_fractional_scale_v1_api API + * See @ref iface_wp_fractional_scale_v1. + */ +/** + * @defgroup iface_wp_fractional_scale_v1 The wp_fractional_scale_v1 interface + * + * An additional interface to a wl_surface object which allows the compositor + * to inform the client of the preferred scale. + */ +extern const struct wl_interface wp_fractional_scale_v1_interface; +#endif + +#ifndef WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_ENUM +#define WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_ENUM +enum wp_fractional_scale_manager_v1_error { + /** + * the surface already has a fractional_scale object associated + */ + WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_FRACTIONAL_SCALE_EXISTS = 0, +}; +#endif /* WP_FRACTIONAL_SCALE_MANAGER_V1_ERROR_ENUM */ + +#define WP_FRACTIONAL_SCALE_MANAGER_V1_DESTROY 0 +#define WP_FRACTIONAL_SCALE_MANAGER_V1_GET_FRACTIONAL_SCALE 1 + + +/** + * @ingroup iface_wp_fractional_scale_manager_v1 + */ +#define WP_FRACTIONAL_SCALE_MANAGER_V1_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_wp_fractional_scale_manager_v1 + */ +#define WP_FRACTIONAL_SCALE_MANAGER_V1_GET_FRACTIONAL_SCALE_SINCE_VERSION 1 + +/** @ingroup iface_wp_fractional_scale_manager_v1 */ +static inline void +wp_fractional_scale_manager_v1_set_user_data(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_fractional_scale_manager_v1, user_data); +} + +/** @ingroup iface_wp_fractional_scale_manager_v1 */ +static inline void * +wp_fractional_scale_manager_v1_get_user_data(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_fractional_scale_manager_v1); +} + +static inline uint32_t +wp_fractional_scale_manager_v1_get_version(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_fractional_scale_manager_v1); +} + +/** + * @ingroup iface_wp_fractional_scale_manager_v1 + * + * Informs the server that the client will not be using this protocol + * object anymore. This does not affect any other objects, + * wp_fractional_scale_v1 objects included. + */ +static inline void +wp_fractional_scale_manager_v1_destroy(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_fractional_scale_manager_v1, + WP_FRACTIONAL_SCALE_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_fractional_scale_manager_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_wp_fractional_scale_manager_v1 + * + * Create an add-on object for the the wl_surface to let the compositor + * request fractional scales. If the given wl_surface already has a + * wp_fractional_scale_v1 object associated, the fractional_scale_exists + * protocol error is raised. + */ +static inline struct wp_fractional_scale_v1 * +wp_fractional_scale_manager_v1_get_fractional_scale(struct wp_fractional_scale_manager_v1 *wp_fractional_scale_manager_v1, struct wl_surface *surface) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) wp_fractional_scale_manager_v1, + WP_FRACTIONAL_SCALE_MANAGER_V1_GET_FRACTIONAL_SCALE, &wp_fractional_scale_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_fractional_scale_manager_v1), 0, NULL, surface); + + return (struct wp_fractional_scale_v1 *) id; +} + +/** + * @ingroup iface_wp_fractional_scale_v1 + * @struct wp_fractional_scale_v1_listener + */ +struct wp_fractional_scale_v1_listener { + /** + * notify of new preferred scale + * + * Notification of a new preferred scale for this surface that + * the compositor suggests that the client should use. + * + * The sent scale is the numerator of a fraction with a denominator + * of 120. + * @param scale the new preferred scale + */ + void (*preferred_scale)(void *data, + struct wp_fractional_scale_v1 *wp_fractional_scale_v1, + uint32_t scale); +}; + +/** + * @ingroup iface_wp_fractional_scale_v1 + */ +static inline int +wp_fractional_scale_v1_add_listener(struct wp_fractional_scale_v1 *wp_fractional_scale_v1, + const struct wp_fractional_scale_v1_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) wp_fractional_scale_v1, + (void (**)(void)) listener, data); +} + +#define WP_FRACTIONAL_SCALE_V1_DESTROY 0 + +/** + * @ingroup iface_wp_fractional_scale_v1 + */ +#define WP_FRACTIONAL_SCALE_V1_PREFERRED_SCALE_SINCE_VERSION 1 + +/** + * @ingroup iface_wp_fractional_scale_v1 + */ +#define WP_FRACTIONAL_SCALE_V1_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_wp_fractional_scale_v1 */ +static inline void +wp_fractional_scale_v1_set_user_data(struct wp_fractional_scale_v1 *wp_fractional_scale_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_fractional_scale_v1, user_data); +} + +/** @ingroup iface_wp_fractional_scale_v1 */ +static inline void * +wp_fractional_scale_v1_get_user_data(struct wp_fractional_scale_v1 *wp_fractional_scale_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_fractional_scale_v1); +} + +static inline uint32_t +wp_fractional_scale_v1_get_version(struct wp_fractional_scale_v1 *wp_fractional_scale_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_fractional_scale_v1); +} + +/** + * @ingroup iface_wp_fractional_scale_v1 + * + * Destroy the fractional scale object. When this object is destroyed, + * preferred_scale events will no longer be sent. + */ +static inline void +wp_fractional_scale_v1_destroy(struct wp_fractional_scale_v1 *wp_fractional_scale_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_fractional_scale_v1, + WP_FRACTIONAL_SCALE_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_fractional_scale_v1), WL_MARSHAL_FLAG_DESTROY); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/fractional-scale-v1-protocol.c b/src/platform/wayland/protocols/fractional-scale-v1-protocol.c new file mode 100644 index 0000000..b8c1a63 --- /dev/null +++ b/src/platform/wayland/protocols/fractional-scale-v1-protocol.c @@ -0,0 +1,74 @@ +/* Generated by wayland-scanner 1.26.0 */ + +/* + * Copyright © 2022 Kenny Levinsen + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface wp_fractional_scale_v1_interface; + +static const struct wl_interface *fractional_scale_v1_types[] = { + NULL, + &wp_fractional_scale_v1_interface, + &wl_surface_interface, +}; + +static const struct wl_message wp_fractional_scale_manager_v1_requests[] = { + { "destroy", "", fractional_scale_v1_types + 0 }, + { "get_fractional_scale", "no", fractional_scale_v1_types + 1 }, +}; + +WL_PRIVATE const struct wl_interface wp_fractional_scale_manager_v1_interface = { + "wp_fractional_scale_manager_v1", 1, + 2, wp_fractional_scale_manager_v1_requests, + 0, NULL, +}; + +static const struct wl_message wp_fractional_scale_v1_requests[] = { + { "destroy", "", fractional_scale_v1_types + 0 }, +}; + +static const struct wl_message wp_fractional_scale_v1_events[] = { + { "preferred_scale", "u", fractional_scale_v1_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface wp_fractional_scale_v1_interface = { + "wp_fractional_scale_v1", 1, + 1, wp_fractional_scale_v1_requests, + 1, wp_fractional_scale_v1_events, +}; + diff --git a/src/platform/wayland/protocols/meson.build b/src/platform/wayland/protocols/meson.build new file mode 100644 index 0000000..6e20a6c --- /dev/null +++ b/src/platform/wayland/protocols/meson.build @@ -0,0 +1,15 @@ +wl_protocol_src = files( + 'xdg-shell-protocol.c', + 'xdg-decoration-protocol.c', + 'cursor-shape-v1-protocol.c', + 'fractional-scale-v1-protocol.c', + 'viewporter-protocol.c', + 'tablet-v2-protocol.c', + 'text-input-unstable-v3-protocol.c', + 'tearing-control-v1-protocol.c', + 'presentation-time-protocol.c', + 'xdg-toplevel-drag-v1-protocol.c', + 'fifo-v1-protocol.c', + 'commit-timing-v1-protocol.c', + 'primary-selection-unstable-v1-protocol.c', +) diff --git a/src/platform/wayland/protocols/presentation-time-client-protocol.h b/src/platform/wayland/protocols/presentation-time-client-protocol.h new file mode 100644 index 0000000..720027d --- /dev/null +++ b/src/platform/wayland/protocols/presentation-time-client-protocol.h @@ -0,0 +1,498 @@ +/* Generated by wayland-scanner 1.26.0 */ + +#ifndef PRESENTATION_TIME_CLIENT_PROTOCOL_H +#define PRESENTATION_TIME_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_presentation_time The presentation_time protocol + * @section page_ifaces_presentation_time Interfaces + * - @subpage page_iface_wp_presentation - timed presentation related wl_surface requests + * - @subpage page_iface_wp_presentation_feedback - presentation time feedback event + * @section page_copyright_presentation_time Copyright + * <pre> + * + * Copyright © 2013-2014 Collabora, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * </pre> + */ +struct wl_output; +struct wl_surface; +struct wp_presentation; +struct wp_presentation_feedback; + +#ifndef WP_PRESENTATION_INTERFACE +#define WP_PRESENTATION_INTERFACE +/** + * @page page_iface_wp_presentation wp_presentation + * @section page_iface_wp_presentation_desc Description + * + * + * + * + * The main feature of this interface is accurate presentation + * timing feedback to ensure smooth video playback while maintaining + * audio/video synchronization. Some features use the concept of a + * presentation clock, which is defined in the + * presentation.clock_id event. + * + * A content update for a wl_surface is submitted by a + * wl_surface.commit request. Request 'feedback' associates with + * the wl_surface.commit and provides feedback on the content + * update, particularly the final realized presentation time. + * + * + * + * When the final realized presentation time is available, e.g. + * after a framebuffer flip completes, the requested + * presentation_feedback.presented events are sent. The final + * presentation time can differ from the compositor's predicted + * display update time and the update's target time, especially + * when the compositor misses its target vertical blanking period. + * @section page_iface_wp_presentation_api API + * See @ref iface_wp_presentation. + */ +/** + * @defgroup iface_wp_presentation The wp_presentation interface + * + * + * + * + * The main feature of this interface is accurate presentation + * timing feedback to ensure smooth video playback while maintaining + * audio/video synchronization. Some features use the concept of a + * presentation clock, which is defined in the + * presentation.clock_id event. + * + * A content update for a wl_surface is submitted by a + * wl_surface.commit request. Request 'feedback' associates with + * the wl_surface.commit and provides feedback on the content + * update, particularly the final realized presentation time. + * + * + * + * When the final realized presentation time is available, e.g. + * after a framebuffer flip completes, the requested + * presentation_feedback.presented events are sent. The final + * presentation time can differ from the compositor's predicted + * display update time and the update's target time, especially + * when the compositor misses its target vertical blanking period. + */ +extern const struct wl_interface wp_presentation_interface; +#endif +#ifndef WP_PRESENTATION_FEEDBACK_INTERFACE +#define WP_PRESENTATION_FEEDBACK_INTERFACE +/** + * @page page_iface_wp_presentation_feedback wp_presentation_feedback + * @section page_iface_wp_presentation_feedback_desc Description + * + * A presentation_feedback object returns an indication that a + * wl_surface content update has become visible to the user. + * One object corresponds to one content update submission + * (wl_surface.commit). There are two possible outcomes: the + * content update is presented to the user, and a presentation + * timestamp delivered; or, the user did not see the content + * update because it was superseded or its surface destroyed, + * and the content update is discarded. + * + * Once a presentation_feedback object has delivered a 'presented' + * or 'discarded' event it is automatically destroyed. + * @section page_iface_wp_presentation_feedback_api API + * See @ref iface_wp_presentation_feedback. + */ +/** + * @defgroup iface_wp_presentation_feedback The wp_presentation_feedback interface + * + * A presentation_feedback object returns an indication that a + * wl_surface content update has become visible to the user. + * One object corresponds to one content update submission + * (wl_surface.commit). There are two possible outcomes: the + * content update is presented to the user, and a presentation + * timestamp delivered; or, the user did not see the content + * update because it was superseded or its surface destroyed, + * and the content update is discarded. + * + * Once a presentation_feedback object has delivered a 'presented' + * or 'discarded' event it is automatically destroyed. + */ +extern const struct wl_interface wp_presentation_feedback_interface; +#endif + +#ifndef WP_PRESENTATION_ERROR_ENUM +#define WP_PRESENTATION_ERROR_ENUM +/** + * @ingroup iface_wp_presentation + * fatal presentation errors + * + * These fatal protocol errors may be emitted in response to + * illegal presentation requests. + */ +enum wp_presentation_error { + /** + * invalid value in tv_nsec + */ + WP_PRESENTATION_ERROR_INVALID_TIMESTAMP = 0, + /** + * invalid flag + */ + WP_PRESENTATION_ERROR_INVALID_FLAG = 1, +}; +#endif /* WP_PRESENTATION_ERROR_ENUM */ + +/** + * @ingroup iface_wp_presentation + * @struct wp_presentation_listener + */ +struct wp_presentation_listener { + /** + * clock ID for timestamps + * + * This event tells the client in which clock domain the + * compositor interprets the timestamps used by the presentation + * extension. This clock is called the presentation clock. + * + * The compositor sends this event when the client binds to the + * presentation interface. The presentation clock does not change + * during the lifetime of the client connection. + * + * The clock identifier is platform dependent. On POSIX platforms, + * the identifier value is one of the clockid_t values accepted by + * clock_gettime(). clock_gettime() is defined by POSIX.1-2001. + * + * Timestamps in this clock domain are expressed as tv_sec_hi, + * tv_sec_lo, tv_nsec triples, each component being an unsigned + * 32-bit value. Whole seconds are in tv_sec which is a 64-bit + * value combined from tv_sec_hi and tv_sec_lo, and the additional + * fractional part in tv_nsec as nanoseconds. Hence, for valid + * timestamps tv_nsec must be in [0, 999999999]. + * + * Note that clock_id applies only to the presentation clock, and + * implies nothing about e.g. the timestamps used in the Wayland + * core protocol input events. + * + * Compositors should prefer a clock which does not jump and is not + * slewed e.g. by NTP. The absolute value of the clock is + * irrelevant. Precision of one millisecond or better is + * recommended. Clients must be able to query the current clock + * value directly, not by asking the compositor. + * @param clk_id platform clock identifier + */ + void (*clock_id)(void *data, + struct wp_presentation *wp_presentation, + uint32_t clk_id); +}; + +/** + * @ingroup iface_wp_presentation + */ +static inline int +wp_presentation_add_listener(struct wp_presentation *wp_presentation, + const struct wp_presentation_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) wp_presentation, + (void (**)(void)) listener, data); +} + +#define WP_PRESENTATION_DESTROY 0 +#define WP_PRESENTATION_FEEDBACK 1 + +/** + * @ingroup iface_wp_presentation + */ +#define WP_PRESENTATION_CLOCK_ID_SINCE_VERSION 1 + +/** + * @ingroup iface_wp_presentation + */ +#define WP_PRESENTATION_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_wp_presentation + */ +#define WP_PRESENTATION_FEEDBACK_SINCE_VERSION 1 + +/** @ingroup iface_wp_presentation */ +static inline void +wp_presentation_set_user_data(struct wp_presentation *wp_presentation, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_presentation, user_data); +} + +/** @ingroup iface_wp_presentation */ +static inline void * +wp_presentation_get_user_data(struct wp_presentation *wp_presentation) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_presentation); +} + +static inline uint32_t +wp_presentation_get_version(struct wp_presentation *wp_presentation) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_presentation); +} + +/** + * @ingroup iface_wp_presentation + * + * Informs the server that the client will no longer be using + * this protocol object. Existing objects created by this object + * are not affected. + */ +static inline void +wp_presentation_destroy(struct wp_presentation *wp_presentation) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_presentation, + WP_PRESENTATION_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_presentation), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_wp_presentation + * + * Request presentation feedback for the current content submission + * on the given surface. This creates a new presentation_feedback + * object, which will deliver the feedback information once. If + * multiple presentation_feedback objects are created for the same + * submission, they will all deliver the same information. + * + * For details on what information is returned, see the + * presentation_feedback interface. + */ +static inline struct wp_presentation_feedback * +wp_presentation_feedback(struct wp_presentation *wp_presentation, struct wl_surface *surface) +{ + struct wl_proxy *callback; + + callback = wl_proxy_marshal_flags((struct wl_proxy *) wp_presentation, + WP_PRESENTATION_FEEDBACK, &wp_presentation_feedback_interface, wl_proxy_get_version((struct wl_proxy *) wp_presentation), 0, surface, NULL); + + return (struct wp_presentation_feedback *) callback; +} + +#ifndef WP_PRESENTATION_FEEDBACK_KIND_ENUM +#define WP_PRESENTATION_FEEDBACK_KIND_ENUM +/** + * @ingroup iface_wp_presentation_feedback + * bitmask of flags in presented event + * + * These flags provide information about how the presentation of + * the related content update was done. The intent is to help + * clients assess the reliability of the feedback and the visual + * quality with respect to possible tearing and timings. + */ +enum wp_presentation_feedback_kind { + /** + * presentation was vsync'd + * + * The presentation was synchronized to the "vertical retrace" by + * the display hardware such that tearing does not happen. Relying + * on software scheduling is not acceptable for this flag. If + * presentation is done by a copy to the active frontbuffer, then + * it must guarantee that tearing cannot happen. + */ + WP_PRESENTATION_FEEDBACK_KIND_VSYNC = 0x1, + /** + * hardware provided the presentation timestamp + * + * The display hardware provided measurements that the hardware + * driver converted into a presentation timestamp. Sampling a clock + * in software is not acceptable for this flag. + */ + WP_PRESENTATION_FEEDBACK_KIND_HW_CLOCK = 0x2, + /** + * hardware signalled the start of the presentation + * + * The display hardware signalled that it started using the new + * image content. The opposite of this is e.g. a timer being used + * to guess when the display hardware has switched to the new image + * content. + */ + WP_PRESENTATION_FEEDBACK_KIND_HW_COMPLETION = 0x4, + /** + * presentation was done zero-copy + * + * The presentation of this update was done zero-copy. This means + * the buffer from the client was given to display hardware as is, + * without copying it. Compositing with OpenGL counts as copying, + * even if textured directly from the client buffer. Possible + * zero-copy cases include direct scanout of a fullscreen surface + * and a surface on a hardware overlay. + */ + WP_PRESENTATION_FEEDBACK_KIND_ZERO_COPY = 0x8, +}; +#endif /* WP_PRESENTATION_FEEDBACK_KIND_ENUM */ + +/** + * @ingroup iface_wp_presentation_feedback + * @struct wp_presentation_feedback_listener + */ +struct wp_presentation_feedback_listener { + /** + * presentation synchronized to this output + * + * As presentation can be synchronized to only one output at a + * time, this event tells which output it was. This event is only + * sent prior to the presented event. + * + * As clients may bind to the same global wl_output multiple times, + * this event is sent for each bound instance that matches the + * synchronized output. If a client has not bound to the right + * wl_output global at all, this event is not sent. + * @param output presentation output + */ + void (*sync_output)(void *data, + struct wp_presentation_feedback *wp_presentation_feedback, + struct wl_output *output); + /** + * the content update was displayed + * + * The associated content update was displayed to the user at the + * indicated time (tv_sec_hi/lo, tv_nsec). For the interpretation + * of the timestamp, see presentation.clock_id event. + * + * The timestamp corresponds to the time when the content update + * turned into light the first time on the surface's main output. + * Compositors may approximate this from the framebuffer flip + * completion events from the system, and the latency of the + * physical display path if known. + * + * This event is preceded by all related sync_output events telling + * which output's refresh cycle the feedback corresponds to, i.e. + * the main output for the surface. Compositors are recommended to + * choose the output containing the largest part of the wl_surface, + * or keeping the output they previously chose. Having a stable + * presentation output association helps clients predict future + * output refreshes (vblank). + * + * The 'refresh' argument gives the compositor's prediction of how + * many nanoseconds after tv_sec, tv_nsec the very next output + * refresh may occur. This is to further aid clients in predicting + * future refreshes, i.e., estimating the timestamps targeting the + * next few vblanks. If such prediction cannot usefully be done, + * the argument is zero. + * + * For version 2 and later, if the output does not have a constant + * refresh rate, explicit video mode switches excluded, then the + * refresh argument must be either an appropriate rate picked by + * the compositor (e.g. fastest rate), or 0 if no such rate exists. + * For version 1, if the output does not have a constant refresh + * rate, the refresh argument must be zero. + * + * The 64-bit value combined from seq_hi and seq_lo is the value of + * the output's vertical retrace counter when the content update + * was first scanned out to the display. This value must be + * compatible with the definition of MSC in GLX_OML_sync_control + * specification. Note, that if the display path has a non-zero + * latency, the time instant specified by this counter may differ + * from the timestamp's. + * + * If the output does not have a concept of vertical retrace or a + * refresh cycle, or the output device is self-refreshing without a + * way to query the refresh count, then the arguments seq_hi and + * seq_lo must be zero. + * @param tv_sec_hi high 32 bits of the seconds part of the presentation timestamp + * @param tv_sec_lo low 32 bits of the seconds part of the presentation timestamp + * @param tv_nsec nanoseconds part of the presentation timestamp + * @param refresh nanoseconds till next refresh + * @param seq_hi high 32 bits of refresh counter + * @param seq_lo low 32 bits of refresh counter + * @param flags combination of 'kind' values + */ + void (*presented)(void *data, + struct wp_presentation_feedback *wp_presentation_feedback, + uint32_t tv_sec_hi, + uint32_t tv_sec_lo, + uint32_t tv_nsec, + uint32_t refresh, + uint32_t seq_hi, + uint32_t seq_lo, + uint32_t flags); + /** + * the content update was not displayed + * + * The content update was never displayed to the user. + */ + void (*discarded)(void *data, + struct wp_presentation_feedback *wp_presentation_feedback); +}; + +/** + * @ingroup iface_wp_presentation_feedback + */ +static inline int +wp_presentation_feedback_add_listener(struct wp_presentation_feedback *wp_presentation_feedback, + const struct wp_presentation_feedback_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) wp_presentation_feedback, + (void (**)(void)) listener, data); +} + +/** + * @ingroup iface_wp_presentation_feedback + */ +#define WP_PRESENTATION_FEEDBACK_SYNC_OUTPUT_SINCE_VERSION 1 +/** + * @ingroup iface_wp_presentation_feedback + */ +#define WP_PRESENTATION_FEEDBACK_PRESENTED_SINCE_VERSION 1 +/** + * @ingroup iface_wp_presentation_feedback + */ +#define WP_PRESENTATION_FEEDBACK_DISCARDED_SINCE_VERSION 1 + + +/** @ingroup iface_wp_presentation_feedback */ +static inline void +wp_presentation_feedback_set_user_data(struct wp_presentation_feedback *wp_presentation_feedback, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_presentation_feedback, user_data); +} + +/** @ingroup iface_wp_presentation_feedback */ +static inline void * +wp_presentation_feedback_get_user_data(struct wp_presentation_feedback *wp_presentation_feedback) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_presentation_feedback); +} + +static inline uint32_t +wp_presentation_feedback_get_version(struct wp_presentation_feedback *wp_presentation_feedback) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_presentation_feedback); +} + +/** @ingroup iface_wp_presentation_feedback */ +static inline void +wp_presentation_feedback_destroy(struct wp_presentation_feedback *wp_presentation_feedback) +{ + wl_proxy_destroy((struct wl_proxy *) wp_presentation_feedback); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/presentation-time-protocol.c b/src/platform/wayland/protocols/presentation-time-protocol.c new file mode 100644 index 0000000..b7eef14 --- /dev/null +++ b/src/platform/wayland/protocols/presentation-time-protocol.c @@ -0,0 +1,84 @@ +/* Generated by wayland-scanner 1.26.0 */ + +/* + * Copyright © 2013-2014 Collabora, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_output_interface; +extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface wp_presentation_feedback_interface; + +static const struct wl_interface *presentation_time_types[] = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + &wl_surface_interface, + &wp_presentation_feedback_interface, + &wl_output_interface, +}; + +static const struct wl_message wp_presentation_requests[] = { + { "destroy", "", presentation_time_types + 0 }, + { "feedback", "on", presentation_time_types + 7 }, +}; + +static const struct wl_message wp_presentation_events[] = { + { "clock_id", "u", presentation_time_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface wp_presentation_interface = { + "wp_presentation", 2, + 2, wp_presentation_requests, + 1, wp_presentation_events, +}; + +static const struct wl_message wp_presentation_feedback_events[] = { + { "sync_output", "o", presentation_time_types + 9 }, + { "presented", "uuuuuuu", presentation_time_types + 0 }, + { "discarded", "", presentation_time_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface wp_presentation_feedback_interface = { + "wp_presentation_feedback", 2, + 0, NULL, + 3, wp_presentation_feedback_events, +}; + diff --git a/src/platform/wayland/protocols/primary-selection-unstable-v1-client-protocol.h b/src/platform/wayland/protocols/primary-selection-unstable-v1-client-protocol.h new file mode 100644 index 0000000..01dd0e3 --- /dev/null +++ b/src/platform/wayland/protocols/primary-selection-unstable-v1-client-protocol.h @@ -0,0 +1,582 @@ +/* Generated by wayland-scanner 1.26.0 */ + +#ifndef WP_PRIMARY_SELECTION_UNSTABLE_V1_CLIENT_PROTOCOL_H +#define WP_PRIMARY_SELECTION_UNSTABLE_V1_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_wp_primary_selection_unstable_v1 The wp_primary_selection_unstable_v1 protocol + * Primary selection protocol + * + * @section page_desc_wp_primary_selection_unstable_v1 Description + * + * This protocol provides the ability to have a primary selection device to + * match that of the X server. This primary selection is a shortcut to the + * common clipboard selection, where text just needs to be selected in order + * to allow copying it elsewhere. The de facto way to perform this action + * is the middle mouse button, although it is not limited to this one. + * + * Clients wishing to honor primary selection should create a primary + * selection source and set it as the selection through + * wp_primary_selection_device.set_selection whenever the text selection + * changes. In order to minimize calls in pointer-driven text selection, + * it should happen only once after the operation finished. Similarly, + * a NULL source should be set when text is unselected. + * + * wp_primary_selection_offer objects are first announced through the + * wp_primary_selection_device.data_offer event. Immediately after this event, + * the primary data offer will emit wp_primary_selection_offer.offer events + * to let know of the mime types being offered. + * + * When the primary selection changes, the client with the keyboard focus + * will receive wp_primary_selection_device.selection events. Only the client + * with the keyboard focus will receive such events with a non-NULL + * wp_primary_selection_offer. Across keyboard focus changes, previously + * focused clients will receive wp_primary_selection_device.events with a + * NULL wp_primary_selection_offer. + * + * In order to request the primary selection data, the client must pass + * a recent serial pertaining to the press event that is triggering the + * operation, if the compositor deems the serial valid and recent, the + * wp_primary_selection_source.send event will happen in the other end + * to let the transfer begin. The client owning the primary selection + * should write the requested data, and close the file descriptor + * immediately. + * + * If the primary selection owner client disappeared during the transfer, + * the client reading the data will receive a + * wp_primary_selection_device.selection event with a NULL + * wp_primary_selection_offer, the client should take this as a hint + * to finish the reads related to the no longer existing offer. + * + * The primary selection owner should be checking for errors during + * writes, merely cancelling the ongoing transfer if any happened. + * + * @section page_ifaces_wp_primary_selection_unstable_v1 Interfaces + * - @subpage page_iface_zwp_primary_selection_device_manager_v1 - X primary selection emulation + * - @subpage page_iface_zwp_primary_selection_device_v1 - + * - @subpage page_iface_zwp_primary_selection_offer_v1 - offer to transfer primary selection contents + * - @subpage page_iface_zwp_primary_selection_source_v1 - offer to replace the contents of the primary selection + * @section page_copyright_wp_primary_selection_unstable_v1 Copyright + * <pre> + * + * Copyright © 2015, 2016 Red Hat + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * </pre> + */ +struct wl_seat; +struct zwp_primary_selection_device_manager_v1; +struct zwp_primary_selection_device_v1; +struct zwp_primary_selection_offer_v1; +struct zwp_primary_selection_source_v1; + +#ifndef ZWP_PRIMARY_SELECTION_DEVICE_MANAGER_V1_INTERFACE +#define ZWP_PRIMARY_SELECTION_DEVICE_MANAGER_V1_INTERFACE +/** + * @page page_iface_zwp_primary_selection_device_manager_v1 zwp_primary_selection_device_manager_v1 + * @section page_iface_zwp_primary_selection_device_manager_v1_desc Description + * + * The primary selection device manager is a singleton global object that + * provides access to the primary selection. It allows to create + * wp_primary_selection_source objects, as well as retrieving the per-seat + * wp_primary_selection_device objects. + * @section page_iface_zwp_primary_selection_device_manager_v1_api API + * See @ref iface_zwp_primary_selection_device_manager_v1. + */ +/** + * @defgroup iface_zwp_primary_selection_device_manager_v1 The zwp_primary_selection_device_manager_v1 interface + * + * The primary selection device manager is a singleton global object that + * provides access to the primary selection. It allows to create + * wp_primary_selection_source objects, as well as retrieving the per-seat + * wp_primary_selection_device objects. + */ +extern const struct wl_interface zwp_primary_selection_device_manager_v1_interface; +#endif +#ifndef ZWP_PRIMARY_SELECTION_DEVICE_V1_INTERFACE +#define ZWP_PRIMARY_SELECTION_DEVICE_V1_INTERFACE +/** + * @page page_iface_zwp_primary_selection_device_v1 zwp_primary_selection_device_v1 + * @section page_iface_zwp_primary_selection_device_v1_api API + * See @ref iface_zwp_primary_selection_device_v1. + */ +/** + * @defgroup iface_zwp_primary_selection_device_v1 The zwp_primary_selection_device_v1 interface + */ +extern const struct wl_interface zwp_primary_selection_device_v1_interface; +#endif +#ifndef ZWP_PRIMARY_SELECTION_OFFER_V1_INTERFACE +#define ZWP_PRIMARY_SELECTION_OFFER_V1_INTERFACE +/** + * @page page_iface_zwp_primary_selection_offer_v1 zwp_primary_selection_offer_v1 + * @section page_iface_zwp_primary_selection_offer_v1_desc Description + * + * A wp_primary_selection_offer represents an offer to transfer the contents + * of the primary selection clipboard to the client. Similar to + * wl_data_offer, the offer also describes the mime types that the data can + * be converted to and provides the mechanisms for transferring the data + * directly to the client. + * @section page_iface_zwp_primary_selection_offer_v1_api API + * See @ref iface_zwp_primary_selection_offer_v1. + */ +/** + * @defgroup iface_zwp_primary_selection_offer_v1 The zwp_primary_selection_offer_v1 interface + * + * A wp_primary_selection_offer represents an offer to transfer the contents + * of the primary selection clipboard to the client. Similar to + * wl_data_offer, the offer also describes the mime types that the data can + * be converted to and provides the mechanisms for transferring the data + * directly to the client. + */ +extern const struct wl_interface zwp_primary_selection_offer_v1_interface; +#endif +#ifndef ZWP_PRIMARY_SELECTION_SOURCE_V1_INTERFACE +#define ZWP_PRIMARY_SELECTION_SOURCE_V1_INTERFACE +/** + * @page page_iface_zwp_primary_selection_source_v1 zwp_primary_selection_source_v1 + * @section page_iface_zwp_primary_selection_source_v1_desc Description + * + * The source side of a wp_primary_selection_offer, it provides a way to + * describe the offered data and respond to requests to transfer the + * requested contents of the primary selection clipboard. + * @section page_iface_zwp_primary_selection_source_v1_api API + * See @ref iface_zwp_primary_selection_source_v1. + */ +/** + * @defgroup iface_zwp_primary_selection_source_v1 The zwp_primary_selection_source_v1 interface + * + * The source side of a wp_primary_selection_offer, it provides a way to + * describe the offered data and respond to requests to transfer the + * requested contents of the primary selection clipboard. + */ +extern const struct wl_interface zwp_primary_selection_source_v1_interface; +#endif + +#define ZWP_PRIMARY_SELECTION_DEVICE_MANAGER_V1_CREATE_SOURCE 0 +#define ZWP_PRIMARY_SELECTION_DEVICE_MANAGER_V1_GET_DEVICE 1 +#define ZWP_PRIMARY_SELECTION_DEVICE_MANAGER_V1_DESTROY 2 + + +/** + * @ingroup iface_zwp_primary_selection_device_manager_v1 + */ +#define ZWP_PRIMARY_SELECTION_DEVICE_MANAGER_V1_CREATE_SOURCE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_primary_selection_device_manager_v1 + */ +#define ZWP_PRIMARY_SELECTION_DEVICE_MANAGER_V1_GET_DEVICE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_primary_selection_device_manager_v1 + */ +#define ZWP_PRIMARY_SELECTION_DEVICE_MANAGER_V1_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_primary_selection_device_manager_v1 */ +static inline void +zwp_primary_selection_device_manager_v1_set_user_data(struct zwp_primary_selection_device_manager_v1 *zwp_primary_selection_device_manager_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_primary_selection_device_manager_v1, user_data); +} + +/** @ingroup iface_zwp_primary_selection_device_manager_v1 */ +static inline void * +zwp_primary_selection_device_manager_v1_get_user_data(struct zwp_primary_selection_device_manager_v1 *zwp_primary_selection_device_manager_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_primary_selection_device_manager_v1); +} + +static inline uint32_t +zwp_primary_selection_device_manager_v1_get_version(struct zwp_primary_selection_device_manager_v1 *zwp_primary_selection_device_manager_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_device_manager_v1); +} + +/** + * @ingroup iface_zwp_primary_selection_device_manager_v1 + * + * Create a new primary selection source. + */ +static inline struct zwp_primary_selection_source_v1 * +zwp_primary_selection_device_manager_v1_create_source(struct zwp_primary_selection_device_manager_v1 *zwp_primary_selection_device_manager_v1) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) zwp_primary_selection_device_manager_v1, + ZWP_PRIMARY_SELECTION_DEVICE_MANAGER_V1_CREATE_SOURCE, &zwp_primary_selection_source_v1_interface, wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_device_manager_v1), 0, NULL); + + return (struct zwp_primary_selection_source_v1 *) id; +} + +/** + * @ingroup iface_zwp_primary_selection_device_manager_v1 + * + * Create a new data device for a given seat. + */ +static inline struct zwp_primary_selection_device_v1 * +zwp_primary_selection_device_manager_v1_get_device(struct zwp_primary_selection_device_manager_v1 *zwp_primary_selection_device_manager_v1, struct wl_seat *seat) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) zwp_primary_selection_device_manager_v1, + ZWP_PRIMARY_SELECTION_DEVICE_MANAGER_V1_GET_DEVICE, &zwp_primary_selection_device_v1_interface, wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_device_manager_v1), 0, NULL, seat); + + return (struct zwp_primary_selection_device_v1 *) id; +} + +/** + * @ingroup iface_zwp_primary_selection_device_manager_v1 + * + * Destroy the primary selection device manager. + */ +static inline void +zwp_primary_selection_device_manager_v1_destroy(struct zwp_primary_selection_device_manager_v1 *zwp_primary_selection_device_manager_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_primary_selection_device_manager_v1, + ZWP_PRIMARY_SELECTION_DEVICE_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_device_manager_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_zwp_primary_selection_device_v1 + * @struct zwp_primary_selection_device_v1_listener + */ +struct zwp_primary_selection_device_v1_listener { + /** + * introduce a new wp_primary_selection_offer + * + * Introduces a new wp_primary_selection_offer object that may be + * used to receive the current primary selection. Immediately + * following this event, the new wp_primary_selection_offer object + * will send wp_primary_selection_offer.offer events to describe + * the offered mime types. + */ + void (*data_offer)(void *data, + struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1, + struct zwp_primary_selection_offer_v1 *offer); + /** + * advertise a new primary selection + * + * The wp_primary_selection_device.selection event is sent to + * notify the client of a new primary selection. This event is sent + * after the wp_primary_selection.data_offer event introducing this + * object, and after the offer has announced its mimetypes through + * wp_primary_selection_offer.offer. + * + * The data_offer is valid until a new offer or NULL is received or + * until the client loses keyboard focus. The client must destroy + * the previous selection data_offer, if any, upon receiving this + * event. + */ + void (*selection)(void *data, + struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1, + struct zwp_primary_selection_offer_v1 *id); +}; + +/** + * @ingroup iface_zwp_primary_selection_device_v1 + */ +static inline int +zwp_primary_selection_device_v1_add_listener(struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1, + const struct zwp_primary_selection_device_v1_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zwp_primary_selection_device_v1, + (void (**)(void)) listener, data); +} + +#define ZWP_PRIMARY_SELECTION_DEVICE_V1_SET_SELECTION 0 +#define ZWP_PRIMARY_SELECTION_DEVICE_V1_DESTROY 1 + +/** + * @ingroup iface_zwp_primary_selection_device_v1 + */ +#define ZWP_PRIMARY_SELECTION_DEVICE_V1_DATA_OFFER_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_primary_selection_device_v1 + */ +#define ZWP_PRIMARY_SELECTION_DEVICE_V1_SELECTION_SINCE_VERSION 1 + +/** + * @ingroup iface_zwp_primary_selection_device_v1 + */ +#define ZWP_PRIMARY_SELECTION_DEVICE_V1_SET_SELECTION_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_primary_selection_device_v1 + */ +#define ZWP_PRIMARY_SELECTION_DEVICE_V1_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_primary_selection_device_v1 */ +static inline void +zwp_primary_selection_device_v1_set_user_data(struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_primary_selection_device_v1, user_data); +} + +/** @ingroup iface_zwp_primary_selection_device_v1 */ +static inline void * +zwp_primary_selection_device_v1_get_user_data(struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_primary_selection_device_v1); +} + +static inline uint32_t +zwp_primary_selection_device_v1_get_version(struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_device_v1); +} + +/** + * @ingroup iface_zwp_primary_selection_device_v1 + * + * Replaces the current selection. The previous owner of the primary + * selection will receive a wp_primary_selection_source.cancelled event. + * + * To unset the selection, set the source to NULL. + */ +static inline void +zwp_primary_selection_device_v1_set_selection(struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1, struct zwp_primary_selection_source_v1 *source, uint32_t serial) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_primary_selection_device_v1, + ZWP_PRIMARY_SELECTION_DEVICE_V1_SET_SELECTION, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_device_v1), 0, source, serial); +} + +/** + * @ingroup iface_zwp_primary_selection_device_v1 + * + * Destroy the primary selection device. + */ +static inline void +zwp_primary_selection_device_v1_destroy(struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_primary_selection_device_v1, + ZWP_PRIMARY_SELECTION_DEVICE_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_device_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_zwp_primary_selection_offer_v1 + * @struct zwp_primary_selection_offer_v1_listener + */ +struct zwp_primary_selection_offer_v1_listener { + /** + * advertise offered mime type + * + * Sent immediately after creating announcing the + * wp_primary_selection_offer through + * wp_primary_selection_device.data_offer. One event is sent per + * offered mime type. + */ + void (*offer)(void *data, + struct zwp_primary_selection_offer_v1 *zwp_primary_selection_offer_v1, + const char *mime_type); +}; + +/** + * @ingroup iface_zwp_primary_selection_offer_v1 + */ +static inline int +zwp_primary_selection_offer_v1_add_listener(struct zwp_primary_selection_offer_v1 *zwp_primary_selection_offer_v1, + const struct zwp_primary_selection_offer_v1_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zwp_primary_selection_offer_v1, + (void (**)(void)) listener, data); +} + +#define ZWP_PRIMARY_SELECTION_OFFER_V1_RECEIVE 0 +#define ZWP_PRIMARY_SELECTION_OFFER_V1_DESTROY 1 + +/** + * @ingroup iface_zwp_primary_selection_offer_v1 + */ +#define ZWP_PRIMARY_SELECTION_OFFER_V1_OFFER_SINCE_VERSION 1 + +/** + * @ingroup iface_zwp_primary_selection_offer_v1 + */ +#define ZWP_PRIMARY_SELECTION_OFFER_V1_RECEIVE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_primary_selection_offer_v1 + */ +#define ZWP_PRIMARY_SELECTION_OFFER_V1_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_primary_selection_offer_v1 */ +static inline void +zwp_primary_selection_offer_v1_set_user_data(struct zwp_primary_selection_offer_v1 *zwp_primary_selection_offer_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_primary_selection_offer_v1, user_data); +} + +/** @ingroup iface_zwp_primary_selection_offer_v1 */ +static inline void * +zwp_primary_selection_offer_v1_get_user_data(struct zwp_primary_selection_offer_v1 *zwp_primary_selection_offer_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_primary_selection_offer_v1); +} + +static inline uint32_t +zwp_primary_selection_offer_v1_get_version(struct zwp_primary_selection_offer_v1 *zwp_primary_selection_offer_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_offer_v1); +} + +/** + * @ingroup iface_zwp_primary_selection_offer_v1 + * + * To transfer the contents of the primary selection clipboard, the client + * issues this request and indicates the mime type that it wants to + * receive. The transfer happens through the passed file descriptor + * (typically created with the pipe system call). The source client writes + * the data in the mime type representation requested and then closes the + * file descriptor. + * + * The receiving client reads from the read end of the pipe until EOF and + * closes its end, at which point the transfer is complete. + */ +static inline void +zwp_primary_selection_offer_v1_receive(struct zwp_primary_selection_offer_v1 *zwp_primary_selection_offer_v1, const char *mime_type, int32_t fd) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_primary_selection_offer_v1, + ZWP_PRIMARY_SELECTION_OFFER_V1_RECEIVE, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_offer_v1), 0, mime_type, fd); +} + +/** + * @ingroup iface_zwp_primary_selection_offer_v1 + * + * Destroy the primary selection offer. + */ +static inline void +zwp_primary_selection_offer_v1_destroy(struct zwp_primary_selection_offer_v1 *zwp_primary_selection_offer_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_primary_selection_offer_v1, + ZWP_PRIMARY_SELECTION_OFFER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_offer_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_zwp_primary_selection_source_v1 + * @struct zwp_primary_selection_source_v1_listener + */ +struct zwp_primary_selection_source_v1_listener { + /** + * send the primary selection contents + * + * Request for the current primary selection contents from the + * client. Send the specified mime type over the passed file + * descriptor, then close it. + */ + void (*send)(void *data, + struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1, + const char *mime_type, + int32_t fd); + /** + * request for primary selection contents was canceled + * + * This primary selection source is no longer valid. The client + * should clean up and destroy this primary selection source. + */ + void (*cancelled)(void *data, + struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1); +}; + +/** + * @ingroup iface_zwp_primary_selection_source_v1 + */ +static inline int +zwp_primary_selection_source_v1_add_listener(struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1, + const struct zwp_primary_selection_source_v1_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zwp_primary_selection_source_v1, + (void (**)(void)) listener, data); +} + +#define ZWP_PRIMARY_SELECTION_SOURCE_V1_OFFER 0 +#define ZWP_PRIMARY_SELECTION_SOURCE_V1_DESTROY 1 + +/** + * @ingroup iface_zwp_primary_selection_source_v1 + */ +#define ZWP_PRIMARY_SELECTION_SOURCE_V1_SEND_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_primary_selection_source_v1 + */ +#define ZWP_PRIMARY_SELECTION_SOURCE_V1_CANCELLED_SINCE_VERSION 1 + +/** + * @ingroup iface_zwp_primary_selection_source_v1 + */ +#define ZWP_PRIMARY_SELECTION_SOURCE_V1_OFFER_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_primary_selection_source_v1 + */ +#define ZWP_PRIMARY_SELECTION_SOURCE_V1_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_primary_selection_source_v1 */ +static inline void +zwp_primary_selection_source_v1_set_user_data(struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_primary_selection_source_v1, user_data); +} + +/** @ingroup iface_zwp_primary_selection_source_v1 */ +static inline void * +zwp_primary_selection_source_v1_get_user_data(struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_primary_selection_source_v1); +} + +static inline uint32_t +zwp_primary_selection_source_v1_get_version(struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_source_v1); +} + +/** + * @ingroup iface_zwp_primary_selection_source_v1 + * + * This request adds a mime type to the set of mime types advertised to + * targets. Can be called several times to offer multiple types. + */ +static inline void +zwp_primary_selection_source_v1_offer(struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1, const char *mime_type) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_primary_selection_source_v1, + ZWP_PRIMARY_SELECTION_SOURCE_V1_OFFER, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_source_v1), 0, mime_type); +} + +/** + * @ingroup iface_zwp_primary_selection_source_v1 + * + * Destroy the primary selection source. + */ +static inline void +zwp_primary_selection_source_v1_destroy(struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_primary_selection_source_v1, + ZWP_PRIMARY_SELECTION_SOURCE_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_primary_selection_source_v1), WL_MARSHAL_FLAG_DESTROY); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/primary-selection-unstable-v1-protocol.c b/src/platform/wayland/protocols/primary-selection-unstable-v1-protocol.c new file mode 100644 index 0000000..8c99e28 --- /dev/null +++ b/src/platform/wayland/protocols/primary-selection-unstable-v1-protocol.c @@ -0,0 +1,116 @@ +/* Generated by wayland-scanner 1.26.0 */ + +/* + * Copyright © 2015, 2016 Red Hat + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_seat_interface; +extern const struct wl_interface zwp_primary_selection_device_v1_interface; +extern const struct wl_interface zwp_primary_selection_offer_v1_interface; +extern const struct wl_interface zwp_primary_selection_source_v1_interface; + +static const struct wl_interface *wp_primary_selection_unstable_v1_types[] = { + NULL, + NULL, + &zwp_primary_selection_source_v1_interface, + &zwp_primary_selection_device_v1_interface, + &wl_seat_interface, + &zwp_primary_selection_source_v1_interface, + NULL, + &zwp_primary_selection_offer_v1_interface, + &zwp_primary_selection_offer_v1_interface, +}; + +static const struct wl_message zwp_primary_selection_device_manager_v1_requests[] = { + { "create_source", "n", wp_primary_selection_unstable_v1_types + 2 }, + { "get_device", "no", wp_primary_selection_unstable_v1_types + 3 }, + { "destroy", "", wp_primary_selection_unstable_v1_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface zwp_primary_selection_device_manager_v1_interface = { + "zwp_primary_selection_device_manager_v1", 1, + 3, zwp_primary_selection_device_manager_v1_requests, + 0, NULL, +}; + +static const struct wl_message zwp_primary_selection_device_v1_requests[] = { + { "set_selection", "?ou", wp_primary_selection_unstable_v1_types + 5 }, + { "destroy", "", wp_primary_selection_unstable_v1_types + 0 }, +}; + +static const struct wl_message zwp_primary_selection_device_v1_events[] = { + { "data_offer", "n", wp_primary_selection_unstable_v1_types + 7 }, + { "selection", "?o", wp_primary_selection_unstable_v1_types + 8 }, +}; + +WL_PRIVATE const struct wl_interface zwp_primary_selection_device_v1_interface = { + "zwp_primary_selection_device_v1", 1, + 2, zwp_primary_selection_device_v1_requests, + 2, zwp_primary_selection_device_v1_events, +}; + +static const struct wl_message zwp_primary_selection_offer_v1_requests[] = { + { "receive", "sh", wp_primary_selection_unstable_v1_types + 0 }, + { "destroy", "", wp_primary_selection_unstable_v1_types + 0 }, +}; + +static const struct wl_message zwp_primary_selection_offer_v1_events[] = { + { "offer", "s", wp_primary_selection_unstable_v1_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface zwp_primary_selection_offer_v1_interface = { + "zwp_primary_selection_offer_v1", 1, + 2, zwp_primary_selection_offer_v1_requests, + 1, zwp_primary_selection_offer_v1_events, +}; + +static const struct wl_message zwp_primary_selection_source_v1_requests[] = { + { "offer", "s", wp_primary_selection_unstable_v1_types + 0 }, + { "destroy", "", wp_primary_selection_unstable_v1_types + 0 }, +}; + +static const struct wl_message zwp_primary_selection_source_v1_events[] = { + { "send", "sh", wp_primary_selection_unstable_v1_types + 0 }, + { "cancelled", "", wp_primary_selection_unstable_v1_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface zwp_primary_selection_source_v1_interface = { + "zwp_primary_selection_source_v1", 1, + 2, zwp_primary_selection_source_v1_requests, + 2, zwp_primary_selection_source_v1_events, +}; + diff --git a/src/platform/wayland/protocols/tablet-v2-client-protocol.h b/src/platform/wayland/protocols/tablet-v2-client-protocol.h new file mode 100644 index 0000000..d3aa023 --- /dev/null +++ b/src/platform/wayland/protocols/tablet-v2-client-protocol.h @@ -0,0 +1,2495 @@ +/* Generated by wayland-scanner 1.26.0 */ + +#ifndef TABLET_V2_CLIENT_PROTOCOL_H +#define TABLET_V2_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_tablet_v2 The tablet_v2 protocol + * Wayland protocol for graphics tablets + * + * @section page_desc_tablet_v2 Description + * + * This description provides a high-level overview of the interplay between + * the interfaces defined this protocol. For details, see the protocol + * specification. + * + * More than one tablet may exist, and device-specifics matter. Tablets are + * not represented by a single virtual device like wl_pointer. A client + * binds to the tablet manager object which is just a proxy object. From + * that, the client requests zwp_tablet_manager_v2.get_tablet_seat(wl_seat) + * and that returns the actual interface that has all the tablets. With + * this indirection, we can avoid merging zwp_tablet_v2 into the actual Wayland + * protocol, a long-term benefit. + * + * The zwp_tablet_seat_v2 sends a "tablet added" event for each tablet + * connected. That event is followed by descriptive events about the + * hardware; currently that includes events for name, vid/pid and + * a zwp_tablet_v2.path event that describes a local path. This path can be + * used to uniquely identify a tablet or get more information through + * libwacom. Emulated or nested tablets can skip any of those, e.g. a + * virtual tablet may not have a vid/pid. The sequence of descriptive + * events is terminated by a zwp_tablet_v2.done event to signal that a client + * may now finalize any initialization for that tablet. + * + * Events from tablets require a tool in proximity. Tools are also managed + * by the tablet seat; a "tool added" event is sent whenever a tool is new + * to the compositor. That event is followed by a number of descriptive + * events about the hardware; currently that includes capabilities, + * hardware id and serial number, and tool type. Similar to the tablet + * interface, a zwp_tablet_tool_v2.done event is sent to terminate that initial + * sequence. + * + * Any event from a tool happens on the zwp_tablet_tool_v2 interface. When the + * tool gets into proximity of the tablet, a proximity_in event is sent on + * the zwp_tablet_tool_v2 interface, listing the tablet and the surface. That + * event is followed by a motion event with the coordinates. After that, + * it's the usual motion, axis, button, etc. events. The protocol's + * serialisation means events are grouped by zwp_tablet_tool_v2.frame events. + * + * Two special events (that don't exist in X) are down and up. They signal + * "tip touching the surface". For tablets without real proximity + * detection, the sequence is: proximity_in, motion, down, frame. + * + * When the tool leaves proximity, a proximity_out event is sent. If any + * button is still down, a button release event is sent before this + * proximity event. These button events are sent in the same frame as the + * proximity event to signal to the client that the buttons were held when + * the tool left proximity. + * + * If the tool moves out of the surface but stays in proximity (i.e. + * between windows), compositor-specific grab policies apply. This usually + * means that the proximity-out is delayed until all buttons are released. + * + * Moving a tool physically from one tablet to the other has no real effect + * on the protocol, since we already have the tool object from the "tool + * added" event. All the information is already there and the proximity + * events on both tablets are all a client needs to reconstruct what + * happened. + * + * Some extra axes are normalized, i.e. the client knows the range as + * specified in the protocol (e.g. [0, 65535]), the granularity however is + * unknown. The current normalized axes are pressure, distance, and slider. + * + * Other extra axes are in physical units as specified in the protocol. + * The current extra axes with physical units are tilt, rotation and + * wheel rotation. + * + * Since tablets work independently of the pointer controlled by the mouse, + * the focus handling is independent too and controlled by proximity. + * The zwp_tablet_tool_v2.set_cursor request sets a tool-specific cursor. + * This cursor surface may be the same as the mouse cursor, and it may be + * the same across tools but it is possible to be more fine-grained. For + * example, a client may set different cursors for the pen and eraser. + * + * Tools are generally independent of tablets and it is + * compositor-specific policy when a tool can be removed. Common approaches + * will likely include some form of removing a tool when all tablets the + * tool was used on are removed. + * + * @section page_ifaces_tablet_v2 Interfaces + * - @subpage page_iface_zwp_tablet_manager_v2 - controller object for graphic tablet devices + * - @subpage page_iface_zwp_tablet_seat_v2 - controller object for graphic tablet devices of a seat + * - @subpage page_iface_zwp_tablet_tool_v2 - a physical tablet tool + * - @subpage page_iface_zwp_tablet_v2 - graphics tablet device + * - @subpage page_iface_zwp_tablet_pad_ring_v2 - pad ring + * - @subpage page_iface_zwp_tablet_pad_strip_v2 - pad strip + * - @subpage page_iface_zwp_tablet_pad_group_v2 - a set of buttons, rings and strips + * - @subpage page_iface_zwp_tablet_pad_v2 - a set of buttons, rings, strips and dials + * - @subpage page_iface_zwp_tablet_pad_dial_v2 - pad dial + * @section page_copyright_tablet_v2 Copyright + * <pre> + * + * Copyright 2014 © Stephen "Lyude" Chandler Paul + * Copyright 2015-2024 © Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * </pre> + */ +struct wl_seat; +struct wl_surface; +struct zwp_tablet_manager_v2; +struct zwp_tablet_pad_dial_v2; +struct zwp_tablet_pad_group_v2; +struct zwp_tablet_pad_ring_v2; +struct zwp_tablet_pad_strip_v2; +struct zwp_tablet_pad_v2; +struct zwp_tablet_seat_v2; +struct zwp_tablet_tool_v2; +struct zwp_tablet_v2; + +#ifndef ZWP_TABLET_MANAGER_V2_INTERFACE +#define ZWP_TABLET_MANAGER_V2_INTERFACE +/** + * @page page_iface_zwp_tablet_manager_v2 zwp_tablet_manager_v2 + * @section page_iface_zwp_tablet_manager_v2_desc Description + * + * An object that provides access to the graphics tablets available on this + * system. All tablets are associated with a seat, to get access to the + * actual tablets, use zwp_tablet_manager_v2.get_tablet_seat. + * @section page_iface_zwp_tablet_manager_v2_api API + * See @ref iface_zwp_tablet_manager_v2. + */ +/** + * @defgroup iface_zwp_tablet_manager_v2 The zwp_tablet_manager_v2 interface + * + * An object that provides access to the graphics tablets available on this + * system. All tablets are associated with a seat, to get access to the + * actual tablets, use zwp_tablet_manager_v2.get_tablet_seat. + */ +extern const struct wl_interface zwp_tablet_manager_v2_interface; +#endif +#ifndef ZWP_TABLET_SEAT_V2_INTERFACE +#define ZWP_TABLET_SEAT_V2_INTERFACE +/** + * @page page_iface_zwp_tablet_seat_v2 zwp_tablet_seat_v2 + * @section page_iface_zwp_tablet_seat_v2_desc Description + * + * An object that provides access to the graphics tablets available on this + * seat. After binding to this interface, the compositor sends a set of + * zwp_tablet_seat_v2.tablet_added and zwp_tablet_seat_v2.tool_added events. + * @section page_iface_zwp_tablet_seat_v2_api API + * See @ref iface_zwp_tablet_seat_v2. + */ +/** + * @defgroup iface_zwp_tablet_seat_v2 The zwp_tablet_seat_v2 interface + * + * An object that provides access to the graphics tablets available on this + * seat. After binding to this interface, the compositor sends a set of + * zwp_tablet_seat_v2.tablet_added and zwp_tablet_seat_v2.tool_added events. + */ +extern const struct wl_interface zwp_tablet_seat_v2_interface; +#endif +#ifndef ZWP_TABLET_TOOL_V2_INTERFACE +#define ZWP_TABLET_TOOL_V2_INTERFACE +/** + * @page page_iface_zwp_tablet_tool_v2 zwp_tablet_tool_v2 + * @section page_iface_zwp_tablet_tool_v2_desc Description + * + * An object that represents a physical tool that has been, or is + * currently in use with a tablet in this seat. Each zwp_tablet_tool_v2 + * object stays valid until the client destroys it; the compositor + * reuses the zwp_tablet_tool_v2 object to indicate that the object's + * respective physical tool has come into proximity of a tablet again. + * + * A zwp_tablet_tool_v2 object's relation to a physical tool depends on the + * tablet's ability to report serial numbers. If the tablet supports + * this capability, then the object represents a specific physical tool + * and can be identified even when used on multiple tablets. + * + * A tablet tool has a number of static characteristics, e.g. tool type, + * hardware_serial and capabilities. These capabilities are sent in an + * event sequence after the zwp_tablet_seat_v2.tool_added event before any + * actual events from this tool. This initial event sequence is + * terminated by a zwp_tablet_tool_v2.done event. + * + * Tablet tool events are grouped by zwp_tablet_tool_v2.frame events. + * Any events received before a zwp_tablet_tool_v2.frame event should be + * considered part of the same hardware state change. + * @section page_iface_zwp_tablet_tool_v2_api API + * See @ref iface_zwp_tablet_tool_v2. + */ +/** + * @defgroup iface_zwp_tablet_tool_v2 The zwp_tablet_tool_v2 interface + * + * An object that represents a physical tool that has been, or is + * currently in use with a tablet in this seat. Each zwp_tablet_tool_v2 + * object stays valid until the client destroys it; the compositor + * reuses the zwp_tablet_tool_v2 object to indicate that the object's + * respective physical tool has come into proximity of a tablet again. + * + * A zwp_tablet_tool_v2 object's relation to a physical tool depends on the + * tablet's ability to report serial numbers. If the tablet supports + * this capability, then the object represents a specific physical tool + * and can be identified even when used on multiple tablets. + * + * A tablet tool has a number of static characteristics, e.g. tool type, + * hardware_serial and capabilities. These capabilities are sent in an + * event sequence after the zwp_tablet_seat_v2.tool_added event before any + * actual events from this tool. This initial event sequence is + * terminated by a zwp_tablet_tool_v2.done event. + * + * Tablet tool events are grouped by zwp_tablet_tool_v2.frame events. + * Any events received before a zwp_tablet_tool_v2.frame event should be + * considered part of the same hardware state change. + */ +extern const struct wl_interface zwp_tablet_tool_v2_interface; +#endif +#ifndef ZWP_TABLET_V2_INTERFACE +#define ZWP_TABLET_V2_INTERFACE +/** + * @page page_iface_zwp_tablet_v2 zwp_tablet_v2 + * @section page_iface_zwp_tablet_v2_desc Description + * + * The zwp_tablet_v2 interface represents one graphics tablet device. The + * tablet interface itself does not generate events; all events are + * generated by zwp_tablet_tool_v2 objects when in proximity above a tablet. + * + * A tablet has a number of static characteristics, e.g. device name and + * pid/vid. These capabilities are sent in an event sequence after the + * zwp_tablet_seat_v2.tablet_added event. This initial event sequence is + * terminated by a zwp_tablet_v2.done event. + * @section page_iface_zwp_tablet_v2_api API + * See @ref iface_zwp_tablet_v2. + */ +/** + * @defgroup iface_zwp_tablet_v2 The zwp_tablet_v2 interface + * + * The zwp_tablet_v2 interface represents one graphics tablet device. The + * tablet interface itself does not generate events; all events are + * generated by zwp_tablet_tool_v2 objects when in proximity above a tablet. + * + * A tablet has a number of static characteristics, e.g. device name and + * pid/vid. These capabilities are sent in an event sequence after the + * zwp_tablet_seat_v2.tablet_added event. This initial event sequence is + * terminated by a zwp_tablet_v2.done event. + */ +extern const struct wl_interface zwp_tablet_v2_interface; +#endif +#ifndef ZWP_TABLET_PAD_RING_V2_INTERFACE +#define ZWP_TABLET_PAD_RING_V2_INTERFACE +/** + * @page page_iface_zwp_tablet_pad_ring_v2 zwp_tablet_pad_ring_v2 + * @section page_iface_zwp_tablet_pad_ring_v2_desc Description + * + * A circular interaction area, such as the touch ring on the Wacom Intuos + * Pro series tablets. + * + * Events on a ring are logically grouped by the zwp_tablet_pad_ring_v2.frame + * event. + * @section page_iface_zwp_tablet_pad_ring_v2_api API + * See @ref iface_zwp_tablet_pad_ring_v2. + */ +/** + * @defgroup iface_zwp_tablet_pad_ring_v2 The zwp_tablet_pad_ring_v2 interface + * + * A circular interaction area, such as the touch ring on the Wacom Intuos + * Pro series tablets. + * + * Events on a ring are logically grouped by the zwp_tablet_pad_ring_v2.frame + * event. + */ +extern const struct wl_interface zwp_tablet_pad_ring_v2_interface; +#endif +#ifndef ZWP_TABLET_PAD_STRIP_V2_INTERFACE +#define ZWP_TABLET_PAD_STRIP_V2_INTERFACE +/** + * @page page_iface_zwp_tablet_pad_strip_v2 zwp_tablet_pad_strip_v2 + * @section page_iface_zwp_tablet_pad_strip_v2_desc Description + * + * A linear interaction area, such as the strips found in Wacom Cintiq + * models. + * + * Events on a strip are logically grouped by the zwp_tablet_pad_strip_v2.frame + * event. + * @section page_iface_zwp_tablet_pad_strip_v2_api API + * See @ref iface_zwp_tablet_pad_strip_v2. + */ +/** + * @defgroup iface_zwp_tablet_pad_strip_v2 The zwp_tablet_pad_strip_v2 interface + * + * A linear interaction area, such as the strips found in Wacom Cintiq + * models. + * + * Events on a strip are logically grouped by the zwp_tablet_pad_strip_v2.frame + * event. + */ +extern const struct wl_interface zwp_tablet_pad_strip_v2_interface; +#endif +#ifndef ZWP_TABLET_PAD_GROUP_V2_INTERFACE +#define ZWP_TABLET_PAD_GROUP_V2_INTERFACE +/** + * @page page_iface_zwp_tablet_pad_group_v2 zwp_tablet_pad_group_v2 + * @section page_iface_zwp_tablet_pad_group_v2_desc Description + * + * A pad group describes a distinct (sub)set of buttons, rings and strips + * present in the tablet. The criteria of this grouping is usually positional, + * eg. if a tablet has buttons on the left and right side, 2 groups will be + * presented. The physical arrangement of groups is undisclosed and may + * change on the fly. + * + * Pad groups will announce their features during pad initialization. Between + * the corresponding zwp_tablet_pad_v2.group event and zwp_tablet_pad_group_v2.done, the + * pad group will announce the buttons, rings and strips contained in it, + * plus the number of supported modes. + * + * Modes are a mechanism to allow multiple groups of actions for every element + * in the pad group. The number of groups and available modes in each is + * persistent across device plugs. The current mode is user-switchable, it + * will be announced through the zwp_tablet_pad_group_v2.mode_switch event both + * whenever it is switched, and after zwp_tablet_pad_v2.enter. + * + * The current mode logically applies to all elements in the pad group, + * although it is at clients' discretion whether to actually perform different + * actions, and/or issue the respective .set_feedback requests to notify the + * compositor. See the zwp_tablet_pad_group_v2.mode_switch event for more details. + * @section page_iface_zwp_tablet_pad_group_v2_api API + * See @ref iface_zwp_tablet_pad_group_v2. + */ +/** + * @defgroup iface_zwp_tablet_pad_group_v2 The zwp_tablet_pad_group_v2 interface + * + * A pad group describes a distinct (sub)set of buttons, rings and strips + * present in the tablet. The criteria of this grouping is usually positional, + * eg. if a tablet has buttons on the left and right side, 2 groups will be + * presented. The physical arrangement of groups is undisclosed and may + * change on the fly. + * + * Pad groups will announce their features during pad initialization. Between + * the corresponding zwp_tablet_pad_v2.group event and zwp_tablet_pad_group_v2.done, the + * pad group will announce the buttons, rings and strips contained in it, + * plus the number of supported modes. + * + * Modes are a mechanism to allow multiple groups of actions for every element + * in the pad group. The number of groups and available modes in each is + * persistent across device plugs. The current mode is user-switchable, it + * will be announced through the zwp_tablet_pad_group_v2.mode_switch event both + * whenever it is switched, and after zwp_tablet_pad_v2.enter. + * + * The current mode logically applies to all elements in the pad group, + * although it is at clients' discretion whether to actually perform different + * actions, and/or issue the respective .set_feedback requests to notify the + * compositor. See the zwp_tablet_pad_group_v2.mode_switch event for more details. + */ +extern const struct wl_interface zwp_tablet_pad_group_v2_interface; +#endif +#ifndef ZWP_TABLET_PAD_V2_INTERFACE +#define ZWP_TABLET_PAD_V2_INTERFACE +/** + * @page page_iface_zwp_tablet_pad_v2 zwp_tablet_pad_v2 + * @section page_iface_zwp_tablet_pad_v2_desc Description + * + * A pad device is a set of buttons, rings, strips and dials + * usually physically present on the tablet device itself. Some + * exceptions exist where the pad device is physically detached, e.g. the + * Wacom ExpressKey Remote. + * + * Pad devices have no axes that control the cursor and are generally + * auxiliary devices to the tool devices used on the tablet surface. + * + * A pad device has a number of static characteristics, e.g. the number + * of rings. These capabilities are sent in an event sequence after the + * zwp_tablet_seat_v2.pad_added event before any actual events from this pad. + * This initial event sequence is terminated by a zwp_tablet_pad_v2.done + * event. + * + * All pad features (buttons, rings, strips and dials) are logically divided into + * groups and all pads have at least one group. The available groups are + * notified through the zwp_tablet_pad_v2.group event; the compositor will + * emit one event per group before emitting zwp_tablet_pad_v2.done. + * + * Groups may have multiple modes. Modes allow clients to map multiple + * actions to a single pad feature. Only one mode can be active per group, + * although different groups may have different active modes. + * @section page_iface_zwp_tablet_pad_v2_api API + * See @ref iface_zwp_tablet_pad_v2. + */ +/** + * @defgroup iface_zwp_tablet_pad_v2 The zwp_tablet_pad_v2 interface + * + * A pad device is a set of buttons, rings, strips and dials + * usually physically present on the tablet device itself. Some + * exceptions exist where the pad device is physically detached, e.g. the + * Wacom ExpressKey Remote. + * + * Pad devices have no axes that control the cursor and are generally + * auxiliary devices to the tool devices used on the tablet surface. + * + * A pad device has a number of static characteristics, e.g. the number + * of rings. These capabilities are sent in an event sequence after the + * zwp_tablet_seat_v2.pad_added event before any actual events from this pad. + * This initial event sequence is terminated by a zwp_tablet_pad_v2.done + * event. + * + * All pad features (buttons, rings, strips and dials) are logically divided into + * groups and all pads have at least one group. The available groups are + * notified through the zwp_tablet_pad_v2.group event; the compositor will + * emit one event per group before emitting zwp_tablet_pad_v2.done. + * + * Groups may have multiple modes. Modes allow clients to map multiple + * actions to a single pad feature. Only one mode can be active per group, + * although different groups may have different active modes. + */ +extern const struct wl_interface zwp_tablet_pad_v2_interface; +#endif +#ifndef ZWP_TABLET_PAD_DIAL_V2_INTERFACE +#define ZWP_TABLET_PAD_DIAL_V2_INTERFACE +/** + * @page page_iface_zwp_tablet_pad_dial_v2 zwp_tablet_pad_dial_v2 + * @section page_iface_zwp_tablet_pad_dial_v2_desc Description + * + * A rotary control, e.g. a dial or a wheel. + * + * Events on a dial are logically grouped by the zwp_tablet_pad_dial_v2.frame + * event. + * @section page_iface_zwp_tablet_pad_dial_v2_api API + * See @ref iface_zwp_tablet_pad_dial_v2. + */ +/** + * @defgroup iface_zwp_tablet_pad_dial_v2 The zwp_tablet_pad_dial_v2 interface + * + * A rotary control, e.g. a dial or a wheel. + * + * Events on a dial are logically grouped by the zwp_tablet_pad_dial_v2.frame + * event. + */ +extern const struct wl_interface zwp_tablet_pad_dial_v2_interface; +#endif + +#define ZWP_TABLET_MANAGER_V2_GET_TABLET_SEAT 0 +#define ZWP_TABLET_MANAGER_V2_DESTROY 1 + + +/** + * @ingroup iface_zwp_tablet_manager_v2 + */ +#define ZWP_TABLET_MANAGER_V2_GET_TABLET_SEAT_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_manager_v2 + */ +#define ZWP_TABLET_MANAGER_V2_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_tablet_manager_v2 */ +static inline void +zwp_tablet_manager_v2_set_user_data(struct zwp_tablet_manager_v2 *zwp_tablet_manager_v2, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_tablet_manager_v2, user_data); +} + +/** @ingroup iface_zwp_tablet_manager_v2 */ +static inline void * +zwp_tablet_manager_v2_get_user_data(struct zwp_tablet_manager_v2 *zwp_tablet_manager_v2) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_tablet_manager_v2); +} + +static inline uint32_t +zwp_tablet_manager_v2_get_version(struct zwp_tablet_manager_v2 *zwp_tablet_manager_v2) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_tablet_manager_v2); +} + +/** + * @ingroup iface_zwp_tablet_manager_v2 + * + * Get the zwp_tablet_seat_v2 object for the given seat. This object + * provides access to all graphics tablets in this seat. + */ +static inline struct zwp_tablet_seat_v2 * +zwp_tablet_manager_v2_get_tablet_seat(struct zwp_tablet_manager_v2 *zwp_tablet_manager_v2, struct wl_seat *seat) +{ + struct wl_proxy *tablet_seat; + + tablet_seat = wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_manager_v2, + ZWP_TABLET_MANAGER_V2_GET_TABLET_SEAT, &zwp_tablet_seat_v2_interface, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_manager_v2), 0, NULL, seat); + + return (struct zwp_tablet_seat_v2 *) tablet_seat; +} + +/** + * @ingroup iface_zwp_tablet_manager_v2 + * + * Destroy the zwp_tablet_manager_v2 object. Objects created from this + * object are unaffected and should be destroyed separately. + */ +static inline void +zwp_tablet_manager_v2_destroy(struct zwp_tablet_manager_v2 *zwp_tablet_manager_v2) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_manager_v2, + ZWP_TABLET_MANAGER_V2_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_manager_v2), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_zwp_tablet_seat_v2 + * @struct zwp_tablet_seat_v2_listener + */ +struct zwp_tablet_seat_v2_listener { + /** + * new device notification + * + * This event is sent whenever a new tablet becomes available on + * this seat. This event only provides the object id of the tablet, + * any static information about the tablet (device name, vid/pid, + * etc.) is sent through the zwp_tablet_v2 interface. + * @param id the newly added graphics tablet + */ + void (*tablet_added)(void *data, + struct zwp_tablet_seat_v2 *zwp_tablet_seat_v2, + struct zwp_tablet_v2 *id); + /** + * a new tool has been used with a tablet + * + * This event is sent whenever a tool that has not previously + * been used with a tablet comes into use. This event only provides + * the object id of the tool; any static information about the tool + * (capabilities, type, etc.) is sent through the + * zwp_tablet_tool_v2 interface. + * @param id the newly added tablet tool + */ + void (*tool_added)(void *data, + struct zwp_tablet_seat_v2 *zwp_tablet_seat_v2, + struct zwp_tablet_tool_v2 *id); + /** + * new pad notification + * + * This event is sent whenever a new pad is known to the system. + * Typically, pads are physically attached to tablets and a + * pad_added event is sent immediately after the + * zwp_tablet_seat_v2.tablet_added. However, some standalone pad + * devices logically attach to tablets at runtime, and the client + * must wait for zwp_tablet_pad_v2.enter to know the tablet a pad + * is attached to. + * + * This event only provides the object id of the pad. All further + * features (buttons, strips, rings) are sent through the + * zwp_tablet_pad_v2 interface. + * @param id the newly added pad + */ + void (*pad_added)(void *data, + struct zwp_tablet_seat_v2 *zwp_tablet_seat_v2, + struct zwp_tablet_pad_v2 *id); +}; + +/** + * @ingroup iface_zwp_tablet_seat_v2 + */ +static inline int +zwp_tablet_seat_v2_add_listener(struct zwp_tablet_seat_v2 *zwp_tablet_seat_v2, + const struct zwp_tablet_seat_v2_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zwp_tablet_seat_v2, + (void (**)(void)) listener, data); +} + +#define ZWP_TABLET_SEAT_V2_DESTROY 0 + +/** + * @ingroup iface_zwp_tablet_seat_v2 + */ +#define ZWP_TABLET_SEAT_V2_TABLET_ADDED_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_seat_v2 + */ +#define ZWP_TABLET_SEAT_V2_TOOL_ADDED_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_seat_v2 + */ +#define ZWP_TABLET_SEAT_V2_PAD_ADDED_SINCE_VERSION 1 + +/** + * @ingroup iface_zwp_tablet_seat_v2 + */ +#define ZWP_TABLET_SEAT_V2_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_tablet_seat_v2 */ +static inline void +zwp_tablet_seat_v2_set_user_data(struct zwp_tablet_seat_v2 *zwp_tablet_seat_v2, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_tablet_seat_v2, user_data); +} + +/** @ingroup iface_zwp_tablet_seat_v2 */ +static inline void * +zwp_tablet_seat_v2_get_user_data(struct zwp_tablet_seat_v2 *zwp_tablet_seat_v2) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_tablet_seat_v2); +} + +static inline uint32_t +zwp_tablet_seat_v2_get_version(struct zwp_tablet_seat_v2 *zwp_tablet_seat_v2) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_tablet_seat_v2); +} + +/** + * @ingroup iface_zwp_tablet_seat_v2 + * + * Destroy the zwp_tablet_seat_v2 object. Objects created from this + * object are unaffected and should be destroyed separately. + */ +static inline void +zwp_tablet_seat_v2_destroy(struct zwp_tablet_seat_v2 *zwp_tablet_seat_v2) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_seat_v2, + ZWP_TABLET_SEAT_V2_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_seat_v2), WL_MARSHAL_FLAG_DESTROY); +} + +#ifndef ZWP_TABLET_TOOL_V2_TYPE_ENUM +#define ZWP_TABLET_TOOL_V2_TYPE_ENUM +/** + * @ingroup iface_zwp_tablet_tool_v2 + * a physical tool type + * + * Describes the physical type of a tool. The physical type of a tool + * generally defines its base usage. + * + * The mouse tool represents a mouse-shaped tool that is not a relative + * device but bound to the tablet's surface, providing absolute + * coordinates. + * + * The lens tool is a mouse-shaped tool with an attached lens to + * provide precision focus. + */ +enum zwp_tablet_tool_v2_type { + /** + * Pen + */ + ZWP_TABLET_TOOL_V2_TYPE_PEN = 0x140, + /** + * Eraser + */ + ZWP_TABLET_TOOL_V2_TYPE_ERASER = 0x141, + /** + * Brush + */ + ZWP_TABLET_TOOL_V2_TYPE_BRUSH = 0x142, + /** + * Pencil + */ + ZWP_TABLET_TOOL_V2_TYPE_PENCIL = 0x143, + /** + * Airbrush + */ + ZWP_TABLET_TOOL_V2_TYPE_AIRBRUSH = 0x144, + /** + * Finger + */ + ZWP_TABLET_TOOL_V2_TYPE_FINGER = 0x145, + /** + * Mouse + */ + ZWP_TABLET_TOOL_V2_TYPE_MOUSE = 0x146, + /** + * Lens + */ + ZWP_TABLET_TOOL_V2_TYPE_LENS = 0x147, +}; +#endif /* ZWP_TABLET_TOOL_V2_TYPE_ENUM */ + +#ifndef ZWP_TABLET_TOOL_V2_CAPABILITY_ENUM +#define ZWP_TABLET_TOOL_V2_CAPABILITY_ENUM +/** + * @ingroup iface_zwp_tablet_tool_v2 + * capability flags for a tool + * + * Describes extra capabilities on a tablet. + * + * Any tool must provide x and y values, extra axes are + * device-specific. + */ +enum zwp_tablet_tool_v2_capability { + /** + * Tilt axes + */ + ZWP_TABLET_TOOL_V2_CAPABILITY_TILT = 1, + /** + * Pressure axis + */ + ZWP_TABLET_TOOL_V2_CAPABILITY_PRESSURE = 2, + /** + * Distance axis + */ + ZWP_TABLET_TOOL_V2_CAPABILITY_DISTANCE = 3, + /** + * Z-rotation axis + */ + ZWP_TABLET_TOOL_V2_CAPABILITY_ROTATION = 4, + /** + * Slider axis + */ + ZWP_TABLET_TOOL_V2_CAPABILITY_SLIDER = 5, + /** + * Wheel axis + */ + ZWP_TABLET_TOOL_V2_CAPABILITY_WHEEL = 6, +}; +#endif /* ZWP_TABLET_TOOL_V2_CAPABILITY_ENUM */ + +#ifndef ZWP_TABLET_TOOL_V2_BUTTON_STATE_ENUM +#define ZWP_TABLET_TOOL_V2_BUTTON_STATE_ENUM +/** + * @ingroup iface_zwp_tablet_tool_v2 + * physical button state + * + * Describes the physical state of a button that produced the button event. + */ +enum zwp_tablet_tool_v2_button_state { + /** + * button is not pressed + */ + ZWP_TABLET_TOOL_V2_BUTTON_STATE_RELEASED = 0, + /** + * button is pressed + */ + ZWP_TABLET_TOOL_V2_BUTTON_STATE_PRESSED = 1, +}; +#endif /* ZWP_TABLET_TOOL_V2_BUTTON_STATE_ENUM */ + +#ifndef ZWP_TABLET_TOOL_V2_ERROR_ENUM +#define ZWP_TABLET_TOOL_V2_ERROR_ENUM +enum zwp_tablet_tool_v2_error { + /** + * given wl_surface has another role + */ + ZWP_TABLET_TOOL_V2_ERROR_ROLE = 0, +}; +#endif /* ZWP_TABLET_TOOL_V2_ERROR_ENUM */ + +/** + * @ingroup iface_zwp_tablet_tool_v2 + * @struct zwp_tablet_tool_v2_listener + */ +struct zwp_tablet_tool_v2_listener { + /** + * tool type + * + * The tool type is the high-level type of the tool and usually + * decides the interaction expected from this tool. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_tool_v2.done event. + * @param tool_type the physical tool type + */ + void (*type)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + uint32_t tool_type); + /** + * unique hardware serial number of the tool + * + * If the physical tool can be identified by a unique 64-bit + * serial number, this event notifies the client of this serial + * number. + * + * If multiple tablets are available in the same seat and the tool + * is uniquely identifiable by the serial number, that tool may + * move between tablets. + * + * Otherwise, if the tool has no serial number and this event is + * missing, the tool is tied to the tablet it first comes into + * proximity with. Even if the physical tool is used on multiple + * tablets, separate zwp_tablet_tool_v2 objects will be created, + * one per tablet. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_tool_v2.done event. + * @param hardware_serial_hi the unique serial number of the tool, most significant bits + * @param hardware_serial_lo the unique serial number of the tool, least significant bits + */ + void (*hardware_serial)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + uint32_t hardware_serial_hi, + uint32_t hardware_serial_lo); + /** + * hardware id notification in Wacom's format + * + * This event notifies the client of a hardware id available on + * this tool. + * + * The hardware id is a device-specific 64-bit id that provides + * extra information about the tool in use, beyond the wl_tool.type + * enumeration. The format of the id is specific to tablets made by + * Wacom Inc. For example, the hardware id of a Wacom Grip Pen (a + * stylus) is 0x802. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_tool_v2.done event. + * @param hardware_id_hi the hardware id, most significant bits + * @param hardware_id_lo the hardware id, least significant bits + */ + void (*hardware_id_wacom)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + uint32_t hardware_id_hi, + uint32_t hardware_id_lo); + /** + * tool capability notification + * + * This event notifies the client of any capabilities of this + * tool, beyond the main set of x/y axes and tip up/down detection. + * + * One event is sent for each extra capability available on this + * tool. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_tool_v2.done event. + * @param capability the capability + */ + void (*capability)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + uint32_t capability); + /** + * tool description events sequence complete + * + * This event signals the end of the initial burst of descriptive + * events. A client may consider the static description of the tool + * to be complete and finalize initialization of the tool. + */ + void (*done)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2); + /** + * tool removed + * + * This event is sent when the tool is removed from the system + * and will send no further events. Should the physical tool come + * back into proximity later, a new zwp_tablet_tool_v2 object will + * be created. + * + * It is compositor-dependent when a tool is removed. A compositor + * may remove a tool on proximity out, tablet removal or any other + * reason. A compositor may also keep a tool alive until shutdown. + * + * If the tool is currently in proximity, a proximity_out event + * will be sent before the removed event. See + * zwp_tablet_tool_v2.proximity_out for the handling of any buttons + * logically down. + * + * When this event is received, the client must + * zwp_tablet_tool_v2.destroy the object. + */ + void (*removed)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2); + /** + * proximity in event + * + * Notification that this tool is focused on a certain surface. + * + * This event can be received when the tool has moved from one + * surface to another, or when the tool has come back into + * proximity above the surface. + * + * If any button is logically down when the tool comes into + * proximity, the respective button event is sent after the + * proximity_in event but within the same frame as the proximity_in + * event. + * @param tablet The tablet the tool is in proximity of + * @param surface The current surface the tablet tool is over + */ + void (*proximity_in)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + uint32_t serial, + struct zwp_tablet_v2 *tablet, + struct wl_surface *surface); + /** + * proximity out event + * + * Notification that this tool has either left proximity, or is + * no longer focused on a certain surface. + * + * When the tablet tool leaves proximity of the tablet, button + * release events are sent for each button that was held down at + * the time of leaving proximity. These events are sent before the + * proximity_out event but within the same zwp_tablet_v2.frame. + * + * If the tool stays within proximity of the tablet, but the focus + * changes from one surface to another, a button release event may + * not be sent until the button is actually released or the tool + * leaves the proximity of the tablet. + */ + void (*proximity_out)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2); + /** + * tablet tool is making contact + * + * Sent whenever the tablet tool comes in contact with the + * surface of the tablet. + * + * If the tool is already in contact with the tablet when entering + * the input region, the client owning said region will receive a + * zwp_tablet_v2.proximity_in event, followed by a + * zwp_tablet_v2.down event and a zwp_tablet_v2.frame event. + * + * Note that this event describes logical contact, not physical + * contact. On some devices, a compositor may not consider a tool + * in logical contact until a minimum physical pressure threshold + * is exceeded. + */ + void (*down)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + uint32_t serial); + /** + * tablet tool is no longer making contact + * + * Sent whenever the tablet tool stops making contact with the + * surface of the tablet, or when the tablet tool moves out of the + * input region and the compositor grab (if any) is dismissed. + * + * If the tablet tool moves out of the input region while in + * contact with the surface of the tablet and the compositor does + * not have an ongoing grab on the surface, the client owning said + * region will receive a zwp_tablet_v2.up event, followed by a + * zwp_tablet_v2.proximity_out event and a zwp_tablet_v2.frame + * event. If the compositor has an ongoing grab on this device, + * this event sequence is sent whenever the grab is dismissed in + * the future. + * + * Note that this event describes logical contact, not physical + * contact. On some devices, a compositor may not consider a tool + * out of logical contact until physical pressure falls below a + * specific threshold. + */ + void (*up)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2); + /** + * motion event + * + * Sent whenever a tablet tool moves. + * @param x surface-local x coordinate + * @param y surface-local y coordinate + */ + void (*motion)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + wl_fixed_t x, + wl_fixed_t y); + /** + * pressure change event + * + * Sent whenever the pressure axis on a tool changes. The value + * of this event is normalized to a value between 0 and 65535. + * + * Note that pressure may be nonzero even when a tool is not in + * logical contact. See the down and up events for more details. + * @param pressure The current pressure value + */ + void (*pressure)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + uint32_t pressure); + /** + * distance change event + * + * Sent whenever the distance axis on a tool changes. The value + * of this event is normalized to a value between 0 and 65535. + * + * Note that distance may be nonzero even when a tool is not in + * logical contact. See the down and up events for more details. + * @param distance The current distance value + */ + void (*distance)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + uint32_t distance); + /** + * tilt change event + * + * Sent whenever one or both of the tilt axes on a tool change. + * Each tilt value is in degrees, relative to the z-axis of the + * tablet. The angle is positive when the top of a tool tilts along + * the positive x or y axis. + * @param tilt_x The current value of the X tilt axis + * @param tilt_y The current value of the Y tilt axis + */ + void (*tilt)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + wl_fixed_t tilt_x, + wl_fixed_t tilt_y); + /** + * z-rotation change event + * + * Sent whenever the z-rotation axis on the tool changes. The + * rotation value is in degrees clockwise from the tool's logical + * neutral position. + * @param degrees The current rotation of the Z axis + */ + void (*rotation)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + wl_fixed_t degrees); + /** + * Slider position change event + * + * Sent whenever the slider position on the tool changes. The + * value is normalized between -65535 and 65535, with 0 as the + * logical neutral position of the slider. + * + * The slider is available on e.g. the Wacom Airbrush tool. + * @param position The current position of slider + */ + void (*slider)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + int32_t position); + /** + * Wheel delta event + * + * Sent whenever the wheel on the tool emits an event. This event + * contains two values for the same axis change. The degrees value + * is in the same orientation as the wl_pointer.vertical_scroll + * axis. The clicks value is in discrete logical clicks of the + * mouse wheel. This value may be zero if the movement of the wheel + * was less than one logical click. + * + * Clients should choose either value and avoid mixing degrees and + * clicks. The compositor may accumulate values smaller than a + * logical click and emulate click events when a certain threshold + * is met. Thus, zwp_tablet_tool_v2.wheel events with non-zero + * clicks values may have different degrees values. + * @param degrees The wheel delta in degrees + * @param clicks The wheel delta in discrete clicks + */ + void (*wheel)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + wl_fixed_t degrees, + int32_t clicks); + /** + * button event + * + * Sent whenever a button on the tool is pressed or released. + * + * If a button is held down when the tool moves in or out of + * proximity, button events are generated by the compositor. See + * zwp_tablet_tool_v2.proximity_in and + * zwp_tablet_tool_v2.proximity_out for details. + * @param button The button whose state has changed + * @param state Whether the button was pressed or released + */ + void (*button)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + uint32_t serial, + uint32_t button, + uint32_t state); + /** + * frame event + * + * Marks the end of a series of axis and/or button updates from + * the tablet. The Wayland protocol requires axis updates to be + * sent sequentially, however all events within a frame should be + * considered one hardware event. + * @param time The time of the event with millisecond granularity + */ + void (*frame)(void *data, + struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + uint32_t time); +}; + +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +static inline int +zwp_tablet_tool_v2_add_listener(struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, + const struct zwp_tablet_tool_v2_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zwp_tablet_tool_v2, + (void (**)(void)) listener, data); +} + +#define ZWP_TABLET_TOOL_V2_SET_CURSOR 0 +#define ZWP_TABLET_TOOL_V2_DESTROY 1 + +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_TYPE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_HARDWARE_SERIAL_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_HARDWARE_ID_WACOM_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_CAPABILITY_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_DONE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_REMOVED_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_PROXIMITY_IN_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_PROXIMITY_OUT_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_DOWN_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_UP_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_MOTION_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_PRESSURE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_DISTANCE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_TILT_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_ROTATION_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_SLIDER_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_WHEEL_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_BUTTON_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_FRAME_SINCE_VERSION 1 + +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_SET_CURSOR_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_tool_v2 + */ +#define ZWP_TABLET_TOOL_V2_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_tablet_tool_v2 */ +static inline void +zwp_tablet_tool_v2_set_user_data(struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_tablet_tool_v2, user_data); +} + +/** @ingroup iface_zwp_tablet_tool_v2 */ +static inline void * +zwp_tablet_tool_v2_get_user_data(struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_tablet_tool_v2); +} + +static inline uint32_t +zwp_tablet_tool_v2_get_version(struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_tablet_tool_v2); +} + +/** + * @ingroup iface_zwp_tablet_tool_v2 + * + * Sets the surface of the cursor used for this tool on the given + * tablet. This request only takes effect if the tool is in proximity + * of one of the requesting client's surfaces or the surface parameter + * is the current pointer surface. If there was a previous surface set + * with this request it is replaced. If surface is NULL, the cursor + * image is hidden. + * + * The parameters hotspot_x and hotspot_y define the position of the + * pointer surface relative to the pointer location. Its top-left corner + * is always at (x, y) - (hotspot_x, hotspot_y), where (x, y) are the + * coordinates of the pointer location, in surface-local coordinates. + * + * On surface.attach requests to the pointer surface, hotspot_x and + * hotspot_y are decremented by the x and y parameters passed to the + * request. Attach must be confirmed by wl_surface.commit as usual. + * + * The hotspot can also be updated by passing the currently set pointer + * surface to this request with new values for hotspot_x and hotspot_y. + * + * The current and pending input regions of the wl_surface are cleared, + * and wl_surface.set_input_region is ignored until the wl_surface is no + * longer used as the cursor. When the use as a cursor ends, the current + * and pending input regions become undefined, and the wl_surface is + * unmapped. + * + * This request gives the surface the role of a zwp_tablet_tool_v2 cursor. A + * surface may only ever be used as the cursor surface for one + * zwp_tablet_tool_v2. If the surface already has another role or has + * previously been used as cursor surface for a different tool, a + * protocol error is raised. + */ +static inline void +zwp_tablet_tool_v2_set_cursor(struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2, uint32_t serial, struct wl_surface *surface, int32_t hotspot_x, int32_t hotspot_y) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_tool_v2, + ZWP_TABLET_TOOL_V2_SET_CURSOR, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_tool_v2), 0, serial, surface, hotspot_x, hotspot_y); +} + +/** + * @ingroup iface_zwp_tablet_tool_v2 + * + * This destroys the client's resource for this tool object. + */ +static inline void +zwp_tablet_tool_v2_destroy(struct zwp_tablet_tool_v2 *zwp_tablet_tool_v2) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_tool_v2, + ZWP_TABLET_TOOL_V2_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_tool_v2), WL_MARSHAL_FLAG_DESTROY); +} + +#ifndef ZWP_TABLET_V2_BUSTYPE_ENUM +#define ZWP_TABLET_V2_BUSTYPE_ENUM +/** + * @ingroup iface_zwp_tablet_v2 + * bus type + * + * Describes the bus types this tablet is connected to. + */ +enum zwp_tablet_v2_bustype { + /** + * USB + */ + ZWP_TABLET_V2_BUSTYPE_USB = 3, + /** + * Bluetooth + */ + ZWP_TABLET_V2_BUSTYPE_BLUETOOTH = 5, + /** + * Virtual + */ + ZWP_TABLET_V2_BUSTYPE_VIRTUAL = 6, + /** + * Serial + */ + ZWP_TABLET_V2_BUSTYPE_SERIAL = 17, + /** + * I2C + */ + ZWP_TABLET_V2_BUSTYPE_I2C = 24, +}; +#endif /* ZWP_TABLET_V2_BUSTYPE_ENUM */ + +/** + * @ingroup iface_zwp_tablet_v2 + * @struct zwp_tablet_v2_listener + */ +struct zwp_tablet_v2_listener { + /** + * tablet device name + * + * A descriptive name for the tablet device. + * + * If the device has no descriptive name, this event is not sent. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_v2.done event. + * @param name the device name + */ + void (*name)(void *data, + struct zwp_tablet_v2 *zwp_tablet_v2, + const char *name); + /** + * tablet device vendor/product id + * + * The vendor and product IDs for the tablet device. + * + * The interpretation of the id depends on the + * zwp_tablet_v2.bustype. Prior to version v2 of this protocol, the + * id was implied to be a USB vendor and product ID. If no + * zwp_tablet_v2.bustype is sent, the ID is to be interpreted as + * USB vendor and product ID. + * + * If the device has no vendor/product ID, this event is not sent. + * This can happen for virtual devices or non-USB devices, for + * instance. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_v2.done event. + * @param vid vendor id + * @param pid product id + */ + void (*id)(void *data, + struct zwp_tablet_v2 *zwp_tablet_v2, + uint32_t vid, + uint32_t pid); + /** + * path to the device + * + * A system-specific device path that indicates which device is + * behind this zwp_tablet_v2. This information may be used to + * gather additional information about the device, e.g. through + * libwacom. + * + * A device may have more than one device path. If so, multiple + * zwp_tablet_v2.path events are sent. A device may be emulated and + * not have a device path, and in that case this event will not be + * sent. + * + * The format of the path is unspecified, it may be a device node, + * a sysfs path, or some other identifier. It is up to the client + * to identify the string provided. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_v2.done event. + * @param path path to local device + */ + void (*path)(void *data, + struct zwp_tablet_v2 *zwp_tablet_v2, + const char *path); + /** + * tablet description events sequence complete + * + * This event is sent immediately to signal the end of the + * initial burst of descriptive events. A client may consider the + * static description of the tablet to be complete and finalize + * initialization of the tablet. + */ + void (*done)(void *data, + struct zwp_tablet_v2 *zwp_tablet_v2); + /** + * tablet removed event + * + * Sent when the tablet has been removed from the system. When a + * tablet is removed, some tools may be removed. + * + * When this event is received, the client must + * zwp_tablet_v2.destroy the object. + */ + void (*removed)(void *data, + struct zwp_tablet_v2 *zwp_tablet_v2); + /** + * tablet device bus type + * + * The bustype argument is one of the BUS_ defines in the Linux + * kernel's linux/input.h + * + * If the device has no known bustype or the bustype cannot be + * queried, this event is not sent. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_v2.done event. + * @param bustype bus type + * @since 2 + */ + void (*bustype)(void *data, + struct zwp_tablet_v2 *zwp_tablet_v2, + uint32_t bustype); +}; + +/** + * @ingroup iface_zwp_tablet_v2 + */ +static inline int +zwp_tablet_v2_add_listener(struct zwp_tablet_v2 *zwp_tablet_v2, + const struct zwp_tablet_v2_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zwp_tablet_v2, + (void (**)(void)) listener, data); +} + +#define ZWP_TABLET_V2_DESTROY 0 + +/** + * @ingroup iface_zwp_tablet_v2 + */ +#define ZWP_TABLET_V2_NAME_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_v2 + */ +#define ZWP_TABLET_V2_ID_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_v2 + */ +#define ZWP_TABLET_V2_PATH_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_v2 + */ +#define ZWP_TABLET_V2_DONE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_v2 + */ +#define ZWP_TABLET_V2_REMOVED_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_v2 + */ +#define ZWP_TABLET_V2_BUSTYPE_SINCE_VERSION 2 + +/** + * @ingroup iface_zwp_tablet_v2 + */ +#define ZWP_TABLET_V2_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_tablet_v2 */ +static inline void +zwp_tablet_v2_set_user_data(struct zwp_tablet_v2 *zwp_tablet_v2, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_tablet_v2, user_data); +} + +/** @ingroup iface_zwp_tablet_v2 */ +static inline void * +zwp_tablet_v2_get_user_data(struct zwp_tablet_v2 *zwp_tablet_v2) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_tablet_v2); +} + +static inline uint32_t +zwp_tablet_v2_get_version(struct zwp_tablet_v2 *zwp_tablet_v2) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_tablet_v2); +} + +/** + * @ingroup iface_zwp_tablet_v2 + * + * This destroys the client's resource for this tablet object. + */ +static inline void +zwp_tablet_v2_destroy(struct zwp_tablet_v2 *zwp_tablet_v2) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_v2, + ZWP_TABLET_V2_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_v2), WL_MARSHAL_FLAG_DESTROY); +} + +#ifndef ZWP_TABLET_PAD_RING_V2_SOURCE_ENUM +#define ZWP_TABLET_PAD_RING_V2_SOURCE_ENUM +/** + * @ingroup iface_zwp_tablet_pad_ring_v2 + * ring axis source + * + * Describes the source types for ring events. This indicates to the + * client how a ring event was physically generated; a client may + * adjust the user interface accordingly. For example, events + * from a "finger" source may trigger kinetic scrolling. + */ +enum zwp_tablet_pad_ring_v2_source { + /** + * finger + */ + ZWP_TABLET_PAD_RING_V2_SOURCE_FINGER = 1, +}; +#endif /* ZWP_TABLET_PAD_RING_V2_SOURCE_ENUM */ + +/** + * @ingroup iface_zwp_tablet_pad_ring_v2 + * @struct zwp_tablet_pad_ring_v2_listener + */ +struct zwp_tablet_pad_ring_v2_listener { + /** + * ring event source + * + * Source information for ring events. + * + * This event does not occur on its own. It is sent before a + * zwp_tablet_pad_ring_v2.frame event and carries the source + * information for all events within that frame. + * + * The source specifies how this event was generated. If the source + * is zwp_tablet_pad_ring_v2.source.finger, a + * zwp_tablet_pad_ring_v2.stop event will be sent when the user + * lifts the finger off the device. + * + * This event is optional. If the source is unknown for an + * interaction, no event is sent. + * @param source the event source + */ + void (*source)(void *data, + struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2, + uint32_t source); + /** + * angle changed + * + * Sent whenever the angle on a ring changes. + * + * The angle is provided in degrees clockwise from the logical + * north of the ring in the pad's current rotation. + * @param degrees the current angle in degrees + */ + void (*angle)(void *data, + struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2, + wl_fixed_t degrees); + /** + * interaction stopped + * + * Stop notification for ring events. + * + * For some zwp_tablet_pad_ring_v2.source types, a + * zwp_tablet_pad_ring_v2.stop event is sent to notify a client + * that the interaction with the ring has terminated. This enables + * the client to implement kinetic scrolling. See the + * zwp_tablet_pad_ring_v2.source documentation for information on + * when this event may be generated. + * + * Any zwp_tablet_pad_ring_v2.angle events with the same source + * after this event should be considered as the start of a new + * interaction. + */ + void (*stop)(void *data, + struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2); + /** + * end of a ring event sequence + * + * Indicates the end of a set of ring events that logically + * belong together. A client is expected to accumulate the data in + * all events within the frame before proceeding. + * + * All zwp_tablet_pad_ring_v2 events before a + * zwp_tablet_pad_ring_v2.frame event belong logically together. + * For example, on termination of a finger interaction on a ring + * the compositor will send a zwp_tablet_pad_ring_v2.source event, + * a zwp_tablet_pad_ring_v2.stop event and a + * zwp_tablet_pad_ring_v2.frame event. + * + * A zwp_tablet_pad_ring_v2.frame event is sent for every logical + * event group, even if the group only contains a single + * zwp_tablet_pad_ring_v2 event. Specifically, a client may get a + * sequence: angle, frame, angle, frame, etc. + * @param time timestamp with millisecond granularity + */ + void (*frame)(void *data, + struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2, + uint32_t time); +}; + +/** + * @ingroup iface_zwp_tablet_pad_ring_v2 + */ +static inline int +zwp_tablet_pad_ring_v2_add_listener(struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2, + const struct zwp_tablet_pad_ring_v2_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zwp_tablet_pad_ring_v2, + (void (**)(void)) listener, data); +} + +#define ZWP_TABLET_PAD_RING_V2_SET_FEEDBACK 0 +#define ZWP_TABLET_PAD_RING_V2_DESTROY 1 + +/** + * @ingroup iface_zwp_tablet_pad_ring_v2 + */ +#define ZWP_TABLET_PAD_RING_V2_SOURCE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_ring_v2 + */ +#define ZWP_TABLET_PAD_RING_V2_ANGLE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_ring_v2 + */ +#define ZWP_TABLET_PAD_RING_V2_STOP_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_ring_v2 + */ +#define ZWP_TABLET_PAD_RING_V2_FRAME_SINCE_VERSION 1 + +/** + * @ingroup iface_zwp_tablet_pad_ring_v2 + */ +#define ZWP_TABLET_PAD_RING_V2_SET_FEEDBACK_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_ring_v2 + */ +#define ZWP_TABLET_PAD_RING_V2_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_tablet_pad_ring_v2 */ +static inline void +zwp_tablet_pad_ring_v2_set_user_data(struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_tablet_pad_ring_v2, user_data); +} + +/** @ingroup iface_zwp_tablet_pad_ring_v2 */ +static inline void * +zwp_tablet_pad_ring_v2_get_user_data(struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_tablet_pad_ring_v2); +} + +static inline uint32_t +zwp_tablet_pad_ring_v2_get_version(struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_ring_v2); +} + +/** + * @ingroup iface_zwp_tablet_pad_ring_v2 + * + * Request that the compositor use the provided feedback string + * associated with this ring. This request should be issued immediately + * after a zwp_tablet_pad_group_v2.mode_switch event from the corresponding + * group is received, or whenever the ring is mapped to a different + * action. See zwp_tablet_pad_group_v2.mode_switch for more details. + * + * Clients are encouraged to provide context-aware descriptions for + * the actions associated with the ring; compositors may use this + * information to offer visual feedback about the button layout + * (eg. on-screen displays). + * + * The provided string 'description' is a UTF-8 encoded string to be + * associated with this ring, and is considered user-visible; general + * internationalization rules apply. + * + * The serial argument will be that of the last + * zwp_tablet_pad_group_v2.mode_switch event received for the group of this + * ring. Requests providing other serials than the most recent one will be + * ignored. + */ +static inline void +zwp_tablet_pad_ring_v2_set_feedback(struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2, const char *description, uint32_t serial) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_pad_ring_v2, + ZWP_TABLET_PAD_RING_V2_SET_FEEDBACK, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_ring_v2), 0, description, serial); +} + +/** + * @ingroup iface_zwp_tablet_pad_ring_v2 + * + * This destroys the client's resource for this ring object. + */ +static inline void +zwp_tablet_pad_ring_v2_destroy(struct zwp_tablet_pad_ring_v2 *zwp_tablet_pad_ring_v2) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_pad_ring_v2, + ZWP_TABLET_PAD_RING_V2_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_ring_v2), WL_MARSHAL_FLAG_DESTROY); +} + +#ifndef ZWP_TABLET_PAD_STRIP_V2_SOURCE_ENUM +#define ZWP_TABLET_PAD_STRIP_V2_SOURCE_ENUM +/** + * @ingroup iface_zwp_tablet_pad_strip_v2 + * strip axis source + * + * Describes the source types for strip events. This indicates to the + * client how a strip event was physically generated; a client may + * adjust the user interface accordingly. For example, events + * from a "finger" source may trigger kinetic scrolling. + */ +enum zwp_tablet_pad_strip_v2_source { + /** + * finger + */ + ZWP_TABLET_PAD_STRIP_V2_SOURCE_FINGER = 1, +}; +#endif /* ZWP_TABLET_PAD_STRIP_V2_SOURCE_ENUM */ + +/** + * @ingroup iface_zwp_tablet_pad_strip_v2 + * @struct zwp_tablet_pad_strip_v2_listener + */ +struct zwp_tablet_pad_strip_v2_listener { + /** + * strip event source + * + * Source information for strip events. + * + * This event does not occur on its own. It is sent before a + * zwp_tablet_pad_strip_v2.frame event and carries the source + * information for all events within that frame. + * + * The source specifies how this event was generated. If the source + * is zwp_tablet_pad_strip_v2.source.finger, a + * zwp_tablet_pad_strip_v2.stop event will be sent when the user + * lifts their finger off the device. + * + * This event is optional. If the source is unknown for an + * interaction, no event is sent. + * @param source the event source + */ + void (*source)(void *data, + struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2, + uint32_t source); + /** + * position changed + * + * Sent whenever the position on a strip changes. + * + * The position is normalized to a range of [0, 65535], the 0-value + * represents the top-most and/or left-most position of the strip + * in the pad's current rotation. + * @param position the current position + */ + void (*position)(void *data, + struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2, + uint32_t position); + /** + * interaction stopped + * + * Stop notification for strip events. + * + * For some zwp_tablet_pad_strip_v2.source types, a + * zwp_tablet_pad_strip_v2.stop event is sent to notify a client + * that the interaction with the strip has terminated. This enables + * the client to implement kinetic scrolling. See the + * zwp_tablet_pad_strip_v2.source documentation for information on + * when this event may be generated. + * + * Any zwp_tablet_pad_strip_v2.position events with the same source + * after this event should be considered as the start of a new + * interaction. + */ + void (*stop)(void *data, + struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2); + /** + * end of a strip event sequence + * + * Indicates the end of a set of events that represent one + * logical hardware strip event. A client is expected to accumulate + * the data in all events within the frame before proceeding. + * + * All zwp_tablet_pad_strip_v2 events before a + * zwp_tablet_pad_strip_v2.frame event belong logically together. + * For example, on termination of a finger interaction on a strip + * the compositor will send a zwp_tablet_pad_strip_v2.source event, + * a zwp_tablet_pad_strip_v2.stop event and a + * zwp_tablet_pad_strip_v2.frame event. + * + * A zwp_tablet_pad_strip_v2.frame event is sent for every logical + * event group, even if the group only contains a single + * zwp_tablet_pad_strip_v2 event. Specifically, a client may get a + * sequence: position, frame, position, frame, etc. + * @param time timestamp with millisecond granularity + */ + void (*frame)(void *data, + struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2, + uint32_t time); +}; + +/** + * @ingroup iface_zwp_tablet_pad_strip_v2 + */ +static inline int +zwp_tablet_pad_strip_v2_add_listener(struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2, + const struct zwp_tablet_pad_strip_v2_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zwp_tablet_pad_strip_v2, + (void (**)(void)) listener, data); +} + +#define ZWP_TABLET_PAD_STRIP_V2_SET_FEEDBACK 0 +#define ZWP_TABLET_PAD_STRIP_V2_DESTROY 1 + +/** + * @ingroup iface_zwp_tablet_pad_strip_v2 + */ +#define ZWP_TABLET_PAD_STRIP_V2_SOURCE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_strip_v2 + */ +#define ZWP_TABLET_PAD_STRIP_V2_POSITION_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_strip_v2 + */ +#define ZWP_TABLET_PAD_STRIP_V2_STOP_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_strip_v2 + */ +#define ZWP_TABLET_PAD_STRIP_V2_FRAME_SINCE_VERSION 1 + +/** + * @ingroup iface_zwp_tablet_pad_strip_v2 + */ +#define ZWP_TABLET_PAD_STRIP_V2_SET_FEEDBACK_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_strip_v2 + */ +#define ZWP_TABLET_PAD_STRIP_V2_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_tablet_pad_strip_v2 */ +static inline void +zwp_tablet_pad_strip_v2_set_user_data(struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_tablet_pad_strip_v2, user_data); +} + +/** @ingroup iface_zwp_tablet_pad_strip_v2 */ +static inline void * +zwp_tablet_pad_strip_v2_get_user_data(struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_tablet_pad_strip_v2); +} + +static inline uint32_t +zwp_tablet_pad_strip_v2_get_version(struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_strip_v2); +} + +/** + * @ingroup iface_zwp_tablet_pad_strip_v2 + * + * Requests the compositor to use the provided feedback string + * associated with this strip. This request should be issued immediately + * after a zwp_tablet_pad_group_v2.mode_switch event from the corresponding + * group is received, or whenever the strip is mapped to a different + * action. See zwp_tablet_pad_group_v2.mode_switch for more details. + * + * Clients are encouraged to provide context-aware descriptions for + * the actions associated with the strip, and compositors may use this + * information to offer visual feedback about the button layout + * (eg. on-screen displays). + * + * The provided string 'description' is a UTF-8 encoded string to be + * associated with this ring, and is considered user-visible; general + * internationalization rules apply. + * + * The serial argument will be that of the last + * zwp_tablet_pad_group_v2.mode_switch event received for the group of this + * strip. Requests providing other serials than the most recent one will be + * ignored. + */ +static inline void +zwp_tablet_pad_strip_v2_set_feedback(struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2, const char *description, uint32_t serial) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_pad_strip_v2, + ZWP_TABLET_PAD_STRIP_V2_SET_FEEDBACK, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_strip_v2), 0, description, serial); +} + +/** + * @ingroup iface_zwp_tablet_pad_strip_v2 + * + * This destroys the client's resource for this strip object. + */ +static inline void +zwp_tablet_pad_strip_v2_destroy(struct zwp_tablet_pad_strip_v2 *zwp_tablet_pad_strip_v2) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_pad_strip_v2, + ZWP_TABLET_PAD_STRIP_V2_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_strip_v2), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_zwp_tablet_pad_group_v2 + * @struct zwp_tablet_pad_group_v2_listener + */ +struct zwp_tablet_pad_group_v2_listener { + /** + * buttons announced + * + * Sent on zwp_tablet_pad_group_v2 initialization to announce the + * available buttons in the group. Button indices start at 0, a + * button may only be in one group at a time. + * + * This event is first sent in the initial burst of events before + * the zwp_tablet_pad_group_v2.done event. + * + * Some buttons are reserved by the compositor. These buttons may + * not be assigned to any zwp_tablet_pad_group_v2. Compositors may + * broadcast this event in the case of changes to the mapping of + * these reserved buttons. If the compositor happens to reserve all + * buttons in a group, this event will be sent with an empty array. + * @param buttons buttons in this group + */ + void (*buttons)(void *data, + struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2, + struct wl_array *buttons); + /** + * ring announced + * + * Sent on zwp_tablet_pad_group_v2 initialization to announce + * available rings. One event is sent for each ring available on + * this pad group. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_pad_group_v2.done event. + */ + void (*ring)(void *data, + struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2, + struct zwp_tablet_pad_ring_v2 *ring); + /** + * strip announced + * + * Sent on zwp_tablet_pad_v2 initialization to announce available + * strips. One event is sent for each strip available on this pad + * group. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_pad_group_v2.done event. + */ + void (*strip)(void *data, + struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2, + struct zwp_tablet_pad_strip_v2 *strip); + /** + * mode-switch ability announced + * + * Sent on zwp_tablet_pad_group_v2 initialization to announce + * that the pad group may switch between modes. A client may use a + * mode to store a specific configuration for buttons, rings and + * strips and use the zwp_tablet_pad_group_v2.mode_switch event to + * toggle between these configurations. Mode indices start at 0. + * + * Switching modes is compositor-dependent. See the + * zwp_tablet_pad_group_v2.mode_switch event for more details. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_pad_group_v2.done event. This event is only sent when + * more than one mode is available. + * @param modes the number of modes + */ + void (*modes)(void *data, + struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2, + uint32_t modes); + /** + * tablet group description events sequence complete + * + * This event is sent immediately to signal the end of the + * initial burst of descriptive events. A client may consider the + * static description of the tablet to be complete and finalize + * initialization of the tablet group. + */ + void (*done)(void *data, + struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2); + /** + * mode switch event + * + * Notification that the mode was switched. + * + * A mode applies to all buttons, rings, strips and dials in a + * group simultaneously, but a client is not required to assign + * different actions for each mode. For example, a client may have + * mode-specific button mappings but map the ring to vertical + * scrolling in all modes. Mode indices start at 0. + * + * Switching modes is compositor-dependent. The compositor may + * provide visual cues to the user about the mode, e.g. by toggling + * LEDs on the tablet device. Mode-switching may be + * software-controlled or controlled by one or more physical + * buttons. For example, on a Wacom Intuos Pro, the button inside + * the ring may be assigned to switch between modes. + * + * The compositor will also send this event after + * zwp_tablet_pad_v2.enter on each group in order to notify of the + * current mode. Groups that only feature one mode will use mode=0 + * when emitting this event. + * + * If a button action in the new mode differs from the action in + * the previous mode, the client should immediately issue a + * zwp_tablet_pad_v2.set_feedback request for each changed button. + * + * If a ring, strip or dial action in the new mode differs from the + * action in the previous mode, the client should immediately issue + * a zwp_tablet_ring_v2.set_feedback, + * zwp_tablet_strip_v2.set_feedback or + * zwp_tablet_dial_v2.set_feedback request for each changed ring, + * strip or dial. + * @param time the time of the event with millisecond granularity + * @param mode the new mode of the pad + */ + void (*mode_switch)(void *data, + struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2, + uint32_t time, + uint32_t serial, + uint32_t mode); + /** + * dial announced + * + * Sent on zwp_tablet_pad_v2 initialization to announce available + * dials. One event is sent for each dial available on this pad + * group. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_pad_group_v2.done event. + * @since 2 + */ + void (*dial)(void *data, + struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2, + struct zwp_tablet_pad_dial_v2 *dial); +}; + +/** + * @ingroup iface_zwp_tablet_pad_group_v2 + */ +static inline int +zwp_tablet_pad_group_v2_add_listener(struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2, + const struct zwp_tablet_pad_group_v2_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zwp_tablet_pad_group_v2, + (void (**)(void)) listener, data); +} + +#define ZWP_TABLET_PAD_GROUP_V2_DESTROY 0 + +/** + * @ingroup iface_zwp_tablet_pad_group_v2 + */ +#define ZWP_TABLET_PAD_GROUP_V2_BUTTONS_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_group_v2 + */ +#define ZWP_TABLET_PAD_GROUP_V2_RING_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_group_v2 + */ +#define ZWP_TABLET_PAD_GROUP_V2_STRIP_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_group_v2 + */ +#define ZWP_TABLET_PAD_GROUP_V2_MODES_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_group_v2 + */ +#define ZWP_TABLET_PAD_GROUP_V2_DONE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_group_v2 + */ +#define ZWP_TABLET_PAD_GROUP_V2_MODE_SWITCH_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_group_v2 + */ +#define ZWP_TABLET_PAD_GROUP_V2_DIAL_SINCE_VERSION 2 + +/** + * @ingroup iface_zwp_tablet_pad_group_v2 + */ +#define ZWP_TABLET_PAD_GROUP_V2_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_tablet_pad_group_v2 */ +static inline void +zwp_tablet_pad_group_v2_set_user_data(struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_tablet_pad_group_v2, user_data); +} + +/** @ingroup iface_zwp_tablet_pad_group_v2 */ +static inline void * +zwp_tablet_pad_group_v2_get_user_data(struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_tablet_pad_group_v2); +} + +static inline uint32_t +zwp_tablet_pad_group_v2_get_version(struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_group_v2); +} + +/** + * @ingroup iface_zwp_tablet_pad_group_v2 + * + * Destroy the zwp_tablet_pad_group_v2 object. Objects created from this object + * are unaffected and should be destroyed separately. + */ +static inline void +zwp_tablet_pad_group_v2_destroy(struct zwp_tablet_pad_group_v2 *zwp_tablet_pad_group_v2) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_pad_group_v2, + ZWP_TABLET_PAD_GROUP_V2_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_group_v2), WL_MARSHAL_FLAG_DESTROY); +} + +#ifndef ZWP_TABLET_PAD_V2_BUTTON_STATE_ENUM +#define ZWP_TABLET_PAD_V2_BUTTON_STATE_ENUM +/** + * @ingroup iface_zwp_tablet_pad_v2 + * physical button state + * + * Describes the physical state of a button that caused the button + * event. + */ +enum zwp_tablet_pad_v2_button_state { + /** + * the button is not pressed + */ + ZWP_TABLET_PAD_V2_BUTTON_STATE_RELEASED = 0, + /** + * the button is pressed + */ + ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED = 1, +}; +#endif /* ZWP_TABLET_PAD_V2_BUTTON_STATE_ENUM */ + +/** + * @ingroup iface_zwp_tablet_pad_v2 + * @struct zwp_tablet_pad_v2_listener + */ +struct zwp_tablet_pad_v2_listener { + /** + * group announced + * + * Sent on zwp_tablet_pad_v2 initialization to announce available + * groups. One event is sent for each pad group available. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_pad_v2.done event. At least one group will be + * announced. + */ + void (*group)(void *data, + struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2, + struct zwp_tablet_pad_group_v2 *pad_group); + /** + * path to the device + * + * A system-specific device path that indicates which device is + * behind this zwp_tablet_pad_v2. This information may be used to + * gather additional information about the device, e.g. through + * libwacom. + * + * The format of the path is unspecified, it may be a device node, + * a sysfs path, or some other identifier. It is up to the client + * to identify the string provided. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_pad_v2.done event. + * @param path path to local device + */ + void (*path)(void *data, + struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2, + const char *path); + /** + * buttons announced + * + * Sent on zwp_tablet_pad_v2 initialization to announce the + * available buttons. + * + * This event is sent in the initial burst of events before the + * zwp_tablet_pad_v2.done event. This event is only sent when at + * least one button is available. + * @param buttons the number of buttons + */ + void (*buttons)(void *data, + struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2, + uint32_t buttons); + /** + * pad description event sequence complete + * + * This event signals the end of the initial burst of descriptive + * events. A client may consider the static description of the pad + * to be complete and finalize initialization of the pad. + */ + void (*done)(void *data, + struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2); + /** + * physical button state + * + * Sent whenever the physical state of a button changes. + * @param time the time of the event with millisecond granularity + * @param button the index of the button that changed state + */ + void (*button)(void *data, + struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2, + uint32_t time, + uint32_t button, + uint32_t state); + /** + * enter event + * + * Notification that this pad is focused on the specified + * surface. + * @param serial serial number of the enter event + * @param tablet the tablet the pad is attached to + * @param surface surface the pad is focused on + */ + void (*enter)(void *data, + struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2, + uint32_t serial, + struct zwp_tablet_v2 *tablet, + struct wl_surface *surface); + /** + * leave event + * + * Notification that this pad is no longer focused on the + * specified surface. + * @param serial serial number of the leave event + * @param surface surface the pad is no longer focused on + */ + void (*leave)(void *data, + struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2, + uint32_t serial, + struct wl_surface *surface); + /** + * pad removed event + * + * Sent when the pad has been removed from the system. When a + * tablet is removed its pad(s) will be removed too. + * + * When this event is received, the client must destroy all rings, + * strips and groups that were offered by this pad, and issue + * zwp_tablet_pad_v2.destroy the pad itself. + */ + void (*removed)(void *data, + struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2); +}; + +/** + * @ingroup iface_zwp_tablet_pad_v2 + */ +static inline int +zwp_tablet_pad_v2_add_listener(struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2, + const struct zwp_tablet_pad_v2_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zwp_tablet_pad_v2, + (void (**)(void)) listener, data); +} + +#define ZWP_TABLET_PAD_V2_SET_FEEDBACK 0 +#define ZWP_TABLET_PAD_V2_DESTROY 1 + +/** + * @ingroup iface_zwp_tablet_pad_v2 + */ +#define ZWP_TABLET_PAD_V2_GROUP_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_v2 + */ +#define ZWP_TABLET_PAD_V2_PATH_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_v2 + */ +#define ZWP_TABLET_PAD_V2_BUTTONS_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_v2 + */ +#define ZWP_TABLET_PAD_V2_DONE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_v2 + */ +#define ZWP_TABLET_PAD_V2_BUTTON_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_v2 + */ +#define ZWP_TABLET_PAD_V2_ENTER_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_v2 + */ +#define ZWP_TABLET_PAD_V2_LEAVE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_v2 + */ +#define ZWP_TABLET_PAD_V2_REMOVED_SINCE_VERSION 1 + +/** + * @ingroup iface_zwp_tablet_pad_v2 + */ +#define ZWP_TABLET_PAD_V2_SET_FEEDBACK_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_v2 + */ +#define ZWP_TABLET_PAD_V2_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_tablet_pad_v2 */ +static inline void +zwp_tablet_pad_v2_set_user_data(struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_tablet_pad_v2, user_data); +} + +/** @ingroup iface_zwp_tablet_pad_v2 */ +static inline void * +zwp_tablet_pad_v2_get_user_data(struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_tablet_pad_v2); +} + +static inline uint32_t +zwp_tablet_pad_v2_get_version(struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_v2); +} + +/** + * @ingroup iface_zwp_tablet_pad_v2 + * + * Requests the compositor to use the provided feedback string + * associated with this button. This request should be issued immediately + * after a zwp_tablet_pad_group_v2.mode_switch event from the corresponding + * group is received, or whenever a button is mapped to a different + * action. See zwp_tablet_pad_group_v2.mode_switch for more details. + * + * Clients are encouraged to provide context-aware descriptions for + * the actions associated with each button, and compositors may use + * this information to offer visual feedback on the button layout + * (e.g. on-screen displays). + * + * Button indices start at 0. Setting the feedback string on a button + * that is reserved by the compositor (i.e. not belonging to any + * zwp_tablet_pad_group_v2) does not generate an error but the compositor + * is free to ignore the request. + * + * The provided string 'description' is a UTF-8 encoded string to be + * associated with this ring, and is considered user-visible; general + * internationalization rules apply. + * + * The serial argument will be that of the last + * zwp_tablet_pad_group_v2.mode_switch event received for the group of this + * button. Requests providing other serials than the most recent one will + * be ignored. + */ +static inline void +zwp_tablet_pad_v2_set_feedback(struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2, uint32_t button, const char *description, uint32_t serial) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_pad_v2, + ZWP_TABLET_PAD_V2_SET_FEEDBACK, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_v2), 0, button, description, serial); +} + +/** + * @ingroup iface_zwp_tablet_pad_v2 + * + * Destroy the zwp_tablet_pad_v2 object. Objects created from this object + * are unaffected and should be destroyed separately. + */ +static inline void +zwp_tablet_pad_v2_destroy(struct zwp_tablet_pad_v2 *zwp_tablet_pad_v2) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_pad_v2, + ZWP_TABLET_PAD_V2_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_v2), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_zwp_tablet_pad_dial_v2 + * @struct zwp_tablet_pad_dial_v2_listener + */ +struct zwp_tablet_pad_dial_v2_listener { + /** + * delta movement + * + * Sent whenever the position on a dial changes. + * + * This event carries the wheel delta as multiples or fractions of + * 120 with each multiple of 120 representing one logical wheel + * detent. For example, an axis_value120 of 30 is one quarter of a + * logical wheel step in the positive direction, a value120 of -240 + * are two logical wheel steps in the negative direction within the + * same hardware event. See the wl_pointer.axis_value120 for more + * details. + * + * The value120 must not be zero. + * @param value120 rotation distance as fraction of 120 + */ + void (*delta)(void *data, + struct zwp_tablet_pad_dial_v2 *zwp_tablet_pad_dial_v2, + int32_t value120); + /** + * end of a dial event sequence + * + * Indicates the end of a set of events that represent one + * logical hardware dial event. A client is expected to accumulate + * the data in all events within the frame before proceeding. + * + * All zwp_tablet_pad_dial_v2 events before a + * zwp_tablet_pad_dial_v2.frame event belong logically together. + * + * A zwp_tablet_pad_dial_v2.frame event is sent for every logical + * event group, even if the group only contains a single + * zwp_tablet_pad_dial_v2 event. Specifically, a client may get a + * sequence: delta, frame, delta, frame, etc. + * @param time timestamp with millisecond granularity + */ + void (*frame)(void *data, + struct zwp_tablet_pad_dial_v2 *zwp_tablet_pad_dial_v2, + uint32_t time); +}; + +/** + * @ingroup iface_zwp_tablet_pad_dial_v2 + */ +static inline int +zwp_tablet_pad_dial_v2_add_listener(struct zwp_tablet_pad_dial_v2 *zwp_tablet_pad_dial_v2, + const struct zwp_tablet_pad_dial_v2_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zwp_tablet_pad_dial_v2, + (void (**)(void)) listener, data); +} + +#define ZWP_TABLET_PAD_DIAL_V2_SET_FEEDBACK 0 +#define ZWP_TABLET_PAD_DIAL_V2_DESTROY 1 + +/** + * @ingroup iface_zwp_tablet_pad_dial_v2 + */ +#define ZWP_TABLET_PAD_DIAL_V2_DELTA_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_dial_v2 + */ +#define ZWP_TABLET_PAD_DIAL_V2_FRAME_SINCE_VERSION 1 + +/** + * @ingroup iface_zwp_tablet_pad_dial_v2 + */ +#define ZWP_TABLET_PAD_DIAL_V2_SET_FEEDBACK_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_tablet_pad_dial_v2 + */ +#define ZWP_TABLET_PAD_DIAL_V2_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_zwp_tablet_pad_dial_v2 */ +static inline void +zwp_tablet_pad_dial_v2_set_user_data(struct zwp_tablet_pad_dial_v2 *zwp_tablet_pad_dial_v2, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_tablet_pad_dial_v2, user_data); +} + +/** @ingroup iface_zwp_tablet_pad_dial_v2 */ +static inline void * +zwp_tablet_pad_dial_v2_get_user_data(struct zwp_tablet_pad_dial_v2 *zwp_tablet_pad_dial_v2) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_tablet_pad_dial_v2); +} + +static inline uint32_t +zwp_tablet_pad_dial_v2_get_version(struct zwp_tablet_pad_dial_v2 *zwp_tablet_pad_dial_v2) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_dial_v2); +} + +/** + * @ingroup iface_zwp_tablet_pad_dial_v2 + * + * Requests the compositor to use the provided feedback string + * associated with this dial. This request should be issued immediately + * after a zwp_tablet_pad_group_v2.mode_switch event from the corresponding + * group is received, or whenever the dial is mapped to a different + * action. See zwp_tablet_pad_group_v2.mode_switch for more details. + * + * Clients are encouraged to provide context-aware descriptions for + * the actions associated with the dial, and compositors may use this + * information to offer visual feedback about the button layout + * (eg. on-screen displays). + * + * The provided string 'description' is a UTF-8 encoded string to be + * associated with this ring, and is considered user-visible; general + * internationalization rules apply. + * + * The serial argument will be that of the last + * zwp_tablet_pad_group_v2.mode_switch event received for the group of this + * dial. Requests providing other serials than the most recent one will be + * ignored. + */ +static inline void +zwp_tablet_pad_dial_v2_set_feedback(struct zwp_tablet_pad_dial_v2 *zwp_tablet_pad_dial_v2, const char *description, uint32_t serial) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_pad_dial_v2, + ZWP_TABLET_PAD_DIAL_V2_SET_FEEDBACK, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_dial_v2), 0, description, serial); +} + +/** + * @ingroup iface_zwp_tablet_pad_dial_v2 + * + * This destroys the client's resource for this dial object. + */ +static inline void +zwp_tablet_pad_dial_v2_destroy(struct zwp_tablet_pad_dial_v2 *zwp_tablet_pad_dial_v2) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_tablet_pad_dial_v2, + ZWP_TABLET_PAD_DIAL_V2_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_tablet_pad_dial_v2), WL_MARSHAL_FLAG_DESTROY); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/tablet-v2-protocol.c b/src/platform/wayland/protocols/tablet-v2-protocol.c new file mode 100644 index 0000000..4a1f57b --- /dev/null +++ b/src/platform/wayland/protocols/tablet-v2-protocol.c @@ -0,0 +1,254 @@ +/* Generated by wayland-scanner 1.26.0 */ + +/* + * Copyright 2014 © Stephen "Lyude" Chandler Paul + * Copyright 2015-2024 © Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial + * portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_seat_interface; +extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface zwp_tablet_pad_dial_v2_interface; +extern const struct wl_interface zwp_tablet_pad_group_v2_interface; +extern const struct wl_interface zwp_tablet_pad_ring_v2_interface; +extern const struct wl_interface zwp_tablet_pad_strip_v2_interface; +extern const struct wl_interface zwp_tablet_pad_v2_interface; +extern const struct wl_interface zwp_tablet_seat_v2_interface; +extern const struct wl_interface zwp_tablet_tool_v2_interface; +extern const struct wl_interface zwp_tablet_v2_interface; + +static const struct wl_interface *tablet_v2_types[] = { + NULL, + NULL, + NULL, + &zwp_tablet_seat_v2_interface, + &wl_seat_interface, + &zwp_tablet_v2_interface, + &zwp_tablet_tool_v2_interface, + &zwp_tablet_pad_v2_interface, + NULL, + &wl_surface_interface, + NULL, + NULL, + NULL, + &zwp_tablet_v2_interface, + &wl_surface_interface, + &zwp_tablet_pad_ring_v2_interface, + &zwp_tablet_pad_strip_v2_interface, + &zwp_tablet_pad_dial_v2_interface, + &zwp_tablet_pad_group_v2_interface, + NULL, + &zwp_tablet_v2_interface, + &wl_surface_interface, + NULL, + &wl_surface_interface, +}; + +static const struct wl_message zwp_tablet_manager_v2_requests[] = { + { "get_tablet_seat", "no", tablet_v2_types + 3 }, + { "destroy", "", tablet_v2_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface zwp_tablet_manager_v2_interface = { + "zwp_tablet_manager_v2", 2, + 2, zwp_tablet_manager_v2_requests, + 0, NULL, +}; + +static const struct wl_message zwp_tablet_seat_v2_requests[] = { + { "destroy", "", tablet_v2_types + 0 }, +}; + +static const struct wl_message zwp_tablet_seat_v2_events[] = { + { "tablet_added", "n", tablet_v2_types + 5 }, + { "tool_added", "n", tablet_v2_types + 6 }, + { "pad_added", "n", tablet_v2_types + 7 }, +}; + +WL_PRIVATE const struct wl_interface zwp_tablet_seat_v2_interface = { + "zwp_tablet_seat_v2", 2, + 1, zwp_tablet_seat_v2_requests, + 3, zwp_tablet_seat_v2_events, +}; + +static const struct wl_message zwp_tablet_tool_v2_requests[] = { + { "set_cursor", "u?oii", tablet_v2_types + 8 }, + { "destroy", "", tablet_v2_types + 0 }, +}; + +static const struct wl_message zwp_tablet_tool_v2_events[] = { + { "type", "u", tablet_v2_types + 0 }, + { "hardware_serial", "uu", tablet_v2_types + 0 }, + { "hardware_id_wacom", "uu", tablet_v2_types + 0 }, + { "capability", "u", tablet_v2_types + 0 }, + { "done", "", tablet_v2_types + 0 }, + { "removed", "", tablet_v2_types + 0 }, + { "proximity_in", "uoo", tablet_v2_types + 12 }, + { "proximity_out", "", tablet_v2_types + 0 }, + { "down", "u", tablet_v2_types + 0 }, + { "up", "", tablet_v2_types + 0 }, + { "motion", "ff", tablet_v2_types + 0 }, + { "pressure", "u", tablet_v2_types + 0 }, + { "distance", "u", tablet_v2_types + 0 }, + { "tilt", "ff", tablet_v2_types + 0 }, + { "rotation", "f", tablet_v2_types + 0 }, + { "slider", "i", tablet_v2_types + 0 }, + { "wheel", "fi", tablet_v2_types + 0 }, + { "button", "uuu", tablet_v2_types + 0 }, + { "frame", "u", tablet_v2_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface zwp_tablet_tool_v2_interface = { + "zwp_tablet_tool_v2", 2, + 2, zwp_tablet_tool_v2_requests, + 19, zwp_tablet_tool_v2_events, +}; + +static const struct wl_message zwp_tablet_v2_requests[] = { + { "destroy", "", tablet_v2_types + 0 }, +}; + +static const struct wl_message zwp_tablet_v2_events[] = { + { "name", "s", tablet_v2_types + 0 }, + { "id", "uu", tablet_v2_types + 0 }, + { "path", "s", tablet_v2_types + 0 }, + { "done", "", tablet_v2_types + 0 }, + { "removed", "", tablet_v2_types + 0 }, + { "bustype", "2u", tablet_v2_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface zwp_tablet_v2_interface = { + "zwp_tablet_v2", 2, + 1, zwp_tablet_v2_requests, + 6, zwp_tablet_v2_events, +}; + +static const struct wl_message zwp_tablet_pad_ring_v2_requests[] = { + { "set_feedback", "su", tablet_v2_types + 0 }, + { "destroy", "", tablet_v2_types + 0 }, +}; + +static const struct wl_message zwp_tablet_pad_ring_v2_events[] = { + { "source", "u", tablet_v2_types + 0 }, + { "angle", "f", tablet_v2_types + 0 }, + { "stop", "", tablet_v2_types + 0 }, + { "frame", "u", tablet_v2_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface zwp_tablet_pad_ring_v2_interface = { + "zwp_tablet_pad_ring_v2", 2, + 2, zwp_tablet_pad_ring_v2_requests, + 4, zwp_tablet_pad_ring_v2_events, +}; + +static const struct wl_message zwp_tablet_pad_strip_v2_requests[] = { + { "set_feedback", "su", tablet_v2_types + 0 }, + { "destroy", "", tablet_v2_types + 0 }, +}; + +static const struct wl_message zwp_tablet_pad_strip_v2_events[] = { + { "source", "u", tablet_v2_types + 0 }, + { "position", "u", tablet_v2_types + 0 }, + { "stop", "", tablet_v2_types + 0 }, + { "frame", "u", tablet_v2_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface zwp_tablet_pad_strip_v2_interface = { + "zwp_tablet_pad_strip_v2", 2, + 2, zwp_tablet_pad_strip_v2_requests, + 4, zwp_tablet_pad_strip_v2_events, +}; + +static const struct wl_message zwp_tablet_pad_group_v2_requests[] = { + { "destroy", "", tablet_v2_types + 0 }, +}; + +static const struct wl_message zwp_tablet_pad_group_v2_events[] = { + { "buttons", "a", tablet_v2_types + 0 }, + { "ring", "n", tablet_v2_types + 15 }, + { "strip", "n", tablet_v2_types + 16 }, + { "modes", "u", tablet_v2_types + 0 }, + { "done", "", tablet_v2_types + 0 }, + { "mode_switch", "uuu", tablet_v2_types + 0 }, + { "dial", "2n", tablet_v2_types + 17 }, +}; + +WL_PRIVATE const struct wl_interface zwp_tablet_pad_group_v2_interface = { + "zwp_tablet_pad_group_v2", 2, + 1, zwp_tablet_pad_group_v2_requests, + 7, zwp_tablet_pad_group_v2_events, +}; + +static const struct wl_message zwp_tablet_pad_v2_requests[] = { + { "set_feedback", "usu", tablet_v2_types + 0 }, + { "destroy", "", tablet_v2_types + 0 }, +}; + +static const struct wl_message zwp_tablet_pad_v2_events[] = { + { "group", "n", tablet_v2_types + 18 }, + { "path", "s", tablet_v2_types + 0 }, + { "buttons", "u", tablet_v2_types + 0 }, + { "done", "", tablet_v2_types + 0 }, + { "button", "uuu", tablet_v2_types + 0 }, + { "enter", "uoo", tablet_v2_types + 19 }, + { "leave", "uo", tablet_v2_types + 22 }, + { "removed", "", tablet_v2_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface zwp_tablet_pad_v2_interface = { + "zwp_tablet_pad_v2", 2, + 2, zwp_tablet_pad_v2_requests, + 8, zwp_tablet_pad_v2_events, +}; + +static const struct wl_message zwp_tablet_pad_dial_v2_requests[] = { + { "set_feedback", "su", tablet_v2_types + 0 }, + { "destroy", "", tablet_v2_types + 0 }, +}; + +static const struct wl_message zwp_tablet_pad_dial_v2_events[] = { + { "delta", "i", tablet_v2_types + 0 }, + { "frame", "u", tablet_v2_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface zwp_tablet_pad_dial_v2_interface = { + "zwp_tablet_pad_dial_v2", 2, + 2, zwp_tablet_pad_dial_v2_requests, + 2, zwp_tablet_pad_dial_v2_events, +}; + diff --git a/src/platform/wayland/protocols/tearing-control-v1-client-protocol.h b/src/platform/wayland/protocols/tearing-control-v1-client-protocol.h new file mode 100644 index 0000000..48f9861 --- /dev/null +++ b/src/platform/wayland/protocols/tearing-control-v1-client-protocol.h @@ -0,0 +1,298 @@ +/* Generated by wayland-scanner 1.26.0 */ + +#ifndef TEARING_CONTROL_V1_CLIENT_PROTOCOL_H +#define TEARING_CONTROL_V1_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_tearing_control_v1 The tearing_control_v1 protocol + * @section page_ifaces_tearing_control_v1 Interfaces + * - @subpage page_iface_wp_tearing_control_manager_v1 - protocol for tearing control + * - @subpage page_iface_wp_tearing_control_v1 - per-surface tearing control interface + * @section page_copyright_tearing_control_v1 Copyright + * <pre> + * + * Copyright © 2021 Xaver Hugl + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * </pre> + */ +struct wl_surface; +struct wp_tearing_control_manager_v1; +struct wp_tearing_control_v1; + +#ifndef WP_TEARING_CONTROL_MANAGER_V1_INTERFACE +#define WP_TEARING_CONTROL_MANAGER_V1_INTERFACE +/** + * @page page_iface_wp_tearing_control_manager_v1 wp_tearing_control_manager_v1 + * @section page_iface_wp_tearing_control_manager_v1_desc Description + * + * For some use cases like games or drawing tablets it can make sense to + * reduce latency by accepting tearing with the use of asynchronous page + * flips. This global is a factory interface, allowing clients to inform + * which type of presentation the content of their surfaces is suitable for. + * + * Graphics APIs like EGL or Vulkan, that manage the buffer queue and commits + * of a wl_surface themselves, are likely to be using this extension + * internally. If a client is using such an API for a wl_surface, it should + * not directly use this extension on that surface, to avoid raising a + * tearing_control_exists protocol error. + * + * Warning! The protocol described in this file is currently in the testing + * phase. Backward compatible changes may be added together with the + * corresponding interface version bump. Backward incompatible changes can + * only be done by creating a new major version of the extension. + * @section page_iface_wp_tearing_control_manager_v1_api API + * See @ref iface_wp_tearing_control_manager_v1. + */ +/** + * @defgroup iface_wp_tearing_control_manager_v1 The wp_tearing_control_manager_v1 interface + * + * For some use cases like games or drawing tablets it can make sense to + * reduce latency by accepting tearing with the use of asynchronous page + * flips. This global is a factory interface, allowing clients to inform + * which type of presentation the content of their surfaces is suitable for. + * + * Graphics APIs like EGL or Vulkan, that manage the buffer queue and commits + * of a wl_surface themselves, are likely to be using this extension + * internally. If a client is using such an API for a wl_surface, it should + * not directly use this extension on that surface, to avoid raising a + * tearing_control_exists protocol error. + * + * Warning! The protocol described in this file is currently in the testing + * phase. Backward compatible changes may be added together with the + * corresponding interface version bump. Backward incompatible changes can + * only be done by creating a new major version of the extension. + */ +extern const struct wl_interface wp_tearing_control_manager_v1_interface; +#endif +#ifndef WP_TEARING_CONTROL_V1_INTERFACE +#define WP_TEARING_CONTROL_V1_INTERFACE +/** + * @page page_iface_wp_tearing_control_v1 wp_tearing_control_v1 + * @section page_iface_wp_tearing_control_v1_desc Description + * + * An additional interface to a wl_surface object, which allows the client + * to hint to the compositor if the content on the surface is suitable for + * presentation with tearing. + * The default presentation hint is vsync. See presentation_hint for more + * details. + * + * If the associated wl_surface is destroyed, this object becomes inert and + * should be destroyed. + * @section page_iface_wp_tearing_control_v1_api API + * See @ref iface_wp_tearing_control_v1. + */ +/** + * @defgroup iface_wp_tearing_control_v1 The wp_tearing_control_v1 interface + * + * An additional interface to a wl_surface object, which allows the client + * to hint to the compositor if the content on the surface is suitable for + * presentation with tearing. + * The default presentation hint is vsync. See presentation_hint for more + * details. + * + * If the associated wl_surface is destroyed, this object becomes inert and + * should be destroyed. + */ +extern const struct wl_interface wp_tearing_control_v1_interface; +#endif + +#ifndef WP_TEARING_CONTROL_MANAGER_V1_ERROR_ENUM +#define WP_TEARING_CONTROL_MANAGER_V1_ERROR_ENUM +enum wp_tearing_control_manager_v1_error { + /** + * the surface already has a tearing object associated + */ + WP_TEARING_CONTROL_MANAGER_V1_ERROR_TEARING_CONTROL_EXISTS = 0, +}; +#endif /* WP_TEARING_CONTROL_MANAGER_V1_ERROR_ENUM */ + +#define WP_TEARING_CONTROL_MANAGER_V1_DESTROY 0 +#define WP_TEARING_CONTROL_MANAGER_V1_GET_TEARING_CONTROL 1 + + +/** + * @ingroup iface_wp_tearing_control_manager_v1 + */ +#define WP_TEARING_CONTROL_MANAGER_V1_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_wp_tearing_control_manager_v1 + */ +#define WP_TEARING_CONTROL_MANAGER_V1_GET_TEARING_CONTROL_SINCE_VERSION 1 + +/** @ingroup iface_wp_tearing_control_manager_v1 */ +static inline void +wp_tearing_control_manager_v1_set_user_data(struct wp_tearing_control_manager_v1 *wp_tearing_control_manager_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_tearing_control_manager_v1, user_data); +} + +/** @ingroup iface_wp_tearing_control_manager_v1 */ +static inline void * +wp_tearing_control_manager_v1_get_user_data(struct wp_tearing_control_manager_v1 *wp_tearing_control_manager_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_tearing_control_manager_v1); +} + +static inline uint32_t +wp_tearing_control_manager_v1_get_version(struct wp_tearing_control_manager_v1 *wp_tearing_control_manager_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_tearing_control_manager_v1); +} + +/** + * @ingroup iface_wp_tearing_control_manager_v1 + * + * Destroy this tearing control factory object. Other objects, including + * wp_tearing_control_v1 objects created by this factory, are not affected + * by this request. + */ +static inline void +wp_tearing_control_manager_v1_destroy(struct wp_tearing_control_manager_v1 *wp_tearing_control_manager_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_tearing_control_manager_v1, + WP_TEARING_CONTROL_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_tearing_control_manager_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_wp_tearing_control_manager_v1 + * + * Instantiate an interface extension for the given wl_surface to request + * asynchronous page flips for presentation. + * + * If the given wl_surface already has a wp_tearing_control_v1 object + * associated, the tearing_control_exists protocol error is raised. + */ +static inline struct wp_tearing_control_v1 * +wp_tearing_control_manager_v1_get_tearing_control(struct wp_tearing_control_manager_v1 *wp_tearing_control_manager_v1, struct wl_surface *surface) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) wp_tearing_control_manager_v1, + WP_TEARING_CONTROL_MANAGER_V1_GET_TEARING_CONTROL, &wp_tearing_control_v1_interface, wl_proxy_get_version((struct wl_proxy *) wp_tearing_control_manager_v1), 0, NULL, surface); + + return (struct wp_tearing_control_v1 *) id; +} + +#ifndef WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ENUM +#define WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ENUM +/** + * @ingroup iface_wp_tearing_control_v1 + * presentation hint values + * + * This enum provides information for if submitted frames from the client + * may be presented with tearing. + */ +enum wp_tearing_control_v1_presentation_hint { + /** + * tearing-free presentation + * + * The content of this surface is meant to be synchronized to the + * vertical blanking period. This should not result in visible + * tearing and may result in a delay before a surface commit is + * presented. + */ + WP_TEARING_CONTROL_V1_PRESENTATION_HINT_VSYNC = 0, + /** + * asynchronous presentation + * + * The content of this surface is meant to be presented with + * minimal latency and tearing is acceptable. + */ + WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ASYNC = 1, +}; +#endif /* WP_TEARING_CONTROL_V1_PRESENTATION_HINT_ENUM */ + +#define WP_TEARING_CONTROL_V1_SET_PRESENTATION_HINT 0 +#define WP_TEARING_CONTROL_V1_DESTROY 1 + + +/** + * @ingroup iface_wp_tearing_control_v1 + */ +#define WP_TEARING_CONTROL_V1_SET_PRESENTATION_HINT_SINCE_VERSION 1 +/** + * @ingroup iface_wp_tearing_control_v1 + */ +#define WP_TEARING_CONTROL_V1_DESTROY_SINCE_VERSION 1 + +/** @ingroup iface_wp_tearing_control_v1 */ +static inline void +wp_tearing_control_v1_set_user_data(struct wp_tearing_control_v1 *wp_tearing_control_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_tearing_control_v1, user_data); +} + +/** @ingroup iface_wp_tearing_control_v1 */ +static inline void * +wp_tearing_control_v1_get_user_data(struct wp_tearing_control_v1 *wp_tearing_control_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_tearing_control_v1); +} + +static inline uint32_t +wp_tearing_control_v1_get_version(struct wp_tearing_control_v1 *wp_tearing_control_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_tearing_control_v1); +} + +/** + * @ingroup iface_wp_tearing_control_v1 + * + * Set the presentation hint for the associated wl_surface. This state is + * double-buffered, see wl_surface.commit. + * + * The compositor is free to dynamically respect or ignore this hint based + * on various conditions like hardware capabilities, surface state and + * user preferences. + */ +static inline void +wp_tearing_control_v1_set_presentation_hint(struct wp_tearing_control_v1 *wp_tearing_control_v1, uint32_t hint) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_tearing_control_v1, + WP_TEARING_CONTROL_V1_SET_PRESENTATION_HINT, NULL, wl_proxy_get_version((struct wl_proxy *) wp_tearing_control_v1), 0, hint); +} + +/** + * @ingroup iface_wp_tearing_control_v1 + * + * Destroy this surface tearing object and revert the presentation hint to + * vsync. The change will be applied on the next wl_surface.commit. + */ +static inline void +wp_tearing_control_v1_destroy(struct wp_tearing_control_v1 *wp_tearing_control_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_tearing_control_v1, + WP_TEARING_CONTROL_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_tearing_control_v1), WL_MARSHAL_FLAG_DESTROY); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/tearing-control-v1-protocol.c b/src/platform/wayland/protocols/tearing-control-v1-protocol.c new file mode 100644 index 0000000..afedad8 --- /dev/null +++ b/src/platform/wayland/protocols/tearing-control-v1-protocol.c @@ -0,0 +1,71 @@ +/* Generated by wayland-scanner 1.26.0 */ + +/* + * Copyright © 2021 Xaver Hugl + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface wp_tearing_control_v1_interface; + +static const struct wl_interface *tearing_control_v1_types[] = { + NULL, + &wp_tearing_control_v1_interface, + &wl_surface_interface, +}; + +static const struct wl_message wp_tearing_control_manager_v1_requests[] = { + { "destroy", "", tearing_control_v1_types + 0 }, + { "get_tearing_control", "no", tearing_control_v1_types + 1 }, +}; + +WL_PRIVATE const struct wl_interface wp_tearing_control_manager_v1_interface = { + "wp_tearing_control_manager_v1", 1, + 2, wp_tearing_control_manager_v1_requests, + 0, NULL, +}; + +static const struct wl_message wp_tearing_control_v1_requests[] = { + { "set_presentation_hint", "u", tearing_control_v1_types + 0 }, + { "destroy", "", tearing_control_v1_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface wp_tearing_control_v1_interface = { + "wp_tearing_control_v1", 1, + 2, wp_tearing_control_v1_requests, + 0, NULL, +}; + diff --git a/src/platform/wayland/protocols/text-input-unstable-v3-client-protocol.h b/src/platform/wayland/protocols/text-input-unstable-v3-client-protocol.h new file mode 100644 index 0000000..2c4c23b --- /dev/null +++ b/src/platform/wayland/protocols/text-input-unstable-v3-client-protocol.h @@ -0,0 +1,1103 @@ +/* Generated by wayland-scanner 1.26.0 */ + +#ifndef TEXT_INPUT_UNSTABLE_V3_CLIENT_PROTOCOL_H +#define TEXT_INPUT_UNSTABLE_V3_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_text_input_unstable_v3 The text_input_unstable_v3 protocol + * Protocol for composing text + * + * @section page_desc_text_input_unstable_v3 Description + * + * This protocol allows compositors to act as input methods and to send text + * to applications. A text input object is used to manage state of what are + * typically text entry fields in the application. + * + * This document adheres to the RFC 2119 when using words like "must", + * "should", "may", etc. + * + * Warning! The protocol described in this file is experimental and + * backward incompatible changes may be made. Backward compatible changes + * may be added together with the corresponding interface version bump. + * Backward incompatible changes are done by bumping the version number in + * the protocol and interface names and resetting the interface version. + * Once the protocol is to be declared stable, the 'z' prefix and the + * version number in the protocol and interface names are removed and the + * interface version number is reset. + * + * @section page_ifaces_text_input_unstable_v3 Interfaces + * - @subpage page_iface_zwp_text_input_v3 - text input + * - @subpage page_iface_zwp_text_input_manager_v3 - text input manager + * @section page_copyright_text_input_unstable_v3 Copyright + * <pre> + * + * Copyright © 2012, 2013 Intel Corporation + * Copyright © 2015, 2016 Jan Arne Petersen + * Copyright © 2017, 2018 Red Hat, Inc. + * Copyright © 2018 Purism SPC + * + * Permission to use, copy, modify, distribute, and sell this + * software and its documentation for any purpose is hereby granted + * without fee, provided that the above copyright notice appear in + * all copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * the copyright holders not be used in advertising or publicity + * pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + * THIS SOFTWARE. + * </pre> + */ +struct wl_seat; +struct wl_surface; +struct zwp_text_input_manager_v3; +struct zwp_text_input_v3; + +#ifndef ZWP_TEXT_INPUT_V3_INTERFACE +#define ZWP_TEXT_INPUT_V3_INTERFACE +/** + * @page page_iface_zwp_text_input_v3 zwp_text_input_v3 + * @section page_iface_zwp_text_input_v3_desc Description + * + * The zwp_text_input_v3 interface represents text input and input methods + * associated with a seat. It provides enter/leave events to follow the + * text input focus for a seat. + * + * Requests are used to enable/disable the text-input object and set + * state information like surrounding and selected text or the content type. + * The information about the entered text is sent to the text-input object + * via the preedit_string and commit_string events. + * + * Text is valid UTF-8 encoded, indices and lengths are in bytes. Indices + * must not point to middle bytes inside a code point: they must either + * point to the first byte of a code point or to the end of the buffer. + * Lengths must be measured between two valid indices. + * + * Focus moving throughout surfaces will result in the emission of + * zwp_text_input_v3.enter and zwp_text_input_v3.leave events. The focused + * surface must commit zwp_text_input_v3.enable and + * zwp_text_input_v3.disable requests as the keyboard focus moves across + * editable and non-editable elements of the UI. Those two requests are not + * expected to be paired with each other, the compositor must be able to + * handle consecutive series of the same request. + * + * State is sent by the state requests (set_surrounding_text, + * set_content_type and set_cursor_rectangle) and a commit request. After an + * enter event or disable request all state information is invalidated and + * needs to be resent by the client. + * @section page_iface_zwp_text_input_v3_api API + * See @ref iface_zwp_text_input_v3. + */ +/** + * @defgroup iface_zwp_text_input_v3 The zwp_text_input_v3 interface + * + * The zwp_text_input_v3 interface represents text input and input methods + * associated with a seat. It provides enter/leave events to follow the + * text input focus for a seat. + * + * Requests are used to enable/disable the text-input object and set + * state information like surrounding and selected text or the content type. + * The information about the entered text is sent to the text-input object + * via the preedit_string and commit_string events. + * + * Text is valid UTF-8 encoded, indices and lengths are in bytes. Indices + * must not point to middle bytes inside a code point: they must either + * point to the first byte of a code point or to the end of the buffer. + * Lengths must be measured between two valid indices. + * + * Focus moving throughout surfaces will result in the emission of + * zwp_text_input_v3.enter and zwp_text_input_v3.leave events. The focused + * surface must commit zwp_text_input_v3.enable and + * zwp_text_input_v3.disable requests as the keyboard focus moves across + * editable and non-editable elements of the UI. Those two requests are not + * expected to be paired with each other, the compositor must be able to + * handle consecutive series of the same request. + * + * State is sent by the state requests (set_surrounding_text, + * set_content_type and set_cursor_rectangle) and a commit request. After an + * enter event or disable request all state information is invalidated and + * needs to be resent by the client. + */ +extern const struct wl_interface zwp_text_input_v3_interface; +#endif +#ifndef ZWP_TEXT_INPUT_MANAGER_V3_INTERFACE +#define ZWP_TEXT_INPUT_MANAGER_V3_INTERFACE +/** + * @page page_iface_zwp_text_input_manager_v3 zwp_text_input_manager_v3 + * @section page_iface_zwp_text_input_manager_v3_desc Description + * + * A factory for text-input objects. This object is a global singleton. + * @section page_iface_zwp_text_input_manager_v3_api API + * See @ref iface_zwp_text_input_manager_v3. + */ +/** + * @defgroup iface_zwp_text_input_manager_v3 The zwp_text_input_manager_v3 interface + * + * A factory for text-input objects. This object is a global singleton. + */ +extern const struct wl_interface zwp_text_input_manager_v3_interface; +#endif + +#ifndef ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_ENUM +#define ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_ENUM +/** + * @ingroup iface_zwp_text_input_v3 + * text change reason + * + * Reason for the change of surrounding text or cursor posision. + */ +enum zwp_text_input_v3_change_cause { + /** + * input method caused the change + */ + ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_INPUT_METHOD = 0, + /** + * something else than the input method caused the change + */ + ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_OTHER = 1, +}; +#endif /* ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_ENUM */ + +#ifndef ZWP_TEXT_INPUT_V3_CONTENT_HINT_ENUM +#define ZWP_TEXT_INPUT_V3_CONTENT_HINT_ENUM +/** + * @ingroup iface_zwp_text_input_v3 + * content hint + * + * Content hint is a bitmask to allow to modify the behavior of the text + * input. + */ +enum zwp_text_input_v3_content_hint { + /** + * no special behavior + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE = 0x0, + /** + * suggest word completions + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_COMPLETION = 0x1, + /** + * suggest word corrections + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_SPELLCHECK = 0x2, + /** + * switch to uppercase letters at the start of a sentence + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_AUTO_CAPITALIZATION = 0x4, + /** + * prefer lowercase letters + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_LOWERCASE = 0x8, + /** + * prefer uppercase letters + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_UPPERCASE = 0x10, + /** + * prefer casing for titles and headings (can be language dependent) + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_TITLECASE = 0x20, + /** + * characters should be hidden + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_HIDDEN_TEXT = 0x40, + /** + * typed text should not be stored + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_SENSITIVE_DATA = 0x80, + /** + * just Latin characters should be entered + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_LATIN = 0x100, + /** + * the text input is multiline + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_MULTILINE = 0x200, + /** + * an on-screen way to fill in the input is already provided by the client + * @since 2 + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_ON_SCREEN_INPUT_PROVIDED = 0x400, + /** + * prefer not offering emoji support + * @since 2 + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_NO_EMOJI = 0x800, + /** + * the text input will display preedit text in place + * @since 2 + */ + ZWP_TEXT_INPUT_V3_CONTENT_HINT_PREEDIT_SHOWN = 0x1000, +}; +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_CONTENT_HINT_ON_SCREEN_INPUT_PROVIDED_SINCE_VERSION 2 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_CONTENT_HINT_NO_EMOJI_SINCE_VERSION 2 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_CONTENT_HINT_PREEDIT_SHOWN_SINCE_VERSION 2 +#endif /* ZWP_TEXT_INPUT_V3_CONTENT_HINT_ENUM */ + +#ifndef ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_ENUM +#define ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_ENUM +/** + * @ingroup iface_zwp_text_input_v3 + * content purpose + * + * The content purpose allows to specify the primary purpose of a text + * input. + * + * This allows an input method to show special purpose input panels with + * extra characters or to disallow some characters. + */ +enum zwp_text_input_v3_content_purpose { + /** + * default input, allowing all characters + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL = 0, + /** + * allow only alphabetic characters + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_ALPHA = 1, + /** + * allow only digits + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_DIGITS = 2, + /** + * input a number (including decimal separator and sign) + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NUMBER = 3, + /** + * input a phone number + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PHONE = 4, + /** + * input an URL + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_URL = 5, + /** + * input an email address + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_EMAIL = 6, + /** + * input a name of a person + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NAME = 7, + /** + * input a password (combine with sensitive_data hint) + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PASSWORD = 8, + /** + * input is a numeric password (combine with sensitive_data hint) + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PIN = 9, + /** + * input a date + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_DATE = 10, + /** + * input a time + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_TIME = 11, + /** + * input a date and time + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_DATETIME = 12, + /** + * input for a terminal + */ + ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_TERMINAL = 13, +}; +#endif /* ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_ENUM */ + +#ifndef ZWP_TEXT_INPUT_V3_ERROR_ENUM +#define ZWP_TEXT_INPUT_V3_ERROR_ENUM +enum zwp_text_input_v3_error { + /** + * an invalid or duplicate action was specified + */ + ZWP_TEXT_INPUT_V3_ERROR_INVALID_ACTION = 0, +}; +#endif /* ZWP_TEXT_INPUT_V3_ERROR_ENUM */ + +#ifndef ZWP_TEXT_INPUT_V3_ACTION_ENUM +#define ZWP_TEXT_INPUT_V3_ACTION_ENUM +/** + * @ingroup iface_zwp_text_input_v3 + * action + * + * A possible action to perform on a text input. + * + * The submit action is intended for input entries that expect some sort of + * activation after user interaction, e.g. the URL entry in a browser. + */ +enum zwp_text_input_v3_action { + /** + * no action + */ + ZWP_TEXT_INPUT_V3_ACTION_NONE = 0, + /** + * the action is submitted + */ + ZWP_TEXT_INPUT_V3_ACTION_SUBMIT = 1, +}; +#endif /* ZWP_TEXT_INPUT_V3_ACTION_ENUM */ + +#ifndef ZWP_TEXT_INPUT_V3_PREEDIT_HINT_ENUM +#define ZWP_TEXT_INPUT_V3_PREEDIT_HINT_ENUM +/** + * @ingroup iface_zwp_text_input_v3 + * preedit style hint + * + * Style hints for the preedit string. + */ +enum zwp_text_input_v3_preedit_hint { + /** + * simple pre-edit text style, typically underlined + */ + ZWP_TEXT_INPUT_V3_PREEDIT_HINT_WHOLE = 1, + /** + * hint for a selected piece of text, e.g. per-character navigation and composition + */ + ZWP_TEXT_INPUT_V3_PREEDIT_HINT_SELECTION = 2, + /** + * predicted text, not typed by the user + */ + ZWP_TEXT_INPUT_V3_PREEDIT_HINT_PREDICTION = 3, + /** + * prefixed text not being currently edited, e.g. prior to a 'selection' section + */ + ZWP_TEXT_INPUT_V3_PREEDIT_HINT_PREFIX = 4, + /** + * suffixed text not being currently edited, e.g. after a 'selection' section + */ + ZWP_TEXT_INPUT_V3_PREEDIT_HINT_SUFFIX = 5, + /** + * spelling error + */ + ZWP_TEXT_INPUT_V3_PREEDIT_HINT_SPELLING_ERROR = 6, + /** + * wrong composition, e.g. user input that can not be transliterated + */ + ZWP_TEXT_INPUT_V3_PREEDIT_HINT_COMPOSE_ERROR = 7, +}; +#endif /* ZWP_TEXT_INPUT_V3_PREEDIT_HINT_ENUM */ + +/** + * @ingroup iface_zwp_text_input_v3 + * @struct zwp_text_input_v3_listener + */ +struct zwp_text_input_v3_listener { + /** + * enter event + * + * Notification that this seat's text-input focus is on a certain + * surface. + * + * If client has created multiple text input objects, compositor + * must send this event to all of them. + * + * When the seat has the keyboard capability the text-input focus + * follows the keyboard focus. This event sets the current surface + * for the text-input object. + */ + void (*enter)(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + struct wl_surface *surface); + /** + * leave event + * + * Notification that this seat's text-input focus is no longer on + * a certain surface. The client should reset any preedit string + * previously set. + * + * The leave notification clears the current surface. It is sent + * before the enter notification for the new focus. After leave + * event, compositor must ignore requests from any text input + * instances until next enter event. + * + * When the seat has the keyboard capability the text-input focus + * follows the keyboard focus. + */ + void (*leave)(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + struct wl_surface *surface); + /** + * pre-edit + * + * Notify when a new composing text (pre-edit) should be set at + * the current cursor position. Any previously set composing text + * must be removed. Any previously existing selected text must be + * removed. + * + * The argument text contains the pre-edit string buffer. + * + * The parameters cursor_begin and cursor_end are counted in bytes + * relative to the beginning of the submitted text buffer. Cursor + * should be hidden when both are equal to -1. + * + * They could be represented by the client as a line if both values + * are the same, or as a text highlight otherwise. + * + * Values set with this event are double-buffered. They must be + * applied and reset to initial on the next zwp_text_input_v3.done + * event. + * + * The initial value of text is an empty string, and cursor_begin, + * cursor_end and cursor_hidden are all 0. + */ + void (*preedit_string)(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + const char *text, + int32_t cursor_begin, + int32_t cursor_end); + /** + * text commit + * + * Notify when text should be inserted into the editor widget. + * The text to commit could be either just a single character after + * a key press or the result of some composing (pre-edit). + * + * Values set with this event are double-buffered. They must be + * applied and reset to initial on the next zwp_text_input_v3.done + * event. + * + * The initial value of text is an empty string. + */ + void (*commit_string)(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + const char *text); + /** + * delete surrounding text + * + * Notify when the text around the current cursor position should + * be deleted. + * + * Before_length and after_length are the number of bytes before + * and after the current cursor index (excluding the selection) to + * delete. + * + * If a preedit text is present, in effect before_length is counted + * from the beginning of it, and after_length from its end (see + * done event sequence). + * + * Values set with this event are double-buffered. They must be + * applied and reset to initial on the next zwp_text_input_v3.done + * event. + * + * The initial values of both before_length and after_length are 0. + * @param before_length length of text before current cursor position + * @param after_length length of text after current cursor position + */ + void (*delete_surrounding_text)(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + uint32_t before_length, + uint32_t after_length); + /** + * apply changes + * + * Instruct the application to apply changes to state requested + * by the preedit_string, commit_string delete_surrounding_text, + * and action events. + * + * The state relating to these events is double-buffered, and each + * one modifies the pending state. This event replaces the current + * state with the pending state. + * + * The application must proceed by evaluating the changes in the + * following order: + * + * 1. Replace existing preedit string with the cursor. 2. Delete + * requested surrounding text. 3. Insert commit string with the + * cursor at its end. 4. Calculate surrounding text to send. 5. + * Insert new preedit text in cursor position. 6. Place cursor + * inside preedit text. 7. Perform the requested action. + * + * The serial number reflects the last state of the + * zwp_text_input_v3 object known to the compositor. The value of + * the serial argument must be equal to the number of commit + * requests already issued on that object. + * + * When the client receives a done event with a serial different + * than the number of past commit requests, it must proceed with + * evaluating and applying the changes as normal, except it should + * not change the current state of the zwp_text_input_v3 object. + * All pending state requests (set_surrounding_text, + * set_content_type and set_cursor_rectangle) on the + * zwp_text_input_v3 object should be sent and committed after + * receiving a zwp_text_input_v3.done event with a matching serial. + */ + void (*done)(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + uint32_t serial); + /** + * action performed + * + * An action was performed on this text input. + * + * Values set with this event are double-buffered. They must be + * applied and reset to initial on the next zwp_text_input_v3.done + * event. + * + * The initial value of action is none. + * @param action action performed + * @param serial serial number of the action event + * @since 2 + */ + void (*action)(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + uint32_t action, + uint32_t serial); + /** + * notify of language selection + * + * Notify the application of language used by the input method. + * + * This event will be sent on creation if known and for all + * subsequent changes. + * + * The language should be specified as an IETF BCP 47 tag. Setting + * an empty string will reset any known language back to the + * default unknown state. + * @param language new language set by IME + * @since 2 + */ + void (*language)(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + const char *language); + /** + * pre-edit + * + * Notify of contextual hints for the pre-edit string. This event + * is always sent together with a zwp_text_input_v3.preedit_string + * event. + * + * The parameters start and end are counted in bytes relative to + * the beginning of the text buffer submitted through + * zwp_text_input_v3.preedit_string, and represent the substring in + * the pre-edit text affected by the hint. + * + * Multiple events may be submitted if the preedit string has + * different sections. The extent of hints may overlap. The parts + * of the preedit string that are not covered by any + * zwp_text_input_v3.preedit_hint event, the text will be + * considered unhinted. This is also the case if no preedit_hint + * event is sent. + * + * Clients should provide recognizable visuals to these hints. if + * they are unable to comply with this requisition, it may be + * preferable for them keep the preedit_shown content hint + * disabled. + * + * Values set with this event are double-buffered. They must be + * applied and reset on the next zwp_text_input_v3.done event. + * @param start starting point of the affected substring + * @param end end point of the affected substring + * @param hint hint to apply + * @since 2 + */ + void (*preedit_hint)(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + uint32_t start, + uint32_t end, + uint32_t hint); +}; + +/** + * @ingroup iface_zwp_text_input_v3 + */ +static inline int +zwp_text_input_v3_add_listener(struct zwp_text_input_v3 *zwp_text_input_v3, + const struct zwp_text_input_v3_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zwp_text_input_v3, + (void (**)(void)) listener, data); +} + +#define ZWP_TEXT_INPUT_V3_DESTROY 0 +#define ZWP_TEXT_INPUT_V3_ENABLE 1 +#define ZWP_TEXT_INPUT_V3_DISABLE 2 +#define ZWP_TEXT_INPUT_V3_SET_SURROUNDING_TEXT 3 +#define ZWP_TEXT_INPUT_V3_SET_TEXT_CHANGE_CAUSE 4 +#define ZWP_TEXT_INPUT_V3_SET_CONTENT_TYPE 5 +#define ZWP_TEXT_INPUT_V3_SET_CURSOR_RECTANGLE 6 +#define ZWP_TEXT_INPUT_V3_COMMIT 7 +#define ZWP_TEXT_INPUT_V3_SET_AVAILABLE_ACTIONS 8 +#define ZWP_TEXT_INPUT_V3_SHOW_INPUT_PANEL 9 +#define ZWP_TEXT_INPUT_V3_HIDE_INPUT_PANEL 10 + +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_ENTER_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_LEAVE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_PREEDIT_STRING_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_COMMIT_STRING_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_DELETE_SURROUNDING_TEXT_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_DONE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_ACTION_SINCE_VERSION 2 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_LANGUAGE_SINCE_VERSION 2 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_PREEDIT_HINT_SINCE_VERSION 2 + +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_ENABLE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_DISABLE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_SET_SURROUNDING_TEXT_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_SET_TEXT_CHANGE_CAUSE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_SET_CONTENT_TYPE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_SET_CURSOR_RECTANGLE_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_COMMIT_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_SET_AVAILABLE_ACTIONS_SINCE_VERSION 2 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_SHOW_INPUT_PANEL_SINCE_VERSION 2 +/** + * @ingroup iface_zwp_text_input_v3 + */ +#define ZWP_TEXT_INPUT_V3_HIDE_INPUT_PANEL_SINCE_VERSION 2 + +/** @ingroup iface_zwp_text_input_v3 */ +static inline void +zwp_text_input_v3_set_user_data(struct zwp_text_input_v3 *zwp_text_input_v3, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_text_input_v3, user_data); +} + +/** @ingroup iface_zwp_text_input_v3 */ +static inline void * +zwp_text_input_v3_get_user_data(struct zwp_text_input_v3 *zwp_text_input_v3) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_text_input_v3); +} + +static inline uint32_t +zwp_text_input_v3_get_version(struct zwp_text_input_v3 *zwp_text_input_v3) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_text_input_v3); +} + +/** + * @ingroup iface_zwp_text_input_v3 + * + * Destroy the wp_text_input object. Also disables all surfaces enabled + * through this wp_text_input object. + */ +static inline void +zwp_text_input_v3_destroy(struct zwp_text_input_v3 *zwp_text_input_v3) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_v3, + ZWP_TEXT_INPUT_V3_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_v3), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_zwp_text_input_v3 + * + * Requests text input on the surface previously obtained from the enter + * event. + * + * This request must be issued every time the focused text input changes + * to a new one, including within the current surface. Use + * zwp_text_input_v3.disable when there is no longer any input focus on + * the current surface. + * + * Clients must not enable more than one text input on the single seat + * and should disable the current text input before enabling the new one. + * Requests to enable a text input when another text input is enabled + * on the same seat must be ignored by compositor. + * + * This request resets all state associated with previous enable, disable, + * set_surrounding_text, set_text_change_cause, set_content_type, and + * set_cursor_rectangle requests, as well as the state associated with + * preedit_string, commit_string, and delete_surrounding_text events. + * + * The set_surrounding_text, set_content_type and set_cursor_rectangle + * requests must follow if the text input supports the necessary + * functionality. + * + * State set with this request is double-buffered. It will get applied on + * the next zwp_text_input_v3.commit request, and stay valid until the + * next committed enable or disable request. + * + * The changes must be applied by the compositor after issuing a + * zwp_text_input_v3.commit request. + */ +static inline void +zwp_text_input_v3_enable(struct zwp_text_input_v3 *zwp_text_input_v3) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_v3, + ZWP_TEXT_INPUT_V3_ENABLE, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_v3), 0); +} + +/** + * @ingroup iface_zwp_text_input_v3 + * + * Explicitly disable text input on the current surface (typically when + * there is no focus on any text entry inside the surface). + * + * State set with this request is double-buffered. It will get applied on + * the next zwp_text_input_v3.commit request. + */ +static inline void +zwp_text_input_v3_disable(struct zwp_text_input_v3 *zwp_text_input_v3) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_v3, + ZWP_TEXT_INPUT_V3_DISABLE, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_v3), 0); +} + +/** + * @ingroup iface_zwp_text_input_v3 + * + * Sets the surrounding plain text around the input, excluding the preedit + * text. + * + * The client should notify the compositor of any changes in any of the + * values carried with this request, including changes caused by handling + * incoming text-input events as well as changes caused by other + * mechanisms like keyboard typing. + * + * If the client is unaware of the text around the cursor, it should not + * issue this request, to signify lack of support to the compositor. + * + * Text is UTF-8 encoded, and should include the cursor position, the + * complete selection and additional characters before and after them. + * There is a maximum length of wayland messages, so text can not be + * longer than 4000 bytes. + * + * Cursor is the byte offset of the cursor within text buffer. + * + * Anchor is the byte offset of the selection anchor within text buffer. + * If there is no selected text, anchor is the same as cursor. + * + * If any preedit text is present, it is replaced with a cursor for the + * purpose of this event. + * + * Values set with this request are double-buffered. They will get applied + * on the next zwp_text_input_v3.commit request, and stay valid until the + * next committed enable or disable request. + * + * The initial state for affected fields is empty, meaning that the text + * input does not support sending surrounding text. If the empty values + * get applied, subsequent attempts to change them may have no effect. + */ +static inline void +zwp_text_input_v3_set_surrounding_text(struct zwp_text_input_v3 *zwp_text_input_v3, const char *text, int32_t cursor, int32_t anchor) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_v3, + ZWP_TEXT_INPUT_V3_SET_SURROUNDING_TEXT, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_v3), 0, text, cursor, anchor); +} + +/** + * @ingroup iface_zwp_text_input_v3 + * + * Tells the compositor why the text surrounding the cursor changed. + * + * Whenever the client detects an external change in text, cursor, or + * anchor posision, it must issue this request to the compositor. This + * request is intended to give the input method a chance to update the + * preedit text in an appropriate way, e.g. by removing it when the user + * starts typing with a keyboard. + * + * cause describes the source of the change. + * + * The value set with this request is double-buffered. It must be applied + * and reset to initial at the next zwp_text_input_v3.commit request. + * + * The initial value of cause is input_method. + */ +static inline void +zwp_text_input_v3_set_text_change_cause(struct zwp_text_input_v3 *zwp_text_input_v3, uint32_t cause) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_v3, + ZWP_TEXT_INPUT_V3_SET_TEXT_CHANGE_CAUSE, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_v3), 0, cause); +} + +/** + * @ingroup iface_zwp_text_input_v3 + * + * Sets the content purpose and content hint. While the purpose is the + * basic purpose of an input field, the hint flags allow to modify some of + * the behavior. + * + * Values set with this request are double-buffered. They will get applied + * on the next zwp_text_input_v3.commit request. + * Subsequent attempts to update them may have no effect. The values + * remain valid until the next committed enable or disable request. + * + * The initial value for hint is none, and the initial value for purpose + * is normal. + */ +static inline void +zwp_text_input_v3_set_content_type(struct zwp_text_input_v3 *zwp_text_input_v3, uint32_t hint, uint32_t purpose) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_v3, + ZWP_TEXT_INPUT_V3_SET_CONTENT_TYPE, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_v3), 0, hint, purpose); +} + +/** + * @ingroup iface_zwp_text_input_v3 + * + * Marks an area around the cursor as a x, y, width, height rectangle in + * surface local coordinates. + * + * Allows the compositor to put a window with word suggestions near the + * cursor, without obstructing the text being input. + * + * If the client is unaware of the position of edited text, it should not + * issue this request, to signify lack of support to the compositor. + * + * Values set with this request are double-buffered. They will get applied + * on the next zwp_text_input_v3.commit request, and stay valid until the + * next committed enable or disable request. + * + * The initial values describing a cursor rectangle are empty. That means + * the text input does not support describing the cursor area. If the + * empty values get applied, subsequent attempts to change them may have + * no effect. + * + * As of version 2, the zwp_text_input_v3.commit request does not apply + * values sent with this request. Instead, it stores them in a separate + * "committed" area. The committed values, if still valid, get applied on + * the next wl_surface.commit request on the surface with text-input focus. + * Both committed and applied values get invalidated on: + * + * - the next committed enable or disable request, or + * - a change of the focused surface of the text-input (leave or enter events). + * + * This double stage application allows the compositor to position + * the input method popup in the same frame as the contents + * of the text on the surface are updated. + */ +static inline void +zwp_text_input_v3_set_cursor_rectangle(struct zwp_text_input_v3 *zwp_text_input_v3, int32_t x, int32_t y, int32_t width, int32_t height) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_v3, + ZWP_TEXT_INPUT_V3_SET_CURSOR_RECTANGLE, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_v3), 0, x, y, width, height); +} + +/** + * @ingroup iface_zwp_text_input_v3 + * + * Atomically applies state changes recently sent to the compositor. + * + * The commit request establishes and updates the state of the client, and + * must be issued after any changes to apply them. + * + * Text input state (enabled status, content purpose, content hint, + * surrounding text and change cause, cursor rectangle) is conceptually + * double-buffered within the context of a text input, i.e. between a + * committed enable request and the following committed enable or disable + * request. + * + * Protocol requests modify the pending state, as opposed to the current + * state in use by the input method. A commit request atomically applies + * all pending state, replacing the current state. After commit, the new + * pending state is as documented for each related request. + * + * Requests are applied in the order of arrival. + * + * Neither current nor pending state are modified unless noted otherwise. + * + * The compositor must count the number of commit requests coming from + * each zwp_text_input_v3 object and use the count as the serial in done + * events. + */ +static inline void +zwp_text_input_v3_commit(struct zwp_text_input_v3 *zwp_text_input_v3) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_v3, + ZWP_TEXT_INPUT_V3_COMMIT, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_v3), 0); +} + +/** + * @ingroup iface_zwp_text_input_v3 + * + * Set the actions available for this text input. + * + * Values set with this request are double-buffered. They will get applied + * on the next zwp_text_input_v3.commit request. + * + * If the available_actions array contains the none action, or contains the + * same action multiple times, the compositor must raise the invalid_action + * protocol error. + * + * Initially, no actions are available. + */ +static inline void +zwp_text_input_v3_set_available_actions(struct zwp_text_input_v3 *zwp_text_input_v3, struct wl_array *available_actions) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_v3, + ZWP_TEXT_INPUT_V3_SET_AVAILABLE_ACTIONS, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_v3), 0, available_actions); +} + +/** + * @ingroup iface_zwp_text_input_v3 + * + * Requests an input panel to be shown (e.g. a on-screen keyboard). + * + * This request only hints the desired interaction pattern from the + * client side, and its effect may be ignored by compositors given + * other environmental factors. Repeated calls will be ignored. + */ +static inline void +zwp_text_input_v3_show_input_panel(struct zwp_text_input_v3 *zwp_text_input_v3) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_v3, + ZWP_TEXT_INPUT_V3_SHOW_INPUT_PANEL, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_v3), 0); +} + +/** + * @ingroup iface_zwp_text_input_v3 + * + * Requests an input panel to be hidden. + * + * This request only hints the desired interaction pattern from the + * client side, and its effect may be ignored by compositors given + * other environmental factors. Repeated calls will be ignored. + */ +static inline void +zwp_text_input_v3_hide_input_panel(struct zwp_text_input_v3 *zwp_text_input_v3) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_v3, + ZWP_TEXT_INPUT_V3_HIDE_INPUT_PANEL, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_v3), 0); +} + +#define ZWP_TEXT_INPUT_MANAGER_V3_DESTROY 0 +#define ZWP_TEXT_INPUT_MANAGER_V3_GET_TEXT_INPUT 1 + + +/** + * @ingroup iface_zwp_text_input_manager_v3 + */ +#define ZWP_TEXT_INPUT_MANAGER_V3_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_zwp_text_input_manager_v3 + */ +#define ZWP_TEXT_INPUT_MANAGER_V3_GET_TEXT_INPUT_SINCE_VERSION 1 + +/** @ingroup iface_zwp_text_input_manager_v3 */ +static inline void +zwp_text_input_manager_v3_set_user_data(struct zwp_text_input_manager_v3 *zwp_text_input_manager_v3, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zwp_text_input_manager_v3, user_data); +} + +/** @ingroup iface_zwp_text_input_manager_v3 */ +static inline void * +zwp_text_input_manager_v3_get_user_data(struct zwp_text_input_manager_v3 *zwp_text_input_manager_v3) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zwp_text_input_manager_v3); +} + +static inline uint32_t +zwp_text_input_manager_v3_get_version(struct zwp_text_input_manager_v3 *zwp_text_input_manager_v3) +{ + return wl_proxy_get_version((struct wl_proxy *) zwp_text_input_manager_v3); +} + +/** + * @ingroup iface_zwp_text_input_manager_v3 + * + * Destroy the wp_text_input_manager object. + */ +static inline void +zwp_text_input_manager_v3_destroy(struct zwp_text_input_manager_v3 *zwp_text_input_manager_v3) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_manager_v3, + ZWP_TEXT_INPUT_MANAGER_V3_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_manager_v3), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_zwp_text_input_manager_v3 + * + * Creates a new text-input object for a given seat. + */ +static inline struct zwp_text_input_v3 * +zwp_text_input_manager_v3_get_text_input(struct zwp_text_input_manager_v3 *zwp_text_input_manager_v3, struct wl_seat *seat) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) zwp_text_input_manager_v3, + ZWP_TEXT_INPUT_MANAGER_V3_GET_TEXT_INPUT, &zwp_text_input_v3_interface, wl_proxy_get_version((struct wl_proxy *) zwp_text_input_manager_v3), 0, NULL, seat); + + return (struct zwp_text_input_v3 *) id; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/text-input-unstable-v3-protocol.c b/src/platform/wayland/protocols/text-input-unstable-v3-protocol.c new file mode 100644 index 0000000..7683650 --- /dev/null +++ b/src/platform/wayland/protocols/text-input-unstable-v3-protocol.c @@ -0,0 +1,103 @@ +/* Generated by wayland-scanner 1.26.0 */ + +/* + * Copyright © 2012, 2013 Intel Corporation + * Copyright © 2015, 2016 Jan Arne Petersen + * Copyright © 2017, 2018 Red Hat, Inc. + * Copyright © 2018 Purism SPC + * + * Permission to use, copy, modify, distribute, and sell this + * software and its documentation for any purpose is hereby granted + * without fee, provided that the above copyright notice appear in + * all copies and that both that copyright notice and this permission + * notice appear in supporting documentation, and that the name of + * the copyright holders not be used in advertising or publicity + * pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no + * representations about the suitability of this software for any + * purpose. It is provided "as is" without express or implied + * warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY + * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN + * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, + * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF + * THIS SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_seat_interface; +extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface zwp_text_input_v3_interface; + +static const struct wl_interface *text_input_unstable_v3_types[] = { + NULL, + NULL, + NULL, + NULL, + &wl_surface_interface, + &wl_surface_interface, + &zwp_text_input_v3_interface, + &wl_seat_interface, +}; + +static const struct wl_message zwp_text_input_v3_requests[] = { + { "destroy", "", text_input_unstable_v3_types + 0 }, + { "enable", "", text_input_unstable_v3_types + 0 }, + { "disable", "", text_input_unstable_v3_types + 0 }, + { "set_surrounding_text", "sii", text_input_unstable_v3_types + 0 }, + { "set_text_change_cause", "u", text_input_unstable_v3_types + 0 }, + { "set_content_type", "uu", text_input_unstable_v3_types + 0 }, + { "set_cursor_rectangle", "iiii", text_input_unstable_v3_types + 0 }, + { "commit", "", text_input_unstable_v3_types + 0 }, + { "set_available_actions", "2a", text_input_unstable_v3_types + 0 }, + { "show_input_panel", "2", text_input_unstable_v3_types + 0 }, + { "hide_input_panel", "2", text_input_unstable_v3_types + 0 }, +}; + +static const struct wl_message zwp_text_input_v3_events[] = { + { "enter", "o", text_input_unstable_v3_types + 4 }, + { "leave", "o", text_input_unstable_v3_types + 5 }, + { "preedit_string", "?sii", text_input_unstable_v3_types + 0 }, + { "commit_string", "?s", text_input_unstable_v3_types + 0 }, + { "delete_surrounding_text", "uu", text_input_unstable_v3_types + 0 }, + { "done", "u", text_input_unstable_v3_types + 0 }, + { "action", "2uu", text_input_unstable_v3_types + 0 }, + { "language", "2s", text_input_unstable_v3_types + 0 }, + { "preedit_hint", "2uuu", text_input_unstable_v3_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface zwp_text_input_v3_interface = { + "zwp_text_input_v3", 2, + 11, zwp_text_input_v3_requests, + 9, zwp_text_input_v3_events, +}; + +static const struct wl_message zwp_text_input_manager_v3_requests[] = { + { "destroy", "", text_input_unstable_v3_types + 0 }, + { "get_text_input", "no", text_input_unstable_v3_types + 6 }, +}; + +WL_PRIVATE const struct wl_interface zwp_text_input_manager_v3_interface = { + "zwp_text_input_manager_v3", 2, + 2, zwp_text_input_manager_v3_requests, + 0, NULL, +}; + diff --git a/src/platform/wayland/protocols/viewporter-client-protocol.h b/src/platform/wayland/protocols/viewporter-client-protocol.h new file mode 100644 index 0000000..a7818d3 --- /dev/null +++ b/src/platform/wayland/protocols/viewporter-client-protocol.h @@ -0,0 +1,394 @@ +/* Generated by wayland-scanner 1.26.0 */ + +#ifndef VIEWPORTER_CLIENT_PROTOCOL_H +#define VIEWPORTER_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_viewporter The viewporter protocol + * @section page_ifaces_viewporter Interfaces + * - @subpage page_iface_wp_viewporter - surface cropping and scaling + * - @subpage page_iface_wp_viewport - crop and scale interface to a wl_surface + * @section page_copyright_viewporter Copyright + * <pre> + * + * Copyright © 2013-2016 Collabora, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * </pre> + */ +struct wl_surface; +struct wp_viewport; +struct wp_viewporter; + +#ifndef WP_VIEWPORTER_INTERFACE +#define WP_VIEWPORTER_INTERFACE +/** + * @page page_iface_wp_viewporter wp_viewporter + * @section page_iface_wp_viewporter_desc Description + * + * The global interface exposing surface cropping and scaling + * capabilities is used to instantiate an interface extension for a + * wl_surface object. This extended interface will then allow + * cropping and scaling the surface contents, effectively + * disconnecting the direct relationship between the buffer and the + * surface size. + * @section page_iface_wp_viewporter_api API + * See @ref iface_wp_viewporter. + */ +/** + * @defgroup iface_wp_viewporter The wp_viewporter interface + * + * The global interface exposing surface cropping and scaling + * capabilities is used to instantiate an interface extension for a + * wl_surface object. This extended interface will then allow + * cropping and scaling the surface contents, effectively + * disconnecting the direct relationship between the buffer and the + * surface size. + */ +extern const struct wl_interface wp_viewporter_interface; +#endif +#ifndef WP_VIEWPORT_INTERFACE +#define WP_VIEWPORT_INTERFACE +/** + * @page page_iface_wp_viewport wp_viewport + * @section page_iface_wp_viewport_desc Description + * + * An additional interface to a wl_surface object, which allows the + * client to specify the cropping and scaling of the surface + * contents. + * + * This interface works with two concepts: the source rectangle (src_x, + * src_y, src_width, src_height), and the destination size (dst_width, + * dst_height). The contents of the source rectangle are scaled to the + * destination size, and content outside the source rectangle is ignored. + * This state is double-buffered, see wl_surface.commit. + * + * The two parts of crop and scale state are independent: the source + * rectangle, and the destination size. Initially both are unset, that + * is, no scaling is applied. The whole of the current wl_buffer is + * used as the source, and the surface size is as defined in + * wl_surface.attach. + * + * If the destination size is set, it causes the surface size to become + * dst_width, dst_height. The source (rectangle) is scaled to exactly + * this size. This overrides whatever the attached wl_buffer size is, + * unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface + * has no content and therefore no size. Otherwise, the size is always + * at least 1x1 in surface local coordinates. + * + * If the source rectangle is set, it defines what area of the wl_buffer is + * taken as the source. If the source rectangle is set and the destination + * size is not set, then src_width and src_height must be integers, and the + * surface size becomes the source rectangle size. This results in cropping + * without scaling. If src_width or src_height are not integers and + * destination size is not set, the bad_size protocol error is raised when + * the surface state is applied. + * + * The coordinate transformations from buffer pixel coordinates up to + * the surface-local coordinates happen in the following order: + * 1. buffer_transform (wl_surface.set_buffer_transform) + * 2. buffer_scale (wl_surface.set_buffer_scale) + * 3. crop and scale (wp_viewport.set*) + * This means, that the source rectangle coordinates of crop and scale + * are given in the coordinates after the buffer transform and scale, + * i.e. in the coordinates that would be the surface-local coordinates + * if the crop and scale was not applied. + * + * If src_x or src_y are negative, the bad_value protocol error is raised. + * Otherwise, if the source rectangle is partially or completely outside of + * the non-NULL wl_buffer, then the out_of_buffer protocol error is raised + * when the surface state is applied. A NULL wl_buffer does not raise the + * out_of_buffer error. + * + * If the wl_surface associated with the wp_viewport is destroyed, + * all wp_viewport requests except 'destroy' raise the protocol error + * no_surface. + * + * If the wp_viewport object is destroyed, the crop and scale + * state is removed from the wl_surface. The change will be applied + * on the next wl_surface.commit. + * @section page_iface_wp_viewport_api API + * See @ref iface_wp_viewport. + */ +/** + * @defgroup iface_wp_viewport The wp_viewport interface + * + * An additional interface to a wl_surface object, which allows the + * client to specify the cropping and scaling of the surface + * contents. + * + * This interface works with two concepts: the source rectangle (src_x, + * src_y, src_width, src_height), and the destination size (dst_width, + * dst_height). The contents of the source rectangle are scaled to the + * destination size, and content outside the source rectangle is ignored. + * This state is double-buffered, see wl_surface.commit. + * + * The two parts of crop and scale state are independent: the source + * rectangle, and the destination size. Initially both are unset, that + * is, no scaling is applied. The whole of the current wl_buffer is + * used as the source, and the surface size is as defined in + * wl_surface.attach. + * + * If the destination size is set, it causes the surface size to become + * dst_width, dst_height. The source (rectangle) is scaled to exactly + * this size. This overrides whatever the attached wl_buffer size is, + * unless the wl_buffer is NULL. If the wl_buffer is NULL, the surface + * has no content and therefore no size. Otherwise, the size is always + * at least 1x1 in surface local coordinates. + * + * If the source rectangle is set, it defines what area of the wl_buffer is + * taken as the source. If the source rectangle is set and the destination + * size is not set, then src_width and src_height must be integers, and the + * surface size becomes the source rectangle size. This results in cropping + * without scaling. If src_width or src_height are not integers and + * destination size is not set, the bad_size protocol error is raised when + * the surface state is applied. + * + * The coordinate transformations from buffer pixel coordinates up to + * the surface-local coordinates happen in the following order: + * 1. buffer_transform (wl_surface.set_buffer_transform) + * 2. buffer_scale (wl_surface.set_buffer_scale) + * 3. crop and scale (wp_viewport.set*) + * This means, that the source rectangle coordinates of crop and scale + * are given in the coordinates after the buffer transform and scale, + * i.e. in the coordinates that would be the surface-local coordinates + * if the crop and scale was not applied. + * + * If src_x or src_y are negative, the bad_value protocol error is raised. + * Otherwise, if the source rectangle is partially or completely outside of + * the non-NULL wl_buffer, then the out_of_buffer protocol error is raised + * when the surface state is applied. A NULL wl_buffer does not raise the + * out_of_buffer error. + * + * If the wl_surface associated with the wp_viewport is destroyed, + * all wp_viewport requests except 'destroy' raise the protocol error + * no_surface. + * + * If the wp_viewport object is destroyed, the crop and scale + * state is removed from the wl_surface. The change will be applied + * on the next wl_surface.commit. + */ +extern const struct wl_interface wp_viewport_interface; +#endif + +#ifndef WP_VIEWPORTER_ERROR_ENUM +#define WP_VIEWPORTER_ERROR_ENUM +enum wp_viewporter_error { + /** + * the surface already has a viewport object associated + */ + WP_VIEWPORTER_ERROR_VIEWPORT_EXISTS = 0, +}; +#endif /* WP_VIEWPORTER_ERROR_ENUM */ + +#define WP_VIEWPORTER_DESTROY 0 +#define WP_VIEWPORTER_GET_VIEWPORT 1 + + +/** + * @ingroup iface_wp_viewporter + */ +#define WP_VIEWPORTER_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_wp_viewporter + */ +#define WP_VIEWPORTER_GET_VIEWPORT_SINCE_VERSION 1 + +/** @ingroup iface_wp_viewporter */ +static inline void +wp_viewporter_set_user_data(struct wp_viewporter *wp_viewporter, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_viewporter, user_data); +} + +/** @ingroup iface_wp_viewporter */ +static inline void * +wp_viewporter_get_user_data(struct wp_viewporter *wp_viewporter) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_viewporter); +} + +static inline uint32_t +wp_viewporter_get_version(struct wp_viewporter *wp_viewporter) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_viewporter); +} + +/** + * @ingroup iface_wp_viewporter + * + * Informs the server that the client will not be using this + * protocol object anymore. This does not affect any other objects, + * wp_viewport objects included. + */ +static inline void +wp_viewporter_destroy(struct wp_viewporter *wp_viewporter) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_viewporter, + WP_VIEWPORTER_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_viewporter), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_wp_viewporter + * + * Instantiate an interface extension for the given wl_surface to + * crop and scale its content. If the given wl_surface already has + * a wp_viewport object associated, the viewport_exists + * protocol error is raised. + */ +static inline struct wp_viewport * +wp_viewporter_get_viewport(struct wp_viewporter *wp_viewporter, struct wl_surface *surface) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) wp_viewporter, + WP_VIEWPORTER_GET_VIEWPORT, &wp_viewport_interface, wl_proxy_get_version((struct wl_proxy *) wp_viewporter), 0, NULL, surface); + + return (struct wp_viewport *) id; +} + +#ifndef WP_VIEWPORT_ERROR_ENUM +#define WP_VIEWPORT_ERROR_ENUM +enum wp_viewport_error { + /** + * negative or zero values in width or height + */ + WP_VIEWPORT_ERROR_BAD_VALUE = 0, + /** + * destination size is not integer + */ + WP_VIEWPORT_ERROR_BAD_SIZE = 1, + /** + * source rectangle extends outside of the content area + */ + WP_VIEWPORT_ERROR_OUT_OF_BUFFER = 2, + /** + * the wl_surface was destroyed + */ + WP_VIEWPORT_ERROR_NO_SURFACE = 3, +}; +#endif /* WP_VIEWPORT_ERROR_ENUM */ + +#define WP_VIEWPORT_DESTROY 0 +#define WP_VIEWPORT_SET_SOURCE 1 +#define WP_VIEWPORT_SET_DESTINATION 2 + + +/** + * @ingroup iface_wp_viewport + */ +#define WP_VIEWPORT_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_wp_viewport + */ +#define WP_VIEWPORT_SET_SOURCE_SINCE_VERSION 1 +/** + * @ingroup iface_wp_viewport + */ +#define WP_VIEWPORT_SET_DESTINATION_SINCE_VERSION 1 + +/** @ingroup iface_wp_viewport */ +static inline void +wp_viewport_set_user_data(struct wp_viewport *wp_viewport, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) wp_viewport, user_data); +} + +/** @ingroup iface_wp_viewport */ +static inline void * +wp_viewport_get_user_data(struct wp_viewport *wp_viewport) +{ + return wl_proxy_get_user_data((struct wl_proxy *) wp_viewport); +} + +static inline uint32_t +wp_viewport_get_version(struct wp_viewport *wp_viewport) +{ + return wl_proxy_get_version((struct wl_proxy *) wp_viewport); +} + +/** + * @ingroup iface_wp_viewport + * + * The associated wl_surface's crop and scale state is removed. + * The change is applied on the next wl_surface.commit. + */ +static inline void +wp_viewport_destroy(struct wp_viewport *wp_viewport) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_viewport, + WP_VIEWPORT_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) wp_viewport), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_wp_viewport + * + * Set the source rectangle of the associated wl_surface. See + * wp_viewport for the description, and relation to the wl_buffer + * size. + * + * If all of x, y, width and height are -1.0, the source rectangle is + * unset instead. Any other set of values where width or height are zero + * or negative, or x or y are negative, raise the bad_value protocol + * error. + * + * The crop and scale state is double-buffered, see wl_surface.commit. + */ +static inline void +wp_viewport_set_source(struct wp_viewport *wp_viewport, wl_fixed_t x, wl_fixed_t y, wl_fixed_t width, wl_fixed_t height) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_viewport, + WP_VIEWPORT_SET_SOURCE, NULL, wl_proxy_get_version((struct wl_proxy *) wp_viewport), 0, x, y, width, height); +} + +/** + * @ingroup iface_wp_viewport + * + * Set the destination size of the associated wl_surface. See + * wp_viewport for the description, and relation to the wl_buffer + * size. + * + * If width is -1 and height is -1, the destination size is unset + * instead. Any other pair of values for width and height that + * contains zero or negative values raises the bad_value protocol + * error. + * + * The crop and scale state is double-buffered, see wl_surface.commit. + */ +static inline void +wp_viewport_set_destination(struct wp_viewport *wp_viewport, int32_t width, int32_t height) +{ + wl_proxy_marshal_flags((struct wl_proxy *) wp_viewport, + WP_VIEWPORT_SET_DESTINATION, NULL, wl_proxy_get_version((struct wl_proxy *) wp_viewport), 0, width, height); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/viewporter-protocol.c b/src/platform/wayland/protocols/viewporter-protocol.c new file mode 100644 index 0000000..12c9527 --- /dev/null +++ b/src/platform/wayland/protocols/viewporter-protocol.c @@ -0,0 +1,75 @@ +/* Generated by wayland-scanner 1.26.0 */ + +/* + * Copyright © 2013-2016 Collabora, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface wp_viewport_interface; + +static const struct wl_interface *viewporter_types[] = { + NULL, + NULL, + NULL, + NULL, + &wp_viewport_interface, + &wl_surface_interface, +}; + +static const struct wl_message wp_viewporter_requests[] = { + { "destroy", "", viewporter_types + 0 }, + { "get_viewport", "no", viewporter_types + 4 }, +}; + +WL_PRIVATE const struct wl_interface wp_viewporter_interface = { + "wp_viewporter", 1, + 2, wp_viewporter_requests, + 0, NULL, +}; + +static const struct wl_message wp_viewport_requests[] = { + { "destroy", "", viewporter_types + 0 }, + { "set_source", "ffff", viewporter_types + 0 }, + { "set_destination", "ii", viewporter_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface wp_viewport_interface = { + "wp_viewport", 1, + 3, wp_viewport_requests, + 0, NULL, +}; + diff --git a/src/platform/wayland/protocols/xdg-decoration-client-protocol.h b/src/platform/wayland/protocols/xdg-decoration-client-protocol.h new file mode 100644 index 0000000..4cbc976 --- /dev/null +++ b/src/platform/wayland/protocols/xdg-decoration-client-protocol.h @@ -0,0 +1,400 @@ +/* Generated by wayland-scanner 1.26.0 */ + +#ifndef XDG_DECORATION_UNSTABLE_V1_CLIENT_PROTOCOL_H +#define XDG_DECORATION_UNSTABLE_V1_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_xdg_decoration_unstable_v1 The xdg_decoration_unstable_v1 protocol + * @section page_ifaces_xdg_decoration_unstable_v1 Interfaces + * - @subpage page_iface_zxdg_decoration_manager_v1 - window decoration manager + * - @subpage page_iface_zxdg_toplevel_decoration_v1 - decoration object for a toplevel surface + * @section page_copyright_xdg_decoration_unstable_v1 Copyright + * <pre> + * + * Copyright © 2018 Simon Ser + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * </pre> + */ +struct xdg_toplevel; +struct zxdg_decoration_manager_v1; +struct zxdg_toplevel_decoration_v1; + +#ifndef ZXDG_DECORATION_MANAGER_V1_INTERFACE +#define ZXDG_DECORATION_MANAGER_V1_INTERFACE +/** + * @page page_iface_zxdg_decoration_manager_v1 zxdg_decoration_manager_v1 + * @section page_iface_zxdg_decoration_manager_v1_desc Description + * + * This interface allows a compositor to announce support for server-side + * decorations. + * + * A window decoration is a set of window controls as deemed appropriate by + * the party managing them, such as user interface components used to move, + * resize and change a window's state. + * + * A client can use this protocol to request being decorated by a supporting + * compositor. + * + * If compositor and client do not negotiate the use of a server-side + * decoration using this protocol, clients continue to self-decorate as they + * see fit. + * + * Warning! The protocol described in this file is experimental and + * backward incompatible changes may be made. Backward compatible changes + * may be added together with the corresponding interface version bump. + * Backward incompatible changes are done by bumping the version number in + * the protocol and interface names and resetting the interface version. + * Once the protocol is to be declared stable, the 'z' prefix and the + * version number in the protocol and interface names are removed and the + * interface version number is reset. + * @section page_iface_zxdg_decoration_manager_v1_api API + * See @ref iface_zxdg_decoration_manager_v1. + */ +/** + * @defgroup iface_zxdg_decoration_manager_v1 The zxdg_decoration_manager_v1 interface + * + * This interface allows a compositor to announce support for server-side + * decorations. + * + * A window decoration is a set of window controls as deemed appropriate by + * the party managing them, such as user interface components used to move, + * resize and change a window's state. + * + * A client can use this protocol to request being decorated by a supporting + * compositor. + * + * If compositor and client do not negotiate the use of a server-side + * decoration using this protocol, clients continue to self-decorate as they + * see fit. + * + * Warning! The protocol described in this file is experimental and + * backward incompatible changes may be made. Backward compatible changes + * may be added together with the corresponding interface version bump. + * Backward incompatible changes are done by bumping the version number in + * the protocol and interface names and resetting the interface version. + * Once the protocol is to be declared stable, the 'z' prefix and the + * version number in the protocol and interface names are removed and the + * interface version number is reset. + */ +extern const struct wl_interface zxdg_decoration_manager_v1_interface; +#endif +#ifndef ZXDG_TOPLEVEL_DECORATION_V1_INTERFACE +#define ZXDG_TOPLEVEL_DECORATION_V1_INTERFACE +/** + * @page page_iface_zxdg_toplevel_decoration_v1 zxdg_toplevel_decoration_v1 + * @section page_iface_zxdg_toplevel_decoration_v1_desc Description + * + * The decoration object allows the compositor to toggle server-side window + * decorations for a toplevel surface. The client can request to switch to + * another mode. + * + * The xdg_toplevel_decoration object must be destroyed before its + * xdg_toplevel. + * @section page_iface_zxdg_toplevel_decoration_v1_api API + * See @ref iface_zxdg_toplevel_decoration_v1. + */ +/** + * @defgroup iface_zxdg_toplevel_decoration_v1 The zxdg_toplevel_decoration_v1 interface + * + * The decoration object allows the compositor to toggle server-side window + * decorations for a toplevel surface. The client can request to switch to + * another mode. + * + * The xdg_toplevel_decoration object must be destroyed before its + * xdg_toplevel. + */ +extern const struct wl_interface zxdg_toplevel_decoration_v1_interface; +#endif + +#define ZXDG_DECORATION_MANAGER_V1_DESTROY 0 +#define ZXDG_DECORATION_MANAGER_V1_GET_TOPLEVEL_DECORATION 1 + + +/** + * @ingroup iface_zxdg_decoration_manager_v1 + */ +#define ZXDG_DECORATION_MANAGER_V1_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_zxdg_decoration_manager_v1 + */ +#define ZXDG_DECORATION_MANAGER_V1_GET_TOPLEVEL_DECORATION_SINCE_VERSION 1 + +/** @ingroup iface_zxdg_decoration_manager_v1 */ +static inline void +zxdg_decoration_manager_v1_set_user_data(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zxdg_decoration_manager_v1, user_data); +} + +/** @ingroup iface_zxdg_decoration_manager_v1 */ +static inline void * +zxdg_decoration_manager_v1_get_user_data(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zxdg_decoration_manager_v1); +} + +static inline uint32_t +zxdg_decoration_manager_v1_get_version(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) zxdg_decoration_manager_v1); +} + +/** + * @ingroup iface_zxdg_decoration_manager_v1 + * + * Destroy the decoration manager. This doesn't destroy objects created + * with the manager. + */ +static inline void +zxdg_decoration_manager_v1_destroy(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zxdg_decoration_manager_v1, + ZXDG_DECORATION_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_decoration_manager_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_zxdg_decoration_manager_v1 + * + * Create a new decoration object associated with the given toplevel. + * + * For objects of version 1, creating an xdg_toplevel_decoration from an + * xdg_toplevel which has a buffer attached or committed is a client + * error, and any attempts by a client to attach or manipulate a buffer + * prior to the first xdg_toplevel_decoration.configure event must also be + * treated as errors. + * + * For objects of version 2 or newer, creating an xdg_toplevel_decoration + * from an xdg_toplevel which has a buffer attached or committed is + * allowed. The initial decoration mode of the surface if a buffer is + * already attached depends on whether a xdg_toplevel_decoration object + * has been associated with the surface or not prior to this request. + * + * If an xdg_toplevel_decoration was associated with the surface, then + * destroyed without a surface commit, the previous decoration mode is + * retained. + * + * If no xdg_toplevel_decoration was associated with the surface prior to + * this request, or if a surface commit has been performed after a previous + * xdg_toplevel_decoration object associated with the surface was + * destroyed, the decoration mode is assumed to be client-side. + */ +static inline struct zxdg_toplevel_decoration_v1 * +zxdg_decoration_manager_v1_get_toplevel_decoration(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1, struct xdg_toplevel *toplevel) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) zxdg_decoration_manager_v1, + ZXDG_DECORATION_MANAGER_V1_GET_TOPLEVEL_DECORATION, &zxdg_toplevel_decoration_v1_interface, wl_proxy_get_version((struct wl_proxy *) zxdg_decoration_manager_v1), 0, NULL, toplevel); + + return (struct zxdg_toplevel_decoration_v1 *) id; +} + +#ifndef ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ENUM +#define ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ENUM +enum zxdg_toplevel_decoration_v1_error { + /** + * xdg_toplevel has a buffer attached before configure + */ + ZXDG_TOPLEVEL_DECORATION_V1_ERROR_UNCONFIGURED_BUFFER = 0, + /** + * xdg_toplevel already has a decoration object + */ + ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ALREADY_CONSTRUCTED = 1, + /** + * xdg_toplevel destroyed before the decoration object + */ + ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ORPHANED = 2, + /** + * invalid mode + */ + ZXDG_TOPLEVEL_DECORATION_V1_ERROR_INVALID_MODE = 3, +}; +#endif /* ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ENUM */ + +#ifndef ZXDG_TOPLEVEL_DECORATION_V1_MODE_ENUM +#define ZXDG_TOPLEVEL_DECORATION_V1_MODE_ENUM +/** + * @ingroup iface_zxdg_toplevel_decoration_v1 + * window decoration modes + * + * These values describe window decoration modes. + */ +enum zxdg_toplevel_decoration_v1_mode { + /** + * no server-side window decoration + */ + ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE = 1, + /** + * server-side window decoration + */ + ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE = 2, +}; +#endif /* ZXDG_TOPLEVEL_DECORATION_V1_MODE_ENUM */ + +/** + * @ingroup iface_zxdg_toplevel_decoration_v1 + * @struct zxdg_toplevel_decoration_v1_listener + */ +struct zxdg_toplevel_decoration_v1_listener { + /** + * notify a decoration mode change + * + * The configure event configures the effective decoration mode. + * The configured state should not be applied immediately. Clients + * must send an ack_configure in response to this event. See + * xdg_surface.configure and xdg_surface.ack_configure for details. + * + * A configure event can be sent at any time. The specified mode + * must be obeyed by the client. + * @param mode the decoration mode + */ + void (*configure)(void *data, + struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, + uint32_t mode); +}; + +/** + * @ingroup iface_zxdg_toplevel_decoration_v1 + */ +static inline int +zxdg_toplevel_decoration_v1_add_listener(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, + const struct zxdg_toplevel_decoration_v1_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) zxdg_toplevel_decoration_v1, + (void (**)(void)) listener, data); +} + +#define ZXDG_TOPLEVEL_DECORATION_V1_DESTROY 0 +#define ZXDG_TOPLEVEL_DECORATION_V1_SET_MODE 1 +#define ZXDG_TOPLEVEL_DECORATION_V1_UNSET_MODE 2 + +/** + * @ingroup iface_zxdg_toplevel_decoration_v1 + */ +#define ZXDG_TOPLEVEL_DECORATION_V1_CONFIGURE_SINCE_VERSION 1 + +/** + * @ingroup iface_zxdg_toplevel_decoration_v1 + */ +#define ZXDG_TOPLEVEL_DECORATION_V1_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_zxdg_toplevel_decoration_v1 + */ +#define ZXDG_TOPLEVEL_DECORATION_V1_SET_MODE_SINCE_VERSION 1 +/** + * @ingroup iface_zxdg_toplevel_decoration_v1 + */ +#define ZXDG_TOPLEVEL_DECORATION_V1_UNSET_MODE_SINCE_VERSION 1 + +/** @ingroup iface_zxdg_toplevel_decoration_v1 */ +static inline void +zxdg_toplevel_decoration_v1_set_user_data(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) zxdg_toplevel_decoration_v1, user_data); +} + +/** @ingroup iface_zxdg_toplevel_decoration_v1 */ +static inline void * +zxdg_toplevel_decoration_v1_get_user_data(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) zxdg_toplevel_decoration_v1); +} + +static inline uint32_t +zxdg_toplevel_decoration_v1_get_version(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1); +} + +/** + * @ingroup iface_zxdg_toplevel_decoration_v1 + * + * Switch back to a mode without any server-side decorations at the next + * commit, unless a new xdg_toplevel_decoration is created for the surface + * first. + */ +static inline void +zxdg_toplevel_decoration_v1_destroy(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zxdg_toplevel_decoration_v1, + ZXDG_TOPLEVEL_DECORATION_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_zxdg_toplevel_decoration_v1 + * + * Set the toplevel surface decoration mode. This informs the compositor + * that the client prefers the provided decoration mode. + * + * After requesting a decoration mode, the compositor will respond by + * emitting an xdg_surface.configure event. The client should then update + * its content, drawing it without decorations if the received mode is + * server-side decorations. The client must also acknowledge the configure + * when committing the new content (see xdg_surface.ack_configure). + * + * The compositor can decide not to use the client's mode and enforce a + * different mode instead. + * + * Clients whose decoration mode depend on the xdg_toplevel state may send + * a set_mode request in response to an xdg_surface.configure event and wait + * for the next xdg_surface.configure event to prevent unwanted state. + * Such clients are responsible for preventing configure loops and must + * make sure not to send multiple successive set_mode requests with the + * same decoration mode. + * + * If an invalid mode is supplied by the client, the invalid_mode protocol + * error is raised by the compositor. + */ +static inline void +zxdg_toplevel_decoration_v1_set_mode(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, uint32_t mode) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zxdg_toplevel_decoration_v1, + ZXDG_TOPLEVEL_DECORATION_V1_SET_MODE, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1), 0, mode); +} + +/** + * @ingroup iface_zxdg_toplevel_decoration_v1 + * + * Unset the toplevel surface decoration mode. This informs the compositor + * that the client doesn't prefer a particular decoration mode. + * + * This request has the same semantics as set_mode. + */ +static inline void +zxdg_toplevel_decoration_v1_unset_mode(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) zxdg_toplevel_decoration_v1, + ZXDG_TOPLEVEL_DECORATION_V1_UNSET_MODE, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1), 0); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/xdg-decoration-protocol.c b/src/platform/wayland/protocols/xdg-decoration-protocol.c new file mode 100644 index 0000000..db0a29d --- /dev/null +++ b/src/platform/wayland/protocols/xdg-decoration-protocol.c @@ -0,0 +1,76 @@ +/* Generated by wayland-scanner 1.26.0 */ + +/* + * Copyright © 2018 Simon Ser + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface xdg_toplevel_interface; +extern const struct wl_interface zxdg_toplevel_decoration_v1_interface; + +static const struct wl_interface *xdg_decoration_unstable_v1_types[] = { + NULL, + &zxdg_toplevel_decoration_v1_interface, + &xdg_toplevel_interface, +}; + +static const struct wl_message zxdg_decoration_manager_v1_requests[] = { + { "destroy", "", xdg_decoration_unstable_v1_types + 0 }, + { "get_toplevel_decoration", "no", xdg_decoration_unstable_v1_types + 1 }, +}; + +WL_PRIVATE const struct wl_interface zxdg_decoration_manager_v1_interface = { + "zxdg_decoration_manager_v1", 2, + 2, zxdg_decoration_manager_v1_requests, + 0, NULL, +}; + +static const struct wl_message zxdg_toplevel_decoration_v1_requests[] = { + { "destroy", "", xdg_decoration_unstable_v1_types + 0 }, + { "set_mode", "u", xdg_decoration_unstable_v1_types + 0 }, + { "unset_mode", "", xdg_decoration_unstable_v1_types + 0 }, +}; + +static const struct wl_message zxdg_toplevel_decoration_v1_events[] = { + { "configure", "u", xdg_decoration_unstable_v1_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface zxdg_toplevel_decoration_v1_interface = { + "zxdg_toplevel_decoration_v1", 2, + 3, zxdg_toplevel_decoration_v1_requests, + 1, zxdg_toplevel_decoration_v1_events, +}; + diff --git a/src/platform/wayland/protocols/xdg-shell-client-protocol.h b/src/platform/wayland/protocols/xdg-shell-client-protocol.h new file mode 100644 index 0000000..1cb6016 --- /dev/null +++ b/src/platform/wayland/protocols/xdg-shell-client-protocol.h @@ -0,0 +1,2392 @@ +/* Generated by wayland-scanner 1.25.0 */ + +#ifndef XDG_SHELL_CLIENT_PROTOCOL_H +#define XDG_SHELL_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_xdg_shell The xdg_shell protocol + * @section page_ifaces_xdg_shell Interfaces + * - @subpage page_iface_xdg_wm_base - create desktop-style surfaces + * - @subpage page_iface_xdg_positioner - child surface positioner + * - @subpage page_iface_xdg_surface - desktop user interface surface base interface + * - @subpage page_iface_xdg_toplevel - toplevel surface + * - @subpage page_iface_xdg_popup - short-lived, popup surfaces for menus + * @section page_copyright_xdg_shell Copyright + * <pre> + * + * Copyright © 2008-2013 Kristian Høgsberg + * Copyright © 2013 Rafael Antognolli + * Copyright © 2013 Jasper St. Pierre + * Copyright © 2010-2013 Intel Corporation + * Copyright © 2015-2017 Samsung Electronics Co., Ltd + * Copyright © 2015-2017 Red Hat Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * </pre> + */ +struct wl_output; +struct wl_seat; +struct wl_surface; +struct xdg_popup; +struct xdg_positioner; +struct xdg_surface; +struct xdg_toplevel; +struct xdg_wm_base; + +#ifndef XDG_WM_BASE_INTERFACE +#define XDG_WM_BASE_INTERFACE +/** + * @page page_iface_xdg_wm_base xdg_wm_base + * @section page_iface_xdg_wm_base_desc Description + * + * The xdg_wm_base interface is exposed as a global object enabling clients + * to turn their wl_surfaces into windows in a desktop environment. It + * defines the basic functionality needed for clients and the compositor to + * create windows that can be dragged, resized, maximized, etc, as well as + * creating transient windows such as popup menus. + * @section page_iface_xdg_wm_base_api API + * See @ref iface_xdg_wm_base. + */ +/** + * @defgroup iface_xdg_wm_base The xdg_wm_base interface + * + * The xdg_wm_base interface is exposed as a global object enabling clients + * to turn their wl_surfaces into windows in a desktop environment. It + * defines the basic functionality needed for clients and the compositor to + * create windows that can be dragged, resized, maximized, etc, as well as + * creating transient windows such as popup menus. + */ +extern const struct wl_interface xdg_wm_base_interface; +#endif +#ifndef XDG_POSITIONER_INTERFACE +#define XDG_POSITIONER_INTERFACE +/** + * @page page_iface_xdg_positioner xdg_positioner + * @section page_iface_xdg_positioner_desc Description + * + * The xdg_positioner provides a collection of rules for the placement of a + * child surface relative to a parent surface. Rules can be defined to ensure + * the child surface remains within the visible area's borders, and to + * specify how the child surface changes its position, such as sliding along + * an axis, or flipping around a rectangle. These positioner-created rules are + * constrained by the requirement that a child surface must intersect with or + * be at least partially adjacent to its parent surface. + * + * See the various requests for details about possible rules. + * + * At the time of the request, the compositor makes a copy of the rules + * specified by the xdg_positioner. Thus, after the request is complete the + * xdg_positioner object can be destroyed or reused; further changes to the + * object will have no effect on previous usages. + * + * For an xdg_positioner object to be considered complete, it must have a + * non-zero size set by set_size, and a non-zero anchor rectangle set by + * set_anchor_rect. Passing an incomplete xdg_positioner object when + * positioning a surface raises an invalid_positioner error. + * @section page_iface_xdg_positioner_api API + * See @ref iface_xdg_positioner. + */ +/** + * @defgroup iface_xdg_positioner The xdg_positioner interface + * + * The xdg_positioner provides a collection of rules for the placement of a + * child surface relative to a parent surface. Rules can be defined to ensure + * the child surface remains within the visible area's borders, and to + * specify how the child surface changes its position, such as sliding along + * an axis, or flipping around a rectangle. These positioner-created rules are + * constrained by the requirement that a child surface must intersect with or + * be at least partially adjacent to its parent surface. + * + * See the various requests for details about possible rules. + * + * At the time of the request, the compositor makes a copy of the rules + * specified by the xdg_positioner. Thus, after the request is complete the + * xdg_positioner object can be destroyed or reused; further changes to the + * object will have no effect on previous usages. + * + * For an xdg_positioner object to be considered complete, it must have a + * non-zero size set by set_size, and a non-zero anchor rectangle set by + * set_anchor_rect. Passing an incomplete xdg_positioner object when + * positioning a surface raises an invalid_positioner error. + */ +extern const struct wl_interface xdg_positioner_interface; +#endif +#ifndef XDG_SURFACE_INTERFACE +#define XDG_SURFACE_INTERFACE +/** + * @page page_iface_xdg_surface xdg_surface + * @section page_iface_xdg_surface_desc Description + * + * An interface that may be implemented by a wl_surface, for + * implementations that provide a desktop-style user interface. + * + * It provides a base set of functionality required to construct user + * interface elements requiring management by the compositor, such as + * toplevel windows, menus, etc. The types of functionality are split into + * xdg_surface roles. + * + * Creating an xdg_surface does not set the role for a wl_surface. In order + * to map an xdg_surface, the client must create a role-specific object + * using, e.g., get_toplevel, get_popup. The wl_surface for any given + * xdg_surface can have at most one role, and may not be assigned any role + * not based on xdg_surface. + * + * A role must be assigned before any other requests are made to the + * xdg_surface object. + * + * The client must call wl_surface.commit on the corresponding wl_surface + * for the xdg_surface state to take effect. + * + * Creating an xdg_surface from a wl_surface which has a buffer attached or + * committed is a client error, and any attempts by a client to attach or + * manipulate a buffer prior to the first xdg_surface.configure call must + * also be treated as errors. + * + * After creating a role-specific object and setting it up (e.g. by sending + * the title, app ID, size constraints, parent, etc), the client must + * perform an initial commit without any buffer attached. The compositor + * will reply with initial wl_surface state such as + * wl_surface.preferred_buffer_scale followed by an xdg_surface.configure + * event. The client must acknowledge it and is then allowed to attach a + * buffer to map the surface. + * + * Mapping an xdg_surface-based role surface is defined as making it + * possible for the surface to be shown by the compositor. Note that + * a mapped surface is not guaranteed to be visible once it is mapped. + * + * For an xdg_surface to be mapped by the compositor, the following + * conditions must be met: + * (1) the client has assigned an xdg_surface-based role to the surface + * (2) the client has set and committed the xdg_surface state and the + * role-dependent state to the surface + * (3) the client has committed a buffer to the surface + * + * A newly-unmapped surface is considered to have met condition (1) out + * of the 3 required conditions for mapping a surface if its role surface + * has not been destroyed, i.e. the client must perform the initial commit + * again before attaching a buffer. + * @section page_iface_xdg_surface_api API + * See @ref iface_xdg_surface. + */ +/** + * @defgroup iface_xdg_surface The xdg_surface interface + * + * An interface that may be implemented by a wl_surface, for + * implementations that provide a desktop-style user interface. + * + * It provides a base set of functionality required to construct user + * interface elements requiring management by the compositor, such as + * toplevel windows, menus, etc. The types of functionality are split into + * xdg_surface roles. + * + * Creating an xdg_surface does not set the role for a wl_surface. In order + * to map an xdg_surface, the client must create a role-specific object + * using, e.g., get_toplevel, get_popup. The wl_surface for any given + * xdg_surface can have at most one role, and may not be assigned any role + * not based on xdg_surface. + * + * A role must be assigned before any other requests are made to the + * xdg_surface object. + * + * The client must call wl_surface.commit on the corresponding wl_surface + * for the xdg_surface state to take effect. + * + * Creating an xdg_surface from a wl_surface which has a buffer attached or + * committed is a client error, and any attempts by a client to attach or + * manipulate a buffer prior to the first xdg_surface.configure call must + * also be treated as errors. + * + * After creating a role-specific object and setting it up (e.g. by sending + * the title, app ID, size constraints, parent, etc), the client must + * perform an initial commit without any buffer attached. The compositor + * will reply with initial wl_surface state such as + * wl_surface.preferred_buffer_scale followed by an xdg_surface.configure + * event. The client must acknowledge it and is then allowed to attach a + * buffer to map the surface. + * + * Mapping an xdg_surface-based role surface is defined as making it + * possible for the surface to be shown by the compositor. Note that + * a mapped surface is not guaranteed to be visible once it is mapped. + * + * For an xdg_surface to be mapped by the compositor, the following + * conditions must be met: + * (1) the client has assigned an xdg_surface-based role to the surface + * (2) the client has set and committed the xdg_surface state and the + * role-dependent state to the surface + * (3) the client has committed a buffer to the surface + * + * A newly-unmapped surface is considered to have met condition (1) out + * of the 3 required conditions for mapping a surface if its role surface + * has not been destroyed, i.e. the client must perform the initial commit + * again before attaching a buffer. + */ +extern const struct wl_interface xdg_surface_interface; +#endif +#ifndef XDG_TOPLEVEL_INTERFACE +#define XDG_TOPLEVEL_INTERFACE +/** + * @page page_iface_xdg_toplevel xdg_toplevel + * @section page_iface_xdg_toplevel_desc Description + * + * This interface defines an xdg_surface role which allows a surface to, + * among other things, set window-like properties such as maximize, + * fullscreen, and minimize, set application-specific metadata like title and + * id, and well as trigger user interactive operations such as interactive + * resize and move. + * + * An xdg_toplevel by default is responsible for providing the full intended + * visual representation of the toplevel, which depending on the window + * state, may mean things like a title bar, window controls and drop shadow. + * + * Unmapping an xdg_toplevel means that the surface cannot be shown + * by the compositor until it is explicitly mapped again. + * All active operations (e.g., move, resize) are canceled and all + * attributes (e.g. title, state, stacking, ...) are discarded for + * an xdg_toplevel surface when it is unmapped. The xdg_toplevel returns to + * the state it had right after xdg_surface.get_toplevel. The client + * can re-map the toplevel by performing a commit without any buffer + * attached, waiting for a configure event and handling it as usual (see + * xdg_surface description). + * + * Attaching a null buffer to a toplevel unmaps the surface. + * @section page_iface_xdg_toplevel_api API + * See @ref iface_xdg_toplevel. + */ +/** + * @defgroup iface_xdg_toplevel The xdg_toplevel interface + * + * This interface defines an xdg_surface role which allows a surface to, + * among other things, set window-like properties such as maximize, + * fullscreen, and minimize, set application-specific metadata like title and + * id, and well as trigger user interactive operations such as interactive + * resize and move. + * + * An xdg_toplevel by default is responsible for providing the full intended + * visual representation of the toplevel, which depending on the window + * state, may mean things like a title bar, window controls and drop shadow. + * + * Unmapping an xdg_toplevel means that the surface cannot be shown + * by the compositor until it is explicitly mapped again. + * All active operations (e.g., move, resize) are canceled and all + * attributes (e.g. title, state, stacking, ...) are discarded for + * an xdg_toplevel surface when it is unmapped. The xdg_toplevel returns to + * the state it had right after xdg_surface.get_toplevel. The client + * can re-map the toplevel by performing a commit without any buffer + * attached, waiting for a configure event and handling it as usual (see + * xdg_surface description). + * + * Attaching a null buffer to a toplevel unmaps the surface. + */ +extern const struct wl_interface xdg_toplevel_interface; +#endif +#ifndef XDG_POPUP_INTERFACE +#define XDG_POPUP_INTERFACE +/** + * @page page_iface_xdg_popup xdg_popup + * @section page_iface_xdg_popup_desc Description + * + * A popup surface is a short-lived, temporary surface. It can be used to + * implement for example menus, popovers, tooltips and other similar user + * interface concepts. + * + * A popup can be made to take an explicit grab. See xdg_popup.grab for + * details. + * + * When the popup is dismissed, a popup_done event will be sent out, and at + * the same time the surface will be unmapped. See the xdg_popup.popup_done + * event for details. + * + * Explicitly destroying the xdg_popup object will also dismiss the popup and + * unmap the surface. Clients that want to dismiss the popup when another + * surface of their own is clicked should dismiss the popup using the destroy + * request. + * + * A newly created xdg_popup will be stacked on top of all previously created + * xdg_popup surfaces associated with the same xdg_toplevel. + * + * The parent of an xdg_popup must be mapped (see the xdg_surface + * description) before the xdg_popup itself. + * + * The client must call wl_surface.commit on the corresponding wl_surface + * for the xdg_popup state to take effect. + * @section page_iface_xdg_popup_api API + * See @ref iface_xdg_popup. + */ +/** + * @defgroup iface_xdg_popup The xdg_popup interface + * + * A popup surface is a short-lived, temporary surface. It can be used to + * implement for example menus, popovers, tooltips and other similar user + * interface concepts. + * + * A popup can be made to take an explicit grab. See xdg_popup.grab for + * details. + * + * When the popup is dismissed, a popup_done event will be sent out, and at + * the same time the surface will be unmapped. See the xdg_popup.popup_done + * event for details. + * + * Explicitly destroying the xdg_popup object will also dismiss the popup and + * unmap the surface. Clients that want to dismiss the popup when another + * surface of their own is clicked should dismiss the popup using the destroy + * request. + * + * A newly created xdg_popup will be stacked on top of all previously created + * xdg_popup surfaces associated with the same xdg_toplevel. + * + * The parent of an xdg_popup must be mapped (see the xdg_surface + * description) before the xdg_popup itself. + * + * The client must call wl_surface.commit on the corresponding wl_surface + * for the xdg_popup state to take effect. + */ +extern const struct wl_interface xdg_popup_interface; +#endif + +#ifndef XDG_WM_BASE_ERROR_ENUM +#define XDG_WM_BASE_ERROR_ENUM +enum xdg_wm_base_error { + /** + * given wl_surface has another role + */ + XDG_WM_BASE_ERROR_ROLE = 0, + /** + * xdg_wm_base was destroyed before children + */ + XDG_WM_BASE_ERROR_DEFUNCT_SURFACES = 1, + /** + * the client tried to map or destroy a non-topmost popup + */ + XDG_WM_BASE_ERROR_NOT_THE_TOPMOST_POPUP = 2, + /** + * the client specified an invalid popup parent surface + */ + XDG_WM_BASE_ERROR_INVALID_POPUP_PARENT = 3, + /** + * the client provided an invalid surface state + */ + XDG_WM_BASE_ERROR_INVALID_SURFACE_STATE = 4, + /** + * the client provided an invalid positioner + */ + XDG_WM_BASE_ERROR_INVALID_POSITIONER = 5, + /** + * the client didn’t respond to a ping event in time + */ + XDG_WM_BASE_ERROR_UNRESPONSIVE = 6, +}; +#endif /* XDG_WM_BASE_ERROR_ENUM */ + +/** + * @ingroup iface_xdg_wm_base + * @struct xdg_wm_base_listener + */ +struct xdg_wm_base_listener { + /** + * check if the client is alive + * + * The ping event asks the client if it's still alive. Pass the + * serial specified in the event back to the compositor by sending + * a "pong" request back with the specified serial. See + * xdg_wm_base.pong. + * + * Compositors can use this to determine if the client is still + * alive. It's unspecified what will happen if the client doesn't + * respond to the ping request, or in what timeframe. Clients + * should try to respond in a reasonable amount of time. The + * “unresponsive” error is provided for compositors that wish + * to disconnect unresponsive clients. + * + * A compositor is free to ping in any way it wants, but a client + * must always respond to any xdg_wm_base object it created. + * @param serial pass this to the pong request + */ + void (*ping)(void *data, + struct xdg_wm_base *xdg_wm_base, + uint32_t serial); +}; + +/** + * @ingroup iface_xdg_wm_base + */ +static inline int +xdg_wm_base_add_listener(struct xdg_wm_base *xdg_wm_base, + const struct xdg_wm_base_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) xdg_wm_base, + (void (**)(void)) listener, data); +} + +#define XDG_WM_BASE_DESTROY 0 +#define XDG_WM_BASE_CREATE_POSITIONER 1 +#define XDG_WM_BASE_GET_XDG_SURFACE 2 +#define XDG_WM_BASE_PONG 3 + +/** + * @ingroup iface_xdg_wm_base + */ +#define XDG_WM_BASE_PING_SINCE_VERSION 1 + +/** + * @ingroup iface_xdg_wm_base + */ +#define XDG_WM_BASE_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_wm_base + */ +#define XDG_WM_BASE_CREATE_POSITIONER_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_wm_base + */ +#define XDG_WM_BASE_GET_XDG_SURFACE_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_wm_base + */ +#define XDG_WM_BASE_PONG_SINCE_VERSION 1 + +/** @ingroup iface_xdg_wm_base */ +static inline void +xdg_wm_base_set_user_data(struct xdg_wm_base *xdg_wm_base, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) xdg_wm_base, user_data); +} + +/** @ingroup iface_xdg_wm_base */ +static inline void * +xdg_wm_base_get_user_data(struct xdg_wm_base *xdg_wm_base) +{ + return wl_proxy_get_user_data((struct wl_proxy *) xdg_wm_base); +} + +static inline uint32_t +xdg_wm_base_get_version(struct xdg_wm_base *xdg_wm_base) +{ + return wl_proxy_get_version((struct wl_proxy *) xdg_wm_base); +} + +/** + * @ingroup iface_xdg_wm_base + * + * Destroy this xdg_wm_base object. + * + * Destroying a bound xdg_wm_base object while there are surfaces + * still alive created by this xdg_wm_base object instance is illegal + * and will result in a defunct_surfaces error. + */ +static inline void +xdg_wm_base_destroy(struct xdg_wm_base *xdg_wm_base) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_wm_base, + XDG_WM_BASE_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_wm_base), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_xdg_wm_base + * + * Create a positioner object. A positioner object is used to position + * surfaces relative to some parent surface. See the interface description + * and xdg_surface.get_popup for details. + */ +static inline struct xdg_positioner * +xdg_wm_base_create_positioner(struct xdg_wm_base *xdg_wm_base) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_wm_base, + XDG_WM_BASE_CREATE_POSITIONER, &xdg_positioner_interface, wl_proxy_get_version((struct wl_proxy *) xdg_wm_base), 0, NULL); + + return (struct xdg_positioner *) id; +} + +/** + * @ingroup iface_xdg_wm_base + * + * This creates an xdg_surface for the given surface. An xdg_surface is + * used as basis to define a role to a given surface, such as xdg_toplevel + * or xdg_popup. It also manages functionality shared between xdg_surface + * based surface roles. + * + * While xdg_surface itself is not a role, the corresponding surface may + * only be assigned a role extending xdg_surface, such as xdg_toplevel or + * xdg_popup. It is illegal to create an xdg_surface for a wl_surface which + * already has anassigned role and this will result in a role error. + * + * See the documentation of xdg_surface for more details about what an + * xdg_surface is and how it is used. + */ +static inline struct xdg_surface * +xdg_wm_base_get_xdg_surface(struct xdg_wm_base *xdg_wm_base, struct wl_surface *surface) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_wm_base, + XDG_WM_BASE_GET_XDG_SURFACE, &xdg_surface_interface, wl_proxy_get_version((struct wl_proxy *) xdg_wm_base), 0, NULL, surface); + + return (struct xdg_surface *) id; +} + +/** + * @ingroup iface_xdg_wm_base + * + * A client must respond to a ping event with a pong request or + * the client may be deemed unresponsive. See xdg_wm_base.ping + * and xdg_wm_base.error.unresponsive. + */ +static inline void +xdg_wm_base_pong(struct xdg_wm_base *xdg_wm_base, uint32_t serial) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_wm_base, + XDG_WM_BASE_PONG, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_wm_base), 0, serial); +} + +#ifndef XDG_POSITIONER_ERROR_ENUM +#define XDG_POSITIONER_ERROR_ENUM +enum xdg_positioner_error { + /** + * invalid input provided + */ + XDG_POSITIONER_ERROR_INVALID_INPUT = 0, +}; +#endif /* XDG_POSITIONER_ERROR_ENUM */ + +#ifndef XDG_POSITIONER_ANCHOR_ENUM +#define XDG_POSITIONER_ANCHOR_ENUM +enum xdg_positioner_anchor { + XDG_POSITIONER_ANCHOR_NONE = 0, + XDG_POSITIONER_ANCHOR_TOP = 1, + XDG_POSITIONER_ANCHOR_BOTTOM = 2, + XDG_POSITIONER_ANCHOR_LEFT = 3, + XDG_POSITIONER_ANCHOR_RIGHT = 4, + XDG_POSITIONER_ANCHOR_TOP_LEFT = 5, + XDG_POSITIONER_ANCHOR_BOTTOM_LEFT = 6, + XDG_POSITIONER_ANCHOR_TOP_RIGHT = 7, + XDG_POSITIONER_ANCHOR_BOTTOM_RIGHT = 8, +}; +#endif /* XDG_POSITIONER_ANCHOR_ENUM */ + +#ifndef XDG_POSITIONER_GRAVITY_ENUM +#define XDG_POSITIONER_GRAVITY_ENUM +enum xdg_positioner_gravity { + XDG_POSITIONER_GRAVITY_NONE = 0, + XDG_POSITIONER_GRAVITY_TOP = 1, + XDG_POSITIONER_GRAVITY_BOTTOM = 2, + XDG_POSITIONER_GRAVITY_LEFT = 3, + XDG_POSITIONER_GRAVITY_RIGHT = 4, + XDG_POSITIONER_GRAVITY_TOP_LEFT = 5, + XDG_POSITIONER_GRAVITY_BOTTOM_LEFT = 6, + XDG_POSITIONER_GRAVITY_TOP_RIGHT = 7, + XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT = 8, +}; +#endif /* XDG_POSITIONER_GRAVITY_ENUM */ + +#ifndef XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM +#define XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM +/** + * @ingroup iface_xdg_positioner + * constraint adjustments + * + * The constraint adjustment value define ways the compositor will adjust + * the position of the surface, if the unadjusted position would result + * in the surface being partly constrained. + * + * Whether a surface is considered 'constrained' is left to the compositor + * to determine. For example, the surface may be partly outside the + * compositor's defined 'work area', thus necessitating the child surface's + * position be adjusted until it is entirely inside the work area. + * + * The adjustments can be combined, according to a defined precedence: 1) + * Flip, 2) Slide, 3) Resize. + */ +enum xdg_positioner_constraint_adjustment { + /** + * don't move the child surface when constrained + * + * Don't alter the surface position even if it is constrained on + * some axis, for example partially outside the edge of an output. + */ + XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_NONE = 0, + /** + * move along the x axis until unconstrained + * + * Slide the surface along the x axis until it is no longer + * constrained. + * + * First try to slide towards the direction of the gravity on the x + * axis until either the edge in the opposite direction of the + * gravity is unconstrained or the edge in the direction of the + * gravity is constrained. + * + * Then try to slide towards the opposite direction of the gravity + * on the x axis until either the edge in the direction of the + * gravity is unconstrained or the edge in the opposite direction + * of the gravity is constrained. + */ + XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X = 1, + /** + * move along the y axis until unconstrained + * + * Slide the surface along the y axis until it is no longer + * constrained. + * + * First try to slide towards the direction of the gravity on the y + * axis until either the edge in the opposite direction of the + * gravity is unconstrained or the edge in the direction of the + * gravity is constrained. + * + * Then try to slide towards the opposite direction of the gravity + * on the y axis until either the edge in the direction of the + * gravity is unconstrained or the edge in the opposite direction + * of the gravity is constrained. + */ + XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y = 2, + /** + * invert the anchor and gravity on the x axis + * + * Invert the anchor and gravity on the x axis if the surface is + * constrained on the x axis. For example, if the left edge of the + * surface is constrained, the gravity is 'left' and the anchor is + * 'left', change the gravity to 'right' and the anchor to 'right'. + * + * If the adjusted position also ends up being constrained, the + * resulting position of the flip_x adjustment will be the one + * before the adjustment. + */ + XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_X = 4, + /** + * invert the anchor and gravity on the y axis + * + * Invert the anchor and gravity on the y axis if the surface is + * constrained on the y axis. For example, if the bottom edge of + * the surface is constrained, the gravity is 'bottom' and the + * anchor is 'bottom', change the gravity to 'top' and the anchor + * to 'top'. + * + * The adjusted position is calculated given the original anchor + * rectangle and offset, but with the new flipped anchor and + * gravity values. + * + * If the adjusted position also ends up being constrained, the + * resulting position of the flip_y adjustment will be the one + * before the adjustment. + */ + XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_FLIP_Y = 8, + /** + * horizontally resize the surface + * + * Resize the surface horizontally so that it is completely + * unconstrained. + */ + XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_X = 16, + /** + * vertically resize the surface + * + * Resize the surface vertically so that it is completely + * unconstrained. + */ + XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_RESIZE_Y = 32, +}; +#endif /* XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_ENUM */ + +#define XDG_POSITIONER_DESTROY 0 +#define XDG_POSITIONER_SET_SIZE 1 +#define XDG_POSITIONER_SET_ANCHOR_RECT 2 +#define XDG_POSITIONER_SET_ANCHOR 3 +#define XDG_POSITIONER_SET_GRAVITY 4 +#define XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT 5 +#define XDG_POSITIONER_SET_OFFSET 6 +#define XDG_POSITIONER_SET_REACTIVE 7 +#define XDG_POSITIONER_SET_PARENT_SIZE 8 +#define XDG_POSITIONER_SET_PARENT_CONFIGURE 9 + + +/** + * @ingroup iface_xdg_positioner + */ +#define XDG_POSITIONER_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_positioner + */ +#define XDG_POSITIONER_SET_SIZE_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_positioner + */ +#define XDG_POSITIONER_SET_ANCHOR_RECT_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_positioner + */ +#define XDG_POSITIONER_SET_ANCHOR_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_positioner + */ +#define XDG_POSITIONER_SET_GRAVITY_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_positioner + */ +#define XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_positioner + */ +#define XDG_POSITIONER_SET_OFFSET_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_positioner + */ +#define XDG_POSITIONER_SET_REACTIVE_SINCE_VERSION 3 +/** + * @ingroup iface_xdg_positioner + */ +#define XDG_POSITIONER_SET_PARENT_SIZE_SINCE_VERSION 3 +/** + * @ingroup iface_xdg_positioner + */ +#define XDG_POSITIONER_SET_PARENT_CONFIGURE_SINCE_VERSION 3 + +/** @ingroup iface_xdg_positioner */ +static inline void +xdg_positioner_set_user_data(struct xdg_positioner *xdg_positioner, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) xdg_positioner, user_data); +} + +/** @ingroup iface_xdg_positioner */ +static inline void * +xdg_positioner_get_user_data(struct xdg_positioner *xdg_positioner) +{ + return wl_proxy_get_user_data((struct wl_proxy *) xdg_positioner); +} + +static inline uint32_t +xdg_positioner_get_version(struct xdg_positioner *xdg_positioner) +{ + return wl_proxy_get_version((struct wl_proxy *) xdg_positioner); +} + +/** + * @ingroup iface_xdg_positioner + * + * Notify the compositor that the xdg_positioner will no longer be used. + */ +static inline void +xdg_positioner_destroy(struct xdg_positioner *xdg_positioner) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, + XDG_POSITIONER_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_xdg_positioner + * + * Set the size of the surface that is to be positioned with the positioner + * object. The size is in surface-local coordinates and corresponds to the + * window geometry. See xdg_surface.set_window_geometry. + * + * If a zero or negative size is set the invalid_input error is raised. + */ +static inline void +xdg_positioner_set_size(struct xdg_positioner *xdg_positioner, int32_t width, int32_t height) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, + XDG_POSITIONER_SET_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, width, height); +} + +/** + * @ingroup iface_xdg_positioner + * + * Specify the anchor rectangle within the parent surface that the child + * surface will be placed relative to. The rectangle is relative to the + * window geometry as defined by xdg_surface.set_window_geometry of the + * parent surface. + * + * When the xdg_positioner object is used to position a child surface, the + * anchor rectangle may not extend outside the window geometry of the + * positioned child's parent surface. + * + * If a negative size is set the invalid_input error is raised. + */ +static inline void +xdg_positioner_set_anchor_rect(struct xdg_positioner *xdg_positioner, int32_t x, int32_t y, int32_t width, int32_t height) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, + XDG_POSITIONER_SET_ANCHOR_RECT, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, x, y, width, height); +} + +/** + * @ingroup iface_xdg_positioner + * + * Defines the anchor point for the anchor rectangle. The specified anchor + * is used to derive an anchor point that the child surface will be + * positioned relative to. If a corner anchor is set (e.g. 'top_left' or + * 'bottom_right'), the anchor point will be at the specified corner; + * otherwise, the derived anchor point will be centered on the specified + * edge, or in the center of the anchor rectangle if no edge is specified. + */ +static inline void +xdg_positioner_set_anchor(struct xdg_positioner *xdg_positioner, uint32_t anchor) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, + XDG_POSITIONER_SET_ANCHOR, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, anchor); +} + +/** + * @ingroup iface_xdg_positioner + * + * Defines in what direction a surface should be positioned, relative to + * the anchor point of the parent surface. If a corner gravity is + * specified (e.g. 'bottom_right' or 'top_left'), then the child surface + * will be placed towards the specified gravity; otherwise, the child + * surface will be centered over the anchor point on any axis that had no + * gravity specified. If the gravity is not in the ‘gravity’ enum, an + * invalid_input error is raised. + */ +static inline void +xdg_positioner_set_gravity(struct xdg_positioner *xdg_positioner, uint32_t gravity) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, + XDG_POSITIONER_SET_GRAVITY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, gravity); +} + +/** + * @ingroup iface_xdg_positioner + * + * Specify how the window should be positioned if the originally intended + * position caused the surface to be constrained, meaning at least + * partially outside positioning boundaries set by the compositor. The + * adjustment is set by constructing a bitmask describing the adjustment to + * be made when the surface is constrained on that axis. + * + * If no bit for one axis is set, the compositor will assume that the child + * surface should not change its position on that axis when constrained. + * + * If more than one bit for one axis is set, the order of how adjustments + * are applied is specified in the corresponding adjustment descriptions. + * + * The default adjustment is none. + */ +static inline void +xdg_positioner_set_constraint_adjustment(struct xdg_positioner *xdg_positioner, uint32_t constraint_adjustment) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, + XDG_POSITIONER_SET_CONSTRAINT_ADJUSTMENT, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, constraint_adjustment); +} + +/** + * @ingroup iface_xdg_positioner + * + * Specify the surface position offset relative to the position of the + * anchor on the anchor rectangle and the anchor on the surface. For + * example if the anchor of the anchor rectangle is at (x, y), the surface + * has the gravity bottom|right, and the offset is (ox, oy), the calculated + * surface position will be (x + ox, y + oy). The offset position of the + * surface is the one used for constraint testing. See + * set_constraint_adjustment. + * + * An example use case is placing a popup menu on top of a user interface + * element, while aligning the user interface element of the parent surface + * with some user interface element placed somewhere in the popup surface. + */ +static inline void +xdg_positioner_set_offset(struct xdg_positioner *xdg_positioner, int32_t x, int32_t y) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, + XDG_POSITIONER_SET_OFFSET, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, x, y); +} + +/** + * @ingroup iface_xdg_positioner + * + * When set reactive, the surface is reconstrained if the conditions used + * for constraining changed, e.g. the parent window moved. + * + * If the conditions changed and the popup was reconstrained, an + * xdg_popup.configure event is sent with updated geometry, followed by an + * xdg_surface.configure event. + */ +static inline void +xdg_positioner_set_reactive(struct xdg_positioner *xdg_positioner) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, + XDG_POSITIONER_SET_REACTIVE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0); +} + +/** + * @ingroup iface_xdg_positioner + * + * Set the parent window geometry the compositor should use when + * positioning the popup. The compositor may use this information to + * determine the future state the popup should be constrained using. If + * this doesn't match the dimension of the parent the popup is eventually + * positioned against, the behavior is undefined. + * + * The arguments are given in the surface-local coordinate space. + */ +static inline void +xdg_positioner_set_parent_size(struct xdg_positioner *xdg_positioner, int32_t parent_width, int32_t parent_height) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, + XDG_POSITIONER_SET_PARENT_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, parent_width, parent_height); +} + +/** + * @ingroup iface_xdg_positioner + * + * Set the serial of an xdg_surface.configure event this positioner will be + * used in response to. The compositor may use this information together + * with set_parent_size to determine what future state the popup should be + * constrained using. + */ +static inline void +xdg_positioner_set_parent_configure(struct xdg_positioner *xdg_positioner, uint32_t serial) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_positioner, + XDG_POSITIONER_SET_PARENT_CONFIGURE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_positioner), 0, serial); +} + +#ifndef XDG_SURFACE_ERROR_ENUM +#define XDG_SURFACE_ERROR_ENUM +enum xdg_surface_error { + /** + * Surface was not fully constructed + */ + XDG_SURFACE_ERROR_NOT_CONSTRUCTED = 1, + /** + * Surface was already constructed + */ + XDG_SURFACE_ERROR_ALREADY_CONSTRUCTED = 2, + /** + * Attaching a buffer to an unconfigured surface + */ + XDG_SURFACE_ERROR_UNCONFIGURED_BUFFER = 3, + /** + * Invalid serial number when acking a configure event + */ + XDG_SURFACE_ERROR_INVALID_SERIAL = 4, + /** + * Width or height was zero or negative + */ + XDG_SURFACE_ERROR_INVALID_SIZE = 5, + /** + * Surface was destroyed before its role object + */ + XDG_SURFACE_ERROR_DEFUNCT_ROLE_OBJECT = 6, +}; +#endif /* XDG_SURFACE_ERROR_ENUM */ + +/** + * @ingroup iface_xdg_surface + * @struct xdg_surface_listener + */ +struct xdg_surface_listener { + /** + * suggest a surface change + * + * The configure event marks the end of a configure sequence. A + * configure sequence is a set of one or more events configuring + * the state of the xdg_surface, including the final + * xdg_surface.configure event. + * + * Where applicable, xdg_surface surface roles will during a + * configure sequence extend this event as a latched state sent as + * events before the xdg_surface.configure event. Such events + * should be considered to make up a set of atomically applied + * configuration states, where the xdg_surface.configure commits + * the accumulated state. + * + * Clients should arrange their surface for the new states, and + * then send an ack_configure request with the serial sent in this + * configure event at some point before committing the new surface. + * + * If the client receives multiple configure events before it can + * respond to one, it is free to discard all but the last event it + * received. + * @param serial serial of the configure event + */ + void (*configure)(void *data, + struct xdg_surface *xdg_surface, + uint32_t serial); +}; + +/** + * @ingroup iface_xdg_surface + */ +static inline int +xdg_surface_add_listener(struct xdg_surface *xdg_surface, + const struct xdg_surface_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) xdg_surface, + (void (**)(void)) listener, data); +} + +#define XDG_SURFACE_DESTROY 0 +#define XDG_SURFACE_GET_TOPLEVEL 1 +#define XDG_SURFACE_GET_POPUP 2 +#define XDG_SURFACE_SET_WINDOW_GEOMETRY 3 +#define XDG_SURFACE_ACK_CONFIGURE 4 + +/** + * @ingroup iface_xdg_surface + */ +#define XDG_SURFACE_CONFIGURE_SINCE_VERSION 1 + +/** + * @ingroup iface_xdg_surface + */ +#define XDG_SURFACE_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_surface + */ +#define XDG_SURFACE_GET_TOPLEVEL_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_surface + */ +#define XDG_SURFACE_GET_POPUP_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_surface + */ +#define XDG_SURFACE_SET_WINDOW_GEOMETRY_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_surface + */ +#define XDG_SURFACE_ACK_CONFIGURE_SINCE_VERSION 1 + +/** @ingroup iface_xdg_surface */ +static inline void +xdg_surface_set_user_data(struct xdg_surface *xdg_surface, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) xdg_surface, user_data); +} + +/** @ingroup iface_xdg_surface */ +static inline void * +xdg_surface_get_user_data(struct xdg_surface *xdg_surface) +{ + return wl_proxy_get_user_data((struct wl_proxy *) xdg_surface); +} + +static inline uint32_t +xdg_surface_get_version(struct xdg_surface *xdg_surface) +{ + return wl_proxy_get_version((struct wl_proxy *) xdg_surface); +} + +/** + * @ingroup iface_xdg_surface + * + * Destroy the xdg_surface object. An xdg_surface must only be destroyed + * after its role object has been destroyed, otherwise + * a defunct_role_object error is raised. + */ +static inline void +xdg_surface_destroy(struct xdg_surface *xdg_surface) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface, + XDG_SURFACE_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_surface), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_xdg_surface + * + * This creates an xdg_toplevel object for the given xdg_surface and gives + * the associated wl_surface the xdg_toplevel role. + * + * See the documentation of xdg_toplevel for more details about what an + * xdg_toplevel is and how it is used. + */ +static inline struct xdg_toplevel * +xdg_surface_get_toplevel(struct xdg_surface *xdg_surface) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface, + XDG_SURFACE_GET_TOPLEVEL, &xdg_toplevel_interface, wl_proxy_get_version((struct wl_proxy *) xdg_surface), 0, NULL); + + return (struct xdg_toplevel *) id; +} + +/** + * @ingroup iface_xdg_surface + * + * This creates an xdg_popup object for the given xdg_surface and gives + * the associated wl_surface the xdg_popup role. + * + * If null is passed as a parent, a parent surface must be specified using + * some other protocol, before committing the initial state. + * + * See the documentation of xdg_popup for more details about what an + * xdg_popup is and how it is used. + */ +static inline struct xdg_popup * +xdg_surface_get_popup(struct xdg_surface *xdg_surface, struct xdg_surface *parent, struct xdg_positioner *positioner) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface, + XDG_SURFACE_GET_POPUP, &xdg_popup_interface, wl_proxy_get_version((struct wl_proxy *) xdg_surface), 0, NULL, parent, positioner); + + return (struct xdg_popup *) id; +} + +/** + * @ingroup iface_xdg_surface + * + * The window geometry of a surface is its "visible bounds" from the + * user's perspective. Client-side decorations often have invisible + * portions like drop-shadows which should be ignored for the + * purposes of aligning, placing and constraining windows. Note that + * in some situations, compositors may clip rendering to the window + * geometry, so the client should avoid putting functional elements + * outside of it. + * + * The window geometry is double-buffered state, see wl_surface.commit. + * + * When maintaining a position, the compositor should treat the (x, y) + * coordinate of the window geometry as the top left corner of the window. + * A client changing the (x, y) window geometry coordinate should in + * general not alter the position of the window. + * + * Once the window geometry of the surface is set, it is not possible to + * unset it, and it will remain the same until set_window_geometry is + * called again, even if a new subsurface or buffer is attached. + * + * If never set, the value is the full bounds of the surface, + * including any subsurfaces. This updates dynamically on every + * commit. This unset is meant for extremely simple clients. + * + * The arguments are given in the surface-local coordinate space of + * the wl_surface associated with this xdg_surface, and may extend outside + * of the wl_surface itself to mark parts of the subsurface tree as part of + * the window geometry. + * + * When applied, the effective window geometry will be the set window + * geometry clamped to the bounding rectangle of the combined + * geometry of the surface of the xdg_surface and the associated + * subsurfaces. + * + * The effective geometry will not be recalculated unless a new call to + * set_window_geometry is done and the new pending surface state is + * subsequently applied. + * + * The width and height of the effective window geometry must be + * greater than zero. Setting an invalid size will raise an + * invalid_size error. + */ +static inline void +xdg_surface_set_window_geometry(struct xdg_surface *xdg_surface, int32_t x, int32_t y, int32_t width, int32_t height) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface, + XDG_SURFACE_SET_WINDOW_GEOMETRY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_surface), 0, x, y, width, height); +} + +/** + * @ingroup iface_xdg_surface + * + * When a configure event is received, if a client commits the + * surface in response to the configure event, then the client + * must make an ack_configure request sometime before the commit + * request, passing along the serial of the configure event. + * + * For instance, for toplevel surfaces the compositor might use this + * information to move a surface to the top left only when the client has + * drawn itself for the maximized or fullscreen state. + * + * If the client receives multiple configure events before it + * can respond to one, it only has to ack the last configure event. + * Acking a configure event that was never sent raises an invalid_serial + * error. + * + * A client is not required to commit immediately after sending + * an ack_configure request - it may even ack_configure several times + * before its next surface commit. + * + * A client may send multiple ack_configure requests before committing, but + * only the last request sent before a commit indicates which configure + * event the client really is responding to. + * + * Sending an ack_configure request consumes the serial number sent with + * the request, as well as serial numbers sent by all configure events + * sent on this xdg_surface prior to the configure event referenced by + * the committed serial. + * + * It is an error to issue multiple ack_configure requests referencing a + * serial from the same configure event, or to issue an ack_configure + * request referencing a serial from a configure event issued before the + * event identified by the last ack_configure request for the same + * xdg_surface. Doing so will raise an invalid_serial error. + */ +static inline void +xdg_surface_ack_configure(struct xdg_surface *xdg_surface, uint32_t serial) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_surface, + XDG_SURFACE_ACK_CONFIGURE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_surface), 0, serial); +} + +#ifndef XDG_TOPLEVEL_ERROR_ENUM +#define XDG_TOPLEVEL_ERROR_ENUM +enum xdg_toplevel_error { + /** + * provided value is not a valid variant of the resize_edge enum + */ + XDG_TOPLEVEL_ERROR_INVALID_RESIZE_EDGE = 0, + /** + * invalid parent toplevel + */ + XDG_TOPLEVEL_ERROR_INVALID_PARENT = 1, + /** + * client provided an invalid min or max size + */ + XDG_TOPLEVEL_ERROR_INVALID_SIZE = 2, +}; +#endif /* XDG_TOPLEVEL_ERROR_ENUM */ + +#ifndef XDG_TOPLEVEL_RESIZE_EDGE_ENUM +#define XDG_TOPLEVEL_RESIZE_EDGE_ENUM +/** + * @ingroup iface_xdg_toplevel + * edge values for resizing + * + * These values are used to indicate which edge of a surface + * is being dragged in a resize operation. + */ +enum xdg_toplevel_resize_edge { + XDG_TOPLEVEL_RESIZE_EDGE_NONE = 0, + XDG_TOPLEVEL_RESIZE_EDGE_TOP = 1, + XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM = 2, + XDG_TOPLEVEL_RESIZE_EDGE_LEFT = 4, + XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT = 5, + XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT = 6, + XDG_TOPLEVEL_RESIZE_EDGE_RIGHT = 8, + XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT = 9, + XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT = 10, +}; +#endif /* XDG_TOPLEVEL_RESIZE_EDGE_ENUM */ + +#ifndef XDG_TOPLEVEL_STATE_ENUM +#define XDG_TOPLEVEL_STATE_ENUM +/** + * @ingroup iface_xdg_toplevel + * types of state on the surface + * + * The different state values used on the surface. This is designed for + * state values like maximized, fullscreen. It is paired with the + * configure event to ensure that both the client and the compositor + * setting the state can be synchronized. + * + * States set in this way are double-buffered, see wl_surface.commit. + */ +enum xdg_toplevel_state { + /** + * the surface is maximized + * the surface is maximized + * + * The surface is maximized. The window geometry specified in the + * configure event must be obeyed by the client, or the + * xdg_wm_base.invalid_surface_state error is raised. + * + * The client should draw without shadow or other decoration + * outside of the window geometry. + */ + XDG_TOPLEVEL_STATE_MAXIMIZED = 1, + /** + * the surface is fullscreen + * the surface is fullscreen + * + * The surface is fullscreen. The window geometry specified in + * the configure event is a maximum; the client cannot resize + * beyond it. For a surface to cover the whole fullscreened area, + * the geometry dimensions must be obeyed by the client. For more + * details, see xdg_toplevel.set_fullscreen. + */ + XDG_TOPLEVEL_STATE_FULLSCREEN = 2, + /** + * the surface is being resized + * the surface is being resized + * + * The surface is being resized. The window geometry specified in + * the configure event is a maximum; the client cannot resize + * beyond it. Clients that have aspect ratio or cell sizing + * configuration can use a smaller size, however. + */ + XDG_TOPLEVEL_STATE_RESIZING = 3, + /** + * the surface is now activated + * the surface is now activated + * + * Client window decorations should be painted as if the window + * is active. Do not assume this means that the window actually has + * keyboard or pointer focus. + */ + XDG_TOPLEVEL_STATE_ACTIVATED = 4, + /** + * the surface’s left edge is tiled + * + * The window is currently in a tiled layout and the left edge is + * considered to be adjacent to another part of the tiling grid. + * + * The client should draw without shadow or other decoration + * outside of the window geometry on the left edge. + * @since 2 + */ + XDG_TOPLEVEL_STATE_TILED_LEFT = 5, + /** + * the surface’s right edge is tiled + * + * The window is currently in a tiled layout and the right edge + * is considered to be adjacent to another part of the tiling grid. + * + * The client should draw without shadow or other decoration + * outside of the window geometry on the right edge. + * @since 2 + */ + XDG_TOPLEVEL_STATE_TILED_RIGHT = 6, + /** + * the surface’s top edge is tiled + * + * The window is currently in a tiled layout and the top edge is + * considered to be adjacent to another part of the tiling grid. + * + * The client should draw without shadow or other decoration + * outside of the window geometry on the top edge. + * @since 2 + */ + XDG_TOPLEVEL_STATE_TILED_TOP = 7, + /** + * the surface’s bottom edge is tiled + * + * The window is currently in a tiled layout and the bottom edge + * is considered to be adjacent to another part of the tiling grid. + * + * The client should draw without shadow or other decoration + * outside of the window geometry on the bottom edge. + * @since 2 + */ + XDG_TOPLEVEL_STATE_TILED_BOTTOM = 8, + /** + * surface repaint is suspended + * + * The surface is currently not ordinarily being repainted; for + * example because its content is occluded by another window, or + * its outputs are switched off due to screen locking. + * @since 6 + */ + XDG_TOPLEVEL_STATE_SUSPENDED = 9, + /** + * the surface’s left edge is constrained + * + * The left edge of the window is currently constrained, meaning + * it shouldn't attempt to resize from that edge. It can for + * example mean it's tiled next to a monitor edge on the + * constrained side of the window. + * @since 7 + */ + XDG_TOPLEVEL_STATE_CONSTRAINED_LEFT = 10, + /** + * the surface’s right edge is constrained + * + * The right edge of the window is currently constrained, meaning + * it shouldn't attempt to resize from that edge. It can for + * example mean it's tiled next to a monitor edge on the + * constrained side of the window. + * @since 7 + */ + XDG_TOPLEVEL_STATE_CONSTRAINED_RIGHT = 11, + /** + * the surface’s top edge is constrained + * + * The top edge of the window is currently constrained, meaning + * it shouldn't attempt to resize from that edge. It can for + * example mean it's tiled next to a monitor edge on the + * constrained side of the window. + * @since 7 + */ + XDG_TOPLEVEL_STATE_CONSTRAINED_TOP = 12, + /** + * the surface’s bottom edge is constrained + * + * The bottom edge of the window is currently constrained, + * meaning it shouldn't attempt to resize from that edge. It can + * for example mean it's tiled next to a monitor edge on the + * constrained side of the window. + * @since 7 + */ + XDG_TOPLEVEL_STATE_CONSTRAINED_BOTTOM = 13, +}; +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_STATE_TILED_LEFT_SINCE_VERSION 2 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION 2 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_STATE_TILED_TOP_SINCE_VERSION 2 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_STATE_TILED_BOTTOM_SINCE_VERSION 2 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_STATE_SUSPENDED_SINCE_VERSION 6 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_STATE_CONSTRAINED_LEFT_SINCE_VERSION 7 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_STATE_CONSTRAINED_RIGHT_SINCE_VERSION 7 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_STATE_CONSTRAINED_TOP_SINCE_VERSION 7 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_STATE_CONSTRAINED_BOTTOM_SINCE_VERSION 7 +#endif /* XDG_TOPLEVEL_STATE_ENUM */ + +#ifndef XDG_TOPLEVEL_WM_CAPABILITIES_ENUM +#define XDG_TOPLEVEL_WM_CAPABILITIES_ENUM +enum xdg_toplevel_wm_capabilities { + /** + * show_window_menu is available + */ + XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU = 1, + /** + * set_maximized and unset_maximized are available + */ + XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE = 2, + /** + * set_fullscreen and unset_fullscreen are available + */ + XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN = 3, + /** + * set_minimized is available + */ + XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE = 4, +}; +#endif /* XDG_TOPLEVEL_WM_CAPABILITIES_ENUM */ + +/** + * @ingroup iface_xdg_toplevel + * @struct xdg_toplevel_listener + */ +struct xdg_toplevel_listener { + /** + * suggest a surface change + * + * This configure event asks the client to resize its toplevel + * surface or to change its state. The configured state should not + * be applied immediately. See xdg_surface.configure for details. + * + * The width and height arguments specify a hint to the window + * about how its surface should be resized in window geometry + * coordinates. See set_window_geometry. + * + * If the width or height arguments are zero, it means the client + * should decide its own window dimension. This may happen when the + * compositor needs to configure the state of the surface but + * doesn't have any information about any previous or expected + * dimension. + * + * The states listed in the event specify how the width/height + * arguments should be interpreted, and possibly how it should be + * drawn. + * + * The states are sent as an array of 32-bit unsigned integers in + * native endianness. State values are defined in the state enum. + * + * Clients must send an ack_configure in response to this event. + * See xdg_surface.configure and xdg_surface.ack_configure for + * details. + * @param width suggested width of window + * @param height suggested height of window + * @param states suggested states of the window + */ + void (*configure)(void *data, + struct xdg_toplevel *xdg_toplevel, + int32_t width, + int32_t height, + struct wl_array *states); + /** + * surface wants to be closed + * + * The close event is sent by the compositor when the user wants + * the surface to be closed. This should be equivalent to the user + * clicking the close button in client-side decorations, if your + * application has any. + * + * This is only a request that the user intends to close the + * window. The client may choose to ignore this request, or show a + * dialog to ask the user to save their data, etc. + */ + void (*close)(void *data, + struct xdg_toplevel *xdg_toplevel); + /** + * recommended window geometry bounds + * + * The configure_bounds event may be sent prior to a + * xdg_toplevel.configure event to communicate the bounds a window + * geometry size is recommended to constrain to. + * + * The passed width and height are in surface coordinate space. If + * width and height are 0, it means bounds is unknown and + * equivalent to as if no configure_bounds event was ever sent for + * this surface. + * + * The bounds can for example correspond to the size of a monitor + * excluding any panels or other shell components, so that a + * surface isn't created in a way that it cannot fit. + * + * The bounds may change at any point, and in such a case, a new + * xdg_toplevel.configure_bounds will be sent, followed by + * xdg_toplevel.configure and xdg_surface.configure. + * @param width suggested maximum width of surface + * @param height suggested maximum height of surface + * @since 4 + */ + void (*configure_bounds)(void *data, + struct xdg_toplevel *xdg_toplevel, + int32_t width, + int32_t height); + /** + * compositor capabilities + * + * This event advertises the capabilities supported by the + * compositor. If a capability isn't supported, clients should hide + * or disable the UI elements that expose this functionality. For + * instance, if the compositor doesn't advertise support for + * minimized toplevels, a button triggering the set_minimized + * request should not be displayed. + * + * The compositor will ignore requests it doesn't support. For + * instance, a compositor which doesn't advertise support for + * minimized will ignore set_minimized requests. + * + * Compositors must send this event once before the first + * xdg_surface.configure event. When the capabilities change, + * compositors must send this event again and then send an + * xdg_surface.configure event. + * + * The configured state should not be applied immediately. See + * xdg_surface.configure for details. + * + * The capabilities are sent as an array of 32-bit unsigned + * integers in native endianness. Capability values are defined in + * the wm_capabilities enum. + * @param capabilities array of 32-bit capabilities + * @since 5 + */ + void (*wm_capabilities)(void *data, + struct xdg_toplevel *xdg_toplevel, + struct wl_array *capabilities); +}; + +/** + * @ingroup iface_xdg_toplevel + */ +static inline int +xdg_toplevel_add_listener(struct xdg_toplevel *xdg_toplevel, + const struct xdg_toplevel_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) xdg_toplevel, + (void (**)(void)) listener, data); +} + +#define XDG_TOPLEVEL_DESTROY 0 +#define XDG_TOPLEVEL_SET_PARENT 1 +#define XDG_TOPLEVEL_SET_TITLE 2 +#define XDG_TOPLEVEL_SET_APP_ID 3 +#define XDG_TOPLEVEL_SHOW_WINDOW_MENU 4 +#define XDG_TOPLEVEL_MOVE 5 +#define XDG_TOPLEVEL_RESIZE 6 +#define XDG_TOPLEVEL_SET_MAX_SIZE 7 +#define XDG_TOPLEVEL_SET_MIN_SIZE 8 +#define XDG_TOPLEVEL_SET_MAXIMIZED 9 +#define XDG_TOPLEVEL_UNSET_MAXIMIZED 10 +#define XDG_TOPLEVEL_SET_FULLSCREEN 11 +#define XDG_TOPLEVEL_UNSET_FULLSCREEN 12 +#define XDG_TOPLEVEL_SET_MINIMIZED 13 + +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_CONFIGURE_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_CLOSE_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION 4 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_WM_CAPABILITIES_SINCE_VERSION 5 + +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_SET_PARENT_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_SET_TITLE_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_SET_APP_ID_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_SHOW_WINDOW_MENU_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_MOVE_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_RESIZE_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_SET_MAX_SIZE_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_SET_MIN_SIZE_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_SET_MAXIMIZED_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_UNSET_MAXIMIZED_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_SET_FULLSCREEN_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_UNSET_FULLSCREEN_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel + */ +#define XDG_TOPLEVEL_SET_MINIMIZED_SINCE_VERSION 1 + +/** @ingroup iface_xdg_toplevel */ +static inline void +xdg_toplevel_set_user_data(struct xdg_toplevel *xdg_toplevel, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) xdg_toplevel, user_data); +} + +/** @ingroup iface_xdg_toplevel */ +static inline void * +xdg_toplevel_get_user_data(struct xdg_toplevel *xdg_toplevel) +{ + return wl_proxy_get_user_data((struct wl_proxy *) xdg_toplevel); +} + +static inline uint32_t +xdg_toplevel_get_version(struct xdg_toplevel *xdg_toplevel) +{ + return wl_proxy_get_version((struct wl_proxy *) xdg_toplevel); +} + +/** + * @ingroup iface_xdg_toplevel + * + * This request destroys the role surface and unmaps the surface; + * see "Unmapping" behavior in interface section for details. + */ +static inline void +xdg_toplevel_destroy(struct xdg_toplevel *xdg_toplevel) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Set the "parent" of this surface. This surface should be stacked + * above the parent surface and all other ancestor surfaces. + * + * Parent surfaces should be set on dialogs, toolboxes, or other + * "auxiliary" surfaces, so that the parent is raised when the dialog + * is raised. + * + * Setting a null parent for a child surface unsets its parent. Setting + * a null parent for a surface which currently has no parent is a no-op. + * + * Only mapped surfaces can have child surfaces. Setting a parent which + * is not mapped is equivalent to setting a null parent. If a surface + * becomes unmapped, its children's parent is set to the parent of + * the now-unmapped surface. If the now-unmapped surface has no parent, + * its children's parent is unset. If the now-unmapped surface becomes + * mapped again, its parent-child relationship is not restored. + * + * The parent toplevel must not be one of the child toplevel's + * descendants, and the parent must be different from the child toplevel, + * otherwise the invalid_parent protocol error is raised. + */ +static inline void +xdg_toplevel_set_parent(struct xdg_toplevel *xdg_toplevel, struct xdg_toplevel *parent) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_SET_PARENT, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, parent); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Set a short title for the surface. + * + * This string may be used to identify the surface in a task bar, + * window list, or other user interface elements provided by the + * compositor. + * + * The string must be encoded in UTF-8. + */ +static inline void +xdg_toplevel_set_title(struct xdg_toplevel *xdg_toplevel, const char *title) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_SET_TITLE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, title); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Set an application identifier for the surface. + * + * The app ID identifies the general class of applications to which + * the surface belongs. The compositor can use this to group multiple + * surfaces together, or to determine how to launch a new application. + * + * For D-Bus activatable applications, the app ID is used as the D-Bus + * service name. + * + * The compositor shell will try to group application surfaces together + * by their app ID. As a best practice, it is suggested to select app + * ID's that match the basename of the application's .desktop file. + * For example, "org.freedesktop.FooViewer" where the .desktop file is + * "org.freedesktop.FooViewer.desktop". + * + * Like other properties, a set_app_id request can be sent after the + * xdg_toplevel has been mapped to update the property. + * + * See the desktop-entry specification [0] for more details on + * application identifiers and how they relate to well-known D-Bus + * names and .desktop files. + * + * [0] https://standards.freedesktop.org/desktop-entry-spec/ + */ +static inline void +xdg_toplevel_set_app_id(struct xdg_toplevel *xdg_toplevel, const char *app_id) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_SET_APP_ID, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, app_id); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Clients implementing client-side decorations might want to show + * a context menu when right-clicking on the decorations, giving the + * user a menu that they can use to maximize or minimize the window. + * + * This request asks the compositor to pop up such a window menu at + * the given position, relative to the local surface coordinates of + * the parent surface. There are no guarantees as to what menu items + * the window menu contains, or even if a window menu will be drawn + * at all. + * + * This request must be used in response to some sort of user action + * like a button press, key press, or touch down event. + */ +static inline void +xdg_toplevel_show_window_menu(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial, int32_t x, int32_t y) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_SHOW_WINDOW_MENU, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, seat, serial, x, y); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Start an interactive, user-driven move of the surface. + * + * This request must be used in response to some sort of user action + * like a button press, key press, or touch down event. The passed + * serial is used to determine the type of interactive move (touch, + * pointer, etc). + * + * The server may ignore move requests depending on the state of + * the surface (e.g. fullscreen or maximized), or if the passed serial + * is no longer valid. + * + * If triggered, the surface will lose the focus of the device + * (wl_pointer, wl_touch, etc) used for the move. It is up to the + * compositor to visually indicate that the move is taking place, such as + * updating a pointer cursor, during the move. There is no guarantee + * that the device focus will return when the move is completed. + */ +static inline void +xdg_toplevel_move(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_MOVE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, seat, serial); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Start a user-driven, interactive resize of the surface. + * + * This request must be used in response to some sort of user action + * like a button press, key press, or touch down event. The passed + * serial is used to determine the type of interactive resize (touch, + * pointer, etc). + * + * The server may ignore resize requests depending on the state of + * the surface (e.g. fullscreen or maximized). + * + * If triggered, the client will receive configure events with the + * "resize" state enum value and the expected sizes. See the "resize" + * enum value for more details about what is required. The client + * must also acknowledge configure events using "ack_configure". After + * the resize is completed, the client will receive another "configure" + * event without the resize state. + * + * If triggered, the surface also will lose the focus of the device + * (wl_pointer, wl_touch, etc) used for the resize. It is up to the + * compositor to visually indicate that the resize is taking place, + * such as updating a pointer cursor, during the resize. There is no + * guarantee that the device focus will return when the resize is + * completed. + * + * The edges parameter specifies how the surface should be resized, and + * is one of the values of the resize_edge enum. Values not matching + * a variant of the enum will cause the invalid_resize_edge protocol error. + * The compositor may use this information to update the surface position + * for example when dragging the top left corner. The compositor may also + * use this information to adapt its behavior, e.g. choose an appropriate + * cursor image. + */ +static inline void +xdg_toplevel_resize(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial, uint32_t edges) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_RESIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, seat, serial, edges); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Set a maximum size for the window. + * + * The client can specify a maximum size so that the compositor does + * not try to configure the window beyond this size. + * + * The width and height arguments are in window geometry coordinates. + * See xdg_surface.set_window_geometry. + * + * Values set in this way are double-buffered, see wl_surface.commit. + * + * The compositor can use this information to allow or disallow + * different states like maximize or fullscreen and draw accurate + * animations. + * + * Similarly, a tiling window manager may use this information to + * place and resize client windows in a more effective way. + * + * The client should not rely on the compositor to obey the maximum + * size. The compositor may decide to ignore the values set by the + * client and request a larger size. + * + * If never set, or a value of zero in the request, means that the + * client has no expected maximum size in the given dimension. + * As a result, a client wishing to reset the maximum size + * to an unspecified state can use zero for width and height in the + * request. + * + * Requesting a maximum size to be smaller than the minimum size of + * a surface is illegal and will result in an invalid_size error. + * + * The width and height must be greater than or equal to zero. Using + * strictly negative values for width or height will result in an + * invalid_size error. + */ +static inline void +xdg_toplevel_set_max_size(struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_SET_MAX_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, width, height); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Set a minimum size for the window. + * + * The client can specify a minimum size so that the compositor does + * not try to configure the window below this size. + * + * The width and height arguments are in window geometry coordinates. + * See xdg_surface.set_window_geometry. + * + * Values set in this way are double-buffered, see wl_surface.commit. + * + * The compositor can use this information to allow or disallow + * different states like maximize or fullscreen and draw accurate + * animations. + * + * Similarly, a tiling window manager may use this information to + * place and resize client windows in a more effective way. + * + * The client should not rely on the compositor to obey the minimum + * size. The compositor may decide to ignore the values set by the + * client and request a smaller size. + * + * If never set, or a value of zero in the request, means that the + * client has no expected minimum size in the given dimension. + * As a result, a client wishing to reset the minimum size + * to an unspecified state can use zero for width and height in the + * request. + * + * Requesting a minimum size to be larger than the maximum size of + * a surface is illegal and will result in an invalid_size error. + * + * The width and height must be greater than or equal to zero. Using + * strictly negative values for width and height will result in an + * invalid_size error. + */ +static inline void +xdg_toplevel_set_min_size(struct xdg_toplevel *xdg_toplevel, int32_t width, int32_t height) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_SET_MIN_SIZE, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, width, height); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Maximize the surface. + * + * After requesting that the surface should be maximized, the compositor + * will respond by emitting a configure event. Whether this configure + * actually sets the window maximized is subject to compositor policies. + * The client must then update its content, drawing in the configured + * state. The client must also acknowledge the configure when committing + * the new content (see ack_configure). + * + * It is up to the compositor to decide how and where to maximize the + * surface, for example which output and what region of the screen should + * be used. + * + * If the surface was already maximized, the compositor will still emit + * a configure event with the "maximized" state. + * + * If the surface is in a fullscreen state, this request has no direct + * effect. It may alter the state the surface is returned to when + * unmaximized unless overridden by the compositor. + */ +static inline void +xdg_toplevel_set_maximized(struct xdg_toplevel *xdg_toplevel) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_SET_MAXIMIZED, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Unmaximize the surface. + * + * After requesting that the surface should be unmaximized, the compositor + * will respond by emitting a configure event. Whether this actually + * un-maximizes the window is subject to compositor policies. + * If available and applicable, the compositor will include the window + * geometry dimensions the window had prior to being maximized in the + * configure event. The client must then update its content, drawing it in + * the configured state. The client must also acknowledge the configure + * when committing the new content (see ack_configure). + * + * It is up to the compositor to position the surface after it was + * unmaximized; usually the position the surface had before maximizing, if + * applicable. + * + * If the surface was already not maximized, the compositor will still + * emit a configure event without the "maximized" state. + * + * If the surface is in a fullscreen state, this request has no direct + * effect. It may alter the state the surface is returned to when + * unmaximized unless overridden by the compositor. + */ +static inline void +xdg_toplevel_unset_maximized(struct xdg_toplevel *xdg_toplevel) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_UNSET_MAXIMIZED, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Make the surface fullscreen. + * + * After requesting that the surface should be fullscreened, the + * compositor will respond by emitting a configure event. Whether the + * client is actually put into a fullscreen state is subject to compositor + * policies. The client must also acknowledge the configure when + * committing the new content (see ack_configure). + * + * The output passed by the request indicates the client's preference as + * to which display it should be set fullscreen on. If this value is NULL, + * it's up to the compositor to choose which display will be used to map + * this surface. + * + * If the surface doesn't cover the whole output, the compositor will + * position the surface in the center of the output and compensate with + * border fill covering the rest of the output. The content of the + * border fill is undefined, but should be assumed to be in some way that + * attempts to blend into the surrounding area (e.g. solid black). + * + * If the fullscreened surface is not opaque, the compositor must make + * sure that other screen content not part of the same surface tree (made + * up of subsurfaces, popups or similarly coupled surfaces) are not + * visible below the fullscreened surface. + */ +static inline void +xdg_toplevel_set_fullscreen(struct xdg_toplevel *xdg_toplevel, struct wl_output *output) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_SET_FULLSCREEN, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0, output); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Make the surface no longer fullscreen. + * + * After requesting that the surface should be unfullscreened, the + * compositor will respond by emitting a configure event. + * Whether this actually removes the fullscreen state of the client is + * subject to compositor policies. + * + * Making a surface unfullscreen sets states for the surface based on the following: + * * the state(s) it may have had before becoming fullscreen + * * any state(s) decided by the compositor + * * any state(s) requested by the client while the surface was fullscreen + * + * The compositor may include the previous window geometry dimensions in + * the configure event, if applicable. + * + * The client must also acknowledge the configure when committing the new + * content (see ack_configure). + */ +static inline void +xdg_toplevel_unset_fullscreen(struct xdg_toplevel *xdg_toplevel) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_UNSET_FULLSCREEN, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0); +} + +/** + * @ingroup iface_xdg_toplevel + * + * Request that the compositor minimize your surface. There is no + * way to know if the surface is currently minimized, nor is there + * any way to unset minimization on this surface. + * + * If you are looking to throttle redrawing when minimized, please + * instead use the wl_surface.frame event for this, as this will + * also work with live previews on windows in Alt-Tab, Expose or + * similar compositor features. + */ +static inline void +xdg_toplevel_set_minimized(struct xdg_toplevel *xdg_toplevel) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel, + XDG_TOPLEVEL_SET_MINIMIZED, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel), 0); +} + +#ifndef XDG_POPUP_ERROR_ENUM +#define XDG_POPUP_ERROR_ENUM +enum xdg_popup_error { + /** + * tried to grab after being mapped + */ + XDG_POPUP_ERROR_INVALID_GRAB = 0, +}; +#endif /* XDG_POPUP_ERROR_ENUM */ + +/** + * @ingroup iface_xdg_popup + * @struct xdg_popup_listener + */ +struct xdg_popup_listener { + /** + * configure the popup surface + * + * This event asks the popup surface to configure itself given + * the configuration. The configured state should not be applied + * immediately. See xdg_surface.configure for details. + * + * The x and y arguments represent the position the popup was + * placed at given the xdg_positioner rule, relative to the upper + * left corner of the window geometry of the parent surface. + * + * For version 2 or older, the configure event for an xdg_popup is + * only ever sent once for the initial configuration. Starting with + * version 3, it may be sent again if the popup is setup with an + * xdg_positioner with set_reactive requested, or in response to + * xdg_popup.reposition requests. + * @param x x position relative to parent surface window geometry + * @param y y position relative to parent surface window geometry + * @param width window geometry width + * @param height window geometry height + */ + void (*configure)(void *data, + struct xdg_popup *xdg_popup, + int32_t x, + int32_t y, + int32_t width, + int32_t height); + /** + * popup interaction is done + * + * The popup_done event is sent out when a popup is dismissed by + * the compositor. The client should destroy the xdg_popup object + * at this point. + */ + void (*popup_done)(void *data, + struct xdg_popup *xdg_popup); + /** + * signal the completion of a repositioned request + * + * The repositioned event is sent as part of a popup + * configuration sequence, together with xdg_popup.configure and + * lastly xdg_surface.configure to notify the completion of a + * reposition request. + * + * The repositioned event is to notify about the completion of a + * xdg_popup.reposition request. The token argument is the token + * passed in the xdg_popup.reposition request. + * + * Immediately after this event is emitted, xdg_popup.configure and + * xdg_surface.configure will be sent with the updated size and + * position, as well as a new configure serial. + * + * The client should optionally update the content of the popup, + * but must acknowledge the new popup configuration for the new + * position to take effect. See xdg_surface.ack_configure for + * details. + * @param token reposition request token + * @since 3 + */ + void (*repositioned)(void *data, + struct xdg_popup *xdg_popup, + uint32_t token); +}; + +/** + * @ingroup iface_xdg_popup + */ +static inline int +xdg_popup_add_listener(struct xdg_popup *xdg_popup, + const struct xdg_popup_listener *listener, void *data) +{ + return wl_proxy_add_listener((struct wl_proxy *) xdg_popup, + (void (**)(void)) listener, data); +} + +#define XDG_POPUP_DESTROY 0 +#define XDG_POPUP_GRAB 1 +#define XDG_POPUP_REPOSITION 2 + +/** + * @ingroup iface_xdg_popup + */ +#define XDG_POPUP_CONFIGURE_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_popup + */ +#define XDG_POPUP_POPUP_DONE_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_popup + */ +#define XDG_POPUP_REPOSITIONED_SINCE_VERSION 3 + +/** + * @ingroup iface_xdg_popup + */ +#define XDG_POPUP_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_popup + */ +#define XDG_POPUP_GRAB_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_popup + */ +#define XDG_POPUP_REPOSITION_SINCE_VERSION 3 + +/** @ingroup iface_xdg_popup */ +static inline void +xdg_popup_set_user_data(struct xdg_popup *xdg_popup, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) xdg_popup, user_data); +} + +/** @ingroup iface_xdg_popup */ +static inline void * +xdg_popup_get_user_data(struct xdg_popup *xdg_popup) +{ + return wl_proxy_get_user_data((struct wl_proxy *) xdg_popup); +} + +static inline uint32_t +xdg_popup_get_version(struct xdg_popup *xdg_popup) +{ + return wl_proxy_get_version((struct wl_proxy *) xdg_popup); +} + +/** + * @ingroup iface_xdg_popup + * + * This destroys the popup. Explicitly destroying the xdg_popup + * object will also dismiss the popup, and unmap the surface. + * + * If this xdg_popup is not the "topmost" popup, the + * xdg_wm_base.not_the_topmost_popup protocol error will be sent. + */ +static inline void +xdg_popup_destroy(struct xdg_popup *xdg_popup) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_popup, + XDG_POPUP_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_popup), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_xdg_popup + * + * This request makes the created popup take an explicit grab. An explicit + * grab will be dismissed when the user dismisses the popup, or when the + * client destroys the xdg_popup. This can be done by the user clicking + * outside the surface, using the keyboard, or even locking the screen + * through closing the lid or a timeout. + * + * If the compositor denies the grab, the popup will be immediately + * dismissed. + * + * This request must be used in response to some sort of user action like a + * button press, key press, or touch down event. The serial number of the + * event should be passed as 'serial'. + * + * The parent of a grabbing popup must either be an xdg_toplevel surface or + * another xdg_popup with an explicit grab. If the parent is another + * xdg_popup it means that the popups are nested, with this popup now being + * the topmost popup. + * + * Nested popups must be destroyed in the reverse order they were created + * in, e.g. the only popup you are allowed to destroy at all times is the + * topmost one. + * + * When compositors choose to dismiss a popup, they may dismiss every + * nested grabbing popup as well. When a compositor dismisses popups, it + * will follow the same dismissing order as required from the client. + * + * If the topmost grabbing popup is destroyed, the grab will be returned to + * the parent of the popup, if that parent previously had an explicit grab. + * + * If the parent is a grabbing popup which has already been dismissed, this + * popup will be immediately dismissed. If the parent is a popup that did + * not take an explicit grab, an error will be raised. + * + * During a popup grab, the client owning the grab will receive pointer + * and touch events for all their surfaces as normal (similar to an + * "owner-events" grab in X11 parlance), while the top most grabbing popup + * will always have keyboard focus. + */ +static inline void +xdg_popup_grab(struct xdg_popup *xdg_popup, struct wl_seat *seat, uint32_t serial) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_popup, + XDG_POPUP_GRAB, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_popup), 0, seat, serial); +} + +/** + * @ingroup iface_xdg_popup + * + * Reposition an already-mapped popup. The popup will be placed given the + * details in the passed xdg_positioner object, and a + * xdg_popup.repositioned followed by xdg_popup.configure and + * xdg_surface.configure will be emitted in response. Any parameters set + * by the previous positioner will be discarded. + * + * The passed token will be sent in the corresponding + * xdg_popup.repositioned event. The new popup position will not take + * effect until the corresponding configure event is acknowledged by the + * client. See xdg_popup.repositioned for details. The token itself is + * opaque, and has no other special meaning. + * + * If multiple reposition requests are sent, the compositor may skip all + * but the last one. + * + * If the popup is repositioned in response to a configure event for its + * parent, the client should send an xdg_positioner.set_parent_configure + * and possibly an xdg_positioner.set_parent_size request to allow the + * compositor to properly constrain the popup. + * + * If the popup is repositioned together with a parent that is being + * resized, but not in response to a configure event, the client should + * send an xdg_positioner.set_parent_size request. + */ +static inline void +xdg_popup_reposition(struct xdg_popup *xdg_popup, struct xdg_positioner *positioner, uint32_t token) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_popup, + XDG_POPUP_REPOSITION, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_popup), 0, positioner, token); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/xdg-shell-protocol.c b/src/platform/wayland/protocols/xdg-shell-protocol.c new file mode 100644 index 0000000..9dc1f61 --- /dev/null +++ b/src/platform/wayland/protocols/xdg-shell-protocol.c @@ -0,0 +1,184 @@ +/* Generated by wayland-scanner 1.25.0 */ + +/* + * Copyright © 2008-2013 Kristian Høgsberg + * Copyright © 2013 Rafael Antognolli + * Copyright © 2013 Jasper St. Pierre + * Copyright © 2010-2013 Intel Corporation + * Copyright © 2015-2017 Samsung Electronics Co., Ltd + * Copyright © 2015-2017 Red Hat Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_output_interface; +extern const struct wl_interface wl_seat_interface; +extern const struct wl_interface wl_surface_interface; +extern const struct wl_interface xdg_popup_interface; +extern const struct wl_interface xdg_positioner_interface; +extern const struct wl_interface xdg_surface_interface; +extern const struct wl_interface xdg_toplevel_interface; + +static const struct wl_interface *xdg_shell_types[] = { + NULL, + NULL, + NULL, + NULL, + &xdg_positioner_interface, + &xdg_surface_interface, + &wl_surface_interface, + &xdg_toplevel_interface, + &xdg_popup_interface, + &xdg_surface_interface, + &xdg_positioner_interface, + &xdg_toplevel_interface, + &wl_seat_interface, + NULL, + NULL, + NULL, + &wl_seat_interface, + NULL, + &wl_seat_interface, + NULL, + NULL, + &wl_output_interface, + &wl_seat_interface, + NULL, + &xdg_positioner_interface, + NULL, +}; + +static const struct wl_message xdg_wm_base_requests[] = { + { "destroy", "", xdg_shell_types + 0 }, + { "create_positioner", "n", xdg_shell_types + 4 }, + { "get_xdg_surface", "no", xdg_shell_types + 5 }, + { "pong", "u", xdg_shell_types + 0 }, +}; + +static const struct wl_message xdg_wm_base_events[] = { + { "ping", "u", xdg_shell_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface xdg_wm_base_interface = { + "xdg_wm_base", 7, + 4, xdg_wm_base_requests, + 1, xdg_wm_base_events, +}; + +static const struct wl_message xdg_positioner_requests[] = { + { "destroy", "", xdg_shell_types + 0 }, + { "set_size", "ii", xdg_shell_types + 0 }, + { "set_anchor_rect", "iiii", xdg_shell_types + 0 }, + { "set_anchor", "u", xdg_shell_types + 0 }, + { "set_gravity", "u", xdg_shell_types + 0 }, + { "set_constraint_adjustment", "u", xdg_shell_types + 0 }, + { "set_offset", "ii", xdg_shell_types + 0 }, + { "set_reactive", "3", xdg_shell_types + 0 }, + { "set_parent_size", "3ii", xdg_shell_types + 0 }, + { "set_parent_configure", "3u", xdg_shell_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface xdg_positioner_interface = { + "xdg_positioner", 7, + 10, xdg_positioner_requests, + 0, NULL, +}; + +static const struct wl_message xdg_surface_requests[] = { + { "destroy", "", xdg_shell_types + 0 }, + { "get_toplevel", "n", xdg_shell_types + 7 }, + { "get_popup", "n?oo", xdg_shell_types + 8 }, + { "set_window_geometry", "iiii", xdg_shell_types + 0 }, + { "ack_configure", "u", xdg_shell_types + 0 }, +}; + +static const struct wl_message xdg_surface_events[] = { + { "configure", "u", xdg_shell_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface xdg_surface_interface = { + "xdg_surface", 7, + 5, xdg_surface_requests, + 1, xdg_surface_events, +}; + +static const struct wl_message xdg_toplevel_requests[] = { + { "destroy", "", xdg_shell_types + 0 }, + { "set_parent", "?o", xdg_shell_types + 11 }, + { "set_title", "s", xdg_shell_types + 0 }, + { "set_app_id", "s", xdg_shell_types + 0 }, + { "show_window_menu", "ouii", xdg_shell_types + 12 }, + { "move", "ou", xdg_shell_types + 16 }, + { "resize", "ouu", xdg_shell_types + 18 }, + { "set_max_size", "ii", xdg_shell_types + 0 }, + { "set_min_size", "ii", xdg_shell_types + 0 }, + { "set_maximized", "", xdg_shell_types + 0 }, + { "unset_maximized", "", xdg_shell_types + 0 }, + { "set_fullscreen", "?o", xdg_shell_types + 21 }, + { "unset_fullscreen", "", xdg_shell_types + 0 }, + { "set_minimized", "", xdg_shell_types + 0 }, +}; + +static const struct wl_message xdg_toplevel_events[] = { + { "configure", "iia", xdg_shell_types + 0 }, + { "close", "", xdg_shell_types + 0 }, + { "configure_bounds", "4ii", xdg_shell_types + 0 }, + { "wm_capabilities", "5a", xdg_shell_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface xdg_toplevel_interface = { + "xdg_toplevel", 7, + 14, xdg_toplevel_requests, + 4, xdg_toplevel_events, +}; + +static const struct wl_message xdg_popup_requests[] = { + { "destroy", "", xdg_shell_types + 0 }, + { "grab", "ou", xdg_shell_types + 22 }, + { "reposition", "3ou", xdg_shell_types + 24 }, +}; + +static const struct wl_message xdg_popup_events[] = { + { "configure", "iiii", xdg_shell_types + 0 }, + { "popup_done", "", xdg_shell_types + 0 }, + { "repositioned", "3u", xdg_shell_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface xdg_popup_interface = { + "xdg_popup", 7, + 3, xdg_popup_requests, + 3, xdg_popup_events, +}; + diff --git a/src/platform/wayland/protocols/xdg-toplevel-drag-v1-client-protocol.h b/src/platform/wayland/protocols/xdg-toplevel-drag-v1-client-protocol.h new file mode 100644 index 0000000..e5d6860 --- /dev/null +++ b/src/platform/wayland/protocols/xdg-toplevel-drag-v1-client-protocol.h @@ -0,0 +1,320 @@ +/* Generated by wayland-scanner 1.26.0 */ + +#ifndef XDG_TOPLEVEL_DRAG_V1_CLIENT_PROTOCOL_H +#define XDG_TOPLEVEL_DRAG_V1_CLIENT_PROTOCOL_H + +#include <stdint.h> +#include <stddef.h> +#include "wayland-client.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @page page_xdg_toplevel_drag_v1 The xdg_toplevel_drag_v1 protocol + * @section page_ifaces_xdg_toplevel_drag_v1 Interfaces + * - @subpage page_iface_xdg_toplevel_drag_manager_v1 - Move a window during a drag + * - @subpage page_iface_xdg_toplevel_drag_v1 - Object representing a toplevel move during a drag + * @section page_copyright_xdg_toplevel_drag_v1 Copyright + * <pre> + * + * Copyright 2023 David Redondo + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * </pre> + */ +struct wl_data_source; +struct xdg_toplevel; +struct xdg_toplevel_drag_manager_v1; +struct xdg_toplevel_drag_v1; + +#ifndef XDG_TOPLEVEL_DRAG_MANAGER_V1_INTERFACE +#define XDG_TOPLEVEL_DRAG_MANAGER_V1_INTERFACE +/** + * @page page_iface_xdg_toplevel_drag_manager_v1 xdg_toplevel_drag_manager_v1 + * @section page_iface_xdg_toplevel_drag_manager_v1_desc Description + * + * This protocol enhances normal drag and drop with the ability to move a + * window at the same time. This allows having detachable parts of a window + * that when dragged out of it become a new window and can be dragged over + * an existing window to be reattached. + * + * A typical workflow would be when the user starts dragging on top of a + * detachable part of a window, the client would create a wl_data_source and + * a xdg_toplevel_drag_v1 object and start the drag as normal via + * wl_data_device.start_drag. Once the client determines that the detachable + * window contents should be detached from the originating window, it creates + * a new xdg_toplevel with these contents and issues a + * xdg_toplevel_drag_v1.attach request before mapping it. From now on the new + * window is moved by the compositor during the drag as if the client called + * xdg_toplevel.move. + * + * Dragging an existing window is similar. The client creates a + * xdg_toplevel_drag_v1 object and attaches the existing toplevel before + * starting the drag. + * + * Clients use the existing drag and drop mechanism to detect when a window + * can be docked or undocked. If the client wants to snap a window into a + * parent window it should delete or unmap the dragged top-level. If the + * contents should be detached again it attaches a new toplevel as described + * above. If a drag operation is cancelled without being dropped, clients + * should revert to the previous state, deleting any newly created windows + * as appropriate. When a drag operation ends as indicated by + * wl_data_source.dnd_drop_performed the dragged toplevel window's final + * position is determined as if a xdg_toplevel_move operation ended. + * + * Warning! The protocol described in this file is currently in the testing + * phase. Backward compatible changes may be added together with the + * corresponding interface version bump. Backward incompatible changes can + * only be done by creating a new major version of the extension. + * @section page_iface_xdg_toplevel_drag_manager_v1_api API + * See @ref iface_xdg_toplevel_drag_manager_v1. + */ +/** + * @defgroup iface_xdg_toplevel_drag_manager_v1 The xdg_toplevel_drag_manager_v1 interface + * + * This protocol enhances normal drag and drop with the ability to move a + * window at the same time. This allows having detachable parts of a window + * that when dragged out of it become a new window and can be dragged over + * an existing window to be reattached. + * + * A typical workflow would be when the user starts dragging on top of a + * detachable part of a window, the client would create a wl_data_source and + * a xdg_toplevel_drag_v1 object and start the drag as normal via + * wl_data_device.start_drag. Once the client determines that the detachable + * window contents should be detached from the originating window, it creates + * a new xdg_toplevel with these contents and issues a + * xdg_toplevel_drag_v1.attach request before mapping it. From now on the new + * window is moved by the compositor during the drag as if the client called + * xdg_toplevel.move. + * + * Dragging an existing window is similar. The client creates a + * xdg_toplevel_drag_v1 object and attaches the existing toplevel before + * starting the drag. + * + * Clients use the existing drag and drop mechanism to detect when a window + * can be docked or undocked. If the client wants to snap a window into a + * parent window it should delete or unmap the dragged top-level. If the + * contents should be detached again it attaches a new toplevel as described + * above. If a drag operation is cancelled without being dropped, clients + * should revert to the previous state, deleting any newly created windows + * as appropriate. When a drag operation ends as indicated by + * wl_data_source.dnd_drop_performed the dragged toplevel window's final + * position is determined as if a xdg_toplevel_move operation ended. + * + * Warning! The protocol described in this file is currently in the testing + * phase. Backward compatible changes may be added together with the + * corresponding interface version bump. Backward incompatible changes can + * only be done by creating a new major version of the extension. + */ +extern const struct wl_interface xdg_toplevel_drag_manager_v1_interface; +#endif +#ifndef XDG_TOPLEVEL_DRAG_V1_INTERFACE +#define XDG_TOPLEVEL_DRAG_V1_INTERFACE +/** + * @page page_iface_xdg_toplevel_drag_v1 xdg_toplevel_drag_v1 + * @section page_iface_xdg_toplevel_drag_v1_desc Description + * + * @section page_iface_xdg_toplevel_drag_v1_api API + * See @ref iface_xdg_toplevel_drag_v1. + */ +/** + * @defgroup iface_xdg_toplevel_drag_v1 The xdg_toplevel_drag_v1 interface + * + */ +extern const struct wl_interface xdg_toplevel_drag_v1_interface; +#endif + +#ifndef XDG_TOPLEVEL_DRAG_MANAGER_V1_ERROR_ENUM +#define XDG_TOPLEVEL_DRAG_MANAGER_V1_ERROR_ENUM +enum xdg_toplevel_drag_manager_v1_error { + /** + * data_source already used for toplevel drag + */ + XDG_TOPLEVEL_DRAG_MANAGER_V1_ERROR_INVALID_SOURCE = 0, +}; +#endif /* XDG_TOPLEVEL_DRAG_MANAGER_V1_ERROR_ENUM */ + +#define XDG_TOPLEVEL_DRAG_MANAGER_V1_DESTROY 0 +#define XDG_TOPLEVEL_DRAG_MANAGER_V1_GET_XDG_TOPLEVEL_DRAG 1 + + +/** + * @ingroup iface_xdg_toplevel_drag_manager_v1 + */ +#define XDG_TOPLEVEL_DRAG_MANAGER_V1_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel_drag_manager_v1 + */ +#define XDG_TOPLEVEL_DRAG_MANAGER_V1_GET_XDG_TOPLEVEL_DRAG_SINCE_VERSION 1 + +/** @ingroup iface_xdg_toplevel_drag_manager_v1 */ +static inline void +xdg_toplevel_drag_manager_v1_set_user_data(struct xdg_toplevel_drag_manager_v1 *xdg_toplevel_drag_manager_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) xdg_toplevel_drag_manager_v1, user_data); +} + +/** @ingroup iface_xdg_toplevel_drag_manager_v1 */ +static inline void * +xdg_toplevel_drag_manager_v1_get_user_data(struct xdg_toplevel_drag_manager_v1 *xdg_toplevel_drag_manager_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) xdg_toplevel_drag_manager_v1); +} + +static inline uint32_t +xdg_toplevel_drag_manager_v1_get_version(struct xdg_toplevel_drag_manager_v1 *xdg_toplevel_drag_manager_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_drag_manager_v1); +} + +/** + * @ingroup iface_xdg_toplevel_drag_manager_v1 + * + * Destroy this xdg_toplevel_drag_manager_v1 object. Other objects, + * including xdg_toplevel_drag_v1 objects created by this factory, are not + * affected by this request. + */ +static inline void +xdg_toplevel_drag_manager_v1_destroy(struct xdg_toplevel_drag_manager_v1 *xdg_toplevel_drag_manager_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel_drag_manager_v1, + XDG_TOPLEVEL_DRAG_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_drag_manager_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_xdg_toplevel_drag_manager_v1 + * + * Create an xdg_toplevel_drag for a drag and drop operation that is going + * to be started with data_source. + * + * This request can only be made on sources used in drag-and-drop, so it + * must be performed before wl_data_device.start_drag. Attempting to use + * the source other than for drag-and-drop such as in + * wl_data_device.set_selection will raise an invalid_source error. + * + * Destroying data_source while a toplevel is attached to the + * xdg_toplevel_drag is undefined. + */ +static inline struct xdg_toplevel_drag_v1 * +xdg_toplevel_drag_manager_v1_get_xdg_toplevel_drag(struct xdg_toplevel_drag_manager_v1 *xdg_toplevel_drag_manager_v1, struct wl_data_source *data_source) +{ + struct wl_proxy *id; + + id = wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel_drag_manager_v1, + XDG_TOPLEVEL_DRAG_MANAGER_V1_GET_XDG_TOPLEVEL_DRAG, &xdg_toplevel_drag_v1_interface, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_drag_manager_v1), 0, NULL, data_source); + + return (struct xdg_toplevel_drag_v1 *) id; +} + +#ifndef XDG_TOPLEVEL_DRAG_V1_ERROR_ENUM +#define XDG_TOPLEVEL_DRAG_V1_ERROR_ENUM +enum xdg_toplevel_drag_v1_error { + /** + * valid toplevel already attached + */ + XDG_TOPLEVEL_DRAG_V1_ERROR_TOPLEVEL_ATTACHED = 0, + /** + * drag has not ended + */ + XDG_TOPLEVEL_DRAG_V1_ERROR_ONGOING_DRAG = 1, +}; +#endif /* XDG_TOPLEVEL_DRAG_V1_ERROR_ENUM */ + +#define XDG_TOPLEVEL_DRAG_V1_DESTROY 0 +#define XDG_TOPLEVEL_DRAG_V1_ATTACH 1 + + +/** + * @ingroup iface_xdg_toplevel_drag_v1 + */ +#define XDG_TOPLEVEL_DRAG_V1_DESTROY_SINCE_VERSION 1 +/** + * @ingroup iface_xdg_toplevel_drag_v1 + */ +#define XDG_TOPLEVEL_DRAG_V1_ATTACH_SINCE_VERSION 1 + +/** @ingroup iface_xdg_toplevel_drag_v1 */ +static inline void +xdg_toplevel_drag_v1_set_user_data(struct xdg_toplevel_drag_v1 *xdg_toplevel_drag_v1, void *user_data) +{ + wl_proxy_set_user_data((struct wl_proxy *) xdg_toplevel_drag_v1, user_data); +} + +/** @ingroup iface_xdg_toplevel_drag_v1 */ +static inline void * +xdg_toplevel_drag_v1_get_user_data(struct xdg_toplevel_drag_v1 *xdg_toplevel_drag_v1) +{ + return wl_proxy_get_user_data((struct wl_proxy *) xdg_toplevel_drag_v1); +} + +static inline uint32_t +xdg_toplevel_drag_v1_get_version(struct xdg_toplevel_drag_v1 *xdg_toplevel_drag_v1) +{ + return wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_drag_v1); +} + +/** + * @ingroup iface_xdg_toplevel_drag_v1 + * + * Destroy this xdg_toplevel_drag_v1 object. This request must only be + * called after the underlying wl_data_source drag has ended, as indicated + * by the dnd_drop_performed or cancelled events. In any other case an + * ongoing_drag error is raised. + */ +static inline void +xdg_toplevel_drag_v1_destroy(struct xdg_toplevel_drag_v1 *xdg_toplevel_drag_v1) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel_drag_v1, + XDG_TOPLEVEL_DRAG_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_drag_v1), WL_MARSHAL_FLAG_DESTROY); +} + +/** + * @ingroup iface_xdg_toplevel_drag_v1 + * + * Request that the window will be moved with the cursor during the drag + * operation. The offset is a hint to the compositor how the toplevel + * should be positioned relative to the cursor hotspot in surface local + * coordinates and relative to the geometry of the toplevel being attached. + * See xdg_surface.set_window_geometry. For example it might only + * be used when an unmapped window is attached. The attached window + * does not participate in the selection of the drag target. + * + * If the toplevel is unmapped while it is attached, it is automatically + * detached from the drag. In this case this request has to be called again + * if the window should be attached after it is remapped. + * + * This request can be called multiple times but issuing it while a + * toplevel with an active role is attached raises a toplevel_attached + * error. + */ +static inline void +xdg_toplevel_drag_v1_attach(struct xdg_toplevel_drag_v1 *xdg_toplevel_drag_v1, struct xdg_toplevel *toplevel, int32_t x_offset, int32_t y_offset) +{ + wl_proxy_marshal_flags((struct wl_proxy *) xdg_toplevel_drag_v1, + XDG_TOPLEVEL_DRAG_V1_ATTACH, NULL, wl_proxy_get_version((struct wl_proxy *) xdg_toplevel_drag_v1), 0, toplevel, x_offset, y_offset); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/platform/wayland/protocols/xdg-toplevel-drag-v1-protocol.c b/src/platform/wayland/protocols/xdg-toplevel-drag-v1-protocol.c new file mode 100644 index 0000000..1411819 --- /dev/null +++ b/src/platform/wayland/protocols/xdg-toplevel-drag-v1-protocol.c @@ -0,0 +1,74 @@ +/* Generated by wayland-scanner 1.26.0 */ + +/* + * Copyright 2023 David Redondo + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include <stdbool.h> +#include <stdlib.h> +#include <stdint.h> +#include "wayland-util.h" + +#ifndef __has_attribute +# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ +#endif + +#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) +#define WL_PRIVATE __attribute__ ((visibility("hidden"))) +#else +#define WL_PRIVATE +#endif + +extern const struct wl_interface wl_data_source_interface; +extern const struct wl_interface xdg_toplevel_interface; +extern const struct wl_interface xdg_toplevel_drag_v1_interface; + +static const struct wl_interface *xdg_toplevel_drag_v1_types[] = { + &xdg_toplevel_drag_v1_interface, + &wl_data_source_interface, + &xdg_toplevel_interface, + NULL, + NULL, +}; + +static const struct wl_message xdg_toplevel_drag_manager_v1_requests[] = { + { "destroy", "", xdg_toplevel_drag_v1_types + 0 }, + { "get_xdg_toplevel_drag", "no", xdg_toplevel_drag_v1_types + 0 }, +}; + +WL_PRIVATE const struct wl_interface xdg_toplevel_drag_manager_v1_interface = { + "xdg_toplevel_drag_manager_v1", 1, + 2, xdg_toplevel_drag_manager_v1_requests, + 0, NULL, +}; + +static const struct wl_message xdg_toplevel_drag_v1_requests[] = { + { "destroy", "", xdg_toplevel_drag_v1_types + 0 }, + { "attach", "oii", xdg_toplevel_drag_v1_types + 2 }, +}; + +WL_PRIVATE const struct wl_interface xdg_toplevel_drag_v1_interface = { + "xdg_toplevel_drag_v1", 1, + 2, xdg_toplevel_drag_v1_requests, + 0, NULL, +}; + |
