/* Generated by wayland-scanner 1.26.0 */

#ifndef XX_FRACTIONAL_SCALE_V2_SERVER_PROTOCOL_H
#define XX_FRACTIONAL_SCALE_V2_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_xx_fractional_scale_v2 The xx_fractional_scale_v2 protocol
 * Protocol for fractional scaling
 *
 * @section page_desc_xx_fractional_scale_v2 Description
 *
 * This protocol allows compositors and clients to communicate the
 * coordinate space their surfaces act in.
 *
 * @section page_ifaces_xx_fractional_scale_v2 Interfaces
 * - @subpage page_iface_xx_fractional_scale_manager_v2 - creates surface scale interfaces
 * - @subpage page_iface_xx_fractional_scale_v2 - interface for fractional scaling
 * @section page_copyright_xx_fractional_scale_v2 Copyright
 * <pre>
 *
 * Copyright © 2022 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 xx_fractional_scale_manager_v2;
struct xx_fractional_scale_v2;

#ifndef XX_FRACTIONAL_SCALE_MANAGER_V2_INTERFACE
#define XX_FRACTIONAL_SCALE_MANAGER_V2_INTERFACE
/**
 * @page page_iface_xx_fractional_scale_manager_v2 xx_fractional_scale_manager_v2
 * @section page_iface_xx_fractional_scale_manager_v2_desc Description
 *
 * A global interface to create xx_fractional_scale_v2 interfaces.
 * @section page_iface_xx_fractional_scale_manager_v2_api API
 * See @ref iface_xx_fractional_scale_manager_v2.
 */
/**
 * @defgroup iface_xx_fractional_scale_manager_v2 The xx_fractional_scale_manager_v2 interface
 *
 * A global interface to create xx_fractional_scale_v2 interfaces.
 */
extern const struct wl_interface xx_fractional_scale_manager_v2_interface;
#endif
#ifndef XX_FRACTIONAL_SCALE_V2_INTERFACE
#define XX_FRACTIONAL_SCALE_V2_INTERFACE
/**
 * @page page_iface_xx_fractional_scale_v2 xx_fractional_scale_v2
 * @section page_iface_xx_fractional_scale_v2_desc Description
 *
 * An additional interface for a wl_surface object that allows compositor and
 * client to communicate in a different coordinate space, in order to enable
 * them to accurately describe coordinates and sizes in pixels.
 * The two coordinate spaces in consideration are logical and pixels, where
 * logical coordinates describe the size content should have and pixels
 * describe the size of buffers.
 *
 * A scale of one equals a lack of scaling, where the communicated values
 * define both logical coordinates and pixels.
 * A scale greater than one describes that for every logical coordinate,
 * more than one pixel is used, and a scale less than one describes that
 * multiple logical coordinates make up one pixel.
 * In mathematical terms, logical coordinates can be obtained by dividing
 * the provided values by the currently active scale.
 *
 * The initial compositor and client coordinate scale factors are 1.
 * @section page_iface_xx_fractional_scale_v2_api API
 * See @ref iface_xx_fractional_scale_v2.
 */
/**
 * @defgroup iface_xx_fractional_scale_v2 The xx_fractional_scale_v2 interface
 *
 * An additional interface for a wl_surface object that allows compositor and
 * client to communicate in a different coordinate space, in order to enable
 * them to accurately describe coordinates and sizes in pixels.
 * The two coordinate spaces in consideration are logical and pixels, where
 * logical coordinates describe the size content should have and pixels
 * describe the size of buffers.
 *
 * A scale of one equals a lack of scaling, where the communicated values
 * define both logical coordinates and pixels.
 * A scale greater than one describes that for every logical coordinate,
 * more than one pixel is used, and a scale less than one describes that
 * multiple logical coordinates make up one pixel.
 * In mathematical terms, logical coordinates can be obtained by dividing
 * the provided values by the currently active scale.
 *
 * The initial compositor and client coordinate scale factors are 1.
 */
extern const struct wl_interface xx_fractional_scale_v2_interface;
#endif

#ifndef XX_FRACTIONAL_SCALE_MANAGER_V2_ERROR_ENUM
#define XX_FRACTIONAL_SCALE_MANAGER_V2_ERROR_ENUM
enum xx_fractional_scale_manager_v2_error {
	/**
	 * xx_fractional_scale_v2 for the surface already exists
	 */
	XX_FRACTIONAL_SCALE_MANAGER_V2_ERROR_FRACTIONAL_SCALE_EXISTS = 0,
};
#endif /* XX_FRACTIONAL_SCALE_MANAGER_V2_ERROR_ENUM */

#ifndef XX_FRACTIONAL_SCALE_MANAGER_V2_ERROR_ENUM_IS_VALID
#define XX_FRACTIONAL_SCALE_MANAGER_V2_ERROR_ENUM_IS_VALID
/**
 * @ingroup iface_xx_fractional_scale_manager_v2
 * Validate a xx_fractional_scale_manager_v2 error value.
 *
 * @return true on success, false on error.
 * @ref xx_fractional_scale_manager_v2_error
 */
