/* Generated by wayland-scanner 1.26.0 */

#ifndef TREELAND_WINE_WINDOW_MANAGEMENT_V1_SERVER_PROTOCOL_H
#define TREELAND_WINE_WINDOW_MANAGEMENT_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_wine_window_management_v1 The treeland_wine_window_management_v1 protocol
 * window geometry and stacking control for Wine
 *
 * @section page_desc_treeland_wine_window_management_v1 Description
 *
 * This protocol provides privileged window management capabilities
 * required by Wine (the Windows API compatibility layer) that are not
 * available through standard Wayland protocols.
 *
 * Standard xdg-shell intentionally prevents clients from setting their
 * own screen position or controlling z-order.  Wine applications rely
 * heavily on absolute positioning (SetWindowPos, MoveWindow) and
 * stacking control (HWND_TOPMOST, HWND_TOP) to implement the Windows
 * window management model.  This protocol bridges that gap by allowing
 * a trusted Wine client to request positioning and stacking changes
 * while leaving the compositor the final authority over actual
 * placement.
 *
 * A client obtains a treeland_wine_window_control_v1 object for each
 * xdg_toplevel it wishes to manage.  Requests on that object express
 * the client's desired geometry and stacking.  The compositor applies
 * or adjusts them and reports the actual result through events.
 *
 * A Wine session is the set of all treeland_wine_window_control_v1
 * objects created through the same treeland_wine_window_manager_v1
 * global binding.  window_id values emitted by the window_id event are
 * unique and valid only within that set.  The compositor must enforce
 * this boundary: a sibling_id supplied to set_z_order that refers to a
 * control object from a different manager binding must be treated as if
 * no matching sibling exists, causing hwnd_insert_after to have no
 * effect.
 *
 * The key words "must", "must not", "should", "should not", and "may"
 * in this document are to be interpreted as described in IETF 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_wine_window_management_v1 Interfaces
 * - @subpage page_iface_treeland_wine_window_manager_v1 - global entry point for Wine window management
 * - @subpage page_iface_treeland_wine_window_control_v1 - per-toplevel position, size, and stacking control
 * @section page_copyright_treeland_wine_window_management_v1 Copyright
 * <pre>
 *
 * SPDX-FileCopyrightText: 2026 UnionTech Software Technology Co., Ltd.
 * SPDX-License-Identifier: MIT
 * </pre>
 */
struct treeland_wine_window_control_v1;
struct treeland_wine_window_manager_v1;
struct xdg_toplevel;

#ifndef TREELAND_WINE_WINDOW_MANAGER_V1_INTERFACE
#define TREELAND_WINE_WINDOW_MANAGER_V1_INTERFACE
/**
 * @page page_iface_treeland_wine_window_manager_v1 treeland_wine_window_manager_v1
 * @section page_iface_treeland_wine_window_manager_v1_desc Description
 *
 * Lets a Wine client create per-toplevel control objects.  The
 * compositor should restrict binding to trusted clients identified
 * by app_id or an equivalent policy mechanism.
 *
 * The client must destroy all child
 * treeland_wine_window_control_v1 objects before destroying this
 * object.
 * @section page_iface_treeland_wine_window_manager_v1_api API
 * See @ref iface_treeland_wine_window_manager_v1.
 */
/**
 * @defgroup iface_treeland_wine_window_manager_v1 The treeland_wine_window_manager_v1 interface
 *
 * Lets a Wine client create per-toplevel control objects.  The
 * compositor should restrict binding to trusted clients identified
 * by app_id or an equivalent policy mechanism.
 *
 * The client must destroy all child
 * treeland_wine_window_control_v1 objects before destroying this
 * object.
 */
