Blame uwac/libuwac/uwac-priv.h

Packit Service fa4841
/*
Packit Service fa4841
 * Copyright © 2014 David FORT <contact@hardening-consulting.com>
Packit Service fa4841
 *
Packit Service fa4841
 * Permission to use, copy, modify, distribute, and sell this software and its
Packit Service fa4841
 * documentation for any purpose is hereby granted without fee, provided that
Packit Service fa4841
 * the above copyright notice appear in all copies and that both that copyright
Packit Service fa4841
 * notice and this permission notice appear in supporting documentation, and
Packit Service fa4841
 * that the name of the copyright holders not be used in advertising or
Packit Service fa4841
 * publicity pertaining to distribution of the software without specific,
Packit Service fa4841
 * written prior permission.  The copyright holders make no representations
Packit Service fa4841
 * about the suitability of this software for any purpose.  It is provided "as
Packit Service fa4841
 * is" without express or implied warranty.
Packit Service fa4841
 *
Packit Service fa4841
 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
Packit Service fa4841
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
Packit Service fa4841
 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
Packit Service fa4841
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
Packit Service fa4841
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
Packit Service fa4841
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
Packit Service fa4841
 * OF THIS SOFTWARE.
Packit Service fa4841
 */
Packit Service fa4841
Packit Service fa4841
#ifndef UWAC_PRIV_H_
Packit Service fa4841
#define UWAC_PRIV_H_
Packit Service fa4841
Packit Service fa4841
#include "config.h"
Packit Service fa4841
Packit Service fa4841
#include <stdbool.h>
Packit Service fa4841
#include <wayland-client.h>
Packit Service fa4841
#include "xdg-shell-client-protocol.h"
Packit Service b1ea74
#include "keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h"
Packit Service b1ea74
#include "xdg-decoration-unstable-v1-client-protocol.h"
Packit Service b1ea74
#include "server-decoration-client-protocol.h"
Packit Service b1ea74
Packit Service fa4841
#ifdef BUILD_IVI
Packit Service fa4841
#include "ivi-application-client-protocol.h"
Packit Service fa4841
#endif
Packit Service fa4841
#ifdef BUILD_FULLSCREEN_SHELL
Packit Service b1ea74
#include "fullscreen-shell-unstable-v1-client-protocol.h"
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#ifdef HAVE_PIXMAN_REGION
Packit Service fa4841
#include <pixman-1/pixman.h>
Packit Service fa4841
#else
Packit Service fa4841
#include <freerdp/codec/region.h>
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service fa4841
#include <xkbcommon/xkbcommon.h>
Packit Service fa4841
Packit Service fa4841
#include <uwac/uwac.h>
Packit Service fa4841
Packit Service fa4841
extern UwacErrorHandler uwacErrorHandler;
Packit Service fa4841
Packit Service fa4841
typedef struct uwac_task UwacTask;
Packit Service fa4841
Packit Service fa4841
/** @brief */
Packit Service b1ea74
struct uwac_task
Packit Service b1ea74
{
Packit Service b1ea74
	void (*run)(UwacTask* task, uint32_t events);
Packit Service fa4841
	struct wl_list link;
Packit Service fa4841
};
Packit Service fa4841
Packit Service fa4841
/** @brief a global registry object */
Packit Service b1ea74
struct uwac_global
Packit Service b1ea74
{
Packit Service fa4841
	uint32_t name;
Packit Service b1ea74
	char* interface;
Packit Service fa4841
	uint32_t version;
Packit Service fa4841
	struct wl_list link;
Packit Service fa4841
};
Packit Service fa4841
typedef struct uwac_global UwacGlobal;
Packit Service fa4841
Packit Service fa4841
struct uwac_event_list_item;
Packit Service fa4841
typedef struct uwac_event_list_item UwacEventListItem;
Packit Service fa4841
Packit Service fa4841
/** @brief */
Packit Service b1ea74
struct uwac_event_list_item
Packit Service b1ea74
{
Packit Service fa4841
	UwacEvent event;
Packit Service fa4841
	UwacEventListItem *tail, *head;
Packit Service fa4841
};
Packit Service fa4841
Packit Service fa4841
/** @brief main connection object to a wayland display */
Packit Service b1ea74
struct uwac_display
Packit Service b1ea74
{
Packit Service fa4841
	struct wl_list globals;
Packit Service fa4841
Packit Service b1ea74
	struct wl_display* display;
Packit Service b1ea74
	struct wl_registry* registry;
Packit Service b1ea74
	struct wl_compositor* compositor;
Packit Service b1ea74
	struct wl_subcompositor* subcompositor;
Packit Service b1ea74
	struct wl_shell* shell;
Packit Service b1ea74
	struct xdg_toplevel* xdg_toplevel;
Packit Service b1ea74
	struct xdg_wm_base* xdg_base;
Packit Service b1ea74
	struct wl_data_device_manager* devicemanager;
Packit Service b1ea74
	struct zwp_keyboard_shortcuts_inhibit_manager_v1* keyboard_inhibit_manager;
Packit Service b1ea74
	struct zxdg_decoration_manager_v1* deco_manager;
Packit Service b1ea74
	struct org_kde_kwin_server_decoration_manager* kde_deco_manager;
Packit Service fa4841
#ifdef BUILD_IVI
Packit Service b1ea74
	struct ivi_application* ivi_application;
Packit Service fa4841
#endif
Packit Service fa4841
#ifdef BUILD_FULLSCREEN_SHELL
Packit Service b1ea74
	struct zwp_fullscreen_shell_v1* fullscreen_shell;
Packit Service fa4841
#endif
Packit Service fa4841
Packit Service b1ea74
	struct wl_shm* shm;
Packit Service b1ea74
	enum wl_shm_format* shm_formats;
Packit Service fa4841
	uint32_t shm_formats_nb;
Packit Service fa4841
	bool has_rgb565;
Packit Service fa4841
Packit Service b1ea74
	struct wl_data_device_manager* data_device_manager;
Packit Service b1ea74
	struct text_cursor_position* text_cursor_position;
Packit Service b1ea74
	struct workspace_manager* workspace_manager;
Packit Service fa4841
Packit Service fa4841
	struct wl_list seats;
Packit Service fa4841
Packit Service fa4841
	int display_fd;
Packit Service fa4841
	UwacReturnCode last_error;
Packit Service fa4841
	uint32_t display_fd_events;
Packit Service fa4841
	int epoll_fd;
Packit Service fa4841
	bool running;
Packit Service fa4841
	UwacTask dispatch_fd_task;
Packit Service fa4841
	uint32_t serial;
Packit Service fa4841
Packit Service fa4841
	struct wl_list windows;
Packit Service fa4841
Packit Service fa4841
	struct wl_list outputs;
Packit Service fa4841
Packit Service fa4841
	UwacEventListItem *push_queue, *pop_queue;
Packit Service fa4841
};
Packit Service fa4841
Packit Service fa4841
/** @brief an output on a wayland display */
Packit Service b1ea74
struct uwac_output
Packit Service b1ea74
{
Packit Service b1ea74
	UwacDisplay* display;
Packit Service fa4841
Packit Service fa4841
	bool doneNeeded;
Packit Service fa4841
	bool doneReceived;
Packit Service fa4841
Packit Service b1ea74
	UwacPosition position;
Packit Service fa4841
	UwacSize resolution;
Packit Service fa4841
	int transform;
Packit Service fa4841
	int scale;
Packit Service b1ea74
	char* make;
Packit Service b1ea74
	char* model;
Packit Service fa4841
	uint32_t server_output_id;
Packit Service b1ea74
	struct wl_output* output;
Packit Service fa4841
Packit Service fa4841
	struct wl_list link;
Packit Service fa4841
};
Packit Service fa4841
Packit Service fa4841
/** @brief a seat attached to a wayland display */
Packit Service b1ea74
struct uwac_seat
Packit Service b1ea74
{
Packit Service b1ea74
	UwacDisplay* display;
Packit Service b1ea74
	char* name;
Packit Service b1ea74
	struct wl_seat* seat;
Packit Service fa4841
	uint32_t seat_id;
Packit Service fa4841
	uint32_t seat_version;
Packit Service b1ea74
	struct wl_data_device* data_device;
Packit Service b1ea74
	struct wl_data_source* data_source;
Packit Service b1ea74
	struct wl_pointer* pointer;
Packit Service b1ea74
	struct wl_surface* pointer_surface;
Packit Service b1ea74
	struct wl_cursor_image* pointer_image;
Packit Service b1ea74
	struct wl_cursor_theme* cursor_theme;
Packit Service b1ea74
	struct wl_cursor* default_cursor;
Packit Service b1ea74
	void* pointer_data;
Packit Service b1ea74
	size_t pointer_size;
Packit Service b1ea74
	int pointer_type;
Packit Service b1ea74
	struct wl_keyboard* keyboard;
Packit Service b1ea74
	struct wl_touch* touch;
Packit Service b1ea74
	struct wl_data_offer* offer;
Packit Service b1ea74
	struct xkb_context* xkb_context;
Packit Service b1ea74
	struct zwp_keyboard_shortcuts_inhibitor_v1* keyboard_inhibitor;
Packit Service b1ea74
Packit Service b1ea74
	struct
Packit Service b1ea74
	{
Packit Service b1ea74
		struct xkb_keymap* keymap;
Packit Service b1ea74
		struct xkb_state* state;
Packit Service fa4841
		xkb_mod_mask_t control_mask;
Packit Service fa4841
		xkb_mod_mask_t alt_mask;
Packit Service fa4841
		xkb_mod_mask_t shift_mask;
Packit Service fa4841
	} xkb;
Packit Service fa4841
	uint32_t modifiers;
Packit Service fa4841
	int32_t repeat_rate_sec, repeat_rate_nsec;
Packit Service fa4841
	int32_t repeat_delay_sec, repeat_delay_nsec;
Packit Service fa4841
	uint32_t repeat_sym, repeat_key, repeat_time;
Packit Service fa4841
Packit Service fa4841
	struct wl_array pressed_keys;
Packit Service fa4841
Packit Service b1ea74
	UwacWindow* pointer_focus;
Packit Service fa4841
Packit Service b1ea74
	UwacWindow* keyboard_focus;
Packit Service fa4841
Packit Service b1ea74
	UwacWindow* touch_focus;
Packit Service fa4841
	bool touch_frame_started;
Packit Service fa4841
Packit Service fa4841
	int repeat_timer_fd;
Packit Service fa4841
	UwacTask repeat_task;
Packit Service fa4841
	float sx, sy;
Packit Service fa4841
	struct wl_list link;
Packit Service fa4841
Packit Service b1ea74
	void* data_context;
Packit Service b1ea74
	UwacDataTransferHandler transfer_data;
Packit Service b1ea74
	UwacCancelDataTransferHandler cancel_data;
Packit Service b1ea74
	bool ignore_announcement;
Packit Service b1ea74
};
Packit Service bb5c11
Packit Service fa4841
/** @brief a buffer used for drawing a surface frame */
Packit Service b1ea74
struct uwac_buffer
Packit Service b1ea74
{
Packit Service fa4841
	bool used;
Packit Service b1ea74
	bool dirty;
Packit Service fa4841
#ifdef HAVE_PIXMAN_REGION
Packit Service fa4841
	pixman_region32_t damage;
Packit Service fa4841
#else
Packit Service fa4841
	REGION16 damage;
Packit Service fa4841
#endif
Packit Service b1ea74
	struct wl_buffer* wayland_buffer;
Packit Service b1ea74
	void* data;
Packit Service b1ea74
	size_t size;
Packit Service fa4841
};
Packit Service fa4841
typedef struct uwac_buffer UwacBuffer;
Packit Service fa4841
Packit Service fa4841
/** @brief a window */
Packit Service b1ea74
struct uwac_window
Packit Service b1ea74
{
Packit Service b1ea74
	UwacDisplay* display;
Packit Service fa4841
	int width, height, stride;
Packit Service fa4841
	int surfaceStates;
Packit Service fa4841
	enum wl_shm_format format;
Packit Service fa4841
Packit Service fa4841
	int nbuffers;
Packit Service b1ea74
	UwacBuffer* buffers;
Packit Service b1ea74
Packit Service b1ea74
	struct wl_region* opaque_region;
Packit Service b1ea74
	struct wl_region* input_region;
Packit Service b1ea74
	SSIZE_T drawingBufferIdx;
Packit Service b1ea74
	SSIZE_T pendingBufferIdx;
Packit Service b1ea74
	struct wl_surface* surface;
Packit Service b1ea74
	struct wl_shell_surface* shell_surface;
Packit Service b1ea74
	struct xdg_surface* xdg_surface;
Packit Service b1ea74
	struct xdg_toplevel* xdg_toplevel;
Packit Service b1ea74
	struct zxdg_toplevel_decoration_v1* deco;
Packit Service b1ea74
	struct org_kde_kwin_server_decoration* kde_deco;
Packit Service fa4841
#ifdef BUILD_IVI
Packit Service b1ea74
	struct ivi_surface* ivi_surface;
Packit Service fa4841
#endif
Packit Service fa4841
	struct wl_list link;
Packit Service fa4841
Packit Service fa4841
	uint32_t pointer_enter_serial;
Packit Service fa4841
	uint32_t pointer_cursor_serial;
Packit Service fa4841
	int pointer_current_cursor;
Packit Service fa4841
};
Packit Service fa4841
Packit Service fa4841
/* in uwa-display.c */
Packit Service b1ea74
UwacEvent* UwacDisplayNewEvent(UwacDisplay* d, int type);
Packit Service b1ea74
int UwacDisplayWatchFd(UwacDisplay* display, int fd, uint32_t events, UwacTask* task);
Packit Service fa4841
Packit Service fa4841
/* in uwac-input.c */
Packit Service b1ea74
UwacSeat* UwacSeatNew(UwacDisplay* d, uint32_t id, uint32_t version);
Packit Service b1ea74
void UwacSeatDestroy(UwacSeat* s);
Packit Service fa4841
Packit Service fa4841
/* in uwac-output.c */
Packit Service b1ea74
UwacOutput* UwacCreateOutput(UwacDisplay* d, uint32_t id, uint32_t version);
Packit Service b1ea74
int UwacDestroyOutput(UwacOutput* output);
Packit Service b1ea74
Packit Service b1ea74
UwacReturnCode UwacSeatRegisterClipboard(UwacSeat* s);
Packit Service fa4841
Packit Service fa4841
#endif /* UWAC_PRIV_H_ */