vxx2 / vlib / sokol / sapp / sapp_linux.c.v
1183 lines · 1001 sloc · 36.0 KB · 106e6ec1141d9a4382a13e40641aadee6313c717
Raw
1@[has_globals]
2module sapp
3
4$if linux_wayland_session ? {
5 $if !sokol_wayland ? {
6 $compile_error('`gg`/`sokol.sapp` cannot run in a Wayland-only Linux session without `-d sokol_wayland`.')
7 }
8}
9
10#preinclude <X11/Xlib.h>
11#preinclude <X11/Xatom.h>
12#preinclude <X11/Xutil.h>
13#preinclude <X11/Xresource.h>
14#preinclude <X11/keysym.h>
15#preinclude <X11/XKBlib.h>
16#preinclude <X11/Xcursor/Xcursor.h>
17#preinclude <X11/extensions/XInput2.h>
18
19// C library bindings for Linux Wayland/X11 backends.
20// These declare the external C types and functions from:
21// - wayland-client, wayland-egl, wayland-cursor (when SOKOL_WAYLAND is defined)
22// - xkbcommon
23// - EGL
24// - Wayland protocol generated headers (when SOKOL_WAYLAND is defined)
25// - Linux syscalls (timerfd, mmap)
26
27$if sokol_wayland ? {
28 // === wayland-client core types ===
29
30 pub struct C.wl_display {}
31
32 pub struct C.wl_registry {}
33
34 pub struct C.wl_compositor {}
35
36 pub struct C.wl_surface {}
37
38 pub struct C.wl_seat {}
39
40 pub struct C.wl_pointer {}
41
42 pub struct C.wl_keyboard {}
43
44 pub struct C.wl_touch {}
45
46 pub struct C.wl_shm {}
47
48 pub struct C.wl_output {}
49
50 pub struct C.wl_data_device_manager {}
51
52 pub struct C.wl_data_device {}
53
54 pub struct C.wl_data_source {}
55
56 pub struct C.wl_data_offer {}
57
58 pub struct C.wl_proxy {}
59
60 pub struct C.wl_interface {}
61
62 pub struct C.wl_array {
63 size usize
64 alloc usize
65 data voidptr
66 }
67
68 // === wayland-client functions ===
69
70 fn C.wl_display_connect(name &char) &C.wl_display
71 fn C.wl_display_disconnect(display &C.wl_display)
72 fn C.wl_display_dispatch(display &C.wl_display) int
73 fn C.wl_display_dispatch_pending(display &C.wl_display) int
74 fn C.wl_display_roundtrip(display &C.wl_display) int
75 fn C.wl_display_flush(display &C.wl_display) int
76 fn C.wl_display_get_registry(display &C.wl_display) &C.wl_registry
77
78 fn C.wl_registry_bind(registry &C.wl_registry, name u32, iface &C.wl_interface, version u32) voidptr
79 fn C.wl_registry_destroy(registry &C.wl_registry)
80
81 fn C.wl_compositor_create_surface(compositor &C.wl_compositor) &C.wl_surface
82 fn C.wl_compositor_destroy(compositor &C.wl_compositor)
83
84 fn C.wl_surface_destroy(surface &C.wl_surface)
85 fn C.wl_surface_commit(surface &C.wl_surface)
86 fn C.wl_surface_set_buffer_scale(surface &C.wl_surface, scale i32)
87
88 fn C.wl_seat_get_pointer(seat &C.wl_seat) &C.wl_pointer
89 fn C.wl_seat_get_keyboard(seat &C.wl_seat) &C.wl_keyboard
90 fn C.wl_seat_get_touch(seat &C.wl_seat) &C.wl_touch
91 fn C.wl_seat_destroy(seat &C.wl_seat)
92
93 fn C.wl_pointer_destroy(pointer &C.wl_pointer)
94 fn C.wl_keyboard_destroy(keyboard &C.wl_keyboard)
95 fn C.wl_touch_destroy(touch &C.wl_touch)
96 fn C.wl_shm_destroy(shm &C.wl_shm)
97
98 fn C.wl_data_device_manager_get_data_device(manager &C.wl_data_device_manager, seat &C.wl_seat) &C.wl_data_device
99 fn C.wl_data_device_manager_create_data_source(manager &C.wl_data_device_manager) &C.wl_data_source
100 fn C.wl_data_device_destroy(device &C.wl_data_device)
101 fn C.wl_data_source_destroy(source &C.wl_data_source)
102 fn C.wl_data_source_offer(source &C.wl_data_source, mime_type &char)
103 fn C.wl_data_offer_destroy(offer &C.wl_data_offer)
104 fn C.wl_data_offer_receive(offer &C.wl_data_offer, mime_type &char, fd int)
105 fn C.wl_data_offer_accept(offer &C.wl_data_offer, serial u32, mime_type &char)
106 fn C.wl_data_offer_set_actions(offer &C.wl_data_offer, dnd_actions u32, preferred_action u32)
107 fn C.wl_data_offer_finish(offer &C.wl_data_offer)
108 fn C.wl_data_device_manager_destroy(manager &C.wl_data_device_manager)
109
110 fn C.wl_proxy_add_listener(proxy &C.wl_proxy, implementation voidptr, data voidptr) int
111 fn C.wl_proxy_get_version(proxy &C.wl_proxy) u32
112
113 fn C.wl_fixed_to_double(f i32) f64
114
115 // wl_registry_add_listener, wl_seat_add_listener, etc. are static inline functions
116 // that call wl_proxy_add_listener. We declare them as C functions since they're
117 // in the included headers.
118 fn C.wl_registry_add_listener(registry &C.wl_registry, listener voidptr, data voidptr) int
119 fn C.wl_seat_add_listener(seat &C.wl_seat, listener voidptr, data voidptr) int
120 fn C.wl_pointer_add_listener(pointer &C.wl_pointer, listener voidptr, data voidptr) int
121 fn C.wl_keyboard_add_listener(keyboard &C.wl_keyboard, listener voidptr, data voidptr) int
122 fn C.wl_data_device_add_listener(device &C.wl_data_device, listener voidptr, data voidptr) int
123 fn C.wl_data_offer_add_listener(offer &C.wl_data_offer, listener voidptr, data voidptr) int
124
125 // === wayland-egl ===
126
127 pub struct C.wl_egl_window {}
128
129 fn C.wl_egl_window_create(surface &C.wl_surface, width int, height int) &C.wl_egl_window
130 fn C.wl_egl_window_destroy(window &C.wl_egl_window)
131 fn C.wl_egl_window_resize(window &C.wl_egl_window, width int, height int, dx int, dy int)
132
133 // === wayland-cursor ===
134
135 pub struct C.wl_cursor_theme {}
136
137 pub struct C.wl_cursor {
138 image_count u32
139 images &&C.wl_cursor_image
140 name &char
141 }
142
143 pub struct C.wl_cursor_image {
144 width u32
145 height u32
146 hotspot_x u32
147 hotspot_y u32
148 delay u32
149 }
150
151 fn C.wl_cursor_theme_load(name &char, size int, shm &C.wl_shm) &C.wl_cursor_theme
152 fn C.wl_cursor_theme_destroy(theme &C.wl_cursor_theme)
153 fn C.wl_cursor_theme_get_cursor(theme &C.wl_cursor_theme, name &char) &C.wl_cursor
154 fn C.wl_cursor_image_get_buffer(image &C.wl_cursor_image) &C.wl_buffer
155
156 pub struct C.wl_buffer {}
157
158 fn C.wl_surface_attach(surface &C.wl_surface, buffer &C.wl_buffer, x i32, y i32)
159
160 // === Wayland protocol interfaces (extern globals from generated .c files) ===
161
162 #include "xdg-shell-client-protocol.h"
163 #include "fractional-scale-v1-client-protocol.h"
164 #include "cursor-shape-v1-client-protocol.h"
165 #include "pointer-constraints-unstable-v1-client-protocol.h"
166 #include "relative-pointer-unstable-v1-client-protocol.h"
167 #include "viewporter-client-protocol.h"
168 #include "xdg-decoration-unstable-v1-client-protocol.h"
169
170 // Protocol object types
171 pub struct C.xdg_wm_base {}
172
173 pub struct C.xdg_surface {}
174
175 pub struct C.xdg_toplevel {}
176
177 pub struct C.wp_fractional_scale_manager_v1 {}
178
179 pub struct C.wp_fractional_scale_v1 {}
180
181 pub struct C.wp_viewporter {}
182
183 pub struct C.wp_viewport {}
184
185 pub struct C.wp_cursor_shape_manager_v1 {}
186
187 pub struct C.wp_cursor_shape_device_v1 {}
188
189 pub struct C.zwp_pointer_constraints_v1 {}
190
191 pub struct C.zwp_locked_pointer_v1 {}
192
193 pub struct C.zwp_relative_pointer_manager_v1 {}
194
195 pub struct C.zwp_relative_pointer_v1 {}
196
197 pub struct C.zxdg_decoration_manager_v1 {}
198
199 pub struct C.zxdg_toplevel_decoration_v1 {}
200
201 // Protocol interface globals (extern const struct wl_interface defined in generated .c and system headers)
202 __global C.wl_compositor_interface C.wl_interface
203 __global C.wl_seat_interface C.wl_interface
204 __global C.wl_shm_interface C.wl_interface
205 __global C.wl_output_interface C.wl_interface
206 __global C.wl_data_device_manager_interface C.wl_interface
207 __global C.xdg_wm_base_interface C.wl_interface
208 __global C.xdg_surface_interface C.wl_interface
209 __global C.wp_fractional_scale_manager_v1_interface C.wl_interface
210 __global C.wp_viewporter_interface C.wl_interface
211 __global C.wp_cursor_shape_manager_v1_interface C.wl_interface
212 __global C.zwp_pointer_constraints_v1_interface C.wl_interface
213 __global C.zwp_relative_pointer_manager_v1_interface C.wl_interface
214 __global C.zxdg_decoration_manager_v1_interface C.wl_interface
215
216 // Protocol functions (static inline in generated headers)
217 fn C.xdg_wm_base_get_xdg_surface(wm_base &C.xdg_wm_base, surface &C.wl_surface) &C.xdg_surface
218 fn C.xdg_wm_base_destroy(wm_base &C.xdg_wm_base)
219 fn C.xdg_wm_base_pong(wm_base &C.xdg_wm_base, serial u32)
220
221 fn C.xdg_surface_get_toplevel(xdg_surface &C.xdg_surface) &C.xdg_toplevel
222 fn C.xdg_surface_ack_configure(xdg_surface &C.xdg_surface, serial u32)
223 fn C.xdg_surface_destroy(xdg_surface &C.xdg_surface)
224 fn C.xdg_surface_add_listener(xdg_surface &C.xdg_surface, listener voidptr, data voidptr) int
225
226 fn C.xdg_toplevel_set_title(toplevel &C.xdg_toplevel, title &char)
227 fn C.xdg_toplevel_set_app_id(toplevel &C.xdg_toplevel, app_id &char)
228 fn C.xdg_toplevel_set_fullscreen(toplevel &C.xdg_toplevel, output &C.wl_output)
229 fn C.xdg_toplevel_unset_fullscreen(toplevel &C.xdg_toplevel)
230 fn C.xdg_toplevel_set_min_size(toplevel &C.xdg_toplevel, width i32, height i32)
231 fn C.xdg_toplevel_set_max_size(toplevel &C.xdg_toplevel, width i32, height i32)
232 fn C.xdg_toplevel_destroy(toplevel &C.xdg_toplevel)
233 fn C.xdg_toplevel_add_listener(toplevel &C.xdg_toplevel, listener voidptr, data voidptr) int
234
235 fn C.wp_fractional_scale_manager_v1_get_fractional_scale(manager &C.wp_fractional_scale_manager_v1, surface &C.wl_surface) &C.wp_fractional_scale_v1
236 fn C.wp_fractional_scale_manager_v1_destroy(manager &C.wp_fractional_scale_manager_v1)
237 fn C.wp_fractional_scale_v1_add_listener(scale &C.wp_fractional_scale_v1, listener voidptr, data voidptr) int
238 fn C.wp_fractional_scale_v1_destroy(scale &C.wp_fractional_scale_v1)
239
240 fn C.wp_viewporter_get_viewport(viewporter &C.wp_viewporter, surface &C.wl_surface) &C.wp_viewport
241 fn C.wp_viewporter_destroy(viewporter &C.wp_viewporter)
242 fn C.wp_viewport_set_destination(viewport &C.wp_viewport, width i32, height i32)
243 fn C.wp_viewport_destroy(viewport &C.wp_viewport)
244
245 fn C.wp_cursor_shape_manager_v1_get_pointer(manager &C.wp_cursor_shape_manager_v1, pointer &C.wl_pointer) &C.wp_cursor_shape_device_v1
246 fn C.wp_cursor_shape_manager_v1_destroy(manager &C.wp_cursor_shape_manager_v1)
247 fn C.wp_cursor_shape_device_v1_set_shape(device &C.wp_cursor_shape_device_v1, serial u32, shape u32)
248 fn C.wp_cursor_shape_device_v1_destroy(device &C.wp_cursor_shape_device_v1)
249
250 fn C.zwp_pointer_constraints_v1_lock_pointer(constraints &C.zwp_pointer_constraints_v1, surface &C.wl_surface, pointer &C.wl_pointer, region voidptr, lifetime u32) &C.zwp_locked_pointer_v1
251 fn C.zwp_pointer_constraints_v1_destroy(constraints &C.zwp_pointer_constraints_v1)
252 fn C.zwp_locked_pointer_v1_destroy(locked &C.zwp_locked_pointer_v1)
253
254 fn C.zwp_relative_pointer_manager_v1_get_relative_pointer(manager &C.zwp_relative_pointer_manager_v1, pointer &C.wl_pointer) &C.zwp_relative_pointer_v1
255 fn C.zwp_relative_pointer_manager_v1_destroy(manager &C.zwp_relative_pointer_manager_v1)
256 fn C.zwp_relative_pointer_v1_destroy(rp &C.zwp_relative_pointer_v1)
257 fn C.zwp_relative_pointer_v1_add_listener(rp &C.zwp_relative_pointer_v1, listener voidptr, data voidptr) int
258
259 fn C.zxdg_decoration_manager_v1_get_toplevel_decoration(manager &C.zxdg_decoration_manager_v1, toplevel &C.xdg_toplevel) &C.zxdg_toplevel_decoration_v1
260 fn C.zxdg_decoration_manager_v1_destroy(manager &C.zxdg_decoration_manager_v1)
261 fn C.zxdg_toplevel_decoration_v1_set_mode(decoration &C.zxdg_toplevel_decoration_v1, mode u32)
262 fn C.zxdg_toplevel_decoration_v1_destroy(decoration &C.zxdg_toplevel_decoration_v1)
263
264 // === xkbcommon ===
265
266 pub struct C.xkb_context {}
267
268 pub struct C.xkb_keymap {}
269
270 pub struct C.xkb_state {}
271
272 pub struct C.xkb_compose_table {}
273
274 pub struct C.xkb_compose_state {}
275
276 pub type Xkb_keysym_t = u32
277
278 fn C.xkb_context_new(flags int) &C.xkb_context
279 fn C.xkb_context_unref(ctx &C.xkb_context)
280
281 fn C.xkb_keymap_new_from_string(ctx &C.xkb_context, str &char, format int, flags int) &C.xkb_keymap
282 fn C.xkb_keymap_unref(keymap &C.xkb_keymap)
283
284 fn C.xkb_state_new(keymap &C.xkb_keymap) &C.xkb_state
285 fn C.xkb_state_unref(state &C.xkb_state)
286 fn C.xkb_state_key_get_one_sym(state &C.xkb_state, key u32) Xkb_keysym_t
287 fn C.xkb_state_key_get_utf8(state &C.xkb_state, key u32, buf &char, size usize) int
288 fn C.xkb_state_update_mask(state &C.xkb_state, depressed u32, latched u32, locked u32, dep_group u32, lat_group u32, lock_group u32) int
289 fn C.xkb_state_mod_name_is_active(state &C.xkb_state, name &char, @type int) int
290
291 fn C.xkb_compose_table_new_from_locale(ctx &C.xkb_context, locale &char, flags int) &C.xkb_compose_table
292 fn C.xkb_compose_table_unref(table &C.xkb_compose_table)
293 fn C.xkb_compose_state_new(table &C.xkb_compose_table, flags int) &C.xkb_compose_state
294 fn C.xkb_compose_state_unref(state &C.xkb_compose_state)
295
296 // xkbcommon constants
297 const xkb_context_no_flags = 0
298 const xkb_keymap_format_text_v1 = 1
299 const xkb_keymap_compile_no_flags = 0
300 const xkb_state_mods_effective = 8
301 const xkb_mod_name_shift = c'Shift'
302 const xkb_mod_name_ctrl = c'Control'
303 const xkb_mod_name_alt = c'Mod1'
304 const xkb_mod_name_logo = c'Mod4'
305
306 // Wayland keyboard state constants
307 const wl_keyboard_keymap_format_xkb_v1 = u32(1)
308 const wl_keyboard_key_state_pressed = u32(1)
309 const wl_keyboard_key_state_released = u32(0)
310 const wl_pointer_button_state_pressed = u32(1)
311 const wl_pointer_button_state_released = u32(0)
312 const wl_pointer_axis_vertical_scroll = u32(0)
313 const wl_pointer_axis_horizontal_scroll = u32(1)
314
315 // wl_seat capabilities
316 const wl_seat_capability_pointer = u32(1)
317 const wl_seat_capability_keyboard = u32(2)
318 const wl_seat_capability_touch = u32(4)
319
320 // XDG toplevel states
321 const xdg_toplevel_state_maximized = u32(1)
322 const xdg_toplevel_state_fullscreen = u32(2)
323 const xdg_toplevel_state_resizing = u32(3)
324 const xdg_toplevel_state_activated = u32(4)
325
326 // zxdg_toplevel_decoration_v1 modes
327 const zxdg_toplevel_decoration_v1_mode_client_side = u32(1)
328 const zxdg_toplevel_decoration_v1_mode_server_side = u32(2)
329
330 // zwp_pointer_constraints_v1 lifetime
331 const zwp_pointer_constraints_v1_lifetime_persistent = u32(2)
332
333 // wl_data_device_manager DND actions
334 const wl_data_device_manager_dnd_action_copy = u32(1)
335
336 // wp_cursor_shape constants (matching sapp MouseCursor values)
337 const wp_cursor_shape_device_v1_shape_default = u32(1)
338 const wp_cursor_shape_device_v1_shape_text = u32(5)
339 const wp_cursor_shape_device_v1_shape_crosshair = u32(3)
340 const wp_cursor_shape_device_v1_shape_pointer = u32(29)
341 const wp_cursor_shape_device_v1_shape_ew_resize = u32(17)
342 const wp_cursor_shape_device_v1_shape_ns_resize = u32(19)
343 const wp_cursor_shape_device_v1_shape_nwse_resize = u32(14)
344 const wp_cursor_shape_device_v1_shape_nesw_resize = u32(12)
345 const wp_cursor_shape_device_v1_shape_all_scroll = u32(21)
346 const wp_cursor_shape_device_v1_shape_not_allowed = u32(25)
347
348 // MAP_FAILED
349 const map_failed = voidptr(usize(~u64(0)))
350
351 // Linux input event codes (from linux/input-event-codes.h)
352 const btn_left = 0x110
353 const btn_right = 0x111
354 const btn_middle = 0x112
355
356 // timerfd
357 #include <sys/timerfd.h>
358
359 pub struct C.itimerspec {
360 it_interval C.timespec
361 it_value C.timespec
362 }
363
364 pub struct C.timespec {
365 tv_sec i64
366 tv_nsec i64
367 }
368
369 fn C.timerfd_create(clockid int, flags int) int
370 fn C.timerfd_settime(fd int, flags int, new_value &C.itimerspec, old_value &C.itimerspec) int
371
372 const clock_monotonic = 1
373 const tfd_cloexec = 0o2000000
374 const tfd_nonblock = 0o4000
375}
376
377// === EGL (shared between Wayland and X11) ===
378
379pub type EGLDisplay = voidptr
380pub type EGLContext = voidptr
381pub type EGLSurface = voidptr
382pub type EGLConfig = voidptr
383pub type EGLNativeWindowType = voidptr
384pub type EGLint = i32
385
386fn C.eglGetDisplay(native_display voidptr) EGLDisplay
387fn C.eglInitialize(display EGLDisplay, major &EGLint, minor &EGLint) int
388fn C.eglTerminate(display EGLDisplay) int
389fn C.eglChooseConfig(display EGLDisplay, attribs &EGLint, configs &EGLConfig, config_size EGLint, num_configs &EGLint) int
390fn C.eglCreateContext(display EGLDisplay, config EGLConfig, share_ctx EGLContext, attribs &EGLint) EGLContext
391fn C.eglDestroyContext(display EGLDisplay, ctx EGLContext) int
392fn C.eglCreateWindowSurface(display EGLDisplay, config EGLConfig, window EGLNativeWindowType, attribs &EGLint) EGLSurface
393fn C.eglDestroySurface(display EGLDisplay, surface EGLSurface) int
394fn C.eglMakeCurrent(display EGLDisplay, draw EGLSurface, read EGLSurface, ctx EGLContext) int
395fn C.eglSwapBuffers(display EGLDisplay, surface EGLSurface) int
396fn C.eglSwapInterval(display EGLDisplay, interval EGLint) int
397fn C.eglGetError() EGLint
398fn C.eglBindAPI(api u32) int
399fn C.eglGetConfigAttrib(display EGLDisplay, config EGLConfig, attribute EGLint, value &EGLint) int
400
401// OpenGL
402fn C.glGetIntegerv(pname u32, data &i32)
403
404// EGL constants
405const egl_opengl_api = u32(0x30A2)
406const egl_opengl_es_api = u32(0x30A0)
407const egl_no_display = EGLDisplay(0)
408const egl_no_context = EGLContext(0)
409const egl_no_surface = EGLSurface(0)
410const egl_none = EGLint(0x3038)
411const egl_red_size = EGLint(0x3024)
412const egl_green_size = EGLint(0x3023)
413const egl_blue_size = EGLint(0x3022)
414const egl_alpha_size = EGLint(0x3021)
415const egl_depth_size = EGLint(0x3025)
416const egl_stencil_size = EGLint(0x3026)
417const egl_sample_buffers = EGLint(0x3032)
418const egl_samples = EGLint(0x3031)
419const egl_surface_type = EGLint(0x3033)
420const egl_window_bit = EGLint(0x0004)
421const egl_renderable_type = EGLint(0x3040)
422const egl_opengl_bit = EGLint(0x0008)
423const egl_opengl_es3_bit = EGLint(0x0040)
424const egl_context_major_version = EGLint(0x3098)
425const egl_context_minor_version = EGLint(0x30FB)
426const egl_context_opengl_profile_mask = EGLint(0x30FD)
427const egl_context_opengl_core_profile_bit = EGLint(0x00000001)
428const egl_true = 1
429const egl_false = 0
430
431// GL constants
432const gl_framebuffer_binding = u32(0x8CA6)
433
434// === Linux syscalls (shared) ===
435
436fn C.mmap(addr voidptr, length usize, prot int, flags int, fd int, offset i64) voidptr
437fn C.munmap(addr voidptr, length usize) int
438fn C.close(fd int) int
439fn C.read(fd int, buf voidptr, count usize) isize
440fn C.pipe(fds &int) int
441fn C.strcmp(s1 &char, s2 &char) int
442fn C.strncmp(s1 &char, s2 &char, n usize) int
443fn C.strlen(s &char) usize
444fn C.strtok(str &char, delim &char) &char
445fn C.strtol(str &char, endptr &&char, base int) i64
446fn C.memset(s voidptr, c int, n usize) voidptr
447fn C.atof(s &char) f64
448
449// mmap constants
450const prot_read = 1
451const map_private = 2
452
453// === X11 / Xlib types and functions ===
454
455#include <X11/Xlib.h>
456#include <X11/Xutil.h>
457#include <X11/Xresource.h>
458#include <X11/Xatom.h>
459#include <X11/keysym.h>
460#include <X11/XKBlib.h>
461#include <X11/extensions/XInput2.h>
462#include <X11/Xcursor/Xcursor.h>
463
464// X11 C typedefs are unsigned long based. Define them locally so V1 can
465// type-check scalar operations while keeping the public aliases compatible
466// with the shared x11 modules.
467pub type C.XID = u64
468pub type C.Atom = C.XID
469pub type C.Window = C.XID
470pub type C.Colormap = C.XID
471pub type C.Cursor = C.XID
472pub type C.KeySym = C.XID
473pub type C.Time = C.XID
474pub type C.VisualID = C.XID
475
476// X11 types
477pub type XID = C.XID
478pub type Atom = C.Atom
479pub type Window = C.Window
480pub type Colormap = C.Colormap
481pub type Cursor = C.Cursor
482pub type KeySym = C.KeySym
483pub type Time = C.Time
484pub type VisualID = C.VisualID
485pub type XlibULong = C.XID
486
487// X11 types are defined by X11 headers (#preinclude above)
488// Forward declarations for V type checking only
489@[typedef]
490pub struct C.Display {
491pub mut:
492 _ int // opaque - actual definition from X11 headers
493}
494
495@[typedef]
496pub struct C.Visual {
497pub mut:
498 _ int // opaque - actual definition from X11 headers
499}
500
501@[typedef]
502pub struct C.Screen {
503pub mut:
504 _ int // opaque - actual definition from X11 headers
505}
506
507@[typedef]
508pub struct C.XSelectionEvent {
509pub mut:
510 type int
511 display &C.Display = unsafe { nil }
512 requestor Window
513 selection Atom
514 target Atom
515 property Atom
516 time int
517}
518
519@[typedef]
520pub struct C.XSelectionClearEvent {
521pub mut:
522 window Window
523 selection Atom
524}
525
526@[typedef]
527pub struct C.XSelectionRequestEvent {
528pub mut:
529 display &C.Display = unsafe { nil }
530 owner Window
531 requestor Window
532 selection Atom
533 target Atom
534 property Atom
535 time int
536}
537
538@[typedef]
539pub struct C.XDestroyWindowEvent {
540pub mut:
541 window Window
542}
543
544@[typedef]
545pub struct C.XPropertyEvent {
546pub mut:
547 state int
548 atom Atom
549}
550
551@[typedef]
552pub struct C.XClientMessageEvent {
553pub mut:
554 window Window
555 format int
556 message_type Atom
557 data C.XClientMessageData
558}
559
560@[typedef]
561pub union C.XClientMessageData {
562pub mut:
563 b [20]u8
564 s [10]i16
565 l [5]i64
566}
567
568@[typedef]
569pub struct C.XGenericEventCookie {
570pub mut:
571 extension int
572 evtype int
573 data voidptr
574}
575
576@[typedef]
577pub struct C.XKeyEvent {
578pub mut:
579 keycode u32
580 state u32
581}
582
583@[typedef]
584pub struct C.XButtonEvent {
585pub mut:
586 button u32
587 state u32
588 x int
589 y int
590}
591
592@[typedef]
593pub struct C.XMotionEvent {
594pub mut:
595 x int
596 y int
597 state u32
598}
599
600@[typedef]
601pub struct C.XCrossingEvent {
602pub mut:
603 x int
604 y int
605 state u32
606}
607
608@[typedef]
609pub struct C.XFocusChangeEvent {
610pub mut:
611 mode int
612}
613
614@[typedef]
615pub union C.XEvent {
616pub mut:
617 type int
618 xclient C.XClientMessageEvent
619 xkey C.XKeyEvent
620 xbutton C.XButtonEvent
621 xmotion C.XMotionEvent
622 xcrossing C.XCrossingEvent
623 xfocus C.XFocusChangeEvent
624 xproperty C.XPropertyEvent
625 xselection C.XSelectionEvent
626 xselectionrequest C.XSelectionRequestEvent
627 xselectionclear C.XSelectionClearEvent
628 xdestroywindow C.XDestroyWindowEvent
629 xcookie C.XGenericEventCookie
630}
631
632pub struct C.XrmDatabase__rec {}
633
634pub type XrmDatabase = &C.XrmDatabase__rec
635
636pub struct C.XSetWindowAttributes {
637mut:
638 colormap Colormap
639 border_pixel u64
640 event_mask u64
641}
642
643@[typedef]
644pub struct C.XWindowAttributes {
645mut:
646 width int
647 height int
648 map_state int
649}
650
651pub struct C.XSizeHintsAspect {
652mut:
653 x int
654 y int
655}
656
657@[typedef]
658pub struct C.XSizeHints {
659mut:
660 flags i64
661 x int
662 y int
663 width int
664 height int
665 min_width int
666 min_height int
667 max_width int
668 max_height int
669 width_inc int
670 height_inc int
671 min_aspect C.XSizeHintsAspect
672 max_aspect C.XSizeHintsAspect
673 base_width int
674 base_height int
675 win_gravity int
676}
677
678pub struct C.XVisualInfo {
679mut:
680 visual &C.Visual = unsafe { nil }
681 visualid VisualID
682 depth int
683}
684
685// X11 event types are defined in vlib/x/x11/x11.v
686// XEvent union is defined here since it's used extensively in sokol
687
688pub union C.XEvent {
689pub mut:
690 @type int
691 xclient C.XClientMessageEvent
692 xkey C.XKeyEvent
693 xbutton C.XButtonEvent
694 xmotion C.XMotionEvent
695 xcrossing C.XCrossingEvent
696 xfocus C.XFocusChangeEvent
697 xproperty C.XPropertyEvent
698 xselection C.XSelectionEvent
699 xselectionrequest C.XSelectionRequestEvent
700 xselectionclear C.XSelectionClearEvent
701 xdestroywindow C.XDestroyWindowEvent
702 xcookie C.XGenericEventCookie
703}
704
705pub struct C.XKeyEvent {
706pub mut:
707 keycode u32
708 state u32
709}
710
711pub struct C.XButtonEvent {
712pub mut:
713 button u32
714 state u32
715 x int
716 y int
717}
718
719pub struct C.XMotionEvent {
720pub mut:
721 x int
722 y int
723 state u32
724}
725
726pub struct C.XCrossingEvent {
727pub mut:
728 x int
729 y int
730 state u32
731}
732
733pub struct C.XFocusChangeEvent {
734pub mut:
735 mode int
736}
737
738pub struct C.XPropertyEvent {
739pub mut:
740 state int
741 atom Atom
742}
743
744// XSelection* structs are forward-declared above
745// Full definitions come from X11 headers or clipboard module
746
747pub struct C.XClientMessageEvent {
748pub mut:
749 window Window
750 format int
751 message_type Atom
752 data C.XClientMessageData
753}
754
755pub union C.XClientMessageData {
756pub mut:
757 l [5]i64
758}
759
760pub struct C.XGenericEventCookie {
761pub mut:
762 extension int
763 evtype int
764 data voidptr
765}
766
767pub struct C.XrmValue {
768 addr &char = unsafe { nil }
769}
770
771// XKB types
772pub struct C.XkbDescRec {
773mut:
774 min_key_code u8
775 max_key_code u8
776 names &C.XkbNamesRec = unsafe { nil }
777}
778
779pub type XkbDescPtr = &C.XkbDescRec
780
781pub struct C.XkbNamesRec {
782mut:
783 keys &C.XkbKeyNameRec = unsafe { nil }
784 key_aliases &C.XkbKeyAliasRec = unsafe { nil }
785 num_key_aliases u8
786}
787
788pub struct C.XkbKeyNameRec {
789mut:
790 name [4]u8
791}
792
793pub struct C.XkbKeyAliasRec {
794mut:
795 real [4]u8
796 alias [4]u8
797}
798
799// XInput2 types
800pub struct C.XIEventMask {
801mut:
802 deviceid int
803 mask_len int
804 mask &u8 = unsafe { nil }
805}
806
807pub struct C.XIRawEvent {
808mut:
809 valuators C.XIValuatorState
810 raw_values &f64 = unsafe { nil }
811}
812
813pub struct C.XIValuatorState {
814mut:
815 mask_len int
816 mask &u8 = unsafe { nil }
817}
818
819// Xcursor types
820pub struct C.XcursorImage {
821mut:
822 width u32
823 height u32
824 xhot u32
825 yhot u32
826 pixels &u32 = unsafe { nil }
827}
828
829pub type XcursorPixel = u32
830
831// === Xlib functions ===
832
833fn C.XOpenDisplay(name &char) &C.Display
834fn C.XCloseDisplay(display &C.Display) int
835fn C.XDefaultScreen(display &C.Display) int
836fn C.XDefaultRootWindow(display &C.Display) Window
837fn C.XDefaultVisual(display &C.Display, screen int) &C.Visual
838fn C.XDefaultDepth(display &C.Display, screen int) int
839fn C.XDisplayWidth(display &C.Display, screen int) int
840fn C.XDisplayHeight(display &C.Display, screen int) int
841fn C.XDisplayWidthMM(display &C.Display, screen int) int
842fn C.XInternAtom(display &C.Display, name &char, only_if_exists int) Atom
843fn C.XCreateColormap(display &C.Display, window Window, visual &C.Visual, alloc int) Colormap
844fn C.XFreeColormap(display &C.Display, colormap Colormap) int
845fn C.XCreateWindow(display &C.Display, parent Window, x int, y int, width u32, height u32, border_width u32, depth int, class_ u32, visual &C.Visual, valuemask u64, attributes &C.XSetWindowAttributes) Window
846fn C.XDestroyWindow(display &C.Display, window Window) int
847fn C.XMapWindow(display &C.Display, window Window) int
848fn C.XUnmapWindow(display &C.Display, window Window) int
849fn C.XRaiseWindow(display &C.Display, window Window) int
850fn C.XFlush(display &C.Display) int
851fn C.XSync(display &C.Display, discard int) int
852fn C.XPending(display &C.Display) int
853fn C.XNextEvent(display &C.Display, event &C.XEvent) int
854fn C.XCheckTypedWindowEvent(display &C.Display, window Window, event_type int, event &C.XEvent) int
855fn C.XSendEvent(display &C.Display, window Window, propagate int, event_mask i64, event &C.XEvent) int
856fn C.XFilterEvent(event &C.XEvent, window Window) int
857fn C.XSetWMProtocols(display &C.Display, window Window, protocols &Atom, count int) int
858fn C.XSetWMNormalHints(display &C.Display, window Window, hints &C.XSizeHints) int
859fn C.XAllocSizeHints() &C.XSizeHints
860fn C.XGetWindowAttributes(display &C.Display, window Window, attrs &C.XWindowAttributes) int
861fn C.XGetWindowProperty(display &C.Display, window Window, property Atom, long_offset i64, long_length i64, delete int, req_type Atom, actual_type &Atom, actual_format &int, nitems &XlibULong, bytes_after &XlibULong, prop &&u8) int
862fn C.XChangeProperty(display &C.Display, window Window, property Atom, @type Atom, format int, mode int, data &u8, nelements int) int
863fn C.Xutf8SetWMProperties(display &C.Display, window Window, window_name &char, icon_name &char, argv &&char, argc int, normal_hints voidptr, wm_hints voidptr, class_hints voidptr)
864fn C.XSetSelectionOwner(display &C.Display, selection Atom, owner Window, time Time)
865fn C.XGetSelectionOwner(display &C.Display, selection Atom) Window
866fn C.XConvertSelection(display &C.Display, selection Atom, target Atom, property Atom, requestor Window, time Time)
867fn C.XFree(data voidptr) int
868fn C.XDefineCursor(display &C.Display, window Window, cursor Cursor) int
869fn C.XUndefineCursor(display &C.Display, window Window) int
870fn C.XCreateFontCursor(display &C.Display, shape u32) Cursor
871fn C.XFreeCursor(display &C.Display, cursor Cursor) int
872fn C.XGrabPointer(display &C.Display, grab_window Window, owner_events int, event_mask u32, pointer_mode int, keyboard_mode int, confine_to Window, cursor Cursor, time Time) int
873fn C.XUngrabPointer(display &C.Display, time Time) int
874fn C.XWarpPointer(display &C.Display, src_w Window, dst_w Window, src_x int, src_y int, src_width u32, src_height u32, dst_x int, dst_y int) int
875fn C.XSetErrorHandler(handler voidptr) voidptr
876fn C.XGetKeyboardMapping(display &C.Display, first_keycode u8, keycode_count int, keysyms_per_keycode &int) &KeySym
877fn C.XLookupString(event &C.XKeyEvent, buf &char, buf_len int, keysym &KeySym, status voidptr) int
878fn C.XQueryExtension(display &C.Display, name &char, major_opcode &int, first_event &int, first_error &int) int
879fn C.XResourceManagerString(display &C.Display) &char
880fn C.XGetVisualInfo(display &C.Display, vinfo_mask i64, vinfo_template &C.XVisualInfo, nitems &int) &C.XVisualInfo
881fn C.XInitThreads() int
882fn C.XrmInitialize()
883fn C.XrmGetStringDatabase(data &char) XrmDatabase
884fn C.XrmDestroyDatabase(db XrmDatabase)
885fn C.XrmGetResource(db XrmDatabase, str_name &char, str_class &char, str_type &&char, value &C.XrmValue) int
886fn C.XGetEventData(display &C.Display, cookie &C.XGenericEventCookie) int
887fn C.XFreeEventData(display &C.Display, cookie &C.XGenericEventCookie)
888
889// XKB functions
890fn C.XkbGetMap(display &C.Display, which u32, device_spec u32) XkbDescPtr
891fn C.XkbGetNames(display &C.Display, which u32, desc XkbDescPtr) int
892fn C.XkbFreeNames(desc XkbDescPtr, which u32, free_map int) int
893fn C.XkbFreeKeyboard(desc XkbDescPtr, which u32, free_all int) int
894fn C.XkbSetDetectableAutoRepeat(display &C.Display, detectable int, supported &int) int
895
896// XInput2 functions
897fn C.XIQueryVersion(display &C.Display, major &int, minor &int) int
898fn C.XISelectEvents(display &C.Display, window Window, masks &C.XIEventMask, num_masks int) int
899
900// Xcursor functions
901fn C.XcursorImageCreate(width int, height int) &C.XcursorImage
902fn C.XcursorImageDestroy(image &C.XcursorImage)
903fn C.XcursorImageLoadCursor(display &C.Display, image &C.XcursorImage) Cursor
904fn C.XcursorLibraryLoadImage(name &char, theme &char, size int) &C.XcursorImage
905fn C.XcursorGetTheme(display &C.Display) &char
906fn C.XcursorGetDefaultSize(display &C.Display) int
907
908// poll
909#include <poll.h>
910
911pub struct C.pollfd {
912mut:
913 fd int
914 events i16
915 revents i16
916}
917
918fn C.poll(fds &C.pollfd, nfds u64, timeout int) int
919
920fn C.ConnectionNumber(display &C.Display) int
921
922fn C.atof(str &char) f64
923fn C.strncmp(s1 &char, s2 &char, n usize) int
924
925// X11 constants
926const x_false = 0
927const x_true = 1
928const x_none = Atom(0)
929const x_window_none = Window(0)
930const x_colormap_none = Colormap(0)
931const x_cursor_none = Cursor(0)
932const xa_atom = Atom(4)
933const xa_cardinal = Atom(6)
934const alloc_none = 0
935const cw_border_pixel = u64(1 << 11)
936const cw_colormap = u64(1 << 13)
937const cw_event_mask = u64(1 << 11) // this is actually CWEventMask
938const input_output = u32(1)
939const structure_notify_mask = i64(1 << 17)
940const key_press_mask = i64(1 << 0)
941const key_release_mask = i64(1 << 1)
942const pointer_motion_mask = i64(1 << 6)
943const button_press_mask = i64(1 << 2)
944const button_release_mask = i64(1 << 3)
945const exposure_mask = i64(1 << 15)
946const focus_change_mask = i64(1 << 21)
947const visibility_change_mask = i64(1 << 16)
948const enter_window_mask = i64(1 << 4)
949const leave_window_mask = i64(1 << 5)
950const property_change_mask = i64(1 << 22)
951const substructure_notify_mask = i64(1 << 19)
952const substructure_redirect_mask = i64(1 << 20)
953const no_event_mask = i64(0)
954
955const prop_mode_replace = 0
956const pw_gravity = i64(1 << 9) // PWinGravity flag
957const center_gravity = 5
958
959const is_viewable = 2
960const visibility_notify = 15
961const normal_state = 1
962const iconic_state = 3
963const withdrawn_state = 0
964
965const current_time = Time(0)
966const grab_mode_async = 1
967
968// Event types
969const x_generic_event = 35
970const x_focus_in = 9
971const x_focus_out = 10
972const x_key_press = 2
973const x_key_release = 3
974const x_button_press = 4
975const x_button_release = 5
976const x_enter_notify = 7
977const x_leave_notify = 8
978const x_motion_notify = 6
979const x_property_notify = 28
980const x_selection_notify = 31
981const x_selection_request = 30
982const x_destroy_notify = 17
983const x_client_message = 33
984const property_new_value = 0
985
986const notify_grab = 1
987const notify_ungrab = 2
988
989// Mouse buttons
990const x_button1 = u32(1)
991const x_button2 = u32(2)
992const x_button3 = u32(3)
993
994// Modifier masks
995const shift_mask = u32(1 << 0)
996const control_mask = u32(1 << 2)
997const mod1_mask = u32(1 << 3) // Alt
998const mod4_mask = u32(1 << 6) // Super
999const button1_mask = u32(1 << 8)
1000const button2_mask = u32(1 << 9)
1001const button3_mask = u32(1 << 10)
1002
1003// Cursor shapes for XCreateFontCursor
1004const xc_left_ptr = u32(68)
1005const xc_xterm = u32(152)
1006const xc_crosshair = u32(34)
1007const xc_hand2 = u32(60)
1008const xc_sb_h_double_arrow = u32(108)
1009const xc_sb_v_double_arrow = u32(116)
1010const xc_fleur = u32(52)
1011
1012// XKB constants
1013const xkb_use_core_kbd = u32(0x0100)
1014const xkb_key_names_mask = u32(1 << 9)
1015const xkb_key_aliases_mask = u32(1 << 10)
1016const xkb_key_name_length = 4
1017
1018// XInput2 constants
1019const xi_all_master_devices = -1
1020const xi_raw_motion = 17
1021const pollin = i16(0x001)
1022
1023// XDnD
1024const x11_xdnd_version = 5
1025
1026// KeySym constants
1027const xk_escape = KeySym(0xff1b)
1028const xk_tab = KeySym(0xff09)
1029const xk_shift_l = KeySym(0xffe1)
1030const xk_shift_r = KeySym(0xffe2)
1031const xk_control_l = KeySym(0xffe3)
1032const xk_control_r = KeySym(0xffe4)
1033const xk_meta_l = KeySym(0xffe7)
1034const xk_alt_l = KeySym(0xffe9)
1035const xk_mode_switch = KeySym(0xff7e)
1036const xk_iso_level3_shift = KeySym(0xfe03)
1037const xk_meta_r = KeySym(0xffe8)
1038const xk_alt_r = KeySym(0xffea)
1039const xk_super_l = KeySym(0xffeb)
1040const xk_super_r = KeySym(0xffec)
1041const xk_menu = KeySym(0xff67)
1042const xk_num_lock = KeySym(0xff7f)
1043const xk_caps_lock = KeySym(0xffe5)
1044const xk_print = KeySym(0xff61)
1045const xk_scroll_lock = KeySym(0xff14)
1046const xk_pause = KeySym(0xff13)
1047const xk_delete = KeySym(0xffff)
1048const xk_backspace = KeySym(0xff08)
1049const xk_return = KeySym(0xff0d)
1050const xk_home = KeySym(0xff50)
1051const xk_end = KeySym(0xff57)
1052const xk_page_up = KeySym(0xff55)
1053const xk_page_down = KeySym(0xff56)
1054const xk_insert = KeySym(0xff63)
1055const xk_left = KeySym(0xff51)
1056const xk_right = KeySym(0xff53)
1057const xk_down = KeySym(0xff54)
1058const xk_up = KeySym(0xff52)
1059const xk_f1 = KeySym(0xffbe)
1060const xk_f2 = KeySym(0xffbf)
1061const xk_f3 = KeySym(0xffc0)
1062const xk_f4 = KeySym(0xffc1)
1063const xk_f5 = KeySym(0xffc2)
1064const xk_f6 = KeySym(0xffc3)
1065const xk_f7 = KeySym(0xffc4)
1066const xk_f8 = KeySym(0xffc5)
1067const xk_f9 = KeySym(0xffc6)
1068const xk_f10 = KeySym(0xffc7)
1069const xk_f11 = KeySym(0xffc8)
1070const xk_f12 = KeySym(0xffc9)
1071const xk_f13 = KeySym(0xffca)
1072const xk_f14 = KeySym(0xffcb)
1073const xk_f15 = KeySym(0xffcc)
1074const xk_f16 = KeySym(0xffcd)
1075const xk_f17 = KeySym(0xffce)
1076const xk_f18 = KeySym(0xffcf)
1077const xk_f19 = KeySym(0xffd0)
1078const xk_f20 = KeySym(0xffd1)
1079const xk_f21 = KeySym(0xffd2)
1080const xk_f22 = KeySym(0xffd3)
1081const xk_f23 = KeySym(0xffd4)
1082const xk_f24 = KeySym(0xffd5)
1083const xk_f25 = KeySym(0xffd6)
1084const xk_kp_divide = KeySym(0xffaf)
1085const xk_kp_multiply = KeySym(0xffaa)
1086const xk_kp_subtract = KeySym(0xffad)
1087const xk_kp_add = KeySym(0xffab)
1088const xk_kp_0 = KeySym(0xffb0)
1089const xk_kp_1 = KeySym(0xffb1)
1090const xk_kp_2 = KeySym(0xffb2)
1091const xk_kp_3 = KeySym(0xffb3)
1092const xk_kp_4 = KeySym(0xffb4)
1093const xk_kp_5 = KeySym(0xffb5)
1094const xk_kp_6 = KeySym(0xffb6)
1095const xk_kp_7 = KeySym(0xffb7)
1096const xk_kp_8 = KeySym(0xffb8)
1097const xk_kp_9 = KeySym(0xffb9)
1098const xk_kp_separator = KeySym(0xffac)
1099const xk_kp_decimal = KeySym(0xffae)
1100const xk_kp_equal = KeySym(0xffbd)
1101const xk_kp_enter = KeySym(0xff8d)
1102const xk_kp_insert = KeySym(0xff9e)
1103const xk_kp_end = KeySym(0xff9c)
1104const xk_kp_down = KeySym(0xff99)
1105const xk_kp_page_down = KeySym(0xff9b)
1106const xk_kp_left = KeySym(0xff96)
1107const xk_kp_right = KeySym(0xff98)
1108const xk_kp_home = KeySym(0xff95)
1109const xk_kp_up = KeySym(0xff97)
1110const xk_kp_page_up = KeySym(0xff9a)
1111const xk_kp_delete = KeySym(0xff9f)
1112const xk_a = KeySym(0x0061)
1113const xk_b = KeySym(0x0062)
1114const xk_c = KeySym(0x0063)
1115const xk_d = KeySym(0x0064)
1116const xk_e = KeySym(0x0065)
1117const xk_f = KeySym(0x0066)
1118const xk_g = KeySym(0x0067)
1119const xk_h = KeySym(0x0068)
1120const xk_i = KeySym(0x0069)
1121const xk_j = KeySym(0x006a)
1122const xk_k = KeySym(0x006b)
1123const xk_l = KeySym(0x006c)
1124const xk_m = KeySym(0x006d)
1125const xk_n = KeySym(0x006e)
1126const xk_o = KeySym(0x006f)
1127const xk_p = KeySym(0x0070)
1128const xk_q = KeySym(0x0071)
1129const xk_r = KeySym(0x0072)
1130const xk_s = KeySym(0x0073)
1131const xk_t = KeySym(0x0074)
1132const xk_u = KeySym(0x0075)
1133const xk_v = KeySym(0x0076)
1134const xk_w = KeySym(0x0077)
1135const xk_x = KeySym(0x0078)
1136const xk_y = KeySym(0x0079)
1137const xk_z = KeySym(0x007a)
1138const xk_0 = KeySym(0x0030)
1139const xk_1 = KeySym(0x0031)
1140const xk_2 = KeySym(0x0032)
1141const xk_3 = KeySym(0x0033)
1142const xk_4 = KeySym(0x0034)
1143const xk_5 = KeySym(0x0035)
1144const xk_6 = KeySym(0x0036)
1145const xk_7 = KeySym(0x0037)
1146const xk_8 = KeySym(0x0038)
1147const xk_9 = KeySym(0x0039)
1148const xk_space = KeySym(0x0020)
1149const xk_minus = KeySym(0x002d)
1150const xk_equal = KeySym(0x003d)
1151const xk_bracketleft = KeySym(0x005b)
1152const xk_bracketright = KeySym(0x005d)
1153const xk_backslash = KeySym(0x005c)
1154const xk_semicolon = KeySym(0x003b)
1155const xk_apostrophe = KeySym(0x0027)
1156const xk_grave = KeySym(0x0060)
1157const xk_comma = KeySym(0x002c)
1158const xk_period = KeySym(0x002e)
1159const xk_slash = KeySym(0x002f)
1160const xk_less = KeySym(0x003c)
1161
1162// XIMaskLen macro equivalent
1163fn xi_mask_len(event int) int {
1164 return (event >> 3) + 1
1165}
1166
1167// XISetMask macro equivalent
1168fn xi_set_mask(mask &u8, event int) {
1169 unsafe {
1170 mut p := mask + (event >> 3)
1171 *p = *p | u8(1 << (event & 7))
1172 }
1173}
1174
1175// XIMaskIsSet macro equivalent
1176fn xi_mask_is_set(mask &u8, event int) bool {
1177 unsafe {
1178 return (mask[event >> 3] & u8(1 << (event & 7))) != 0
1179 }
1180}
1181
1182// VisualIDMask for XGetVisualInfo
1183const visual_id_mask = i64(0x1)
1184