/* Generated by wayland-scanner 1.26.0 */

#ifndef TREELAND_REMOTE_SUBSURFACE_UNSTABLE_V1_SERVER_PROTOCOL_H
#define TREELAND_REMOTE_SUBSURFACE_UNSTABLE_V1_SERVER_PROTOCOL_H

#include <stdint.h>
#include <stddef.h>
#include "wayland-server.h"

#ifdef  __cplusplus
extern "C" {
#endif

struct wl_client;
struct wl_resource;

/**
 * @page page_treeland_remote_subsurface_unstable_v1 The treeland_remote_subsurface_unstable_v1 protocol
 * sub-surface compositing via token-based references
 *
 * @section page_desc_treeland_remote_subsurface_unstable_v1 Description
 *
 * Provides sub-surface relationships between wl_surface objects
 * using token-based identifiers exchanged out-of-band, instead
 * of the direct wl_surface references required by
 * wl_subcompositor.  This allows parent-child relationships
 * both across different client connections and within the
 * same client.
 *
 * In wl_subcompositor both the parent surface and sibling
 * surfaces must be local wl_surface objects from the same
 * client.  This protocol removes that restriction by using
 * token-based identifiers exchanged out-of-band:
 *
 * 1. A client exports a wl_surface and receives a surface_token.
 *
 * 2. Another client (or the same client) exports their own
 * wl_surface and then calls create_remote_subsurface with
 * the parent's surface_token, attaching their surface as a
 * child.
 *
 * All sub-surface semantics follow the wl_subcompositor
 * specification unless explicitly noted in this document.
 * Cross-process sub-surfaces are always in desynchronized mode;
 * synchronized mode is not supported.
 *
 * This protocol is not interoperable with wl_subsurface: a
 * treeland_remote_subsurface_v1 cannot be stacked relative to
 * wl_subsurface siblings, and a wl_subsurface cannot reference
 * a surface that carries a treeland_remote_subsurface_v1 role.
 *
 * Clients should prefer this protocol over wl_subsurface for
 * all sub-surface use, to avoid having two separate sub-surface
 * trees that cannot interact with each other.
 *
 * The compositor must restrict binding to trusted clients.
 * A client that obtains a surface_token must only share it
 * with other trusted clients through a secure mechanism;
 * the compositor does not disclose tokens to other clients.
 *
 * The key words "must", "must not", "required", "shall",
 * "shall not", "should", "should not", "recommended", "may",
 * and "optional" in this document are to be interpreted as
 * described in RFC 2119.
 *
 * Warning! This protocol is EXPERIMENTAL and under active development.
 * It may change at any time, including in backward-incompatible ways,
 * without incrementing the interface major version and without prior
 * notice. No compatibility guarantees of any kind are provided. Clients
 * and compositors must track the upstream definition in treeland-protocols
 * and must not rely on the current interface names, requests, events, or
 * semantics remaining stable across releases.
 *
 * @section page_ifaces_treeland_remote_subsurface_unstable_v1 Interfaces
 * - @subpage page_iface_treeland_subsurface_manager_v1 - factory for remote sub-surfaces
 * - @subpage page_iface_treeland_exported_surface_v1 - an exported surface, addressable by token
 * - @subpage page_iface_treeland_remote_subsurface_v1 - remote sub-surface interface to a wl_surface
 * @section page_copyright_treeland_remote_subsurface_unstable_v1 Copyright
 * <pre>
 *
 * SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
 * SPDX-License-Identifier: MIT
 * </pre>
 */
struct treeland_exported_surface_v1;
struct treeland_remote_subsurface_v1;
struct treeland_subsurface_manager_v1;
struct wl_surface;

#ifndef TREELAND_SUBSURFACE_MANAGER_V1_INTERFACE
#define TREELAND_SUBSURFACE_MANAGER_V1_INTERFACE
/**
 * @page page_iface_treeland_subsurface_manager_v1 treeland_subsurface_manager_v1
 * @section page_iface_treeland_subsurface_manager_v1_desc Description
 *
 * Global factory for exporting surfaces as token-addressable
 * sub-surface parents or children.
 * @section page_iface_treeland_subsurface_manager_v1_api API
 * See @ref iface_treeland_subsurface_manager_v1.
 */
/**
 * @defgroup iface_treeland_subsurface_manager_v1 The treeland_subsurface_manager_v1 interface
 *
 * Global factory for exporting surfaces as token-addressable
 * sub-surface parents or children.
 */
extern const struct wl_interface treeland_subsurface_manager_v1_interface;
#endif
#ifndef TREELAND_EXPORTED_SURFACE_V1_INTERFACE
#define TREELAND_EXPORTED_SURFACE_V1_INTERFACE
/**
 * @page page_iface_treeland_exported_surface_v1 treeland_exported_surface_v1
 * @section page_iface_treeland_exported_surface_v1_desc Description
 *
 * Represents a wl_surface registered for sub-surface use
 * via this protocol.  The surface may act as a parent or a
 * child; a surface can have at most one parent via this
 * protocol.
 *
 * Destroying this object revokes the surface_token without
 * affecting existing parent-child relationships or
 * treeland_remote_subsurface_v1 objects.
 * @section page_iface_treeland_exported_surface_v1_api API
 * See @ref iface_treeland_exported_surface_v1.
 */
/**
 * @defgroup iface_treeland_exported_surface_v1 The treeland_exported_surface_v1 interface
 *
 * Represents a wl_surface registered for sub-surface use
 * via this protocol.  The surface may act as a parent or a
 * child; a surface can have at most one parent via this
 * protocol.
 *
 * Destroying this object revokes the surface_token without
 * affecting existing parent-child relationships or
 * treeland_remote_subsurface_v1 objects.
 */
extern const struct wl_interface treeland_exported_surface_v1_interface;
#endif
#ifndef TREELAND_REMOTE_SUBSURFACE_V1_INTERFACE
#define TREELAND_REMOTE_SUBSURFACE_V1_INTERFACE
/**
 * @page page_iface_treeland_remote_subsurface_v1 treeland_remote_subsurface_v1
 * @section page_iface_treeland_remote_subsurface_v1_desc Description
 *
 * An additional interface to a wl_surface that has been
 * made a sub-surface via this protocol.  A sub-surface has
 * one parent and is not automatically clipped to its
 * parent's area.
 *
 * Mapping and commit semantics follow wl_subcompositor
 * except that desynchronized mode is always used.  A
 * sub-surface never has the keyboard focus of any seat.
 *
 * The parent is identified at creation time and cannot be
 * changed.  place_above and place_below accept a token
 * (string) instead of a wl_surface proxy; see the request
 * documentation for valid values.
 *
 * The wl_surface.offset request is ignored; clients must
 * use set_position instead.
 * @section page_iface_treeland_remote_subsurface_v1_api API
 * See @ref iface_treeland_remote_subsurface_v1.
 */
/**
 * @defgroup iface_treeland_remote_subsurface_v1 The treeland_remote_subsurface_v1 interface
 *
 * An additional interface to a wl_surface that has been
 * made a sub-surface via this protocol.  A sub-surface has
 * one parent and is not automatically clipped to its
 * parent's area.
 *
 * Mapping and commit semantics follow wl_subcompositor
 * except that desynchronized mode is always used.  A
 * sub-surface never has the keyboard focus of any seat.
 *
 * The parent is identified at creation time and cannot be
 * changed.  place_above and place_below accept a token
 * (string) instead of a wl_surface proxy; see the request
 * documentation for valid values.
 *
 * The wl_surface.offset request is ignored; clients must
 * use set_position instead.
 */
extern const struct wl_interface treeland_remote_subsurface_v1_interface;
#endif

#ifndef TREELAND_SUBSURFACE_MANAGER_V1_ERROR_ENUM
#define TREELAND_SUBSURFACE_MANAGER_V1_ERROR_ENUM
enum treeland_subsurface_manager_v1_error {
	/**
	 * the wl_surface has already been exported through this manager
	 */
	TREELAND_SUBSURFACE_MANAGER_V1_ERROR_BAD_SURFACE = 0,
};
#endif /* TREELAND_SUBSURFACE_MANAGER_V1_ERROR_ENUM */

#ifndef TREELAND_SUBSURFACE_MANAGER_V1_ERROR_ENUM_IS_VALID
#define TREELAND_SUBSURFACE_MANAGER_V1_ERROR_ENUM_IS_VALID
/**
 * @ingroup iface_treeland_subsurface_manager_v1
 * Validate a treeland_subsurface_manager_v1 error value.
 *
 * @return true on success, false on error.
 * @ref treeland_subsurface_manager_v1_error
 */
static inline bool
treeland_subsurface_manager_v1_error_is_valid(uint32_t value, uint32_t version) {
	switch (value) {
	case TREELAND_SUBSURFACE_MANAGER_V1_ERROR_BAD_SURFACE:
		return version >= 1;
	default:
		return false;
	}
}
#endif /* TREELAND_SUBSURFACE_MANAGER_V1_ERROR_ENUM_IS_VALID */

/**
 * @ingroup iface_treeland_subsurface_manager_v1
 * @struct treeland_subsurface_manager_v1_interface
 */
struct treeland_subsurface_manager_v1_interface {
	/**
	 * unbind from the sub-surface manager
	 *
	 * Informs the server that the client will no longer use this
	 * global. Child objects are not affected.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
	/**
	 * register a surface for token-addressable sub-surface use
	 *
	 * Register surface as addressable by token, receiving a
	 * treeland_exported_surface_v1. Upon success the compositor emits
	 * the surface_token event.
	 *
	 * The surface must not have been previously exported through this
	 * manager. A surface may carry both an xdg_toplevel (or any other)
	 * role and an export; the export only marks it as addressable by
	 * token.
	 * @param surface the surface to export
	 */
	void (*export_surface)(struct wl_client *client,
			       struct wl_resource *resource,
			       uint32_t id,
			       struct wl_resource *surface);
};


/**
 * @ingroup iface_treeland_subsurface_manager_v1
 */
#define TREELAND_SUBSURFACE_MANAGER_V1_DESTROY_SINCE_VERSION 1
/**
 * @ingroup iface_treeland_subsurface_manager_v1
 */
#define TREELAND_SUBSURFACE_MANAGER_V1_EXPORT_SURFACE_SINCE_VERSION 1

#ifndef TREELAND_EXPORTED_SURFACE_V1_ERROR_ENUM
#define TREELAND_EXPORTED_SURFACE_V1_ERROR_ENUM
enum treeland_exported_surface_v1_error {
	/**
	 * the child surface already has an incompatible role
	 */
	TREELAND_EXPORTED_SURFACE_V1_ERROR_BAD_SURFACE = 0,
};
#endif /* TREELAND_EXPORTED_SURFACE_V1_ERROR_ENUM */

#ifndef TREELAND_EXPORTED_SURFACE_V1_ERROR_ENUM_IS_VALID
#define TREELAND_EXPORTED_SURFACE_V1_ERROR_ENUM_IS_VALID
/**
 * @ingroup iface_treeland_exported_surface_v1
 * Validate a treeland_exported_surface_v1 error value.
 *
 * @return true on success, false on error.
 * @ref treeland_exported_surface_v1_error
 */
static inline bool
treeland_exported_surface_v1_error_is_valid(uint32_t value, uint32_t version) {
	switch (value) {
	case TREELAND_EXPORTED_SURFACE_V1_ERROR_BAD_SURFACE:
		return version >= 1;
	default:
		return false;
	}
}
#endif /* TREELAND_EXPORTED_SURFACE_V1_ERROR_ENUM_IS_VALID */

#ifndef TREELAND_EXPORTED_SURFACE_V1_REJECT_REASON_ENUM
#define TREELAND_EXPORTED_SURFACE_V1_REJECT_REASON_ENUM
/**
 * @ingroup iface_treeland_exported_surface_v1
 * why create_remote_subsurface was rejected
 *
 */
enum treeland_exported_surface_v1_reject_reason {
	/**
	 * parent_token does not identify a live exported surface
	 */
	TREELAND_EXPORTED_SURFACE_V1_REJECT_REASON_INVALID_TOKEN = 0,
	/**
	 * parent_token would introduce a cycle in the sub-surface tree
	 */
	TREELAND_EXPORTED_SURFACE_V1_REJECT_REASON_CYCLIC = 1,
};
#endif /* TREELAND_EXPORTED_SURFACE_V1_REJECT_REASON_ENUM */

#ifndef TREELAND_EXPORTED_SURFACE_V1_REJECT_REASON_ENUM_IS_VALID
#define TREELAND_EXPORTED_SURFACE_V1_REJECT_REASON_ENUM_IS_VALID
/**
 * @ingroup iface_treeland_exported_surface_v1
 * Validate a treeland_exported_surface_v1 reject_reason value.
 *
 * @return true on success, false on error.
 * @ref treeland_exported_surface_v1_reject_reason
 */
static inline bool
treeland_exported_surface_v1_reject_reason_is_valid(uint32_t value, uint32_t version) {
	switch (value) {
	case TREELAND_EXPORTED_SURFACE_V1_REJECT_REASON_INVALID_TOKEN:
		return version >= 1;
	case TREELAND_EXPORTED_SURFACE_V1_REJECT_REASON_CYCLIC:
		return version >= 1;
	default:
		return false;
	}
}
#endif /* TREELAND_EXPORTED_SURFACE_V1_REJECT_REASON_ENUM_IS_VALID */

/**
 * @ingroup iface_treeland_exported_surface_v1
 * @struct treeland_exported_surface_v1_interface
 */
struct treeland_exported_surface_v1_interface {
	/**
	 * revoke the surface token
	 *
	 * Revokes the surface_token; subsequent use results in a
	 * parent_rejected event. The client must destroy this object
	 * before destroying the associated wl_surface.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
	/**
	 * attach this surface as a child to a remote parent
	 *
	 * Attach the exported surface to the parent identified by
	 * parent_token. The surface must not already have a wlroots role;
	 * it will be assigned the exclusive treeland_remote_subsurface_v1
	 * role. If the surface already has an incompatible role, a
	 * bad_surface error is raised and the new
	 * treeland_remote_subsurface_v1 object is inert.
	 *
	 * If the parent_token is invalid or would introduce a cycle, the
	 * request is ignored and a parent_rejected event is emitted.
	 *
	 * The sub-surface addition is double-buffered on the parent.
	 * @param parent_token surface_token of the parent, obtained via export
	 */
	void (*create_remote_subsurface)(struct wl_client *client,
					 struct wl_resource *resource,
					 uint32_t id,
					 const char *parent_token);
};

#define TREELAND_EXPORTED_SURFACE_V1_SURFACE_TOKEN 0
#define TREELAND_EXPORTED_SURFACE_V1_PARENT_REJECTED 1

/**
 * @ingroup iface_treeland_exported_surface_v1
 */
#define TREELAND_EXPORTED_SURFACE_V1_SURFACE_TOKEN_SINCE_VERSION 1
/**
 * @ingroup iface_treeland_exported_surface_v1
 */
#define TREELAND_EXPORTED_SURFACE_V1_PARENT_REJECTED_SINCE_VERSION 1

/**
 * @ingroup iface_treeland_exported_surface_v1
 */
#define TREELAND_EXPORTED_SURFACE_V1_DESTROY_SINCE_VERSION 1
/**
 * @ingroup iface_treeland_exported_surface_v1
 */
#define TREELAND_EXPORTED_SURFACE_V1_CREATE_REMOTE_SUBSURFACE_SINCE_VERSION 1

/**
 * @ingroup iface_treeland_exported_surface_v1
 * Sends an surface_token event to the client owning the resource.
 * @param resource_ The client's resource
 * @param token the surface token
 */
static inline void
treeland_exported_surface_v1_send_surface_token(struct wl_resource *resource_, const char *token)
{
	wl_resource_post_event(resource_, TREELAND_EXPORTED_SURFACE_V1_SURFACE_TOKEN, token);
}

/**
 * @ingroup iface_treeland_exported_surface_v1
 * Sends an parent_rejected event to the client owning the resource.
 * @param resource_ The client's resource
 * @param reason why the parent_token was rejected
 * @param parent_token the rejected parent token
 */
static inline void
treeland_exported_surface_v1_send_parent_rejected(struct wl_resource *resource_, uint32_t reason, const char *parent_token)
{
	wl_resource_post_event(resource_, TREELAND_EXPORTED_SURFACE_V1_PARENT_REJECTED, reason, parent_token);
}

/**
 * @ingroup iface_treeland_remote_subsurface_v1
 * @struct treeland_remote_subsurface_v1_interface
 */
struct treeland_remote_subsurface_v1_interface {
	/**
	 * remove sub-surface interface
	 *
	 * Removes the sub-surface association, unmaps the wl_surface
	 * immediately, and destroys this object.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
	/**
	 * reposition the sub-surface
	 *
	 * Schedules a position change relative to the parent surface
	 * coordinate system. Coordinates are not restricted to the parent
	 * area; negative values are allowed. Double-buffered on the
	 * parent; replaces any previous pending position. Initial position
	 * is 0, 0.
	 * @param x x coordinate in the parent surface local coordinate system
	 * @param y y coordinate in the parent surface local coordinate system
	 */
	void (*set_position)(struct wl_client *client,
			     struct wl_resource *resource,
			     int32_t x,
			     int32_t y);
	/**
	 * restack the sub-surface
	 *
	 * Places this sub-surface just above the reference identified by
	 * sibling_token, changing the z-order. Z-order is double-buffered
	 * on the parent surface. A new sub-surface is initially added at
	 * the top.
	 *
	 * Valid sibling_token values:
	 *
	 * - The surface_token of the parent exported surface.
	 *
	 * - The surface_token of any sibling cross-process sub-surface
	 * under the same parent, shared via out-of-band communication.
	 *
	 * - An empty string (""), a sentinel meaning "place at the very
	 * top of the sibling stack".
	 *
	 * If the sibling_token does not identify a valid target, the
	 * request is ignored and an invalid_sibling event is emitted.
	 * @param sibling_token a surface_token or empty string for top
	 */
	void (*place_above)(struct wl_client *client,
			    struct wl_resource *resource,
			    const char *sibling_token);
	/**
	 * restack the sub-surface
	 *
	 * Places this sub-surface just below the reference identified by
	 * sibling_token. The same values are accepted as in place_above,
	 * except that the empty string sentinel is not valid and triggers
	 * an invalid_sibling event.
	 * @param sibling_token a surface_token
	 */
	void (*place_below)(struct wl_client *client,
			    struct wl_resource *resource,
			    const char *sibling_token);
};

#define TREELAND_REMOTE_SUBSURFACE_V1_INVALID_SIBLING 0

/**
 * @ingroup iface_treeland_remote_subsurface_v1
 */
#define TREELAND_REMOTE_SUBSURFACE_V1_INVALID_SIBLING_SINCE_VERSION 1

/**
 * @ingroup iface_treeland_remote_subsurface_v1
 */
#define TREELAND_REMOTE_SUBSURFACE_V1_DESTROY_SINCE_VERSION 1
/**
 * @ingroup iface_treeland_remote_subsurface_v1
 */
#define TREELAND_REMOTE_SUBSURFACE_V1_SET_POSITION_SINCE_VERSION 1
/**
 * @ingroup iface_treeland_remote_subsurface_v1
 */
#define TREELAND_REMOTE_SUBSURFACE_V1_PLACE_ABOVE_SINCE_VERSION 1
/**
 * @ingroup iface_treeland_remote_subsurface_v1
 */
#define TREELAND_REMOTE_SUBSURFACE_V1_PLACE_BELOW_SINCE_VERSION 1

/**
 * @ingroup iface_treeland_remote_subsurface_v1
 * Sends an invalid_sibling event to the client owning the resource.
 * @param resource_ The client's resource
 * @param sibling_token the unrecognized token
 */
static inline void
treeland_remote_subsurface_v1_send_invalid_sibling(struct wl_resource *resource_, const char *sibling_token)
{
	wl_resource_post_event(resource_, TREELAND_REMOTE_SUBSURFACE_V1_INVALID_SIBLING, sibling_token);
}

#ifdef  __cplusplus
}
#endif

#endif
