/* Generated by wayland-scanner 1.25.0 */

#ifndef GAMESCOPE_INPUT_METHOD_SERVER_PROTOCOL_H
#define GAMESCOPE_INPUT_METHOD_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_gamescope_input_method The gamescope_input_method protocol
 * Protocol for creating input methods
 *
 * @section page_desc_gamescope_input_method Description
 *
 * This protocol allows applications to act as input methods for compositors.
 *
 * An input method context is used to manage the state of the input method.
 *
 * Text strings are UTF-8 encoded, their indices and lengths are in bytes.
 *
 * This iteration of the protocol is a subset of this work-in-progress proposal:
 * https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/112
 *
 * This is a private Gamescope protocol. Regular Wayland clients must not use
 * it.
 *
 * @section page_ifaces_gamescope_input_method Interfaces
 * - @subpage page_iface_gamescope_input_method_manager - input method manager
 * - @subpage page_iface_gamescope_input_method - input method
 * @section page_copyright_gamescope_input_method Copyright
 * <pre>
 *
 * Copyright © 2008-2011 Kristian Høgsberg
 * Copyright © 2010-2011 Intel Corporation
 * Copyright © 2012-2013 Collabora, Ltd.
 * Copyright © 2012, 2013 Intel Corporation
 * Copyright © 2015, 2016 Jan Arne Petersen
 * Copyright © 2017, 2018 Red Hat, Inc.
 * Copyright © 2018       Purism SPC
 * Copyright © 2021       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 gamescope_input_method;
struct gamescope_input_method_manager;
struct wl_seat;

#ifndef GAMESCOPE_INPUT_METHOD_MANAGER_INTERFACE
#define GAMESCOPE_INPUT_METHOD_MANAGER_INTERFACE
/**
 * @page page_iface_gamescope_input_method_manager gamescope_input_method_manager
 * @section page_iface_gamescope_input_method_manager_desc Description
 *
 * The input method manager allows the client to become the input method on
 * a chosen seat.
 *
 * No more than one input method must be associated with any seat at any
 * given time.
 * @section page_iface_gamescope_input_method_manager_api API
 * See @ref iface_gamescope_input_method_manager.
 */
/**
 * @defgroup iface_gamescope_input_method_manager The gamescope_input_method_manager interface
 *
 * The input method manager allows the client to become the input method on
 * a chosen seat.
 *
 * No more than one input method must be associated with any seat at any
 * given time.
 */
extern const struct wl_interface gamescope_input_method_manager_interface;
#endif
#ifndef GAMESCOPE_INPUT_METHOD_INTERFACE
#define GAMESCOPE_INPUT_METHOD_INTERFACE
/**
 * @page page_iface_gamescope_input_method gamescope_input_method
 * @section page_iface_gamescope_input_method_desc Description
 *
 * An input method object allows for clients to compose text.
 *
 * The objects connects the client to a text input in an application, and
 * lets the client to serve as an input method for a seat.
 *
 * There must be no more than one input method object per seat.
 * @section page_iface_gamescope_input_method_api API
 * See @ref iface_gamescope_input_method.
 */
/**
 * @defgroup iface_gamescope_input_method The gamescope_input_method interface
 *
 * An input method object allows for clients to compose text.
 *
 * The objects connects the client to a text input in an application, and
 * lets the client to serve as an input method for a seat.
 *
 * There must be no more than one input method object per seat.
 */
extern const struct wl_interface gamescope_input_method_interface;
#endif

/**
 * @ingroup iface_gamescope_input_method_manager
 * @struct gamescope_input_method_manager_interface
 */
struct gamescope_input_method_manager_interface {
	/**
	 * destroy the input method manager
	 *
	 * Destroys the gamescope_input_method_manager object.
	 *
	 * The gamescope_input_method objects originating from it remain
	 * valid.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
	/**
	 * create an input method object
	 *
	 * Create a new gamescope_input_method object associated with a
	 * given seat.
	 */
	void (*create_input_method)(struct wl_client *client,
				    struct wl_resource *resource,
				    struct wl_resource *seat,
				    uint32_t input_method);
};


/**
 * @ingroup iface_gamescope_input_method_manager
 */
#define GAMESCOPE_INPUT_METHOD_MANAGER_DESTROY_SINCE_VERSION 1
/**
 * @ingroup iface_gamescope_input_method_manager
 */
#define GAMESCOPE_INPUT_METHOD_MANAGER_CREATE_INPUT_METHOD_SINCE_VERSION 1

#ifndef GAMESCOPE_INPUT_METHOD_ACTION_ENUM
#define GAMESCOPE_INPUT_METHOD_ACTION_ENUM
/**
 * @ingroup iface_gamescope_input_method
 * action
 *
 * A possible action to perform on a text input.
 *
 * The backspace and delete actions should be handled in a similar manner
 * to backpace and delete keys being pressed on a keyboard.
 */
