/* Generated by wayland-scanner 1.26.0 */

#ifndef PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_SERVER_PROTOCOL_H
#define PHOC_FOREIGN_TOPLEVEL_PIDFD_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_phoc_foreign_toplevel_pidfd_v1 The phoc_foreign_toplevel_pidfd_v1 protocol
 * Get process identifier
 *
 * @section page_desc_phoc_foreign_toplevel_pidfd_v1 Description
 *
 * The purpose of this protocol is to provide a way for Linux based
 * compositors to identify the process a toplevel belongs to.
 *
 * This protocol depends on the ext-foreign-toplevel-list protocol.
 *
 * The compositor may choose to restrict this protocol to a special client
 * launched by the compositor itself or expose it to all clients,
 * this is compositor policy.
 *
 * 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 IETF RFC 2119.
 *
 * Warning! The protocol described in this file is currently in the
 * experimental phase. Backwards incompatible major versions of the
 * protocol are to be expected. Exposing this protocol without an opt-in
 * mechanism is discouraged.
 *
 * @section page_ifaces_phoc_foreign_toplevel_pidfd_v1 Interfaces
 * - @subpage page_iface_phoc_foreign_toplevel_pidfd_manager_v1 - Get pidfd manager
 * - @subpage page_iface_phoc_foreign_toplevel_pidfd_v1 - Get process identifier
 * @section page_copyright_phoc_foreign_toplevel_pidfd_v1 Copyright
 * <pre>
 *
 * Copyright © 2026 Phosh.mobi e.V.
 *
 * 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 ext_foreign_toplevel_handle_v1;
struct phoc_foreign_toplevel_pidfd_manager_v1;
struct phoc_foreign_toplevel_pidfd_v1;

#ifndef PHOC_FOREIGN_TOPLEVEL_PIDFD_MANAGER_V1_INTERFACE
#define PHOC_FOREIGN_TOPLEVEL_PIDFD_MANAGER_V1_INTERFACE
/**
 * @page page_iface_phoc_foreign_toplevel_pidfd_manager_v1 phoc_foreign_toplevel_pidfd_manager_v1
 * @section page_iface_phoc_foreign_toplevel_pidfd_manager_v1_desc Description
 *
 * The global object used to initialize the extension interfaces to
 * get the pidfd of a toplevel.
 * @section page_iface_phoc_foreign_toplevel_pidfd_manager_v1_api API
 * See @ref iface_phoc_foreign_toplevel_pidfd_manager_v1.
 */
/**
 * @defgroup iface_phoc_foreign_toplevel_pidfd_manager_v1 The phoc_foreign_toplevel_pidfd_manager_v1 interface
 *
 * The global object used to initialize the extension interfaces to
 * get the pidfd of a toplevel.
 */
extern const struct wl_interface phoc_foreign_toplevel_pidfd_manager_v1_interface;
#endif
#ifndef PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_INTERFACE
#define PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_INTERFACE
/**
 * @page page_iface_phoc_foreign_toplevel_pidfd_v1 phoc_foreign_toplevel_pidfd_v1
 * @section page_iface_phoc_foreign_toplevel_pidfd_v1_desc Description
 *
 * This object receives the toplevels pidfd. It extends the
 * ext_foreign_toplevel_handle_v1 interface.
 *
 * If a compositor implementation sends the xx_foreign_toplevel_pidfd_v1.finished event,
 * the compositor must not send any more phoc_foreign_toplevel_pidfd_v1.pidfd events.
 *
 * A pidfd references the toplevel's process identifier (pid) via a file descriptor
 * see pidfd_open(1).
 * @section page_iface_phoc_foreign_toplevel_pidfd_v1_api API
 * See @ref iface_phoc_foreign_toplevel_pidfd_v1.
 */
/**
 * @defgroup iface_phoc_foreign_toplevel_pidfd_v1 The phoc_foreign_toplevel_pidfd_v1 interface
 *
 * This object receives the toplevels pidfd. It extends the
 * ext_foreign_toplevel_handle_v1 interface.
 *
 * If a compositor implementation sends the xx_foreign_toplevel_pidfd_v1.finished event,
 * the compositor must not send any more phoc_foreign_toplevel_pidfd_v1.pidfd events.
 *
 * A pidfd references the toplevel's process identifier (pid) via a file descriptor
 * see pidfd_open(1).
 */
extern const struct wl_interface phoc_foreign_toplevel_pidfd_v1_interface;
#endif

/**
 * @ingroup iface_phoc_foreign_toplevel_pidfd_manager_v1
 * @struct phoc_foreign_toplevel_pidfd_manager_v1_interface
 */