extern const struct wl_interface treeland_wine_window_manager_v1_interface;
#endif
#ifndef TREELAND_WINE_WINDOW_CONTROL_V1_INTERFACE
#define TREELAND_WINE_WINDOW_CONTROL_V1_INTERFACE
/**
 * @page page_iface_treeland_wine_window_control_v1 treeland_wine_window_control_v1
 * @section page_iface_treeland_wine_window_control_v1_desc Description
 *
 * Controls the screen geometry and stacking order for one
 * xdg_toplevel surface.
 *
 * All coordinate values are in the compositor's global logical
 * coordinate space (the same space used by wl_output.geometry and
 * xdg_output.logical_position).
 *
 * Position requests are not applied immediately.  The
 * compositor processes them and reports the result via
 * configure_position.  The client should treat the values in
 * configure_position as authoritative and update its internal
 * state accordingly.
 *
 * If the associated xdg_toplevel is destroyed, this object becomes
 * inert.  All subsequent requests are ignored and no further events
 * are emitted.  The client should destroy the inert object.
 *
 * Window size is managed through the standard xdg_toplevel
 * configure / xdg_surface.ack_configure mechanism.  This interface
 * only controls screen position and stacking order.
 * @section page_iface_treeland_wine_window_control_v1_api API
 * See @ref iface_treeland_wine_window_control_v1.
 */
/**
 * @defgroup iface_treeland_wine_window_control_v1 The treeland_wine_window_control_v1 interface
 *
 * Controls the screen geometry and stacking order for one
 * xdg_toplevel surface.
 *
 * All coordinate values are in the compositor's global logical
 * coordinate space (the same space used by wl_output.geometry and
 * xdg_output.logical_position).
 *
 * Position requests are not applied immediately.  The
 * compositor processes them and reports the result via
 * configure_position.  The client should treat the values in
 * configure_position as authoritative and update its internal
 * state accordingly.
 *
 * If the associated xdg_toplevel is destroyed, this object becomes
 * inert.  All subsequent requests are ignored and no further events
 * are emitted.  The client should destroy the inert object.
 *
 * Window size is managed through the standard xdg_toplevel
 * configure / xdg_surface.ack_configure mechanism.  This interface
 * only controls screen position and stacking order.
 */
extern const struct wl_interface treeland_wine_window_control_v1_interface;
#endif

#ifndef TREELAND_WINE_WINDOW_MANAGER_V1_ERROR_ENUM
#define TREELAND_WINE_WINDOW_MANAGER_V1_ERROR_ENUM
enum treeland_wine_window_manager_v1_error {
	/**
	 * a control object already exists for the given toplevel
	 */
	TREELAND_WINE_WINDOW_MANAGER_V1_ERROR_TOPLEVEL_ALREADY_CONTROLLED = 0,
	/**
	 * the xdg_toplevel has no associated role or has been destroyed
	 */
	TREELAND_WINE_WINDOW_MANAGER_V1_ERROR_DEFUNCT_TOPLEVEL = 1,
};
#endif /* TREELAND_WINE_WINDOW_MANAGER_V1_ERROR_ENUM */

#ifndef TREELAND_WINE_WINDOW_MANAGER_V1_ERROR_ENUM_IS_VALID
#define TREELAND_WINE_WINDOW_MANAGER_V1_ERROR_ENUM_IS_VALID
/**
 * @ingroup iface_treeland_wine_window_manager_v1
 * Validate a treeland_wine_window_manager_v1 error value.
 *
 * @return true on success, false on error.
 * @ref treeland_wine_window_manager_v1_error
 */
static inline bool
treeland_wine_window_manager_v1_error_is_valid(uint32_t value, uint32_t version) {
	switch (value) {
	case TREELAND_WINE_WINDOW_MANAGER_V1_ERROR_TOPLEVEL_ALREADY_CONTROLLED:
		return version >= 1;
	case TREELAND_WINE_WINDOW_MANAGER_V1_ERROR_DEFUNCT_TOPLEVEL:
		return version >= 1;
	default:
		return false;
	}
}
#endif /* TREELAND_WINE_WINDOW_MANAGER_V1_ERROR_ENUM_IS_VALID */

/**
 * @ingroup iface_treeland_wine_window_manager_v1
 * @struct treeland_wine_window_manager_v1_interface
 */
