master uint/maus / include / maus_wayland.h
  1#ifndef MAUS_WAYLAND_H
  2#define MAUS_WAYLAND_H
  3
  4#include <stddef.h>
  5#include <stdint.h>
  6
  7#define MAUS_EVQ_MAX 64
  8
  9/* must forward declare so that other
 10   ANSI abiding files arent affected */
 11struct wl_display;
 12struct wl_buffer;
 13struct wl_registry;
 14struct wl_compositor;
 15struct wl_surface;
 16struct wl_shm;
 17struct wl_seat;
 18struct wl_pointer;
 19struct wl_keyboard;
 20struct wl_cursor_theme;
 21struct wl_cursor;
 22
 23struct xdg_wm_base;
 24struct xdg_surface;
 25struct xdg_toplevel;
 26
 27struct zwp_pointer_constraints_v1;
 28struct zwp_confined_pointer_v1;
 29struct zwp_locked_pointer_v1;
 30struct zwp_relative_pointer_manager_v1;
 31struct zwp_relative_pointer_v1;
 32
 33struct xkb_context;
 34struct xkb_keymap;
 35struct xkb_state;
 36
 37typedef struct {
 38	int8_t  pending;
 39	int32_t type;
 40
 41	uint32_t width;
 42	uint32_t height;
 43
 44	int32_t  mouse_x;
 45	int32_t  mouse_y;
 46	int32_t  mouse_dx;
 47	int32_t  mouse_dy;
 48	uint32_t mouse_button;
 49	uint8_t  mouse_pressed;
 50
 51	uint32_t key_code;
 52	uint32_t key_sym;
 53	char     key_text;
 54	uint8_t  key_pressed;
 55} MausEventPending;
 56
 57typedef struct {
 58	struct wl_buffer* buffer;
 59	void*             data;
 60	size_t            size;
 61	int8_t            busy;
 62} MausWLBuffer;
 63
 64typedef struct {
 65	struct wl_display*    display;
 66	struct wl_compositor* compositor;
 67	struct wl_surface*    surface;
 68
 69	struct wl_shm* shm;
 70	MausWLBuffer   buffers[2];
 71
 72	struct wl_seat*     seat;
 73	struct wl_pointer*  pointer;
 74	struct wl_keyboard* keyboard;
 75
 76	struct wl_cursor_theme* cursor_theme;
 77	struct wl_cursor*       cursor;
 78	struct wl_surface*      cursor_surface;
 79	uint32_t                pointer_enter_serial;
 80	int32_t                 mouse_x;
 81	int32_t                 mouse_y;
 82	int8_t                  mouse_pos_set;
 83	int8_t                  cursor_visible;
 84	int8_t                  cursor_confined;
 85
 86	struct zwp_pointer_constraints_v1*      pointer_constraints;
 87	struct zwp_confined_pointer_v1*         confined_pointer;
 88	struct zwp_locked_pointer_v1*           locked_pointer;
 89	struct zwp_relative_pointer_manager_v1* relative_pointer_manager;
 90	struct zwp_relative_pointer_v1*         relative_pointer;
 91
 92	struct xkb_context* xkb_context;
 93	struct xkb_keymap*  xkb_keymap;
 94	struct xkb_state*   xkb_state;
 95
 96
 97	MausEventPending pending;
 98	MausEventPending evq[MAUS_EVQ_MAX];
 99	uint32_t evq_head;
100	uint32_t evq_tail;
101	uint32_t evq_count;
102
103	int32_t  repeat_rate;
104	int32_t  repeat_delay;
105	uint32_t repeat_key_code;
106	uint32_t repeat_key_sym;
107	char     repeat_key_text;
108	uint64_t repeat_next_ns;
109
110	struct xdg_wm_base*  wm_base;
111	struct xdg_surface*  xdg_surface;
112	struct xdg_toplevel* xdg_toplevel;
113	int8_t               configured;
114
115	struct wl_registry*          registry;
116} MausBackend;
117
118#endif /* MAUS_WAYLAND_H */
119