struct phoc_foreign_toplevel_pidfd_manager_v1_interface {
	/**
	 * destroy the phoc_foreign_toplevel_pidfd_manager_v1 object
	 *
	 * Using this request a client can tell the server that it is not
	 * going to use the phoc_foreign_toplevel_pidfd_manager_v1 object
	 * anymore.
	 *
	 * Any objects already created through this instance are not
	 * affected.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
	/**
	 * create the object to send the pidfd
	 *
	 * This request creates an extension object to receive the pidfd
	 * for the foreign toplevel.
	 *
	 * It is illegal to destroy the ext_foreign_toplevel_handle_v1
	 * before the phoc_foreign_toplevel_pidfd_v1 object is destroyed
	 * and must result in a orphaned error.
	 */
	void (*get_pidfd)(struct wl_client *client,
			  struct wl_resource *resource,
			  struct wl_resource *toplevel_handle,
			  uint32_t id);
};


/**
 * @ingroup iface_phoc_foreign_toplevel_pidfd_manager_v1
 */
#define PHOC_FOREIGN_TOPLEVEL_PIDFD_MANAGER_V1_DESTROY_SINCE_VERSION 1
/**
 * @ingroup iface_phoc_foreign_toplevel_pidfd_manager_v1
 */
#define PHOC_FOREIGN_TOPLEVEL_PIDFD_MANAGER_V1_GET_PIDFD_SINCE_VERSION 1

#ifndef PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_ERROR_ENUM
#define PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_ERROR_ENUM
/**
 * @ingroup iface_phoc_foreign_toplevel_pidfd_v1
 * ext_foreign_toplevel_state_v1 errors
 *
 * These errors are sent in response to phoc_foreign_toplevel_pidfd_v1 requests.
 */
enum phoc_foreign_toplevel_pidfd_v1_error {
	/**
	 * the ext_foreign_toplevel_handle_v1 object was destroyed before the xx_foreign_toplevel_pidfd_v1
	 */
	PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_ERROR_ORPHANED = 0,
};
#endif /* PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_ERROR_ENUM */

#ifndef PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_ERROR_ENUM_IS_VALID
#define PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_ERROR_ENUM_IS_VALID
/**
 * @ingroup iface_phoc_foreign_toplevel_pidfd_v1
 * Validate a phoc_foreign_toplevel_pidfd_v1 error value.
 *
 * @return true on success, false on error.
 * @ref phoc_foreign_toplevel_pidfd_v1_error
 */
static inline bool
phoc_foreign_toplevel_pidfd_v1_error_is_valid(uint32_t value, uint32_t version) {
	switch (value) {
	case PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_ERROR_ORPHANED:
		return version >= 1;
	default:
		return false;
	}
}
#endif /* PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_ERROR_ENUM_IS_VALID */

/**
 * @ingroup iface_phoc_foreign_toplevel_pidfd_v1
 * @struct phoc_foreign_toplevel_pidfd_v1_interface
 */
struct phoc_foreign_toplevel_pidfd_v1_interface {
	/**
	 * destroy the phoc_foreign_toplevel_pidfd_v1 object
	 *
	 * Using this request a client can tell the server that it is not
	 * going to use the phoc_foreign_toplevel_pidfd_v1 object anymore.
	 */
	void (*destroy)(struct wl_client *client,
			struct wl_resource *resource);
};

#define PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_PIDFD 0
#define PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_FINISHED 1

/**
 * @ingroup iface_phoc_foreign_toplevel_pidfd_v1
 */
#define PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_PIDFD_SINCE_VERSION 1
/**
 * @ingroup iface_phoc_foreign_toplevel_pidfd_v1
 */
#define PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_FINISHED_SINCE_VERSION 1

/**
 * @ingroup iface_phoc_foreign_toplevel_pidfd_v1
 */
#define PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_DESTROY_SINCE_VERSION 1

/**
 * @ingroup iface_phoc_foreign_toplevel_pidfd_v1
 * Sends an pidfd event to the client owning the resource.
 * @param resource_ The client's resource
 * @param pidfd pid fd
 */
static inline void
phoc_foreign_toplevel_pidfd_v1_send_pidfd(struct wl_resource *resource_, int32_t pidfd)
{
	wl_resource_post_event(resource_, PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_PIDFD, pidfd);
}

/**
 * @ingroup iface_phoc_foreign_toplevel_pidfd_v1
 * Sends an finished event to the client owning the resource.
 * @param resource_ The client's resource
 */
static inline void
phoc_foreign_toplevel_pidfd_v1_send_finished(struct wl_resource *resource_)
{
	wl_resource_post_event(resource_, PHOC_FOREIGN_TOPLEVEL_PIDFD_V1_FINISHED);
}

#ifdef  __cplusplus
}
#endif

#endif