static inline bool
xx_fractional_scale_manager_v2_error_is_valid(uint32_t value, uint32_t version) {
	switch (value) {
	case XX_FRACTIONAL_SCALE_MANAGER_V2_ERROR_FRACTIONAL_SCALE_EXISTS:
		return version >= 1;
	default:
		return false;
	}
}
#endif /* XX_FRACTIONAL_SCALE_MANAGER_V2_ERROR_ENUM_IS_VALID */

/**
 * @ingroup iface_xx_fractional_scale_manager_v2
 * @struct xx_fractional_scale_manager_v2_interface
 */
struct xx_fractional_scale_manager_v2_interface {
	/**
	 * release the global
	 *
	 * Informs the server that the client will not be using this
	 * protocol object anymore. This does not affect any other objects.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
	/**
	 * create an interface to enable fractional scaling
	 *
	 * Create an interface object for a wl_surface to communicate
	 * scale. If the given wl_surface already has a
	 * xx_fractional_scale_v2 object associated, the
	 * fractional_scale_exists protocol error is raised.
	 * @param id the new scale interface
	 * @param surface the surface
	 */
	void (*get_fractional_scale)(struct wl_client *client,
				     struct wl_resource *resource,
				     uint32_t id,
				     struct wl_resource *surface);
};


/**
 * @ingroup iface_xx_fractional_scale_manager_v2
 */
#define XX_FRACTIONAL_SCALE_MANAGER_V2_DESTROY_SINCE_VERSION 1
/**
 * @ingroup iface_xx_fractional_scale_manager_v2
 */
#define XX_FRACTIONAL_SCALE_MANAGER_V2_GET_FRACTIONAL_SCALE_SINCE_VERSION 1

#ifndef XX_FRACTIONAL_SCALE_V2_ERROR_ENUM
#define XX_FRACTIONAL_SCALE_V2_ERROR_ENUM
enum xx_fractional_scale_v2_error {
	/**
	 * scale value is not valid
	 */
	XX_FRACTIONAL_SCALE_V2_ERROR_INVALID_SCALE = 0,
};
#endif /* XX_FRACTIONAL_SCALE_V2_ERROR_ENUM */

#ifndef XX_FRACTIONAL_SCALE_V2_ERROR_ENUM_IS_VALID
#define XX_FRACTIONAL_SCALE_V2_ERROR_ENUM_IS_VALID
/**
 * @ingroup iface_xx_fractional_scale_v2
 * Validate a xx_fractional_scale_v2 error value.
 *
 * @return true on success, false on error.
 * @ref xx_fractional_scale_v2_error
 */
static inline bool
xx_fractional_scale_v2_error_is_valid(uint32_t value, uint32_t version) {
	switch (value) {
	case XX_FRACTIONAL_SCALE_V2_ERROR_INVALID_SCALE:
		return version >= 1;
	default:
		return false;
	}
}
#endif /* XX_FRACTIONAL_SCALE_V2_ERROR_ENUM_IS_VALID */

/**
 * @ingroup iface_xx_fractional_scale_v2
 * @struct xx_fractional_scale_v2_interface
 */
struct xx_fractional_scale_v2_interface {
	/**
	 * set the client coordinate space scale factor
	 *
	 * This request sets a scale factor for the associated wl_surface
	 * that describes the coordinate system the client uses for
	 * requests following xx_fractional_scale_v2.set_scale_factor.
	 *
	 * The scale factor is encoded in a 8.24 fixed point format.
	 *
	 * If this scale factor does not match the scale factor provided by
	 * the compositor with xx_fractional_scale_v2.scale_factor, the
	 * compositor may apply transformations to the wl_surface that can
	 * result in blurriness or other artifacts.
	 *
	 * If scale_8_24 is zero, the error invalid_scale will be raised.
	 * @param scale_8_24 surface scale factor
	 */
	void (*set_scale_factor)(struct wl_client *client,
				 struct wl_resource *resource,
				 uint32_t scale_8_24);
	/**
	 * remove the scale interface from the surface
	 *
	 * The wl_surface's xx_fractional_scale_v2 object is destroyed,
	 * and the associated scale is reset to 1.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
};

#define XX_FRACTIONAL_SCALE_V2_SCALE_FACTOR 0

/**
 * @ingroup iface_xx_fractional_scale_v2
 */
#define XX_FRACTIONAL_SCALE_V2_SCALE_FACTOR_SINCE_VERSION 1

/**
 * @ingroup iface_xx_fractional_scale_v2
 */
#define XX_FRACTIONAL_SCALE_V2_SET_SCALE_FACTOR_SINCE_VERSION 1
/**
 * @ingroup iface_xx_fractional_scale_v2
 */
#define XX_FRACTIONAL_SCALE_V2_DESTROY_SINCE_VERSION 1

/**
 * @ingroup iface_xx_fractional_scale_v2
 * Sends an scale_factor event to the client owning the resource.
 * @param resource_ The client's resource
 * @param scale_8_24 surface scale factor
 */
static inline void
xx_fractional_scale_v2_send_scale_factor(struct wl_resource *resource_, uint32_t scale_8_24)
{
	wl_resource_post_event(resource_, XX_FRACTIONAL_SCALE_V2_SCALE_FACTOR, scale_8_24);
}

#ifdef  __cplusplus
}
#endif

#endif