enum gamescope_input_method_action {
	/**
	 * no action
	 */
	GAMESCOPE_INPUT_METHOD_ACTION_NONE = 0,
	/**
	 * submit
	 */
	GAMESCOPE_INPUT_METHOD_ACTION_SUBMIT = 1,
	/**
	 * delete one unit before the cursor
	 */
	GAMESCOPE_INPUT_METHOD_ACTION_DELETE_LEFT = 2,
	/**
	 * delete one unit after the cursor
	 */
	GAMESCOPE_INPUT_METHOD_ACTION_DELETE_RIGHT = 3,
	/**
	 * move the cursor to the left by one unit
	 */
	GAMESCOPE_INPUT_METHOD_ACTION_MOVE_LEFT = 4,
	/**
	 * move the cursor to the right by one unit
	 */
	GAMESCOPE_INPUT_METHOD_ACTION_MOVE_RIGHT = 5,
	/**
	 * move the cursor up by one unit
	 * @since 2
	 */
	GAMESCOPE_INPUT_METHOD_ACTION_MOVE_UP = 6,
	/**
	 * move the cursor down by one unit
	 * @since 2
	 */
	GAMESCOPE_INPUT_METHOD_ACTION_MOVE_DOWN = 7,
};
/**
 * @ingroup iface_gamescope_input_method
 */
#define GAMESCOPE_INPUT_METHOD_ACTION_MOVE_UP_SINCE_VERSION 2
/**
 * @ingroup iface_gamescope_input_method
 */
#define GAMESCOPE_INPUT_METHOD_ACTION_MOVE_DOWN_SINCE_VERSION 2
#endif /* GAMESCOPE_INPUT_METHOD_ACTION_ENUM */

#ifndef GAMESCOPE_INPUT_METHOD_ACTION_ENUM_IS_VALID
#define GAMESCOPE_INPUT_METHOD_ACTION_ENUM_IS_VALID
/**
 * @ingroup iface_gamescope_input_method
 * Validate a gamescope_input_method action value.
 *
 * @return true on success, false on error.
 * @ref gamescope_input_method_action
 */
static inline bool
gamescope_input_method_action_is_valid(uint32_t value, uint32_t version) {
	switch (value) {
	case GAMESCOPE_INPUT_METHOD_ACTION_NONE:
		return version >= 1;
	case GAMESCOPE_INPUT_METHOD_ACTION_SUBMIT:
		return version >= 1;
	case GAMESCOPE_INPUT_METHOD_ACTION_DELETE_LEFT:
		return version >= 1;
	case GAMESCOPE_INPUT_METHOD_ACTION_DELETE_RIGHT:
		return version >= 1;
	case GAMESCOPE_INPUT_METHOD_ACTION_MOVE_LEFT:
		return version >= 1;
	case GAMESCOPE_INPUT_METHOD_ACTION_MOVE_RIGHT:
		return version >= 1;
	case GAMESCOPE_INPUT_METHOD_ACTION_MOVE_UP:
		return version >= 2;
	case GAMESCOPE_INPUT_METHOD_ACTION_MOVE_DOWN:
		return version >= 2;
	default:
		return false;
	}
}
#endif /* GAMESCOPE_INPUT_METHOD_ACTION_ENUM_IS_VALID */

#ifndef GAMESCOPE_INPUT_METHOD_BUTTON_STATE_ENUM
#define GAMESCOPE_INPUT_METHOD_BUTTON_STATE_ENUM
/**
 * @ingroup iface_gamescope_input_method
 * physical button state
 *
 * Describes the physical state of a button that produced the button
 * event.
 */
enum gamescope_input_method_button_state {
	/**
	 * the button is not pressed
	 */
	GAMESCOPE_INPUT_METHOD_BUTTON_STATE_RELEASED = 0,
	/**
	 * the button is pressed
	 */
	GAMESCOPE_INPUT_METHOD_BUTTON_STATE_PRESSED = 1,
};
#endif /* GAMESCOPE_INPUT_METHOD_BUTTON_STATE_ENUM */

#ifndef GAMESCOPE_INPUT_METHOD_BUTTON_STATE_ENUM_IS_VALID
#define GAMESCOPE_INPUT_METHOD_BUTTON_STATE_ENUM_IS_VALID
/**
 * @ingroup iface_gamescope_input_method
 * Validate a gamescope_input_method button_state value.
 *
 * @return true on success, false on error.
 * @ref gamescope_input_method_button_state
 */
static inline bool
gamescope_input_method_button_state_is_valid(uint32_t value, uint32_t version) {
	switch (value) {
	case GAMESCOPE_INPUT_METHOD_BUTTON_STATE_RELEASED:
		return version >= 1;
	case GAMESCOPE_INPUT_METHOD_BUTTON_STATE_PRESSED:
		return version >= 1;
	default:
		return false;
	}
}
#endif /* GAMESCOPE_INPUT_METHOD_BUTTON_STATE_ENUM_IS_VALID */

/**
 * @ingroup iface_gamescope_input_method
 * @struct gamescope_input_method_interface
 */
