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_relative_pointer_manager_v1;
30struct zwp_relative_pointer_v1;
31
32struct xkb_context;
33struct xkb_keymap;
34struct xkb_state;
35
36typedef struct {
37 int8_t pending;
38 int32_t type;
39
40 uint32_t width;
41 uint32_t height;
42
43 int32_t mouse_x;
44 int32_t mouse_y;
45 int32_t mouse_dx;
46 int32_t mouse_dy;
47 uint32_t mouse_button;
48 uint8_t mouse_pressed;
49
50 uint32_t key_code;
51 uint32_t key_sym;
52 char key_text;
53 uint8_t key_pressed;
54} MausEventPending;
55
56typedef struct {
57 struct wl_buffer* buffer;
58 void* data;
59 size_t size;
60 int8_t busy;
61} MausWLBuffer;
62
63typedef struct {
64 struct wl_display* display;
65 struct wl_compositor* compositor;
66 struct wl_surface* surface;
67
68 struct wl_shm* shm;
69 MausWLBuffer buffers[2];
70
71 struct wl_seat* seat;
72 struct wl_pointer* pointer;
73 struct wl_keyboard* keyboard;
74
75 struct wl_cursor_theme* cursor_theme;
76 struct wl_cursor* cursor;
77 struct wl_surface* cursor_surface;
78 uint32_t pointer_enter_serial;
79 int32_t mouse_x;
80 int32_t mouse_y;
81 int8_t mouse_pos_set;
82 int8_t cursor_state;
83
84 struct zwp_pointer_constraints_v1* pointer_constraints;
85 struct zwp_confined_pointer_v1* locked_pointer;
86 struct zwp_relative_pointer_manager_v1* relative_pointer_manager;
87 struct zwp_relative_pointer_v1* relative_pointer;
88
89 struct xkb_context* xkb_context;
90 struct xkb_keymap* xkb_keymap;
91 struct xkb_state* xkb_state;
92
93
94 MausEventPending pending;
95 MausEventPending evq[MAUS_EVQ_MAX];
96 uint32_t evq_head;
97 uint32_t evq_tail;
98 uint32_t evq_count;
99
100 int32_t repeat_rate;
101 int32_t repeat_delay;
102 uint32_t repeat_key_code;
103 uint32_t repeat_key_sym;
104 char repeat_key_text;
105 uint64_t repeat_next_ns;
106
107 struct xdg_wm_base* wm_base;
108 struct xdg_surface* xdg_surface;
109 struct xdg_toplevel* xdg_toplevel;
110 int8_t configured;
111
112 struct wl_registry* registry;
113} MausBackend;
114
115#endif /* MAUS_WAYLAND_H */
116