struct treeland_wine_window_manager_v1_interface {
	/**
	 * destroy the manager
	 *
	 * Destroys this manager object. The client must destroy every
	 * treeland_wine_window_control_v1 created through this manager
	 * before sending this request; otherwise the compositor must raise
	 * an implementation-defined protocol error.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
	/**
	 * create a control object for an xdg_toplevel
	 *
	 * Creates a treeland_wine_window_control_v1 bound to the given
	 * xdg_toplevel. At most one control object may exist for each
	 * toplevel; requesting a second one is a
	 * toplevel_already_controlled error. If the xdg_toplevel has been
	 * destroyed or has no configured role the compositor must raise a
	 * defunct_toplevel error.
	 */
	void (*get_window_control)(struct wl_client *client,
				   struct wl_resource *resource,
				   uint32_t id,
				   struct wl_resource *toplevel);
};


/**
 * @ingroup iface_treeland_wine_window_manager_v1
 */
#define TREELAND_WINE_WINDOW_MANAGER_V1_DESTROY_SINCE_VERSION 1
/**
 * @ingroup iface_treeland_wine_window_manager_v1
 */
#define TREELAND_WINE_WINDOW_MANAGER_V1_GET_WINDOW_CONTROL_SINCE_VERSION 1

#ifndef TREELAND_WINE_WINDOW_CONTROL_V1_ERROR_ENUM
#define TREELAND_WINE_WINDOW_CONTROL_V1_ERROR_ENUM
enum treeland_wine_window_control_v1_error {
	/**
	 * sibling_id is non-zero for an op that does not accept a sibling
	 */
	TREELAND_WINE_WINDOW_CONTROL_V1_ERROR_INVALID_SIBLING = 0,
};
#endif /* TREELAND_WINE_WINDOW_CONTROL_V1_ERROR_ENUM */

#ifndef TREELAND_WINE_WINDOW_CONTROL_V1_ERROR_ENUM_IS_VALID
#define TREELAND_WINE_WINDOW_CONTROL_V1_ERROR_ENUM_IS_VALID
/**
 * @ingroup iface_treeland_wine_window_control_v1
 * Validate a treeland_wine_window_control_v1 error value.
 *
 * @return true on success, false on error.
 * @ref treeland_wine_window_control_v1_error
 */
static inline bool
treeland_wine_window_control_v1_error_is_valid(uint32_t value, uint32_t version) {
	switch (value) {
	case TREELAND_WINE_WINDOW_CONTROL_V1_ERROR_INVALID_SIBLING:
		return version >= 1;
	default:
		return false;
	}
}
#endif /* TREELAND_WINE_WINDOW_CONTROL_V1_ERROR_ENUM_IS_VALID */

#ifndef TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_ENUM
#define TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_ENUM
/**
 * @ingroup iface_treeland_wine_window_control_v1
 * Z-order operation matching Windows SetWindowPos hWndInsertAfter
 *
 * Encodes the Windows SetWindowPos hWndInsertAfter parameter
 * directly.  The first four values correspond to the four
 * special HWND constants.  hwnd_insert_after requires a
 * non-zero sibling_id in set_z_order.
 *
 * hwnd_topmost and hwnd_notopmost change WS_EX_TOPMOST tier
 * membership; the compositor must preserve the resulting tier
 * until explicitly changed.  hwnd_bottom also clears topmost.
 * hwnd_top does not alter tier membership.
 *
 * This is a superset of what the Wine X11 driver implements:
 * the X11 driver tracks only the topmost flag and a boolean
 * "raise to top", skipping HWND_BOTTOM and sibling-relative
 * ordering (see sync_window_position comment in winex11.drv).
 * This protocol implements all five Windows cases.
 */