struct gamescope_input_method_interface {
	/**
	 * destroy the text input
	 *
	 * Destroys the gamescope_text_input object.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
	/**
	 * apply state
	 *
	 * Apply state changes from set_string and set_action requests.
	 *
	 * The state relating to these events is double-buffered, and each
	 * one modifies the pending state. This request replaces the
	 * current state with the pending state.
	 *
	 * The client must set the serial to the last received serial in
	 * the done event.
	 * @param serial last received serial
	 */
	void (*commit)(struct wl_client *client,
		       struct wl_resource *resource,
		       uint32_t serial);
	/**
	 * set string to be committed
	 *
	 * Send the string text for insertion to the application.
	 *
	 * Inserts a string at current cursor position (see commit event
	 * sequence). The string to commit could be either just a single
	 * character after a key press or the result of some composing.
	 *
	 * Values set with this event are double-buffered. They must be
	 * applied and reset to initial on the next
	 * gamescope_text_input.commit request.
	 *
	 * The initial value of text is an empty string.
	 * @param text text to insert
	 */
	void (*set_string)(struct wl_client *client,
			   struct wl_resource *resource,
			   const char *text);
	/**
	 * perform an action
	 *
	 * Set the action to be performed on commit.
	 *
	 * Values set with this event are double-buffered. They must be
	 * applied and reset to initial on the next
	 * gamescope_text_input.commit request.
	 * @param action action performed
	 */
	void (*set_action)(struct wl_client *client,
			   struct wl_resource *resource,
			   uint32_t action);
	/**
	 * move the cursor!
	 *
	 * 
	 * @param dx delta x
	 * @param dy delta y
	 * @since 3
	 */
	void (*pointer_motion)(struct wl_client *client,
			       struct wl_resource *resource,
			       wl_fixed_t dx,
			       wl_fixed_t dy);
	/**
	 * warp the cursor!
	 *
	 * 
	 * @param x x pos
	 * @param y y pos
	 * @since 3
	 */
	void (*pointer_warp)(struct wl_client *client,
			     struct wl_resource *resource,
			     wl_fixed_t x,
			     wl_fixed_t y);
	/**
	 * scroll the cursor! Uses the 120 scaling mechanism.
	 *
	 * 
	 * @param x x * 120 -> 120 = 1.0
	 * @param y y * 120 -> 120 = 1.0
	 * @since 3
	 */
	void (*pointer_wheel)(struct wl_client *client,
			      struct wl_resource *resource,
			      int32_t x,
			      int32_t y);
	/**
	 * click the cursor!
	 *
	 * 
	 * @param button Linux button code, eg. BTN_LEFT
	 * @param state wl_pointer_button_state
	 * @since 3
	 */
	void (*pointer_button)(struct wl_client *client,
			       struct wl_resource *resource,
			       uint32_t button,
			       uint32_t state);
};

#define GAMESCOPE_INPUT_METHOD_UNAVAILABLE 0
#define GAMESCOPE_INPUT_METHOD_DONE 1

/**
 * @ingroup iface_gamescope_input_method
 */
#define GAMESCOPE_INPUT_METHOD_UNAVAILABLE_SINCE_VERSION 1
/**
 * @ingroup iface_gamescope_input_method
 */
#define GAMESCOPE_INPUT_METHOD_DONE_SINCE_VERSION 1

/**
 * @ingroup iface_gamescope_input_method
 */
#define GAMESCOPE_INPUT_METHOD_DESTROY_SINCE_VERSION 1
/**
 * @ingroup iface_gamescope_input_method
 */
#define GAMESCOPE_INPUT_METHOD_COMMIT_SINCE_VERSION 1
/**
 * @ingroup iface_gamescope_input_method
 */
#define GAMESCOPE_INPUT_METHOD_SET_STRING_SINCE_VERSION 1
/**
 * @ingroup iface_gamescope_input_method
 */
#define GAMESCOPE_INPUT_METHOD_SET_ACTION_SINCE_VERSION 1
/**
 * @ingroup iface_gamescope_input_method
 */
#define GAMESCOPE_INPUT_METHOD_POINTER_MOTION_SINCE_VERSION 3
/**
 * @ingroup iface_gamescope_input_method
 */
#define GAMESCOPE_INPUT_METHOD_POINTER_WARP_SINCE_VERSION 3
/**
 * @ingroup iface_gamescope_input_method
 */
#define GAMESCOPE_INPUT_METHOD_POINTER_WHEEL_SINCE_VERSION 3
/**
 * @ingroup iface_gamescope_input_method
 */
#define GAMESCOPE_INPUT_METHOD_POINTER_BUTTON_SINCE_VERSION 3

/**
 * @ingroup iface_gamescope_input_method
 * Sends an unavailable event to the client owning the resource.
 * @param resource_ The client's resource
 */
static inline void
gamescope_input_method_send_unavailable(struct wl_resource *resource_)
{
	wl_resource_post_event(resource_, GAMESCOPE_INPUT_METHOD_UNAVAILABLE);
}

/**
 * @ingroup iface_gamescope_input_method
 * Sends an done event to the client owning the resource.
 * @param resource_ The client's resource
 */
static inline void
gamescope_input_method_send_done(struct wl_resource *resource_, uint32_t serial)
{
	wl_resource_post_event(resource_, GAMESCOPE_INPUT_METHOD_DONE, serial);
}

#ifdef  __cplusplus
}
#endif

#endif
