Wise&mystical  1.0
Project about Europe
Loading...
Searching...
No Matches
wl_platform.h
Go to the documentation of this file.
1//========================================================================
2// GLFW 3.4 Wayland - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2014 Jonas Ã…dahl <jadahl@gmail.com>
5//
6// This software is provided 'as-is', without any express or implied
7// warranty. In no event will the authors be held liable for any damages
8// arising from the use of this software.
9//
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13//
14// 1. The origin of this software must not be misrepresented; you must not
15// claim that you wrote the original software. If you use this software
16// in a product, an acknowledgment in the product documentation would
17// be appreciated but is not required.
18//
19// 2. Altered source versions must be plainly marked as such, and must not
20// be misrepresented as being the original software.
21//
22// 3. This notice may not be removed or altered from any source
23// distribution.
24//
25//========================================================================
26
27#include <wayland-client.h>
28#include <xkbcommon/xkbcommon.h>
29#ifdef HAVE_XKBCOMMON_COMPOSE_H
30#include <xkbcommon/xkbcommon-compose.h>
31#endif
32#include <dlfcn.h>
33
35
37{
39 const void* pNext;
41 struct wl_display* display;
42 struct wl_surface* surface;
44
47
48#include "posix_thread.h"
49#include "posix_time.h"
50#ifdef __linux__
51#include "linux_joystick.h"
52#else
53#include "null_joystick.h"
54#endif
55#include "xkb_unicode.h"
56
57#include "wayland-xdg-shell-client-protocol.h"
58#include "wayland-xdg-decoration-client-protocol.h"
59#include "wayland-viewporter-client-protocol.h"
60#include "wayland-relative-pointer-unstable-v1-client-protocol.h"
61#include "wayland-pointer-constraints-unstable-v1-client-protocol.h"
62#include "wayland-idle-inhibit-unstable-v1-client-protocol.h"
63
64#define _glfw_dlopen(name) dlopen(name, RTLD_LAZY | RTLD_LOCAL)
65#define _glfw_dlclose(handle) dlclose(handle)
66#define _glfw_dlsym(handle, name) dlsym(handle, name)
67
68#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWayland wl
69#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl
70#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWayland wl
71#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWayland wl
72
73#define _GLFW_PLATFORM_CONTEXT_STATE struct { int dummyContext; }
74#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE struct { int dummyLibraryContext; }
75
82};
83struct wl_cursor {
84 unsigned int image_count;
86 char* name;
87};
88typedef struct wl_cursor_theme* (* PFN_wl_cursor_theme_load)(const char*, int, struct wl_shm*);
89typedef void (* PFN_wl_cursor_theme_destroy)(struct wl_cursor_theme*);
90typedef struct wl_cursor* (* PFN_wl_cursor_theme_get_cursor)(struct wl_cursor_theme*, const char*);
91typedef struct wl_buffer* (* PFN_wl_cursor_image_get_buffer)(struct wl_cursor_image*);
92#define wl_cursor_theme_load _glfw.wl.cursor.theme_load
93#define wl_cursor_theme_destroy _glfw.wl.cursor.theme_destroy
94#define wl_cursor_theme_get_cursor _glfw.wl.cursor.theme_get_cursor
95#define wl_cursor_image_get_buffer _glfw.wl.cursor.image_get_buffer
96
97typedef struct wl_egl_window* (* PFN_wl_egl_window_create)(struct wl_surface*, int, int);
98typedef void (* PFN_wl_egl_window_destroy)(struct wl_egl_window*);
99typedef void (* PFN_wl_egl_window_resize)(struct wl_egl_window*, int, int, int, int);
100#define wl_egl_window_create _glfw.wl.egl.window_create
101#define wl_egl_window_destroy _glfw.wl.egl.window_destroy
102#define wl_egl_window_resize _glfw.wl.egl.window_resize
103
104typedef struct xkb_context* (* PFN_xkb_context_new)(enum xkb_context_flags);
105typedef void (* PFN_xkb_context_unref)(struct xkb_context*);
106typedef struct xkb_keymap* (* PFN_xkb_keymap_new_from_string)(struct xkb_context*, const char*, enum xkb_keymap_format, enum xkb_keymap_compile_flags);
107typedef void (* PFN_xkb_keymap_unref)(struct xkb_keymap*);
108typedef xkb_mod_index_t (* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap*, const char*);
109typedef int (* PFN_xkb_keymap_key_repeats)(struct xkb_keymap*, xkb_keycode_t);
110typedef struct xkb_state* (* PFN_xkb_state_new)(struct xkb_keymap*);
111typedef void (* PFN_xkb_state_unref)(struct xkb_state*);
112typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**);
113typedef enum xkb_state_component (* PFN_xkb_state_update_mask)(struct xkb_state*, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t);
114typedef xkb_mod_mask_t (* PFN_xkb_state_serialize_mods)(struct xkb_state*, enum xkb_state_component);
115#define xkb_context_new _glfw.wl.xkb.context_new
116#define xkb_context_unref _glfw.wl.xkb.context_unref
117#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string
118#define xkb_keymap_unref _glfw.wl.xkb.keymap_unref
119#define xkb_keymap_mod_get_index _glfw.wl.xkb.keymap_mod_get_index
120#define xkb_keymap_key_repeats _glfw.wl.xkb.keymap_key_repeats
121#define xkb_state_new _glfw.wl.xkb.state_new
122#define xkb_state_unref _glfw.wl.xkb.state_unref
123#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms
124#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask
125#define xkb_state_serialize_mods _glfw.wl.xkb.state_serialize_mods
126
127#ifdef HAVE_XKBCOMMON_COMPOSE_H
128typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags);
129typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*);
130typedef struct xkb_compose_state* (* PFN_xkb_compose_state_new)(struct xkb_compose_table*, enum xkb_compose_state_flags);
131typedef void (* PFN_xkb_compose_state_unref)(struct xkb_compose_state*);
132typedef enum xkb_compose_feed_result (* PFN_xkb_compose_state_feed)(struct xkb_compose_state*, xkb_keysym_t);
133typedef enum xkb_compose_status (* PFN_xkb_compose_state_get_status)(struct xkb_compose_state*);
134typedef xkb_keysym_t (* PFN_xkb_compose_state_get_one_sym)(struct xkb_compose_state*);
135#define xkb_compose_table_new_from_locale _glfw.wl.xkb.compose_table_new_from_locale
136#define xkb_compose_table_unref _glfw.wl.xkb.compose_table_unref
137#define xkb_compose_state_new _glfw.wl.xkb.compose_state_new
138#define xkb_compose_state_unref _glfw.wl.xkb.compose_state_unref
139#define xkb_compose_state_feed _glfw.wl.xkb.compose_state_feed
140#define xkb_compose_state_get_status _glfw.wl.xkb.compose_state_get_status
141#define xkb_compose_state_get_one_sym _glfw.wl.xkb.compose_state_get_one_sym
142#endif
143
144#define _GLFW_DECORATION_WIDTH 4
145#define _GLFW_DECORATION_TOP 24
146#define _GLFW_DECORATION_VERTICAL (_GLFW_DECORATION_TOP + _GLFW_DECORATION_WIDTH)
147#define _GLFW_DECORATION_HORIZONTAL (2 * _GLFW_DECORATION_WIDTH)
148
150{
156
158
160{
161 struct wl_surface* surface;
162 struct wl_subsurface* subsurface;
163 struct wp_viewport* viewport;
164
166
167// Wayland-specific per-window data
168//
169typedef struct _GLFWwindowWayland
170{
176 struct wl_surface* surface;
177 struct wl_egl_window* native;
178 struct wl_callback* callback;
179
180 struct {
181 struct xdg_surface* surface;
182 struct xdg_toplevel* toplevel;
183 struct zxdg_toplevel_decoration_v1* decoration;
185
188
189 char* title;
190
191 // We need to track the monitors the window spans on to calculate the
192 // optimal scaling factor.
193 int scale;
197
198 struct {
199 struct zwp_relative_pointer_v1* relativePointer;
200 struct zwp_locked_pointer_v1* lockedPointer;
202
203 struct zwp_idle_inhibitor_v1* idleInhibitor;
204
206
207 struct {
209 struct wl_buffer* buffer;
211 int focus;
213
215
216// Wayland-specific global data
217//
219{
220 struct wl_display* display;
221 struct wl_registry* registry;
222 struct wl_compositor* compositor;
223 struct wl_subcompositor* subcompositor;
224 struct wl_shm* shm;
225 struct wl_seat* seat;
226 struct wl_pointer* pointer;
227 struct wl_keyboard* keyboard;
228 struct wl_data_device_manager* dataDeviceManager;
229 struct wl_data_device* dataDevice;
230 struct wl_data_offer* dataOffer;
231 struct wl_data_source* dataSource;
232 struct xdg_wm_base* wmBase;
233 struct zxdg_decoration_manager_v1* decorationManager;
234 struct wp_viewporter* viewporter;
235 struct zwp_relative_pointer_manager_v1* relativePointerManager;
236 struct zwp_pointer_constraints_v1* pointerConstraints;
237 struct zwp_idle_inhibit_manager_v1* idleInhibitManager;
238
241
242 struct wl_cursor_theme* cursorTheme;
243 struct wl_cursor_theme* cursorThemeHiDPI;
244 struct wl_surface* cursorSurface;
248
258 short int keycodes[256];
259 short int scancodes[GLFW_KEY_LAST + 1];
260
261 struct {
262 void* handle;
263 struct xkb_context* context;
264 struct xkb_keymap* keymap;
265 struct xkb_state* state;
266
267#ifdef HAVE_XKBCOMMON_COMPOSE_H
268 struct xkb_compose_state* composeState;
269#endif
270
271 xkb_mod_mask_t controlMask;
272 xkb_mod_mask_t altMask;
273 xkb_mod_mask_t shiftMask;
274 xkb_mod_mask_t superMask;
275 xkb_mod_mask_t capsLockMask;
276 xkb_mod_mask_t numLockMask;
277 unsigned int modifiers;
278
290
291#ifdef HAVE_XKBCOMMON_COMPOSE_H
292 PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale;
293 PFN_xkb_compose_table_unref compose_table_unref;
294 PFN_xkb_compose_state_new compose_state_new;
295 PFN_xkb_compose_state_unref compose_state_unref;
296 PFN_xkb_compose_state_feed compose_state_feed;
297 PFN_xkb_compose_state_get_status compose_state_get_status;
298 PFN_xkb_compose_state_get_one_sym compose_state_get_one_sym;
299#endif
301
304
305 struct {
306 void* handle;
307
313
314 struct {
315 void* handle;
316
321
323
324// Wayland-specific per-monitor data
325//
327{
328 struct wl_output* output;
331
332 int x;
333 int y;
334 int scale;
335
337
338// Wayland-specific per-cursor data
339//
340typedef struct _GLFWcursorWayland
341{
344 struct wl_buffer* buffer;
346 int xhot, yhot;
349
350
351void _glfwAddOutputWayland(uint32_t name, uint32_t version);
352
#define APIENTRY
Compiler- and platform-specific preprocessor work.
Definition: glfw3.h:125
#define GLFW_KEY_LAST
Definition: glfw3.h:515
uint64_t VkSurfaceKHR
Definition: internal.h:120
void * VkInstance
Definition: internal.h:118
void * VkPhysicalDevice
Definition: internal.h:119
int GLFWbool
Definition: internal.h:61
unsigned int uint32_t
Definition: stdint.h:80
signed int int32_t
Definition: stdint.h:77
struct wl_buffer * buffer
Definition: wl_platform.h:344
struct wl_cursor * cursor
Definition: wl_platform.h:342
struct wl_cursor * cursorHiDPI
Definition: wl_platform.h:343
struct wl_subsurface * subsurface
Definition: wl_platform.h:162
struct wp_viewport * viewport
Definition: wl_platform.h:163
struct wl_surface * surface
Definition: wl_platform.h:161
PFN_xkb_state_unref state_unref
Definition: wl_platform.h:286
struct zwp_pointer_constraints_v1 * pointerConstraints
Definition: wl_platform.h:236
const char * cursorPreviousName
Definition: wl_platform.h:245
struct wl_surface * cursorSurface
Definition: wl_platform.h:244
struct wl_pointer * pointer
Definition: wl_platform.h:226
struct wl_data_device_manager * dataDeviceManager
Definition: wl_platform.h:228
struct wl_shm * shm
Definition: wl_platform.h:224
_GLFWwindow * keyboardFocus
Definition: wl_platform.h:303
PFN_xkb_keymap_unref keymap_unref
Definition: wl_platform.h:282
short int scancodes[GLFW_KEY_LAST+1]
Definition: wl_platform.h:259
struct xkb_keymap * keymap
Definition: wl_platform.h:264
PFN_xkb_state_key_get_syms state_key_get_syms
Definition: wl_platform.h:287
struct xdg_wm_base * wmBase
Definition: wl_platform.h:232
PFN_wl_egl_window_create window_create
Definition: wl_platform.h:317
xkb_mod_mask_t capsLockMask
Definition: wl_platform.h:275
char * clipboardSendString
Definition: wl_platform.h:255
xkb_mod_mask_t shiftMask
Definition: wl_platform.h:273
xkb_mod_mask_t superMask
Definition: wl_platform.h:274
PFN_wl_cursor_theme_load theme_load
Definition: wl_platform.h:308
xkb_mod_mask_t numLockMask
Definition: wl_platform.h:276
PFN_xkb_keymap_new_from_string keymap_new_from_string
Definition: wl_platform.h:281
xkb_mod_mask_t controlMask
Definition: wl_platform.h:271
int32_t keyboardRepeatDelay
Definition: wl_platform.h:250
PFN_xkb_state_update_mask state_update_mask
Definition: wl_platform.h:288
PFN_wl_egl_window_destroy window_destroy
Definition: wl_platform.h:318
PFN_xkb_state_new state_new
Definition: wl_platform.h:285
xkb_mod_mask_t altMask
Definition: wl_platform.h:272
_GLFWwindow * pointerFocus
Definition: wl_platform.h:302
PFN_xkb_context_new context_new
Definition: wl_platform.h:279
struct zxdg_decoration_manager_v1 * decorationManager
Definition: wl_platform.h:233
struct wl_cursor_theme * cursorTheme
Definition: wl_platform.h:242
struct wl_subcompositor * subcompositor
Definition: wl_platform.h:223
struct wl_seat * seat
Definition: wl_platform.h:225
struct xkb_context * context
Definition: wl_platform.h:263
struct wl_cursor_theme * cursorThemeHiDPI
Definition: wl_platform.h:243
PFN_wl_egl_window_resize window_resize
Definition: wl_platform.h:319
struct _GLFWlibraryWayland::@39 egl
PFN_xkb_context_unref context_unref
Definition: wl_platform.h:280
struct xkb_state * state
Definition: wl_platform.h:265
struct wl_display * display
Definition: wl_platform.h:220
PFN_wl_cursor_theme_get_cursor theme_get_cursor
Definition: wl_platform.h:310
PFN_xkb_state_serialize_mods state_serialize_mods
Definition: wl_platform.h:289
PFN_xkb_keymap_mod_get_index keymap_mod_get_index
Definition: wl_platform.h:283
struct wl_data_offer * dataOffer
Definition: wl_platform.h:230
PFN_wl_cursor_theme_destroy theme_destroy
Definition: wl_platform.h:309
int32_t keyboardRepeatRate
Definition: wl_platform.h:249
struct wl_data_device * dataDevice
Definition: wl_platform.h:229
struct zwp_relative_pointer_manager_v1 * relativePointerManager
Definition: wl_platform.h:235
struct wl_data_source * dataSource
Definition: wl_platform.h:231
short int keycodes[256]
Definition: wl_platform.h:258
struct _GLFWlibraryWayland::@38 cursor
unsigned int modifiers
Definition: wl_platform.h:277
struct wl_keyboard * keyboard
Definition: wl_platform.h:227
struct _GLFWlibraryWayland::@37 xkb
PFN_xkb_keymap_key_repeats keymap_key_repeats
Definition: wl_platform.h:284
struct wl_compositor * compositor
Definition: wl_platform.h:222
PFN_wl_cursor_image_get_buffer image_get_buffer
Definition: wl_platform.h:311
struct zwp_idle_inhibit_manager_v1 * idleInhibitManager
Definition: wl_platform.h:237
struct wl_registry * registry
Definition: wl_platform.h:221
struct wp_viewporter * viewporter
Definition: wl_platform.h:234
struct wl_output * output
Definition: wl_platform.h:328
struct wl_buffer * buffer
Definition: wl_platform.h:209
struct zwp_locked_pointer_v1 * lockedPointer
Definition: wl_platform.h:200
struct _GLFWwindowWayland::@34 xdg
_GLFWmonitor ** monitors
Definition: wl_platform.h:194
struct wl_surface * surface
Definition: wl_platform.h:176
struct zwp_relative_pointer_v1 * relativePointer
Definition: wl_platform.h:199
GLFWbool wasFullscreen
Definition: wl_platform.h:205
struct zwp_idle_inhibitor_v1 * idleInhibitor
Definition: wl_platform.h:203
struct xdg_toplevel * toplevel
Definition: wl_platform.h:182
struct zxdg_toplevel_decoration_v1 * decoration
Definition: wl_platform.h:183
_GLFWcursor * currentCursor
Definition: wl_platform.h:186
struct wl_callback * callback
Definition: wl_platform.h:178
struct wl_egl_window * native
Definition: wl_platform.h:177
struct xdg_surface * surface
Definition: wl_platform.h:181
_GLFWdecorationWayland bottom
Definition: wl_platform.h:210
GLFWbool transparent
Definition: wl_platform.h:175
struct _GLFWwindowWayland::@35 pointerLock
struct _GLFWwindowWayland::@36 decorations
VkWaylandSurfaceCreateFlagsKHR flags
Definition: wl_platform.h:40
struct wl_display * display
Definition: wl_platform.h:41
struct wl_surface * surface
Definition: wl_platform.h:42
uint32_t hotspot_y
Definition: wl_platform.h:80
uint32_t hotspot_x
Definition: wl_platform.h:79
uint32_t height
Definition: wl_platform.h:78
uint32_t width
Definition: wl_platform.h:77
uint32_t delay
Definition: wl_platform.h:81
struct wl_cursor_image ** images
Definition: wl_platform.h:85
char * name
Definition: wl_platform.h:86
unsigned int image_count
Definition: wl_platform.h:84
uint32_t VkFlags
Definition: vulkan.h:1688
VkResult
Definition: vulkan.h:842
uint32_t VkBool32
Definition: vulkan.h:1687
VkStructureType
Definition: vulkan.h:897
void(* PFN_wl_cursor_theme_destroy)(struct wl_cursor_theme *)
Definition: wl_platform.h:89
void(* PFN_xkb_state_unref)(struct xkb_state *)
Definition: wl_platform.h:111
int(* PFN_xkb_keymap_key_repeats)(struct xkb_keymap *, xkb_keycode_t)
Definition: wl_platform.h:109
struct xkb_keymap *(* PFN_xkb_keymap_new_from_string)(struct xkb_context *, const char *, enum xkb_keymap_format, enum xkb_keymap_compile_flags)
Definition: wl_platform.h:106
struct xkb_state *(* PFN_xkb_state_new)(struct xkb_keymap *)
Definition: wl_platform.h:110
void(* PFN_wl_egl_window_destroy)(struct wl_egl_window *)
Definition: wl_platform.h:98
VkFlags VkWaylandSurfaceCreateFlagsKHR
Definition: wl_platform.h:34
struct wl_buffer *(* PFN_wl_cursor_image_get_buffer)(struct wl_cursor_image *)
Definition: wl_platform.h:91
void _glfwAddOutputWayland(uint32_t name, uint32_t version)
Definition: wl_monitor.c:121
xkb_mod_index_t(* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap *, const char *)
Definition: wl_platform.h:108
VkResult(APIENTRY * PFN_vkCreateWaylandSurfaceKHR)(VkInstance, const VkWaylandSurfaceCreateInfoKHR *, const VkAllocationCallbacks *, VkSurfaceKHR *)
Definition: wl_platform.h:45
enum xkb_state_component(* PFN_xkb_state_update_mask)(struct xkb_state *, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t)
Definition: wl_platform.h:113
xkb_mod_mask_t(* PFN_xkb_state_serialize_mods)(struct xkb_state *, enum xkb_state_component)
Definition: wl_platform.h:114
struct wl_cursor_theme *(* PFN_wl_cursor_theme_load)(const char *, int, struct wl_shm *)
Definition: wl_platform.h:88
void(* PFN_xkb_keymap_unref)(struct xkb_keymap *)
Definition: wl_platform.h:107
struct xkb_context *(* PFN_xkb_context_new)(enum xkb_context_flags)
Definition: wl_platform.h:104
VkBool32(APIENTRY * PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice, uint32_t, struct wl_display *)
Definition: wl_platform.h:46
int(* PFN_xkb_state_key_get_syms)(struct xkb_state *, xkb_keycode_t, const xkb_keysym_t **)
Definition: wl_platform.h:112
struct wl_cursor *(* PFN_wl_cursor_theme_get_cursor)(struct wl_cursor_theme *, const char *)
Definition: wl_platform.h:90
_GLFWdecorationSideWayland
Definition: wl_platform.h:150
@ bottomDecoration
Definition: wl_platform.h:155
@ topDecoration
Definition: wl_platform.h:152
@ leftDecoration
Definition: wl_platform.h:153
@ rightDecoration
Definition: wl_platform.h:154
@ mainWindow
Definition: wl_platform.h:151
struct wl_egl_window *(* PFN_wl_egl_window_create)(struct wl_surface *, int, int)
Definition: wl_platform.h:97
void(* PFN_wl_egl_window_resize)(struct wl_egl_window *, int, int, int, int)
Definition: wl_platform.h:99
void(* PFN_xkb_context_unref)(struct xkb_context *)
Definition: wl_platform.h:105