enum treeland_wine_window_control_v1_z_order_op {
	/**
	 * raise to top of current tier; no tier change (HWND_TOP)
	 */
	TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_HWND_TOP = 0,
	/**
	 * lower to absolute bottom of Z-order; clears topmost (HWND_BOTTOM)
	 */
	TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_HWND_BOTTOM = 1,
	/**
	 * enter topmost tier at its top; sets WS_EX_TOPMOST (HWND_TOPMOST)
	 */
	TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_HWND_TOPMOST = 2,
	/**
	 * leave topmost tier; raise to top of normal tier (HWND_NOTOPMOST)
	 */
	TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_HWND_NOTOPMOST = 3,
	/**
	 * place directly below the sibling identified by sibling_id
	 */
	TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_HWND_INSERT_AFTER = 4,
};
#endif /* TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_ENUM */

#ifndef TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_ENUM_IS_VALID
#define TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_ENUM_IS_VALID
/**
 * @ingroup iface_treeland_wine_window_control_v1
 * Validate a treeland_wine_window_control_v1 z_order_op value.
 *
 * @return true on success, false on error.
 * @ref treeland_wine_window_control_v1_z_order_op
 */
static inline bool
treeland_wine_window_control_v1_z_order_op_is_valid(uint32_t value, uint32_t version) {
	switch (value) {
	case TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_HWND_TOP:
		return version >= 1;
	case TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_HWND_BOTTOM:
		return version >= 1;
	case TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_HWND_TOPMOST:
		return version >= 1;
	case TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_HWND_NOTOPMOST:
		return version >= 1;
	case TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_HWND_INSERT_AFTER:
		return version >= 1;
	default:
		return false;
	}
}
#endif /* TREELAND_WINE_WINDOW_CONTROL_V1_Z_ORDER_OP_ENUM_IS_VALID */

/**
 * @ingroup iface_treeland_wine_window_control_v1
 * @struct treeland_wine_window_control_v1_interface
 */
struct treeland_wine_window_control_v1_interface {
	/**
	 * destroy this control object
	 *
	 * Destroys the control object. This does not affect the
	 * associated xdg_toplevel or its current position on screen.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
	/**
	 * request a new absolute screen position
	 *
	 * Requests that the compositor place this window at the
	 * specified position in the compositor's global logical coordinate
	 * space.
	 *
	 * The client must supply a non-zero serial that monotonically
	 * increases with each request, starting from 1. The compositor
	 * echoes this serial in the resulting configure_position event so
	 * the client can correlate responses to requests.
	 *
	 * The requested position must fall within the bounds of an active
	 * screen. If the compositor determines that (x, y) is outside all
	 * screen regions, it rejects the request and emits a
	 * configure_position event reporting the current unchanged
	 * position.
	 *
	 * Even for valid positions the compositor does not guarantee exact
	 * placement: it may adjust the position to respect window
	 * management rules or layer-shell exclusive zones. The client must
	 * treat the values in the resulting configure_position event as
	 * authoritative and update its internal state accordingly.
	 *
	 * Window size changes must use the standard xdg_toplevel configure
	 * / xdg_surface.ack_configure flow and are outside the scope of
	 * this protocol.
	 *
	 * Corresponds to the position component of the Windows
	 * SetWindowPos and MoveWindow APIs.
	 * @param x desired x in global logical coordinates
	 * @param y desired y in global logical coordinates
	 * @param serial client-generated serial, starting from 1, incremented per request
	 */
	void (*set_position)(struct wl_client *client,
			     struct wl_resource *resource,
			     int32_t x,
			     int32_t y,
			     uint32_t serial);
	/**
	 * request a Z-order change using Windows SetWindowPos semantics
	 *
	 * Requests a Z-order change that directly encodes the Windows
	 * SetWindowPos hWndInsertAfter parameter.
	 *
	 * For ops hwnd_top, hwnd_bottom, hwnd_topmost, and hwnd_notopmost,
	 * sibling_id must be 0; a non-zero value is an invalid_sibling
	 * error.
	 *
	 * For op hwnd_insert_after, sibling_id must be the window_id of a
	 * control object in the same Wine session as emitted by the
	 * window_id event on that control. The compositor places this
	 * surface directly below the identified sibling in Z-order. If
	 * sibling_id is 0 or does not identify a live surface in the same
	 * session, the compositor must ignore the request and leave the
	 * current Z-order unchanged.
	 *
	 * hwnd_insert_after must not mix tiers: if the sibling is in a
	 * different tier from this surface, the compositor must clamp to
	 * hwnd_top within the appropriate tier.
	 *
	 * The compositor reports the resulting stacking state via
	 * configure_stacking.
	 *
	 * Note: hwnd_top and hwnd_insert_after do not change tier
	 * membership and therefore do not emit configure_stacking.
	 * @param op Z-order operation
	 * @param sibling_id window_id of the sibling for hwnd_insert_after; 0 for all other ops
	 */
	void (*set_z_order)(struct wl_client *client,
			    struct wl_resource *resource,
			    uint32_t op,
			    uint32_t sibling_id);
};

