1//======================================================================== 2// GLFW 3.5 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-core.h> 28#include <xkbcommon/xkbcommon.h> 29#include <xkbcommon/xkbcommon-compose.h> 30 31typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; 32 33typedef struct VkWaylandSurfaceCreateInfoKHR 34{ 35 VkStructureType sType; 36 const void* pNext; 37 VkWaylandSurfaceCreateFlagsKHR flags; 38 struct wl_display* display; 39 struct wl_surface* surface; 40} VkWaylandSurfaceCreateInfoKHR; 41 42typedef VkResult (APIENTRY *PFN_vkCreateWaylandSurfaceKHR)(VkInstance,const VkWaylandSurfaceCreateInfoKHR*,const VkAllocationCallbacks*,VkSurfaceKHR*); 43typedef VkBool32 (APIENTRY *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice,uint32_t,struct wl_display*); 44 45#include "xkb_unicode.h" 46#include "posix_poll.h" 47 48typedef int (* PFN_wl_display_flush)(struct wl_display* display); 49typedef void (* PFN_wl_display_cancel_read)(struct wl_display* display); 50typedef int (* PFN_wl_display_dispatch_pending)(struct wl_display* display); 51typedef int (* PFN_wl_display_read_events)(struct wl_display* display); 52typedef struct wl_display* (* PFN_wl_display_connect)(const char*); 53typedef void (* PFN_wl_display_disconnect)(struct wl_display*); 54typedef int (* PFN_wl_display_roundtrip)(struct wl_display*); 55typedef int (* PFN_wl_display_get_fd)(struct wl_display*); 56typedef int (* PFN_wl_display_prepare_read)(struct wl_display*); 57typedef void (* PFN_wl_proxy_marshal)(struct wl_proxy*,uint32_t,...); 58typedef int (* PFN_wl_proxy_add_listener)(struct wl_proxy*,void(**)(void),void*); 59typedef void (* PFN_wl_proxy_destroy)(struct wl_proxy*); 60typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor)(struct wl_proxy*,uint32_t,const struct wl_interface*,...); 61typedef struct wl_proxy* (* PFN_wl_proxy_marshal_constructor_versioned)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,...); 62typedef void* (* PFN_wl_proxy_get_user_data)(struct wl_proxy*); 63typedef void (* PFN_wl_proxy_set_user_data)(struct wl_proxy*,void*); 64typedef void (* PFN_wl_proxy_set_tag)(struct wl_proxy*,const char*const*); 65typedef const char* const* (* PFN_wl_proxy_get_tag)(struct wl_proxy*); 66typedef uint32_t (* PFN_wl_proxy_get_version)(struct wl_proxy*); 67typedef struct wl_proxy* (* PFN_wl_proxy_marshal_flags)(struct wl_proxy*,uint32_t,const struct wl_interface*,uint32_t,uint32_t,...); 68#define wl_display_flush _glfw.wl.client.display_flush 69#define wl_display_cancel_read _glfw.wl.client.display_cancel_read 70#define wl_display_dispatch_pending _glfw.wl.client.display_dispatch_pending 71#define wl_display_read_events _glfw.wl.client.display_read_events 72#define wl_display_disconnect _glfw.wl.client.display_disconnect 73#define wl_display_roundtrip _glfw.wl.client.display_roundtrip 74#define wl_display_get_fd _glfw.wl.client.display_get_fd 75#define wl_display_prepare_read _glfw.wl.client.display_prepare_read 76#define wl_proxy_marshal _glfw.wl.client.proxy_marshal 77#define wl_proxy_add_listener _glfw.wl.client.proxy_add_listener 78#define wl_proxy_destroy _glfw.wl.client.proxy_destroy 79#define wl_proxy_marshal_constructor _glfw.wl.client.proxy_marshal_constructor 80#define wl_proxy_marshal_constructor_versioned _glfw.wl.client.proxy_marshal_constructor_versioned 81#define wl_proxy_get_user_data _glfw.wl.client.proxy_get_user_data 82#define wl_proxy_set_user_data _glfw.wl.client.proxy_set_user_data 83#define wl_proxy_get_tag _glfw.wl.client.proxy_get_tag 84#define wl_proxy_set_tag _glfw.wl.client.proxy_set_tag 85#define wl_proxy_get_version _glfw.wl.client.proxy_get_version 86#define wl_proxy_marshal_flags _glfw.wl.client.proxy_marshal_flags 87 88struct wl_shm; 89struct wl_output; 90 91#define wl_display_interface _glfw_wl_display_interface 92#define wl_subcompositor_interface _glfw_wl_subcompositor_interface 93#define wl_compositor_interface _glfw_wl_compositor_interface 94#define wl_shm_interface _glfw_wl_shm_interface 95#define wl_data_device_manager_interface _glfw_wl_data_device_manager_interface 96#define wl_shell_interface _glfw_wl_shell_interface 97#define wl_buffer_interface _glfw_wl_buffer_interface 98#define wl_callback_interface _glfw_wl_callback_interface 99#define wl_data_device_interface _glfw_wl_data_device_interface 100#define wl_data_offer_interface _glfw_wl_data_offer_interface 101#define wl_data_source_interface _glfw_wl_data_source_interface 102#define wl_keyboard_interface _glfw_wl_keyboard_interface 103#define wl_output_interface _glfw_wl_output_interface 104#define wl_pointer_interface _glfw_wl_pointer_interface 105#define wl_region_interface _glfw_wl_region_interface 106#define wl_registry_interface _glfw_wl_registry_interface 107#define wl_seat_interface _glfw_wl_seat_interface 108#define wl_shell_surface_interface _glfw_wl_shell_surface_interface 109#define wl_shm_pool_interface _glfw_wl_shm_pool_interface 110#define wl_subsurface_interface _glfw_wl_subsurface_interface 111#define wl_surface_interface _glfw_wl_surface_interface 112#define wl_touch_interface _glfw_wl_touch_interface 113#define zwp_idle_inhibitor_v1_interface _glfw_zwp_idle_inhibitor_v1_interface 114#define zwp_idle_inhibit_manager_v1_interface _glfw_zwp_idle_inhibit_manager_v1_interface 115#define zwp_confined_pointer_v1_interface _glfw_zwp_confined_pointer_v1_interface 116#define zwp_locked_pointer_v1_interface _glfw_zwp_locked_pointer_v1_interface 117#define zwp_pointer_constraints_v1_interface _glfw_zwp_pointer_constraints_v1_interface 118#define zwp_relative_pointer_v1_interface _glfw_zwp_relative_pointer_v1_interface 119#define zwp_relative_pointer_manager_v1_interface _glfw_zwp_relative_pointer_manager_v1_interface 120#define wp_viewport_interface _glfw_wp_viewport_interface 121#define wp_viewporter_interface _glfw_wp_viewporter_interface 122#define xdg_toplevel_interface _glfw_xdg_toplevel_interface 123#define zxdg_toplevel_decoration_v1_interface _glfw_zxdg_toplevel_decoration_v1_interface 124#define zxdg_decoration_manager_v1_interface _glfw_zxdg_decoration_manager_v1_interface 125#define xdg_popup_interface _glfw_xdg_popup_interface 126#define xdg_positioner_interface _glfw_xdg_positioner_interface 127#define xdg_surface_interface _glfw_xdg_surface_interface 128#define xdg_toplevel_interface _glfw_xdg_toplevel_interface 129#define xdg_wm_base_interface _glfw_xdg_wm_base_interface 130#define xdg_activation_v1_interface _glfw_xdg_activation_v1_interface 131#define xdg_activation_token_v1_interface _glfw_xdg_activation_token_v1_interface 132#define wl_surface_interface _glfw_wl_surface_interface 133#define wp_fractional_scale_v1_interface _glfw_wp_fractional_scale_v1_interface 134 135#define GLFW_WAYLAND_WINDOW_STATE _GLFWwindowWayland wl; 136#define GLFW_WAYLAND_LIBRARY_WINDOW_STATE _GLFWlibraryWayland wl; 137#define GLFW_WAYLAND_MONITOR_STATE _GLFWmonitorWayland wl; 138#define GLFW_WAYLAND_CURSOR_STATE _GLFWcursorWayland wl; 139 140struct wl_cursor_image { 141 uint32_t width; 142 uint32_t height; 143 uint32_t hotspot_x; 144 uint32_t hotspot_y; 145 uint32_t delay; 146}; 147struct wl_cursor { 148 unsigned int image_count; 149 struct wl_cursor_image** images; 150 char* name; 151}; 152typedef struct wl_cursor_theme* (* PFN_wl_cursor_theme_load)(const char*, int, struct wl_shm*); 153typedef void (* PFN_wl_cursor_theme_destroy)(struct wl_cursor_theme*); 154typedef struct wl_cursor* (* PFN_wl_cursor_theme_get_cursor)(struct wl_cursor_theme*, const char*); 155typedef struct wl_buffer* (* PFN_wl_cursor_image_get_buffer)(struct wl_cursor_image*); 156#define wl_cursor_theme_load _glfw.wl.cursor.theme_load 157#define wl_cursor_theme_destroy _glfw.wl.cursor.theme_destroy 158#define wl_cursor_theme_get_cursor _glfw.wl.cursor.theme_get_cursor 159#define wl_cursor_image_get_buffer _glfw.wl.cursor.image_get_buffer 160 161typedef struct wl_egl_window* (* PFN_wl_egl_window_create)(struct wl_surface*, int, int); 162typedef void (* PFN_wl_egl_window_destroy)(struct wl_egl_window*); 163typedef void (* PFN_wl_egl_window_resize)(struct wl_egl_window*, int, int, int, int); 164#define wl_egl_window_create _glfw.wl.egl.window_create 165#define wl_egl_window_destroy _glfw.wl.egl.window_destroy 166#define wl_egl_window_resize _glfw.wl.egl.window_resize 167 168typedef struct xkb_context* (* PFN_xkb_context_new)(enum xkb_context_flags); 169typedef void (* PFN_xkb_context_unref)(struct xkb_context*); 170typedef struct xkb_keymap* (* PFN_xkb_keymap_new_from_string)(struct xkb_context*, const char*, enum xkb_keymap_format, enum xkb_keymap_compile_flags); 171typedef void (* PFN_xkb_keymap_unref)(struct xkb_keymap*); 172typedef xkb_mod_index_t (* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap*, const char*); 173typedef int (* PFN_xkb_keymap_key_repeats)(struct xkb_keymap*, xkb_keycode_t); 174typedef int (* PFN_xkb_keymap_key_get_syms_by_level)(struct xkb_keymap*,xkb_keycode_t,xkb_layout_index_t,xkb_level_index_t,const xkb_keysym_t**); 175typedef struct xkb_state* (* PFN_xkb_state_new)(struct xkb_keymap*); 176typedef void (* PFN_xkb_state_unref)(struct xkb_state*); 177typedef int (* PFN_xkb_state_key_get_syms)(struct xkb_state*, xkb_keycode_t, const xkb_keysym_t**); 178typedef 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); 179typedef xkb_layout_index_t (* PFN_xkb_state_key_get_layout)(struct xkb_state*,xkb_keycode_t); 180typedef int (* PFN_xkb_state_mod_index_is_active)(struct xkb_state*,xkb_mod_index_t,enum xkb_state_component); 181#define xkb_context_new _glfw.wl.xkb.context_new 182#define xkb_context_unref _glfw.wl.xkb.context_unref 183#define xkb_keymap_new_from_string _glfw.wl.xkb.keymap_new_from_string 184#define xkb_keymap_unref _glfw.wl.xkb.keymap_unref 185#define xkb_keymap_mod_get_index _glfw.wl.xkb.keymap_mod_get_index 186#define xkb_keymap_key_repeats _glfw.wl.xkb.keymap_key_repeats 187#define xkb_keymap_key_get_syms_by_level _glfw.wl.xkb.keymap_key_get_syms_by_level 188#define xkb_state_new _glfw.wl.xkb.state_new 189#define xkb_state_unref _glfw.wl.xkb.state_unref 190#define xkb_state_key_get_syms _glfw.wl.xkb.state_key_get_syms 191#define xkb_state_update_mask _glfw.wl.xkb.state_update_mask 192#define xkb_state_key_get_layout _glfw.wl.xkb.state_key_get_layout 193#define xkb_state_mod_index_is_active _glfw.wl.xkb.state_mod_index_is_active 194 195typedef struct xkb_compose_table* (* PFN_xkb_compose_table_new_from_locale)(struct xkb_context*, const char*, enum xkb_compose_compile_flags); 196typedef void (* PFN_xkb_compose_table_unref)(struct xkb_compose_table*); 197typedef struct xkb_compose_state* (* PFN_xkb_compose_state_new)(struct xkb_compose_table*, enum xkb_compose_state_flags); 198typedef void (* PFN_xkb_compose_state_unref)(struct xkb_compose_state*); 199typedef enum xkb_compose_feed_result (* PFN_xkb_compose_state_feed)(struct xkb_compose_state*, xkb_keysym_t); 200typedef enum xkb_compose_status (* PFN_xkb_compose_state_get_status)(struct xkb_compose_state*); 201typedef xkb_keysym_t (* PFN_xkb_compose_state_get_one_sym)(struct xkb_compose_state*); 202#define xkb_compose_table_new_from_locale _glfw.wl.xkb.compose_table_new_from_locale 203#define xkb_compose_table_unref _glfw.wl.xkb.compose_table_unref 204#define xkb_compose_state_new _glfw.wl.xkb.compose_state_new 205#define xkb_compose_state_unref _glfw.wl.xkb.compose_state_unref 206#define xkb_compose_state_feed _glfw.wl.xkb.compose_state_feed 207#define xkb_compose_state_get_status _glfw.wl.xkb.compose_state_get_status 208#define xkb_compose_state_get_one_sym _glfw.wl.xkb.compose_state_get_one_sym 209 210struct libdecor; 211struct libdecor_frame; 212struct libdecor_state; 213struct libdecor_configuration; 214 215enum libdecor_error 216{ 217 LIBDECOR_ERROR_COMPOSITOR_INCOMPATIBLE, 218 LIBDECOR_ERROR_INVALID_FRAME_CONFIGURATION, 219}; 220 221enum libdecor_window_state 222{ 223 LIBDECOR_WINDOW_STATE_NONE = 0, 224 LIBDECOR_WINDOW_STATE_ACTIVE = 1, 225 LIBDECOR_WINDOW_STATE_MAXIMIZED = 2, 226 LIBDECOR_WINDOW_STATE_FULLSCREEN = 4, 227 LIBDECOR_WINDOW_STATE_TILED_LEFT = 8, 228 LIBDECOR_WINDOW_STATE_TILED_RIGHT = 16, 229 LIBDECOR_WINDOW_STATE_TILED_TOP = 32, 230 LIBDECOR_WINDOW_STATE_TILED_BOTTOM = 64 231}; 232 233enum libdecor_capabilities 234{ 235 LIBDECOR_ACTION_MOVE = 1, 236 LIBDECOR_ACTION_RESIZE = 2, 237 LIBDECOR_ACTION_MINIMIZE = 4, 238 LIBDECOR_ACTION_FULLSCREEN = 8, 239 LIBDECOR_ACTION_CLOSE = 16 240}; 241 242struct libdecor_interface 243{ 244 void (* error)(struct libdecor*,enum libdecor_error,const char*); 245 void (* reserved0)(void); 246 void (* reserved1)(void); 247 void (* reserved2)(void); 248 void (* reserved3)(void); 249 void (* reserved4)(void); 250 void (* reserved5)(void); 251 void (* reserved6)(void); 252 void (* reserved7)(void); 253 void (* reserved8)(void); 254 void (* reserved9)(void); 255}; 256 257struct libdecor_frame_interface 258{ 259 void (* configure)(struct libdecor_frame*,struct libdecor_configuration*,void*); 260 void (* close)(struct libdecor_frame*,void*); 261 void (* commit)(struct libdecor_frame*,void*); 262 void (* dismiss_popup)(struct libdecor_frame*,const char*,void*); 263 void (* reserved0)(void); 264 void (* reserved1)(void); 265 void (* reserved2)(void); 266 void (* reserved3)(void); 267 void (* reserved4)(void); 268 void (* reserved5)(void); 269 void (* reserved6)(void); 270 void (* reserved7)(void); 271 void (* reserved8)(void); 272 void (* reserved9)(void); 273}; 274 275typedef struct libdecor* (* PFN_libdecor_new)(struct wl_display*,const struct libdecor_interface*); 276typedef void (* PFN_libdecor_unref)(struct libdecor*); 277typedef int (* PFN_libdecor_get_fd)(struct libdecor*); 278typedef int (* PFN_libdecor_dispatch)(struct libdecor*,int); 279typedef struct libdecor_frame* (* PFN_libdecor_decorate)(struct libdecor*,struct wl_surface*,const struct libdecor_frame_interface*,void*); 280typedef void (* PFN_libdecor_frame_unref)(struct libdecor_frame*); 281typedef void (* PFN_libdecor_frame_set_app_id)(struct libdecor_frame*,const char*); 282typedef void (* PFN_libdecor_frame_set_title)(struct libdecor_frame*,const char*); 283typedef void (* PFN_libdecor_frame_set_minimized)(struct libdecor_frame*); 284typedef void (* PFN_libdecor_frame_set_fullscreen)(struct libdecor_frame*,struct wl_output*); 285typedef void (* PFN_libdecor_frame_unset_fullscreen)(struct libdecor_frame*); 286typedef void (* PFN_libdecor_frame_map)(struct libdecor_frame*); 287typedef void (* PFN_libdecor_frame_commit)(struct libdecor_frame*,struct libdecor_state*,struct libdecor_configuration*); 288typedef void (* PFN_libdecor_frame_set_min_content_size)(struct libdecor_frame*,int,int); 289typedef void (* PFN_libdecor_frame_set_max_content_size)(struct libdecor_frame*,int,int); 290typedef void (* PFN_libdecor_frame_set_maximized)(struct libdecor_frame*); 291typedef void (* PFN_libdecor_frame_unset_maximized)(struct libdecor_frame*); 292typedef void (* PFN_libdecor_frame_set_capabilities)(struct libdecor_frame*,enum libdecor_capabilities); 293typedef void (* PFN_libdecor_frame_unset_capabilities)(struct libdecor_frame*,enum libdecor_capabilities); 294typedef void (* PFN_libdecor_frame_set_visibility)(struct libdecor_frame*,bool visible); 295typedef struct xdg_toplevel* (* PFN_libdecor_frame_get_xdg_toplevel)(struct libdecor_frame*); 296typedef bool (* PFN_libdecor_configuration_get_content_size)(struct libdecor_configuration*,struct libdecor_frame*,int*,int*); 297typedef bool (* PFN_libdecor_configuration_get_window_state)(struct libdecor_configuration*,enum libdecor_window_state*); 298typedef struct libdecor_state* (* PFN_libdecor_state_new)(int,int); 299typedef void (* PFN_libdecor_state_free)(struct libdecor_state*); 300#define libdecor_new _glfw.wl.libdecor.libdecor_new_ 301#define libdecor_unref _glfw.wl.libdecor.libdecor_unref_ 302#define libdecor_get_fd _glfw.wl.libdecor.libdecor_get_fd_ 303#define libdecor_dispatch _glfw.wl.libdecor.libdecor_dispatch_ 304#define libdecor_decorate _glfw.wl.libdecor.libdecor_decorate_ 305#define libdecor_frame_unref _glfw.wl.libdecor.libdecor_frame_unref_ 306#define libdecor_frame_set_app_id _glfw.wl.libdecor.libdecor_frame_set_app_id_ 307#define libdecor_frame_set_title _glfw.wl.libdecor.libdecor_frame_set_title_ 308#define libdecor_frame_set_minimized _glfw.wl.libdecor.libdecor_frame_set_minimized_ 309#define libdecor_frame_set_fullscreen _glfw.wl.libdecor.libdecor_frame_set_fullscreen_ 310#define libdecor_frame_unset_fullscreen _glfw.wl.libdecor.libdecor_frame_unset_fullscreen_ 311#define libdecor_frame_map _glfw.wl.libdecor.libdecor_frame_map_ 312#define libdecor_frame_commit _glfw.wl.libdecor.libdecor_frame_commit_ 313#define libdecor_frame_set_min_content_size _glfw.wl.libdecor.libdecor_frame_set_min_content_size_ 314#define libdecor_frame_set_max_content_size _glfw.wl.libdecor.libdecor_frame_set_max_content_size_ 315#define libdecor_frame_set_maximized _glfw.wl.libdecor.libdecor_frame_set_maximized_ 316#define libdecor_frame_unset_maximized _glfw.wl.libdecor.libdecor_frame_unset_maximized_ 317#define libdecor_frame_set_capabilities _glfw.wl.libdecor.libdecor_frame_set_capabilities_ 318#define libdecor_frame_unset_capabilities _glfw.wl.libdecor.libdecor_frame_unset_capabilities_ 319#define libdecor_frame_set_visibility _glfw.wl.libdecor.libdecor_frame_set_visibility_ 320#define libdecor_frame_get_xdg_toplevel _glfw.wl.libdecor.libdecor_frame_get_xdg_toplevel_ 321#define libdecor_configuration_get_content_size _glfw.wl.libdecor.libdecor_configuration_get_content_size_ 322#define libdecor_configuration_get_window_state _glfw.wl.libdecor.libdecor_configuration_get_window_state_ 323#define libdecor_state_new _glfw.wl.libdecor.libdecor_state_new_ 324#define libdecor_state_free _glfw.wl.libdecor.libdecor_state_free_ 325 326typedef struct _GLFWfallbackEdgeWayland 327{ 328 struct wl_surface* surface; 329 struct wl_subsurface* subsurface; 330 struct wp_viewport* viewport; 331} _GLFWfallbackEdgeWayland; 332 333typedef struct _GLFWofferWayland 334{ 335 struct wl_data_offer* offer; 336 GLFWbool text_plain_utf8; 337 GLFWbool text_uri_list; 338} _GLFWofferWayland; 339 340typedef struct _GLFWscaleWayland 341{ 342 struct wl_output* output; 343 int32_t factor; 344} _GLFWscaleWayland; 345 346// Wayland-specific per-window data 347// 348typedef struct _GLFWwindowWayland 349{ 350 int width, height; 351 int fbWidth, fbHeight; 352 GLFWbool visible; 353 GLFWbool maximized; 354 GLFWbool activated; 355 GLFWbool fullscreen; 356 GLFWbool hovered; 357 GLFWbool transparent; 358 GLFWbool scaleFramebuffer; 359 struct wl_surface* surface; 360 struct wl_callback* callback; 361 362 struct { 363 struct wl_egl_window* window; 364 } egl; 365 366 struct { 367 int width, height; 368 GLFWbool maximized; 369 GLFWbool iconified; 370 GLFWbool activated; 371 GLFWbool fullscreen; 372 } pending; 373 374 struct { 375 struct xdg_surface* surface; 376 struct xdg_toplevel* toplevel; 377 struct zxdg_toplevel_decoration_v1* decoration; 378 uint32_t decorationMode; 379 } xdg; 380 381 struct { 382 struct libdecor_frame* frame; 383 } libdecor; 384 385 _GLFWcursor* currentCursor; 386 double cursorPosX, cursorPosY; 387 388 char* appId; 389 390 // We need to track the monitors the window spans on to calculate the 391 // optimal scaling factor. 392 int32_t bufferScale; 393 _GLFWscaleWayland* outputScales; 394 size_t outputScaleCount; 395 size_t outputScaleSize; 396 397 struct wp_viewport* scalingViewport; 398 uint32_t scalingNumerator; 399 struct wp_fractional_scale_v1* fractionalScale; 400 401 struct zwp_relative_pointer_v1* relativePointer; 402 struct zwp_locked_pointer_v1* lockedPointer; 403 struct zwp_confined_pointer_v1* confinedPointer; 404 405 struct zwp_idle_inhibitor_v1* idleInhibitor; 406 struct xdg_activation_token_v1* activationToken; 407 408 struct { 409 GLFWbool decorations; 410 struct wl_buffer* buffer; 411 _GLFWfallbackEdgeWayland top, left, right, bottom; 412 struct wl_surface* focus; 413 } fallback; 414} _GLFWwindowWayland; 415 416// Wayland-specific global data 417// 418typedef struct _GLFWlibraryWayland 419{ 420 struct wl_display* display; 421 struct wl_registry* registry; 422 struct wl_compositor* compositor; 423 struct wl_subcompositor* subcompositor; 424 struct wl_shm* shm; 425 struct wl_seat* seat; 426 struct wl_pointer* pointer; 427 struct wl_keyboard* keyboard; 428 struct wl_data_device_manager* dataDeviceManager; 429 struct wl_data_device* dataDevice; 430 struct xdg_wm_base* wmBase; 431 struct zxdg_decoration_manager_v1* decorationManager; 432 struct wp_viewporter* viewporter; 433 struct zwp_relative_pointer_manager_v1* relativePointerManager; 434 struct zwp_pointer_constraints_v1* pointerConstraints; 435 struct zwp_idle_inhibit_manager_v1* idleInhibitManager; 436 struct xdg_activation_v1* activationManager; 437 struct wp_fractional_scale_manager_v1* fractionalScaleManager; 438 439 _GLFWofferWayland* offers; 440 unsigned int offerCount; 441 442 struct wl_data_offer* selectionOffer; 443 struct wl_data_source* selectionSource; 444 445 struct wl_data_offer* dragOffer; 446 _GLFWwindow* dragFocus; 447 uint32_t dragSerial; 448 449 const char* tag; 450 451 struct wl_cursor_theme* cursorTheme; 452 struct wl_cursor_theme* cursorThemeHiDPI; 453 struct wl_surface* cursorSurface; 454 const char* cursorPreviousName; 455 int cursorTimerfd; 456 uint32_t serial; 457 uint32_t pointerEnterSerial; 458 459 int keyRepeatTimerfd; 460 int32_t keyRepeatRate; 461 int32_t keyRepeatDelay; 462 int keyRepeatScancode; 463 464 char* clipboardString; 465 short int keycodes[256]; 466 short int scancodes[GLFW_KEY_LAST + 1]; 467 char keynames[GLFW_KEY_LAST + 1][5]; 468 469 struct { 470 void* handle; 471 struct xkb_context* context; 472 struct xkb_keymap* keymap; 473 struct xkb_state* state; 474 475 struct xkb_compose_state* composeState; 476 477 xkb_mod_index_t controlIndex; 478 xkb_mod_index_t altIndex; 479 xkb_mod_index_t shiftIndex; 480 xkb_mod_index_t superIndex; 481 xkb_mod_index_t capsLockIndex; 482 xkb_mod_index_t numLockIndex; 483 unsigned int modifiers; 484 485 PFN_xkb_context_new context_new; 486 PFN_xkb_context_unref context_unref; 487 PFN_xkb_keymap_new_from_string keymap_new_from_string; 488 PFN_xkb_keymap_unref keymap_unref; 489 PFN_xkb_keymap_mod_get_index keymap_mod_get_index; 490 PFN_xkb_keymap_key_repeats keymap_key_repeats; 491 PFN_xkb_keymap_key_get_syms_by_level keymap_key_get_syms_by_level; 492 PFN_xkb_state_new state_new; 493 PFN_xkb_state_unref state_unref; 494 PFN_xkb_state_key_get_syms state_key_get_syms; 495 PFN_xkb_state_update_mask state_update_mask; 496 PFN_xkb_state_key_get_layout state_key_get_layout; 497 PFN_xkb_state_mod_index_is_active state_mod_index_is_active; 498 499 PFN_xkb_compose_table_new_from_locale compose_table_new_from_locale; 500 PFN_xkb_compose_table_unref compose_table_unref; 501 PFN_xkb_compose_state_new compose_state_new; 502 PFN_xkb_compose_state_unref compose_state_unref; 503 PFN_xkb_compose_state_feed compose_state_feed; 504 PFN_xkb_compose_state_get_status compose_state_get_status; 505 PFN_xkb_compose_state_get_one_sym compose_state_get_one_sym; 506 } xkb; 507 508 _GLFWwindow* pointerFocus; 509 _GLFWwindow* keyboardFocus; 510 511 struct { 512 void* handle; 513 PFN_wl_display_flush display_flush; 514 PFN_wl_display_cancel_read display_cancel_read; 515 PFN_wl_display_dispatch_pending display_dispatch_pending; 516 PFN_wl_display_read_events display_read_events; 517 PFN_wl_display_disconnect display_disconnect; 518 PFN_wl_display_roundtrip display_roundtrip; 519 PFN_wl_display_get_fd display_get_fd; 520 PFN_wl_display_prepare_read display_prepare_read; 521 PFN_wl_proxy_marshal proxy_marshal; 522 PFN_wl_proxy_add_listener proxy_add_listener; 523 PFN_wl_proxy_destroy proxy_destroy; 524 PFN_wl_proxy_marshal_constructor proxy_marshal_constructor; 525 PFN_wl_proxy_marshal_constructor_versioned proxy_marshal_constructor_versioned; 526 PFN_wl_proxy_get_user_data proxy_get_user_data; 527 PFN_wl_proxy_set_user_data proxy_set_user_data; 528 PFN_wl_proxy_get_tag proxy_get_tag; 529 PFN_wl_proxy_set_tag proxy_set_tag; 530 PFN_wl_proxy_get_version proxy_get_version; 531 PFN_wl_proxy_marshal_flags proxy_marshal_flags; 532 } client; 533 534 struct { 535 void* handle; 536 537 PFN_wl_cursor_theme_load theme_load; 538 PFN_wl_cursor_theme_destroy theme_destroy; 539 PFN_wl_cursor_theme_get_cursor theme_get_cursor; 540 PFN_wl_cursor_image_get_buffer image_get_buffer; 541 } cursor; 542 543 struct { 544 void* handle; 545 546 PFN_wl_egl_window_create window_create; 547 PFN_wl_egl_window_destroy window_destroy; 548 PFN_wl_egl_window_resize window_resize; 549 } egl; 550 551 struct { 552 void* handle; 553 struct libdecor* context; 554 struct wl_callback* callback; 555 GLFWbool ready; 556 PFN_libdecor_new libdecor_new_; 557 PFN_libdecor_unref libdecor_unref_; 558 PFN_libdecor_get_fd libdecor_get_fd_; 559 PFN_libdecor_dispatch libdecor_dispatch_; 560 PFN_libdecor_decorate libdecor_decorate_; 561 PFN_libdecor_frame_unref libdecor_frame_unref_; 562 PFN_libdecor_frame_set_app_id libdecor_frame_set_app_id_; 563 PFN_libdecor_frame_set_title libdecor_frame_set_title_; 564 PFN_libdecor_frame_set_minimized libdecor_frame_set_minimized_; 565 PFN_libdecor_frame_set_fullscreen libdecor_frame_set_fullscreen_; 566 PFN_libdecor_frame_unset_fullscreen libdecor_frame_unset_fullscreen_; 567 PFN_libdecor_frame_map libdecor_frame_map_; 568 PFN_libdecor_frame_commit libdecor_frame_commit_; 569 PFN_libdecor_frame_set_min_content_size libdecor_frame_set_min_content_size_; 570 PFN_libdecor_frame_set_max_content_size libdecor_frame_set_max_content_size_; 571 PFN_libdecor_frame_set_maximized libdecor_frame_set_maximized_; 572 PFN_libdecor_frame_unset_maximized libdecor_frame_unset_maximized_; 573 PFN_libdecor_frame_set_capabilities libdecor_frame_set_capabilities_; 574 PFN_libdecor_frame_unset_capabilities libdecor_frame_unset_capabilities_; 575 PFN_libdecor_frame_set_visibility libdecor_frame_set_visibility_; 576 PFN_libdecor_frame_get_xdg_toplevel libdecor_frame_get_xdg_toplevel_; 577 PFN_libdecor_configuration_get_content_size libdecor_configuration_get_content_size_; 578 PFN_libdecor_configuration_get_window_state libdecor_configuration_get_window_state_; 579 PFN_libdecor_state_new libdecor_state_new_; 580 PFN_libdecor_state_free libdecor_state_free_; 581 } libdecor; 582} _GLFWlibraryWayland; 583 584// Wayland-specific per-monitor data 585// 586typedef struct _GLFWmonitorWayland 587{ 588 struct wl_output* output; 589 uint32_t name; 590 int currentMode; 591 592 int x; 593 int y; 594 int32_t scale; 595} _GLFWmonitorWayland; 596 597// Wayland-specific per-cursor data 598// 599typedef struct _GLFWcursorWayland 600{ 601 struct wl_cursor* cursor; 602 struct wl_cursor* cursorHiDPI; 603 struct wl_buffer* buffer; 604 int width, height; 605 int xhot, yhot; 606 int currentImage; 607} _GLFWcursorWayland; 608 609GLFWbool _glfwConnectWayland(int platformID, _GLFWplatform* platform); 610int _glfwInitWayland(void); 611void _glfwTerminateWayland(void); 612 613GLFWbool _glfwCreateWindowWayland(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWctxconfig* ctxconfig, const _GLFWfbconfig* fbconfig); 614void _glfwDestroyWindowWayland(_GLFWwindow* window); 615void _glfwSetWindowTitleWayland(_GLFWwindow* window, const char* title); 616void _glfwSetWindowIconWayland(_GLFWwindow* window, int count, const GLFWimage* images); 617void _glfwGetWindowPosWayland(_GLFWwindow* window, int* xpos, int* ypos); 618void _glfwSetWindowPosWayland(_GLFWwindow* window, int xpos, int ypos); 619void _glfwGetWindowSizeWayland(_GLFWwindow* window, int* width, int* height); 620void _glfwSetWindowSizeWayland(_GLFWwindow* window, int width, int height); 621void _glfwSetWindowSizeLimitsWayland(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight); 622void _glfwSetWindowAspectRatioWayland(_GLFWwindow* window, int numer, int denom); 623void _glfwGetFramebufferSizeWayland(_GLFWwindow* window, int* width, int* height); 624void _glfwGetWindowFrameSizeWayland(_GLFWwindow* window, int* left, int* top, int* right, int* bottom); 625void _glfwGetWindowContentScaleWayland(_GLFWwindow* window, float* xscale, float* yscale); 626void _glfwIconifyWindowWayland(_GLFWwindow* window); 627void _glfwRestoreWindowWayland(_GLFWwindow* window); 628void _glfwMaximizeWindowWayland(_GLFWwindow* window); 629void _glfwShowWindowWayland(_GLFWwindow* window); 630void _glfwHideWindowWayland(_GLFWwindow* window); 631void _glfwRequestWindowAttentionWayland(_GLFWwindow* window); 632void _glfwFocusWindowWayland(_GLFWwindow* window); 633void _glfwSetWindowMonitorWayland(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); 634GLFWbool _glfwWindowFocusedWayland(_GLFWwindow* window); 635GLFWbool _glfwWindowIconifiedWayland(_GLFWwindow* window); 636GLFWbool _glfwWindowVisibleWayland(_GLFWwindow* window); 637GLFWbool _glfwWindowMaximizedWayland(_GLFWwindow* window); 638GLFWbool _glfwWindowHoveredWayland(_GLFWwindow* window); 639GLFWbool _glfwFramebufferTransparentWayland(_GLFWwindow* window); 640void _glfwSetWindowResizableWayland(_GLFWwindow* window, GLFWbool enabled); 641void _glfwSetWindowDecoratedWayland(_GLFWwindow* window, GLFWbool enabled); 642void _glfwSetWindowFloatingWayland(_GLFWwindow* window, GLFWbool enabled); 643float _glfwGetWindowOpacityWayland(_GLFWwindow* window); 644void _glfwSetWindowOpacityWayland(_GLFWwindow* window, float opacity); 645void _glfwSetWindowMousePassthroughWayland(_GLFWwindow* window, GLFWbool enabled); 646 647void _glfwSetRawMouseMotionWayland(_GLFWwindow* window, GLFWbool enabled); 648GLFWbool _glfwRawMouseMotionSupportedWayland(void); 649 650void _glfwPollEventsWayland(void); 651void _glfwWaitEventsWayland(void); 652void _glfwWaitEventsTimeoutWayland(double timeout); 653void _glfwPostEmptyEventWayland(void); 654 655void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos); 656void _glfwSetCursorPosWayland(_GLFWwindow* window, double xpos, double ypos); 657void _glfwSetCursorModeWayland(_GLFWwindow* window, int mode); 658const char* _glfwGetScancodeNameWayland(int scancode); 659int _glfwGetKeyScancodeWayland(int key); 660GLFWbool _glfwCreateCursorWayland(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot); 661GLFWbool _glfwCreateStandardCursorWayland(_GLFWcursor* cursor, int shape); 662void _glfwDestroyCursorWayland(_GLFWcursor* cursor); 663void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor); 664void _glfwSetClipboardStringWayland(const char* string); 665const char* _glfwGetClipboardStringWayland(void); 666 667EGLenum _glfwGetEGLPlatformWayland(EGLint** attribs); 668EGLNativeDisplayType _glfwGetEGLNativeDisplayWayland(void); 669EGLNativeWindowType _glfwGetEGLNativeWindowWayland(_GLFWwindow* window); 670 671void _glfwGetRequiredInstanceExtensionsWayland(char** extensions); 672GLFWbool _glfwGetPhysicalDevicePresentationSupportWayland(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); 673VkResult _glfwCreateWindowSurfaceWayland(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); 674 675void _glfwFreeMonitorWayland(_GLFWmonitor* monitor); 676void _glfwGetMonitorPosWayland(_GLFWmonitor* monitor, int* xpos, int* ypos); 677void _glfwGetMonitorContentScaleWayland(_GLFWmonitor* monitor, float* xscale, float* yscale); 678void _glfwGetMonitorWorkareaWayland(_GLFWmonitor* monitor, int* xpos, int* ypos, int* width, int* height); 679GLFWvidmode* _glfwGetVideoModesWayland(_GLFWmonitor* monitor, int* count); 680GLFWbool _glfwGetVideoModeWayland(_GLFWmonitor* monitor, GLFWvidmode* mode); 681GLFWbool _glfwGetGammaRampWayland(_GLFWmonitor* monitor, GLFWgammaramp* ramp); 682void _glfwSetGammaRampWayland(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); 683 684void _glfwAddOutputWayland(uint32_t name, uint32_t version); 685void _glfwUpdateBufferScaleFromOutputsWayland(_GLFWwindow* window); 686 687void _glfwAddSeatListenerWayland(struct wl_seat* seat); 688void _glfwAddDataDeviceListenerWayland(struct wl_data_device* device); 689 690