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