#define TREELAND_WINE_WINDOW_CONTROL_V1_WINDOW_ID 0
#define TREELAND_WINE_WINDOW_CONTROL_V1_CONFIGURE_POSITION 1
#define TREELAND_WINE_WINDOW_CONTROL_V1_CONFIGURE_STACKING 2

/**
 * @ingroup iface_treeland_wine_window_control_v1
 */
#define TREELAND_WINE_WINDOW_CONTROL_V1_WINDOW_ID_SINCE_VERSION 1
/**
 * @ingroup iface_treeland_wine_window_control_v1
 */
#define TREELAND_WINE_WINDOW_CONTROL_V1_CONFIGURE_POSITION_SINCE_VERSION 1
/**
 * @ingroup iface_treeland_wine_window_control_v1
 */
#define TREELAND_WINE_WINDOW_CONTROL_V1_CONFIGURE_STACKING_SINCE_VERSION 1

/**
 * @ingroup iface_treeland_wine_window_control_v1
 */
#define TREELAND_WINE_WINDOW_CONTROL_V1_DESTROY_SINCE_VERSION 1
/**
 * @ingroup iface_treeland_wine_window_control_v1
 */
#define TREELAND_WINE_WINDOW_CONTROL_V1_SET_POSITION_SINCE_VERSION 1
/**
 * @ingroup iface_treeland_wine_window_control_v1
 */
#define TREELAND_WINE_WINDOW_CONTROL_V1_SET_Z_ORDER_SINCE_VERSION 1

/**
 * @ingroup iface_treeland_wine_window_control_v1
 * Sends an window_id event to the client owning the resource.
 * @param resource_ The client's resource
 * @param id non-zero session-scoped window identifier
 */
static inline void
treeland_wine_window_control_v1_send_window_id(struct wl_resource *resource_, uint32_t id)
{
	wl_resource_post_event(resource_, TREELAND_WINE_WINDOW_CONTROL_V1_WINDOW_ID, id);
}

/**
 * @ingroup iface_treeland_wine_window_control_v1
 * Sends an configure_position event to the client owning the resource.
 * @param resource_ The client's resource
 * @param x actual x in global logical coordinates
 * @param y actual y in global logical coordinates
 * @param serial echoes the set_position serial, or 0 if not in response to a client request
 */
static inline void
treeland_wine_window_control_v1_send_configure_position(struct wl_resource *resource_, int32_t x, int32_t y, uint32_t serial)
{
	wl_resource_post_event(resource_, TREELAND_WINE_WINDOW_CONTROL_V1_CONFIGURE_POSITION, x, y, serial);
}

/**
 * @ingroup iface_treeland_wine_window_control_v1
 * Sends an configure_stacking event to the client owning the resource.
 * @param resource_ The client's resource
 * @param topmost non-zero if the toplevel is in the topmost tier
 */
static inline void
treeland_wine_window_control_v1_send_configure_stacking(struct wl_resource *resource_, uint32_t topmost)
{
	wl_resource_post_event(resource_, TREELAND_WINE_WINDOW_CONTROL_V1_CONFIGURE_STACKING, topmost);
}

#ifdef  __cplusplus
}
#endif

#endif
