-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathwayland_common.h
More file actions
308 lines (260 loc) · 8.84 KB
/
wayland_common.h
File metadata and controls
308 lines (260 loc) · 8.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _WAYLAND_COMMON_H
#define _WAYLAND_COMMON_H
#include <stdint.h>
#include <boolean.h>
#include <linux/input.h>
#include <wayland-client.h>
#include <wayland-cursor.h>
#include "../input_driver.h"
#ifdef HAVE_EGL
#include "../../gfx/common/egl_common.h"
#endif
#ifdef HAVE_VULKAN
#include "../../gfx/common/vulkan_common.h"
#endif
/* Generated from wayland protocol files by generate_wayland_protos.sh */
#include "../../gfx/common/wayland/content-type-v1.h"
#include "../../gfx/common/wayland/cursor-shape-v1.h"
#include "../../gfx/common/wayland/fractional-scale-v1.h"
#include "../../gfx/common/wayland/idle-inhibit-unstable-v1.h"
#include "../../gfx/common/wayland/pointer-constraints-unstable-v1.h"
#include "../../gfx/common/wayland/relative-pointer-unstable-v1.h"
#include "../../gfx/common/wayland/single-pixel-buffer-v1.h"
#include "../../gfx/common/wayland/viewporter.h"
#include "../../gfx/common/wayland/xdg-decoration-unstable-v1.h"
#include "../../gfx/common/wayland/xdg-shell.h"
#include "../../gfx/common/wayland/xdg-toplevel-icon-v1.h"
#include "../../gfx/common/wayland/xdg-toplevel-tag-v1.h"
#ifdef WEBOS
#include "wayland_common_webos.h"
#endif
#define FRACTIONAL_SCALE_V1_DEN 120
#define FRACTIONAL_SCALE_MULT(v, scale_num) \
(((v) * (scale_num) + FRACTIONAL_SCALE_V1_DEN / 2) / FRACTIONAL_SCALE_V1_DEN)
#define UDEV_KEY_MAX 0x2ff
#define UDEV_MAX_KEYS (UDEV_KEY_MAX + 7) / 8
#define MAX_TOUCHES 16
#define WL_ARRAY_FOR_EACH(pos, array, type) \
for (pos = (type)(array)->data; \
(const char *) pos < ((const char *) (array)->data + (array)->size); \
(pos)++)
#ifdef HAVE_LIBDECOR_H
#include <libdecor.h>
#endif
typedef struct
{
int16_t x;
int16_t y;
bool active;
} wayland_touch_data_t;
typedef struct touch_pos
{
int32_t id;
unsigned x;
unsigned y;
bool active;
} touch_pos_t;
typedef struct output_info
{
struct wl_output *output;
int refresh_rate;
uint32_t global_id;
unsigned width;
unsigned height;
unsigned physical_width;
unsigned physical_height;
unsigned scale;
char *make;
char *model;
} output_info_t;
typedef struct display_output
{
output_info_t *output;
struct wl_list link;
} display_output_t;
typedef struct surface_output
{
output_info_t *output;
struct wl_list link;
} surface_output_t;
struct gfx_ctx_wayland_data;
typedef struct input_ctx_wayland_data
{
struct wl_display *dpy;
const input_device_driver_t *joypad;
struct gfx_ctx_wayland_data *gfx;
int fd;
wayland_touch_data_t touches[MAX_TOUCHES]; /* int16_t alignment */
/* Wayland uses Linux keysyms. */
uint8_t key_state[UDEV_MAX_KEYS];
struct
{
struct wl_surface *surface;
int last_x, last_y;
int x, y;
int delta_x, delta_y;
bool last_valid;
bool focus;
bool left, right, middle, side, extra;
bool wu, wd, wl, wr;
} mouse;
bool keyboard_focus;
bool blocked;
} input_ctx_wayland_data_t;
typedef struct data_offer_ctx
{
struct wl_data_offer *offer;
struct wl_data_device *data_device;
bool is_file_mime_type;
bool dropped;
enum wl_data_device_manager_dnd_action supported_actions;
} data_offer_ctx;
typedef struct gfx_ctx_wayland_data
{
#ifdef HAVE_EGL
egl_ctx_data_t egl;
struct wl_egl_window *win;
#endif
struct wl_registry *registry;
struct wl_compositor *compositor;
struct wp_viewporter *viewporter;
struct wp_fractional_scale_manager_v1 *fractional_scale_manager;
struct wl_surface *surface;
struct xdg_surface *xdg_surface;
struct wp_viewport *viewport;
struct wp_fractional_scale_v1 *fractional_scale;
struct xdg_wm_base *xdg_shell;
struct xdg_toplevel *xdg_toplevel;
struct xdg_toplevel_icon_v1 *xdg_toplevel_icon;
struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager;
struct xdg_toplevel_tag_manager_v1 *xdg_toplevel_tag_manager;
struct wl_keyboard *wl_keyboard;
struct wl_pointer *wl_pointer;
struct zwp_relative_pointer_v1 *wl_relative_pointer;
struct zwp_locked_pointer_v1 *locked_pointer;
struct wl_touch *wl_touch;
struct wl_seat *seat;
struct wl_shm *shm;
struct wl_data_device_manager *data_device_manager;
struct wl_data_device *data_device;
#ifdef WEBOS
struct wl_shell *shell;
struct wl_shell_surface *shell_surface;
struct wl_webos_shell *webos_shell;
struct wl_webos_shell_surface *webos_shell_surface;
struct wl_webos_foreign *webos_foreign;
struct wl_webos_surface_group_compositor *webos_surface_group_compositor;
struct wl_webos_input_manager *webos_input_manager;
#endif
data_offer_ctx *current_drag_offer;
#ifdef HAVE_LIBDECOR_H
struct libdecor *libdecor_context;
struct libdecor_frame *libdecor_frame;
struct xdg_toplevel_icon_v1 *libdecor_icon;
#ifdef HAVE_DYLIB
dylib_t libdecor;
#define RA_WAYLAND_SYM(rc,fn,params) rc (*fn) params;
#include "../../gfx/common/wayland/libdecor_sym.h"
#endif
#endif
struct zxdg_decoration_manager_v1 *deco_manager;
struct zxdg_toplevel_decoration_v1 *deco;
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager;
struct zwp_idle_inhibitor_v1 *idle_inhibitor;
struct zwp_pointer_constraints_v1 *pointer_constraints;
struct zwp_relative_pointer_manager_v1 *relative_pointer_manager;
struct wp_cursor_shape_manager_v1 *cursor_shape_manager;
struct wp_cursor_shape_device_v1 *cursor_shape_device;
struct wp_content_type_manager_v1 *content_type_manager;
struct wp_content_type_v1 *content_type;
struct wp_single_pixel_buffer_manager_v1 *single_pixel_manager;
output_info_t *current_output;
#ifdef HAVE_VULKAN
gfx_ctx_vulkan_data_t vk;
#endif
input_ctx_wayland_data_t input; /* ptr alignment */
struct wl_list all_outputs;
struct wl_list current_outputs;
#ifdef WEBOS
struct wl_list all_seats;
#endif
struct
{
struct wl_cursor *default_cursor;
struct wl_cursor_theme *theme;
struct wl_surface *surface;
uint32_t serial;
bool visible;
} cursor;
int num_active_touches;
int swap_interval;
touch_pos_t active_touch_positions[MAX_TOUCHES]; /* int32_t alignment */
unsigned width;
unsigned height;
unsigned buffer_width;
unsigned buffer_height;
unsigned floating_width;
unsigned floating_height;
unsigned last_buffer_scale;
unsigned pending_buffer_scale;
unsigned buffer_scale;
unsigned last_fractional_scale_num;
unsigned pending_fractional_scale_num;
unsigned fractional_scale_num;
#ifdef WEBOS
uint32_t webos_surface_state;
#endif
bool core_hw_context_enable;
bool fullscreen;
bool maximized;
bool resize;
bool configured;
bool ignore_configuration;
bool activated;
bool reported_display_size;
bool swap_complete;
} gfx_ctx_wayland_data_t;
#ifdef HAVE_XKBCOMMON
/* FIXME: Move this into a header? */
int init_xkb(int fd, size_t len);
int handle_xkb(int code, int value);
void handle_xkb_state_mask(uint32_t depressed,
uint32_t latched, uint32_t locked, uint32_t group);
void free_xkb(void);
#endif
void gfx_ctx_wl_show_mouse(void *data, bool state);
void flush_wayland_fd(void *data);
extern const struct wl_keyboard_listener keyboard_listener;
extern const struct wl_pointer_listener pointer_listener;
extern const struct zwp_relative_pointer_v1_listener relative_pointer_listener;
extern const struct zwp_locked_pointer_v1_listener locked_pointer_listener;
extern const struct wl_touch_listener touch_listener;
extern const struct wl_seat_listener seat_listener;
extern const struct wp_fractional_scale_v1_listener wp_fractional_scale_v1_listener;
extern const struct wl_surface_listener wl_surface_listener;
extern const struct xdg_wm_base_listener xdg_shell_listener;
extern const struct xdg_surface_listener xdg_surface_listener;
extern const struct wl_output_listener output_listener;
extern const struct wl_registry_listener registry_listener;
extern const struct wl_buffer_listener shm_buffer_listener;
extern const struct wl_data_device_listener data_device_listener;
extern const struct wl_data_offer_listener data_offer_listener;
#ifdef WEBOS
extern void wl_keyboard_handle_key_webos(void *data, struct wl_keyboard *keyboard, uint32_t serial,
uint32_t time, uint32_t key, uint32_t state);
#endif
#endif