wl_init.c
Go to the documentation of this file.
1 //========================================================================
2 // GLFW 3.3 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 "internal.h"
28 
29 #include <assert.h>
30 #include <errno.h>
31 #include <limits.h>
32 #include <linux/input.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <sys/mman.h>
37 #include <sys/timerfd.h>
38 #include <unistd.h>
39 #include <wayland-client.h>
40 
41 
42 static inline int min(int n1, int n2)
43 {
44  return n1 < n2 ? n1 : n2;
45 }
46 
47 static _GLFWwindow* findWindowFromDecorationSurface(struct wl_surface* surface,
48  int* which)
49 {
50  int focus;
52  if (!which)
53  which = &focus;
54  while (window)
55  {
56  if (surface == window->wl.decorations.top.surface)
57  {
58  *which = topDecoration;
59  break;
60  }
61  if (surface == window->wl.decorations.left.surface)
62  {
63  *which = leftDecoration;
64  break;
65  }
66  if (surface == window->wl.decorations.right.surface)
67  {
68  *which = rightDecoration;
69  break;
70  }
71  if (surface == window->wl.decorations.bottom.surface)
72  {
73  *which = bottomDecoration;
74  break;
75  }
76  window = window->next;
77  }
78  return window;
79 }
80 
81 static void pointerHandleEnter(void* data,
82  struct wl_pointer* pointer,
83  uint32_t serial,
84  struct wl_surface* surface,
85  wl_fixed_t sx,
86  wl_fixed_t sy)
87 {
88  // Happens in the case we just destroyed the surface.
89  if (!surface)
90  return;
91 
92  int focus = 0;
93  _GLFWwindow* window = wl_surface_get_user_data(surface);
94  if (!window)
95  {
96  window = findWindowFromDecorationSurface(surface, &focus);
97  if (!window)
98  return;
99  }
100 
101  window->wl.decorations.focus = focus;
102  _glfw.wl.serial = serial;
103  _glfw.wl.pointerFocus = window;
104 
105  window->wl.hovered = GLFW_TRUE;
106 
107  _glfwPlatformSetCursor(window, window->wl.currentCursor);
109 }
110 
111 static void pointerHandleLeave(void* data,
112  struct wl_pointer* pointer,
113  uint32_t serial,
114  struct wl_surface* surface)
115 {
116  _GLFWwindow* window = _glfw.wl.pointerFocus;
117 
118  if (!window)
119  return;
120 
121  window->wl.hovered = GLFW_FALSE;
122 
123  _glfw.wl.serial = serial;
124  _glfw.wl.pointerFocus = NULL;
126 }
127 
128 static void setCursor(_GLFWwindow* window, const char* name)
129 {
130  struct wl_buffer* buffer;
131  struct wl_cursor* cursor;
132  struct wl_cursor_image* image;
133  struct wl_surface* surface = _glfw.wl.cursorSurface;
134  struct wl_cursor_theme* theme = _glfw.wl.cursorTheme;
135  int scale = 1;
136 
137  if (window->wl.scale > 1 && _glfw.wl.cursorThemeHiDPI)
138  {
139  // We only support up to scale=2 for now, since libwayland-cursor
140  // requires us to load a different theme for each size.
141  scale = 2;
142  theme = _glfw.wl.cursorThemeHiDPI;
143  }
144 
145  cursor = wl_cursor_theme_get_cursor(theme, name);
146  if (!cursor)
147  {
149  "Wayland: Standard cursor not found");
150  return;
151  }
152  // TODO: handle animated cursors too.
153  image = cursor->images[0];
154 
155  if (!image)
156  return;
157 
158  buffer = wl_cursor_image_get_buffer(image);
159  if (!buffer)
160  return;
161  wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.serial,
162  surface,
163  image->hotspot_x / scale,
164  image->hotspot_y / scale);
165  wl_surface_set_buffer_scale(surface, scale);
166  wl_surface_attach(surface, buffer, 0, 0);
167  wl_surface_damage(surface, 0, 0,
168  image->width, image->height);
169  wl_surface_commit(surface);
170 }
171 
172 static void pointerHandleMotion(void* data,
173  struct wl_pointer* pointer,
174  uint32_t time,
175  wl_fixed_t sx,
176  wl_fixed_t sy)
177 {
178  _GLFWwindow* window = _glfw.wl.pointerFocus;
179  const char* cursorName;
180 
181  if (!window)
182  return;
183 
184  if (window->cursorMode == GLFW_CURSOR_DISABLED)
185  return;
186  else
187  {
188  window->wl.cursorPosX = wl_fixed_to_double(sx);
189  window->wl.cursorPosY = wl_fixed_to_double(sy);
190  }
191 
192  switch (window->wl.decorations.focus)
193  {
194  case mainWindow:
195  _glfwInputCursorPos(window,
196  wl_fixed_to_double(sx),
197  wl_fixed_to_double(sy));
198  return;
199  case topDecoration:
200  if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
201  cursorName = "n-resize";
202  else
203  cursorName = "left_ptr";
204  break;
205  case leftDecoration:
206  if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
207  cursorName = "nw-resize";
208  else
209  cursorName = "w-resize";
210  break;
211  case rightDecoration:
212  if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
213  cursorName = "ne-resize";
214  else
215  cursorName = "e-resize";
216  break;
217  case bottomDecoration:
218  if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
219  cursorName = "sw-resize";
220  else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
221  cursorName = "se-resize";
222  else
223  cursorName = "s-resize";
224  break;
225  default:
226  assert(0);
227  }
228  setCursor(window, cursorName);
229 }
230 
231 static void pointerHandleButton(void* data,
232  struct wl_pointer* pointer,
233  uint32_t serial,
234  uint32_t time,
235  uint32_t button,
236  uint32_t state)
237 {
238  _GLFWwindow* window = _glfw.wl.pointerFocus;
239  int glfwButton;
240 
241  // Both xdg-shell and wl_shell use the same values.
242  uint32_t edges = WL_SHELL_SURFACE_RESIZE_NONE;
243 
244  if (!window)
245  return;
246  if (button == BTN_LEFT)
247  {
248  switch (window->wl.decorations.focus)
249  {
250  case mainWindow:
251  break;
252  case topDecoration:
253  if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
254  edges = WL_SHELL_SURFACE_RESIZE_TOP;
255  else
256  {
257  if (window->wl.xdg.toplevel)
258  xdg_toplevel_move(window->wl.xdg.toplevel, _glfw.wl.seat, serial);
259  else
260  wl_shell_surface_move(window->wl.shellSurface, _glfw.wl.seat, serial);
261  }
262  break;
263  case leftDecoration:
264  if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
265  edges = WL_SHELL_SURFACE_RESIZE_TOP_LEFT;
266  else
267  edges = WL_SHELL_SURFACE_RESIZE_LEFT;
268  break;
269  case rightDecoration:
270  if (window->wl.cursorPosY < _GLFW_DECORATION_WIDTH)
271  edges = WL_SHELL_SURFACE_RESIZE_TOP_RIGHT;
272  else
273  edges = WL_SHELL_SURFACE_RESIZE_RIGHT;
274  break;
275  case bottomDecoration:
276  if (window->wl.cursorPosX < _GLFW_DECORATION_WIDTH)
277  edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT;
278  else if (window->wl.cursorPosX > window->wl.width + _GLFW_DECORATION_WIDTH)
279  edges = WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT;
280  else
281  edges = WL_SHELL_SURFACE_RESIZE_BOTTOM;
282  break;
283  default:
284  assert(0);
285  }
286  if (edges != WL_SHELL_SURFACE_RESIZE_NONE)
287  {
288  if (window->wl.xdg.toplevel)
289  xdg_toplevel_resize(window->wl.xdg.toplevel, _glfw.wl.seat,
290  serial, edges);
291  else
292  wl_shell_surface_resize(window->wl.shellSurface, _glfw.wl.seat,
293  serial, edges);
294  }
295  }
296  else if (button == BTN_RIGHT)
297  {
298  if (window->wl.decorations.focus != mainWindow && window->wl.xdg.toplevel)
299  {
300  xdg_toplevel_show_window_menu(window->wl.xdg.toplevel,
301  _glfw.wl.seat, serial,
302  window->wl.cursorPosX,
303  window->wl.cursorPosY);
304  return;
305  }
306  }
307 
308  // Don’t pass the button to the user if it was related to a decoration.
309  if (window->wl.decorations.focus != mainWindow)
310  return;
311 
312  _glfw.wl.serial = serial;
313 
314  /* Makes left, right and middle 0, 1 and 2. Overall order follows evdev
315  * codes. */
316  glfwButton = button - BTN_LEFT;
317 
318  _glfwInputMouseClick(window,
319  glfwButton,
320  state == WL_POINTER_BUTTON_STATE_PRESSED
321  ? GLFW_PRESS
322  : GLFW_RELEASE,
323  _glfw.wl.xkb.modifiers);
324 }
325 
326 static void pointerHandleAxis(void* data,
327  struct wl_pointer* pointer,
328  uint32_t time,
329  uint32_t axis,
330  wl_fixed_t value)
331 {
332  _GLFWwindow* window = _glfw.wl.pointerFocus;
333  double x = 0.0, y = 0.0;
334  // Wayland scroll events are in pointer motion coordinate space (think two
335  // finger scroll). The factor 10 is commonly used to convert to "scroll
336  // step means 1.0.
337  const double scrollFactor = 1.0 / 10.0;
338 
339  if (!window)
340  return;
341 
342  assert(axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL ||
343  axis == WL_POINTER_AXIS_VERTICAL_SCROLL);
344 
345  if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
346  x = wl_fixed_to_double(value) * scrollFactor;
347  else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
348  y = wl_fixed_to_double(value) * scrollFactor;
349 
350  _glfwInputScroll(window, x, y);
351 }
352 
353 static const struct wl_pointer_listener pointerListener = {
359 };
360 
361 static void keyboardHandleKeymap(void* data,
362  struct wl_keyboard* keyboard,
364  int fd,
365  uint32_t size)
366 {
367  struct xkb_keymap* keymap;
368  struct xkb_state* state;
369 
370 #ifdef HAVE_XKBCOMMON_COMPOSE_H
371  struct xkb_compose_table* composeTable;
372  struct xkb_compose_state* composeState;
373 #endif
374 
375  char* mapStr;
376  const char* locale;
377 
378  if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1)
379  {
380  close(fd);
381  return;
382  }
383 
384  mapStr = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
385  if (mapStr == MAP_FAILED) {
386  close(fd);
387  return;
388  }
389 
390  keymap = xkb_keymap_new_from_string(_glfw.wl.xkb.context,
391  mapStr,
392  XKB_KEYMAP_FORMAT_TEXT_V1,
393  0);
394  munmap(mapStr, size);
395  close(fd);
396 
397  if (!keymap)
398  {
400  "Wayland: Failed to compile keymap");
401  return;
402  }
403 
404  state = xkb_state_new(keymap);
405  if (!state)
406  {
408  "Wayland: Failed to create XKB state");
409  xkb_keymap_unref(keymap);
410  return;
411  }
412 
413  // Look up the preferred locale, falling back to "C" as default.
414  locale = getenv("LC_ALL");
415  if (!locale)
416  locale = getenv("LC_CTYPE");
417  if (!locale)
418  locale = getenv("LANG");
419  if (!locale)
420  locale = "C";
421 
422 #ifdef HAVE_XKBCOMMON_COMPOSE_H
423  composeTable =
424  xkb_compose_table_new_from_locale(_glfw.wl.xkb.context, locale,
425  XKB_COMPOSE_COMPILE_NO_FLAGS);
426  if (composeTable)
427  {
428  composeState =
429  xkb_compose_state_new(composeTable, XKB_COMPOSE_STATE_NO_FLAGS);
430  xkb_compose_table_unref(composeTable);
431  if (composeState)
432  _glfw.wl.xkb.composeState = composeState;
433  else
435  "Wayland: Failed to create XKB compose state");
436  }
437  else
438  {
440  "Wayland: Failed to create XKB compose table");
441  }
442 #endif
443 
444  xkb_keymap_unref(_glfw.wl.xkb.keymap);
445  xkb_state_unref(_glfw.wl.xkb.state);
446  _glfw.wl.xkb.keymap = keymap;
447  _glfw.wl.xkb.state = state;
448 
449  _glfw.wl.xkb.controlMask =
450  1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Control");
451  _glfw.wl.xkb.altMask =
452  1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod1");
453  _glfw.wl.xkb.shiftMask =
454  1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Shift");
455  _glfw.wl.xkb.superMask =
456  1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4");
457  _glfw.wl.xkb.capsLockMask =
458  1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Lock");
459  _glfw.wl.xkb.numLockMask =
460  1 << xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2");
461 }
462 
463 static void keyboardHandleEnter(void* data,
464  struct wl_keyboard* keyboard,
465  uint32_t serial,
466  struct wl_surface* surface,
467  struct wl_array* keys)
468 {
469  // Happens in the case we just destroyed the surface.
470  if (!surface)
471  return;
472 
473  _GLFWwindow* window = wl_surface_get_user_data(surface);
474  if (!window)
475  {
476  window = findWindowFromDecorationSurface(surface, NULL);
477  if (!window)
478  return;
479  }
480 
481  _glfw.wl.serial = serial;
482  _glfw.wl.keyboardFocus = window;
484 }
485 
486 static void keyboardHandleLeave(void* data,
487  struct wl_keyboard* keyboard,
488  uint32_t serial,
489  struct wl_surface* surface)
490 {
491  _GLFWwindow* window = _glfw.wl.keyboardFocus;
492 
493  if (!window)
494  return;
495 
496  _glfw.wl.serial = serial;
497  _glfw.wl.keyboardFocus = NULL;
499 }
500 
502 {
503  if (key < sizeof(_glfw.wl.keycodes) / sizeof(_glfw.wl.keycodes[0]))
504  return _glfw.wl.keycodes[key];
505 
506  return GLFW_KEY_UNKNOWN;
507 }
508 
509 #ifdef HAVE_XKBCOMMON_COMPOSE_H
510 static xkb_keysym_t composeSymbol(xkb_keysym_t sym)
511 {
512  if (sym == XKB_KEY_NoSymbol || !_glfw.wl.xkb.composeState)
513  return sym;
514  if (xkb_compose_state_feed(_glfw.wl.xkb.composeState, sym)
515  != XKB_COMPOSE_FEED_ACCEPTED)
516  return sym;
517  switch (xkb_compose_state_get_status(_glfw.wl.xkb.composeState))
518  {
519  case XKB_COMPOSE_COMPOSED:
520  return xkb_compose_state_get_one_sym(_glfw.wl.xkb.composeState);
521  case XKB_COMPOSE_COMPOSING:
522  case XKB_COMPOSE_CANCELLED:
523  return XKB_KEY_NoSymbol;
524  case XKB_COMPOSE_NOTHING:
525  default:
526  return sym;
527  }
528 }
529 #endif
530 
532 {
533  uint32_t code, numSyms;
534  long cp;
535  const xkb_keysym_t *syms;
536  xkb_keysym_t sym;
537 
538  code = key + 8;
539  numSyms = xkb_state_key_get_syms(_glfw.wl.xkb.state, code, &syms);
540 
541  if (numSyms == 1)
542  {
543 #ifdef HAVE_XKBCOMMON_COMPOSE_H
544  sym = composeSymbol(syms[0]);
545 #else
546  sym = syms[0];
547 #endif
548  cp = _glfwKeySym2Unicode(sym);
549  if (cp != -1)
550  {
551  const int mods = _glfw.wl.xkb.modifiers;
552  const int plain = !(mods & (GLFW_MOD_CONTROL | GLFW_MOD_ALT));
553  _glfwInputChar(window, cp, mods, plain);
554  }
555  }
556 
557  return xkb_keymap_key_repeats(_glfw.wl.xkb.keymap, syms[0]);
558 }
559 
560 static void keyboardHandleKey(void* data,
561  struct wl_keyboard* keyboard,
562  uint32_t serial,
563  uint32_t time,
564  uint32_t key,
565  uint32_t state)
566 {
567  int keyCode;
568  int action;
569  _GLFWwindow* window = _glfw.wl.keyboardFocus;
570  GLFWbool shouldRepeat;
571  struct itimerspec timer = {};
572 
573  if (!window)
574  return;
575 
576  keyCode = toGLFWKeyCode(key);
577  action = state == WL_KEYBOARD_KEY_STATE_PRESSED
579 
580  _glfw.wl.serial = serial;
581  _glfwInputKey(window, keyCode, key, action,
582  _glfw.wl.xkb.modifiers);
583 
584  if (action == GLFW_PRESS)
585  {
586  shouldRepeat = inputChar(window, key);
587 
588  if (shouldRepeat && _glfw.wl.keyboardRepeatRate > 0)
589  {
590  _glfw.wl.keyboardLastKey = keyCode;
591  _glfw.wl.keyboardLastScancode = key;
592  timer.it_interval.tv_sec = _glfw.wl.keyboardRepeatRate / 1000;
593  timer.it_interval.tv_nsec = (_glfw.wl.keyboardRepeatRate % 1000) * 1000000;
594  timer.it_value.tv_sec = _glfw.wl.keyboardRepeatDelay / 1000;
595  timer.it_value.tv_nsec = (_glfw.wl.keyboardRepeatDelay % 1000) * 1000000;
596  }
597  }
598  timerfd_settime(_glfw.wl.timerfd, 0, &timer, NULL);
599 }
600 
601 static void keyboardHandleModifiers(void* data,
602  struct wl_keyboard* keyboard,
603  uint32_t serial,
604  uint32_t modsDepressed,
605  uint32_t modsLatched,
606  uint32_t modsLocked,
607  uint32_t group)
608 {
609  xkb_mod_mask_t mask;
610  unsigned int modifiers = 0;
611 
612  _glfw.wl.serial = serial;
613 
614  if (!_glfw.wl.xkb.keymap)
615  return;
616 
617  xkb_state_update_mask(_glfw.wl.xkb.state,
618  modsDepressed,
619  modsLatched,
620  modsLocked,
621  0,
622  0,
623  group);
624 
625  mask = xkb_state_serialize_mods(_glfw.wl.xkb.state,
626  XKB_STATE_MODS_DEPRESSED |
627  XKB_STATE_LAYOUT_DEPRESSED |
628  XKB_STATE_MODS_LATCHED |
629  XKB_STATE_LAYOUT_LATCHED);
630  if (mask & _glfw.wl.xkb.controlMask)
631  modifiers |= GLFW_MOD_CONTROL;
632  if (mask & _glfw.wl.xkb.altMask)
633  modifiers |= GLFW_MOD_ALT;
634  if (mask & _glfw.wl.xkb.shiftMask)
635  modifiers |= GLFW_MOD_SHIFT;
636  if (mask & _glfw.wl.xkb.superMask)
637  modifiers |= GLFW_MOD_SUPER;
638  if (mask & _glfw.wl.xkb.capsLockMask)
639  modifiers |= GLFW_MOD_CAPS_LOCK;
640  if (mask & _glfw.wl.xkb.numLockMask)
641  modifiers |= GLFW_MOD_NUM_LOCK;
642  _glfw.wl.xkb.modifiers = modifiers;
643 }
644 
645 #ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
646 static void keyboardHandleRepeatInfo(void* data,
647  struct wl_keyboard* keyboard,
648  int32_t rate,
649  int32_t delay)
650 {
651  if (keyboard != _glfw.wl.keyboard)
652  return;
653 
654  _glfw.wl.keyboardRepeatRate = rate;
655  _glfw.wl.keyboardRepeatDelay = delay;
656 }
657 #endif
658 
659 static const struct wl_keyboard_listener keyboardListener = {
665 #ifdef WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION
666  keyboardHandleRepeatInfo,
667 #endif
668 };
669 
670 static void seatHandleCapabilities(void* data,
671  struct wl_seat* seat,
672  enum wl_seat_capability caps)
673 {
674  if ((caps & WL_SEAT_CAPABILITY_POINTER) && !_glfw.wl.pointer)
675  {
676  _glfw.wl.pointer = wl_seat_get_pointer(seat);
677  wl_pointer_add_listener(_glfw.wl.pointer, &pointerListener, NULL);
678  }
679  else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && _glfw.wl.pointer)
680  {
681  wl_pointer_destroy(_glfw.wl.pointer);
682  _glfw.wl.pointer = NULL;
683  }
684 
685  if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !_glfw.wl.keyboard)
686  {
687  _glfw.wl.keyboard = wl_seat_get_keyboard(seat);
688  wl_keyboard_add_listener(_glfw.wl.keyboard, &keyboardListener, NULL);
689  }
690  else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && _glfw.wl.keyboard)
691  {
692  wl_keyboard_destroy(_glfw.wl.keyboard);
693  _glfw.wl.keyboard = NULL;
694  }
695 }
696 
697 static void seatHandleName(void* data,
698  struct wl_seat* seat,
699  const char* name)
700 {
701 }
702 
703 static const struct wl_seat_listener seatListener = {
706 };
707 
708 static void dataOfferHandleOffer(void* data,
709  struct wl_data_offer* dataOffer,
710  const char* mimeType)
711 {
712 }
713 
714 static const struct wl_data_offer_listener dataOfferListener = {
716 };
717 
718 static void dataDeviceHandleDataOffer(void* data,
719  struct wl_data_device* dataDevice,
720  struct wl_data_offer* id)
721 {
722  if (_glfw.wl.dataOffer)
723  wl_data_offer_destroy(_glfw.wl.dataOffer);
724 
725  _glfw.wl.dataOffer = id;
726  wl_data_offer_add_listener(_glfw.wl.dataOffer, &dataOfferListener, NULL);
727 }
728 
729 static void dataDeviceHandleEnter(void* data,
730  struct wl_data_device* dataDevice,
731  uint32_t serial,
732  struct wl_surface *surface,
733  wl_fixed_t x,
734  wl_fixed_t y,
735  struct wl_data_offer *id)
736 {
737 }
738 
739 static void dataDeviceHandleLeave(void* data,
740  struct wl_data_device* dataDevice)
741 {
742 }
743 
744 static void dataDeviceHandleMotion(void* data,
745  struct wl_data_device* dataDevice,
746  uint32_t time,
747  wl_fixed_t x,
748  wl_fixed_t y)
749 {
750 }
751 
752 static void dataDeviceHandleDrop(void* data,
753  struct wl_data_device* dataDevice)
754 {
755 }
756 
757 static void dataDeviceHandleSelection(void* data,
758  struct wl_data_device* dataDevice,
759  struct wl_data_offer* id)
760 {
761 }
762 
763 static const struct wl_data_device_listener dataDeviceListener = {
770 };
771 
772 static void wmBaseHandlePing(void* data,
773  struct xdg_wm_base* wmBase,
774  uint32_t serial)
775 {
776  xdg_wm_base_pong(wmBase, serial);
777 }
778 
779 static const struct xdg_wm_base_listener wmBaseListener = {
781 };
782 
783 static void registryHandleGlobal(void* data,
784  struct wl_registry* registry,
785  uint32_t name,
786  const char* interface,
787  uint32_t version)
788 {
789  if (strcmp(interface, "wl_compositor") == 0)
790  {
791  _glfw.wl.compositorVersion = min(3, version);
792  _glfw.wl.compositor =
793  wl_registry_bind(registry, name, &wl_compositor_interface,
794  _glfw.wl.compositorVersion);
795  }
796  else if (strcmp(interface, "wl_subcompositor") == 0)
797  {
798  _glfw.wl.subcompositor =
799  wl_registry_bind(registry, name, &wl_subcompositor_interface, 1);
800  }
801  else if (strcmp(interface, "wl_shm") == 0)
802  {
803  _glfw.wl.shm =
804  wl_registry_bind(registry, name, &wl_shm_interface, 1);
805  }
806  else if (strcmp(interface, "wl_shell") == 0)
807  {
808  _glfw.wl.shell =
809  wl_registry_bind(registry, name, &wl_shell_interface, 1);
810  }
811  else if (strcmp(interface, "wl_output") == 0)
812  {
813  _glfwAddOutputWayland(name, version);
814  }
815  else if (strcmp(interface, "wl_seat") == 0)
816  {
817  if (!_glfw.wl.seat)
818  {
819  _glfw.wl.seatVersion = min(4, version);
820  _glfw.wl.seat =
821  wl_registry_bind(registry, name, &wl_seat_interface,
822  _glfw.wl.seatVersion);
823  wl_seat_add_listener(_glfw.wl.seat, &seatListener, NULL);
824  }
825  }
826  else if (strcmp(interface, "wl_data_device_manager") == 0)
827  {
828  if (!_glfw.wl.dataDeviceManager)
829  {
830  _glfw.wl.dataDeviceManager =
831  wl_registry_bind(registry, name,
832  &wl_data_device_manager_interface, 1);
833  }
834  }
835  else if (strcmp(interface, "xdg_wm_base") == 0)
836  {
837  _glfw.wl.wmBase =
838  wl_registry_bind(registry, name, &xdg_wm_base_interface, 1);
839  xdg_wm_base_add_listener(_glfw.wl.wmBase, &wmBaseListener, NULL);
840  }
841  else if (strcmp(interface, "zxdg_decoration_manager_v1") == 0)
842  {
843  _glfw.wl.decorationManager =
844  wl_registry_bind(registry, name,
845  &zxdg_decoration_manager_v1_interface,
846  1);
847  }
848  else if (strcmp(interface, "wp_viewporter") == 0)
849  {
850  _glfw.wl.viewporter =
851  wl_registry_bind(registry, name, &wp_viewporter_interface, 1);
852  }
853  else if (strcmp(interface, "zwp_relative_pointer_manager_v1") == 0)
854  {
855  _glfw.wl.relativePointerManager =
856  wl_registry_bind(registry, name,
857  &zwp_relative_pointer_manager_v1_interface,
858  1);
859  }
860  else if (strcmp(interface, "zwp_pointer_constraints_v1") == 0)
861  {
862  _glfw.wl.pointerConstraints =
863  wl_registry_bind(registry, name,
864  &zwp_pointer_constraints_v1_interface,
865  1);
866  }
867  else if (strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0)
868  {
869  _glfw.wl.idleInhibitManager =
870  wl_registry_bind(registry, name,
871  &zwp_idle_inhibit_manager_v1_interface,
872  1);
873  }
874 }
875 
877  struct wl_registry *registry,
878  uint32_t name)
879 {
880  int i;
881  _GLFWmonitor* monitor;
882 
883  for (i = 0; i < _glfw.monitorCount; ++i)
884  {
885  monitor = _glfw.monitors[i];
886  if (monitor->wl.name == name)
887  {
889  return;
890  }
891  }
892 }
893 
894 
895 static const struct wl_registry_listener registryListener = {
898 };
899 
900 // Create key code translation tables
901 //
902 static void createKeyTables(void)
903 {
904  int scancode;
905 
906  memset(_glfw.wl.keycodes, -1, sizeof(_glfw.wl.keycodes));
907  memset(_glfw.wl.scancodes, -1, sizeof(_glfw.wl.scancodes));
908 
909  _glfw.wl.keycodes[KEY_GRAVE] = GLFW_KEY_GRAVE_ACCENT;
910  _glfw.wl.keycodes[KEY_1] = GLFW_KEY_1;
911  _glfw.wl.keycodes[KEY_2] = GLFW_KEY_2;
912  _glfw.wl.keycodes[KEY_3] = GLFW_KEY_3;
913  _glfw.wl.keycodes[KEY_4] = GLFW_KEY_4;
914  _glfw.wl.keycodes[KEY_5] = GLFW_KEY_5;
915  _glfw.wl.keycodes[KEY_6] = GLFW_KEY_6;
916  _glfw.wl.keycodes[KEY_7] = GLFW_KEY_7;
917  _glfw.wl.keycodes[KEY_8] = GLFW_KEY_8;
918  _glfw.wl.keycodes[KEY_9] = GLFW_KEY_9;
919  _glfw.wl.keycodes[KEY_0] = GLFW_KEY_0;
920  _glfw.wl.keycodes[KEY_SPACE] = GLFW_KEY_SPACE;
921  _glfw.wl.keycodes[KEY_MINUS] = GLFW_KEY_MINUS;
922  _glfw.wl.keycodes[KEY_EQUAL] = GLFW_KEY_EQUAL;
923  _glfw.wl.keycodes[KEY_Q] = GLFW_KEY_Q;
924  _glfw.wl.keycodes[KEY_W] = GLFW_KEY_W;
925  _glfw.wl.keycodes[KEY_E] = GLFW_KEY_E;
926  _glfw.wl.keycodes[KEY_R] = GLFW_KEY_R;
927  _glfw.wl.keycodes[KEY_T] = GLFW_KEY_T;
928  _glfw.wl.keycodes[KEY_Y] = GLFW_KEY_Y;
929  _glfw.wl.keycodes[KEY_U] = GLFW_KEY_U;
930  _glfw.wl.keycodes[KEY_I] = GLFW_KEY_I;
931  _glfw.wl.keycodes[KEY_O] = GLFW_KEY_O;
932  _glfw.wl.keycodes[KEY_P] = GLFW_KEY_P;
933  _glfw.wl.keycodes[KEY_LEFTBRACE] = GLFW_KEY_LEFT_BRACKET;
934  _glfw.wl.keycodes[KEY_RIGHTBRACE] = GLFW_KEY_RIGHT_BRACKET;
935  _glfw.wl.keycodes[KEY_A] = GLFW_KEY_A;
936  _glfw.wl.keycodes[KEY_S] = GLFW_KEY_S;
937  _glfw.wl.keycodes[KEY_D] = GLFW_KEY_D;
938  _glfw.wl.keycodes[KEY_F] = GLFW_KEY_F;
939  _glfw.wl.keycodes[KEY_G] = GLFW_KEY_G;
940  _glfw.wl.keycodes[KEY_H] = GLFW_KEY_H;
941  _glfw.wl.keycodes[KEY_J] = GLFW_KEY_J;
942  _glfw.wl.keycodes[KEY_K] = GLFW_KEY_K;
943  _glfw.wl.keycodes[KEY_L] = GLFW_KEY_L;
944  _glfw.wl.keycodes[KEY_SEMICOLON] = GLFW_KEY_SEMICOLON;
945  _glfw.wl.keycodes[KEY_APOSTROPHE] = GLFW_KEY_APOSTROPHE;
946  _glfw.wl.keycodes[KEY_Z] = GLFW_KEY_Z;
947  _glfw.wl.keycodes[KEY_X] = GLFW_KEY_X;
948  _glfw.wl.keycodes[KEY_C] = GLFW_KEY_C;
949  _glfw.wl.keycodes[KEY_V] = GLFW_KEY_V;
950  _glfw.wl.keycodes[KEY_B] = GLFW_KEY_B;
951  _glfw.wl.keycodes[KEY_N] = GLFW_KEY_N;
952  _glfw.wl.keycodes[KEY_M] = GLFW_KEY_M;
953  _glfw.wl.keycodes[KEY_COMMA] = GLFW_KEY_COMMA;
954  _glfw.wl.keycodes[KEY_DOT] = GLFW_KEY_PERIOD;
955  _glfw.wl.keycodes[KEY_SLASH] = GLFW_KEY_SLASH;
956  _glfw.wl.keycodes[KEY_BACKSLASH] = GLFW_KEY_BACKSLASH;
957  _glfw.wl.keycodes[KEY_ESC] = GLFW_KEY_ESCAPE;
958  _glfw.wl.keycodes[KEY_TAB] = GLFW_KEY_TAB;
959  _glfw.wl.keycodes[KEY_LEFTSHIFT] = GLFW_KEY_LEFT_SHIFT;
960  _glfw.wl.keycodes[KEY_RIGHTSHIFT] = GLFW_KEY_RIGHT_SHIFT;
961  _glfw.wl.keycodes[KEY_LEFTCTRL] = GLFW_KEY_LEFT_CONTROL;
962  _glfw.wl.keycodes[KEY_RIGHTCTRL] = GLFW_KEY_RIGHT_CONTROL;
963  _glfw.wl.keycodes[KEY_LEFTALT] = GLFW_KEY_LEFT_ALT;
964  _glfw.wl.keycodes[KEY_RIGHTALT] = GLFW_KEY_RIGHT_ALT;
965  _glfw.wl.keycodes[KEY_LEFTMETA] = GLFW_KEY_LEFT_SUPER;
966  _glfw.wl.keycodes[KEY_RIGHTMETA] = GLFW_KEY_RIGHT_SUPER;
967  _glfw.wl.keycodes[KEY_MENU] = GLFW_KEY_MENU;
968  _glfw.wl.keycodes[KEY_NUMLOCK] = GLFW_KEY_NUM_LOCK;
969  _glfw.wl.keycodes[KEY_CAPSLOCK] = GLFW_KEY_CAPS_LOCK;
970  _glfw.wl.keycodes[KEY_PRINT] = GLFW_KEY_PRINT_SCREEN;
971  _glfw.wl.keycodes[KEY_SCROLLLOCK] = GLFW_KEY_SCROLL_LOCK;
972  _glfw.wl.keycodes[KEY_PAUSE] = GLFW_KEY_PAUSE;
973  _glfw.wl.keycodes[KEY_DELETE] = GLFW_KEY_DELETE;
974  _glfw.wl.keycodes[KEY_BACKSPACE] = GLFW_KEY_BACKSPACE;
975  _glfw.wl.keycodes[KEY_ENTER] = GLFW_KEY_ENTER;
976  _glfw.wl.keycodes[KEY_HOME] = GLFW_KEY_HOME;
977  _glfw.wl.keycodes[KEY_END] = GLFW_KEY_END;
978  _glfw.wl.keycodes[KEY_PAGEUP] = GLFW_KEY_PAGE_UP;
979  _glfw.wl.keycodes[KEY_PAGEDOWN] = GLFW_KEY_PAGE_DOWN;
980  _glfw.wl.keycodes[KEY_INSERT] = GLFW_KEY_INSERT;
981  _glfw.wl.keycodes[KEY_LEFT] = GLFW_KEY_LEFT;
982  _glfw.wl.keycodes[KEY_RIGHT] = GLFW_KEY_RIGHT;
983  _glfw.wl.keycodes[KEY_DOWN] = GLFW_KEY_DOWN;
984  _glfw.wl.keycodes[KEY_UP] = GLFW_KEY_UP;
985  _glfw.wl.keycodes[KEY_F1] = GLFW_KEY_F1;
986  _glfw.wl.keycodes[KEY_F2] = GLFW_KEY_F2;
987  _glfw.wl.keycodes[KEY_F3] = GLFW_KEY_F3;
988  _glfw.wl.keycodes[KEY_F4] = GLFW_KEY_F4;
989  _glfw.wl.keycodes[KEY_F5] = GLFW_KEY_F5;
990  _glfw.wl.keycodes[KEY_F6] = GLFW_KEY_F6;
991  _glfw.wl.keycodes[KEY_F7] = GLFW_KEY_F7;
992  _glfw.wl.keycodes[KEY_F8] = GLFW_KEY_F8;
993  _glfw.wl.keycodes[KEY_F9] = GLFW_KEY_F9;
994  _glfw.wl.keycodes[KEY_F10] = GLFW_KEY_F10;
995  _glfw.wl.keycodes[KEY_F11] = GLFW_KEY_F11;
996  _glfw.wl.keycodes[KEY_F12] = GLFW_KEY_F12;
997  _glfw.wl.keycodes[KEY_F13] = GLFW_KEY_F13;
998  _glfw.wl.keycodes[KEY_F14] = GLFW_KEY_F14;
999  _glfw.wl.keycodes[KEY_F15] = GLFW_KEY_F15;
1000  _glfw.wl.keycodes[KEY_F16] = GLFW_KEY_F16;
1001  _glfw.wl.keycodes[KEY_F17] = GLFW_KEY_F17;
1002  _glfw.wl.keycodes[KEY_F18] = GLFW_KEY_F18;
1003  _glfw.wl.keycodes[KEY_F19] = GLFW_KEY_F19;
1004  _glfw.wl.keycodes[KEY_F20] = GLFW_KEY_F20;
1005  _glfw.wl.keycodes[KEY_F21] = GLFW_KEY_F21;
1006  _glfw.wl.keycodes[KEY_F22] = GLFW_KEY_F22;
1007  _glfw.wl.keycodes[KEY_F23] = GLFW_KEY_F23;
1008  _glfw.wl.keycodes[KEY_F24] = GLFW_KEY_F24;
1009  _glfw.wl.keycodes[KEY_KPSLASH] = GLFW_KEY_KP_DIVIDE;
1010  _glfw.wl.keycodes[KEY_KPDOT] = GLFW_KEY_KP_MULTIPLY;
1011  _glfw.wl.keycodes[KEY_KPMINUS] = GLFW_KEY_KP_SUBTRACT;
1012  _glfw.wl.keycodes[KEY_KPPLUS] = GLFW_KEY_KP_ADD;
1013  _glfw.wl.keycodes[KEY_KP0] = GLFW_KEY_KP_0;
1014  _glfw.wl.keycodes[KEY_KP1] = GLFW_KEY_KP_1;
1015  _glfw.wl.keycodes[KEY_KP2] = GLFW_KEY_KP_2;
1016  _glfw.wl.keycodes[KEY_KP3] = GLFW_KEY_KP_3;
1017  _glfw.wl.keycodes[KEY_KP4] = GLFW_KEY_KP_4;
1018  _glfw.wl.keycodes[KEY_KP5] = GLFW_KEY_KP_5;
1019  _glfw.wl.keycodes[KEY_KP6] = GLFW_KEY_KP_6;
1020  _glfw.wl.keycodes[KEY_KP7] = GLFW_KEY_KP_7;
1021  _glfw.wl.keycodes[KEY_KP8] = GLFW_KEY_KP_8;
1022  _glfw.wl.keycodes[KEY_KP9] = GLFW_KEY_KP_9;
1023  _glfw.wl.keycodes[KEY_KPCOMMA] = GLFW_KEY_KP_DECIMAL;
1024  _glfw.wl.keycodes[KEY_KPEQUAL] = GLFW_KEY_KP_EQUAL;
1025  _glfw.wl.keycodes[KEY_KPENTER] = GLFW_KEY_KP_ENTER;
1026 
1027  for (scancode = 0; scancode < 256; scancode++)
1028  {
1029  if (_glfw.wl.keycodes[scancode] > 0)
1030  _glfw.wl.scancodes[_glfw.wl.keycodes[scancode]] = scancode;
1031  }
1032 }
1033 
1034 
1038 
1040 {
1041  const char *cursorTheme;
1042  const char *cursorSizeStr;
1043  char *cursorSizeEnd;
1044  long cursorSizeLong;
1045  int cursorSize;
1046 
1047  _glfw.wl.cursor.handle = _glfw_dlopen("libwayland-cursor.so.0");
1048  if (!_glfw.wl.cursor.handle)
1049  {
1051  "Wayland: Failed to open libwayland-cursor");
1052  return GLFW_FALSE;
1053  }
1054 
1055  _glfw.wl.cursor.theme_load = (PFN_wl_cursor_theme_load)
1056  _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_load");
1057  _glfw.wl.cursor.theme_destroy = (PFN_wl_cursor_theme_destroy)
1058  _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_destroy");
1059  _glfw.wl.cursor.theme_get_cursor = (PFN_wl_cursor_theme_get_cursor)
1060  _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_theme_get_cursor");
1061  _glfw.wl.cursor.image_get_buffer = (PFN_wl_cursor_image_get_buffer)
1062  _glfw_dlsym(_glfw.wl.cursor.handle, "wl_cursor_image_get_buffer");
1063 
1064  _glfw.wl.egl.handle = _glfw_dlopen("libwayland-egl.so.1");
1065  if (!_glfw.wl.egl.handle)
1066  {
1068  "Wayland: Failed to open libwayland-egl");
1069  return GLFW_FALSE;
1070  }
1071 
1072  _glfw.wl.egl.window_create = (PFN_wl_egl_window_create)
1073  _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_create");
1074  _glfw.wl.egl.window_destroy = (PFN_wl_egl_window_destroy)
1075  _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_destroy");
1076  _glfw.wl.egl.window_resize = (PFN_wl_egl_window_resize)
1077  _glfw_dlsym(_glfw.wl.egl.handle, "wl_egl_window_resize");
1078 
1079  _glfw.wl.xkb.handle = _glfw_dlopen("libxkbcommon.so.0");
1080  if (!_glfw.wl.xkb.handle)
1081  {
1083  "Wayland: Failed to open libxkbcommon");
1084  return GLFW_FALSE;
1085  }
1086 
1087  _glfw.wl.xkb.context_new = (PFN_xkb_context_new)
1088  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_new");
1089  _glfw.wl.xkb.context_unref = (PFN_xkb_context_unref)
1090  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_context_unref");
1091  _glfw.wl.xkb.keymap_new_from_string = (PFN_xkb_keymap_new_from_string)
1092  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_new_from_string");
1093  _glfw.wl.xkb.keymap_unref = (PFN_xkb_keymap_unref)
1094  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_unref");
1095  _glfw.wl.xkb.keymap_mod_get_index = (PFN_xkb_keymap_mod_get_index)
1096  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_mod_get_index");
1097  _glfw.wl.xkb.keymap_key_repeats = (PFN_xkb_keymap_key_repeats)
1098  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_keymap_key_repeats");
1099  _glfw.wl.xkb.state_new = (PFN_xkb_state_new)
1100  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_new");
1101  _glfw.wl.xkb.state_unref = (PFN_xkb_state_unref)
1102  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_unref");
1103  _glfw.wl.xkb.state_key_get_syms = (PFN_xkb_state_key_get_syms)
1104  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_key_get_syms");
1105  _glfw.wl.xkb.state_update_mask = (PFN_xkb_state_update_mask)
1106  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_update_mask");
1107  _glfw.wl.xkb.state_serialize_mods = (PFN_xkb_state_serialize_mods)
1108  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_state_serialize_mods");
1109 
1110 #ifdef HAVE_XKBCOMMON_COMPOSE_H
1111  _glfw.wl.xkb.compose_table_new_from_locale = (PFN_xkb_compose_table_new_from_locale)
1112  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_new_from_locale");
1113  _glfw.wl.xkb.compose_table_unref = (PFN_xkb_compose_table_unref)
1114  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_table_unref");
1115  _glfw.wl.xkb.compose_state_new = (PFN_xkb_compose_state_new)
1116  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_new");
1117  _glfw.wl.xkb.compose_state_unref = (PFN_xkb_compose_state_unref)
1118  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_unref");
1119  _glfw.wl.xkb.compose_state_feed = (PFN_xkb_compose_state_feed)
1120  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_feed");
1121  _glfw.wl.xkb.compose_state_get_status = (PFN_xkb_compose_state_get_status)
1122  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_status");
1123  _glfw.wl.xkb.compose_state_get_one_sym = (PFN_xkb_compose_state_get_one_sym)
1124  _glfw_dlsym(_glfw.wl.xkb.handle, "xkb_compose_state_get_one_sym");
1125 #endif
1126 
1127  _glfw.wl.display = wl_display_connect(NULL);
1128  if (!_glfw.wl.display)
1129  {
1131  "Wayland: Failed to connect to display");
1132  return GLFW_FALSE;
1133  }
1134 
1135  _glfw.wl.registry = wl_display_get_registry(_glfw.wl.display);
1136  wl_registry_add_listener(_glfw.wl.registry, &registryListener, NULL);
1137 
1138  createKeyTables();
1139 
1140  _glfw.wl.xkb.context = xkb_context_new(0);
1141  if (!_glfw.wl.xkb.context)
1142  {
1144  "Wayland: Failed to initialize xkb context");
1145  return GLFW_FALSE;
1146  }
1147 
1148  // Sync so we got all registry objects
1149  wl_display_roundtrip(_glfw.wl.display);
1150 
1151  // Sync so we got all initial output events
1152  wl_display_roundtrip(_glfw.wl.display);
1153 
1154 #ifdef __linux__
1155  if (!_glfwInitJoysticksLinux())
1156  return GLFW_FALSE;
1157 #endif
1158 
1160 
1161  _glfw.wl.timerfd = -1;
1162  if (_glfw.wl.seatVersion >= 4)
1163  _glfw.wl.timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
1164 
1165  if (_glfw.wl.pointer && _glfw.wl.shm)
1166  {
1167  cursorTheme = getenv("XCURSOR_THEME");
1168  cursorSizeStr = getenv("XCURSOR_SIZE");
1169  cursorSize = 32;
1170  if (cursorSizeStr)
1171  {
1172  errno = 0;
1173  cursorSizeLong = strtol(cursorSizeStr, &cursorSizeEnd, 10);
1174  if (!*cursorSizeEnd && !errno && cursorSizeLong > 0 && cursorSizeLong <= INT_MAX)
1175  cursorSize = (int)cursorSizeLong;
1176  }
1177  _glfw.wl.cursorTheme =
1178  wl_cursor_theme_load(cursorTheme, cursorSize, _glfw.wl.shm);
1179  if (!_glfw.wl.cursorTheme)
1180  {
1182  "Wayland: Unable to load default cursor theme");
1183  return GLFW_FALSE;
1184  }
1185  // If this happens to be NULL, we just fallback to the scale=1 version.
1186  _glfw.wl.cursorThemeHiDPI =
1187  wl_cursor_theme_load(cursorTheme, 2 * cursorSize, _glfw.wl.shm);
1188  _glfw.wl.cursorSurface =
1189  wl_compositor_create_surface(_glfw.wl.compositor);
1190  _glfw.wl.cursorTimerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
1191  }
1192 
1193  if (_glfw.wl.seat && _glfw.wl.dataDeviceManager)
1194  {
1195  _glfw.wl.dataDevice =
1196  wl_data_device_manager_get_data_device(_glfw.wl.dataDeviceManager,
1197  _glfw.wl.seat);
1198  wl_data_device_add_listener(_glfw.wl.dataDevice, &dataDeviceListener, NULL);
1199  _glfw.wl.clipboardString = malloc(4096);
1200  if (!_glfw.wl.clipboardString)
1201  {
1203  "Wayland: Unable to allocate clipboard memory");
1204  return GLFW_FALSE;
1205  }
1206  _glfw.wl.clipboardSize = 4096;
1207  }
1208 
1209  return GLFW_TRUE;
1210 }
1211 
1213 {
1214 #ifdef __linux__
1216 #endif
1218  if (_glfw.wl.egl.handle)
1219  {
1220  _glfw_dlclose(_glfw.wl.egl.handle);
1221  _glfw.wl.egl.handle = NULL;
1222  }
1223 
1224 #ifdef HAVE_XKBCOMMON_COMPOSE_H
1225  if (_glfw.wl.xkb.composeState)
1226  xkb_compose_state_unref(_glfw.wl.xkb.composeState);
1227 #endif
1228  if (_glfw.wl.xkb.keymap)
1229  xkb_keymap_unref(_glfw.wl.xkb.keymap);
1230  if (_glfw.wl.xkb.state)
1231  xkb_state_unref(_glfw.wl.xkb.state);
1232  if (_glfw.wl.xkb.context)
1234  if (_glfw.wl.xkb.handle)
1235  {
1236  _glfw_dlclose(_glfw.wl.xkb.handle);
1237  _glfw.wl.xkb.handle = NULL;
1238  }
1239 
1240  if (_glfw.wl.cursorTheme)
1241  wl_cursor_theme_destroy(_glfw.wl.cursorTheme);
1242  if (_glfw.wl.cursorThemeHiDPI)
1243  wl_cursor_theme_destroy(_glfw.wl.cursorThemeHiDPI);
1244  if (_glfw.wl.cursor.handle)
1245  {
1246  _glfw_dlclose(_glfw.wl.cursor.handle);
1247  _glfw.wl.cursor.handle = NULL;
1248  }
1249 
1250  if (_glfw.wl.cursorSurface)
1251  wl_surface_destroy(_glfw.wl.cursorSurface);
1252  if (_glfw.wl.subcompositor)
1253  wl_subcompositor_destroy(_glfw.wl.subcompositor);
1254  if (_glfw.wl.compositor)
1255  wl_compositor_destroy(_glfw.wl.compositor);
1256  if (_glfw.wl.shm)
1257  wl_shm_destroy(_glfw.wl.shm);
1258  if (_glfw.wl.shell)
1259  wl_shell_destroy(_glfw.wl.shell);
1260  if (_glfw.wl.viewporter)
1261  wp_viewporter_destroy(_glfw.wl.viewporter);
1262  if (_glfw.wl.decorationManager)
1263  zxdg_decoration_manager_v1_destroy(_glfw.wl.decorationManager);
1264  if (_glfw.wl.wmBase)
1265  xdg_wm_base_destroy(_glfw.wl.wmBase);
1266  if (_glfw.wl.dataSource)
1267  wl_data_source_destroy(_glfw.wl.dataSource);
1268  if (_glfw.wl.dataDevice)
1269  wl_data_device_destroy(_glfw.wl.dataDevice);
1270  if (_glfw.wl.dataOffer)
1271  wl_data_offer_destroy(_glfw.wl.dataOffer);
1272  if (_glfw.wl.dataDeviceManager)
1273  wl_data_device_manager_destroy(_glfw.wl.dataDeviceManager);
1274  if (_glfw.wl.pointer)
1275  wl_pointer_destroy(_glfw.wl.pointer);
1276  if (_glfw.wl.keyboard)
1277  wl_keyboard_destroy(_glfw.wl.keyboard);
1278  if (_glfw.wl.seat)
1279  wl_seat_destroy(_glfw.wl.seat);
1280  if (_glfw.wl.relativePointerManager)
1281  zwp_relative_pointer_manager_v1_destroy(_glfw.wl.relativePointerManager);
1282  if (_glfw.wl.pointerConstraints)
1283  zwp_pointer_constraints_v1_destroy(_glfw.wl.pointerConstraints);
1284  if (_glfw.wl.idleInhibitManager)
1285  zwp_idle_inhibit_manager_v1_destroy(_glfw.wl.idleInhibitManager);
1286  if (_glfw.wl.registry)
1287  wl_registry_destroy(_glfw.wl.registry);
1288  if (_glfw.wl.display)
1289  {
1290  wl_display_flush(_glfw.wl.display);
1291  wl_display_disconnect(_glfw.wl.display);
1292  }
1293 
1294  if (_glfw.wl.timerfd >= 0)
1295  close(_glfw.wl.timerfd);
1296  if (_glfw.wl.cursorTimerfd >= 0)
1297  close(_glfw.wl.cursorTimerfd);
1298 
1299  if (_glfw.wl.clipboardString)
1300  free(_glfw.wl.clipboardString);
1301  if (_glfw.wl.clipboardSendString)
1302  free(_glfw.wl.clipboardSendString);
1303 }
1304 
1306 {
1307  return _GLFW_VERSION_NUMBER " Wayland EGL"
1308 #if defined(_POSIX_TIMERS) && defined(_POSIX_MONOTONIC_CLOCK)
1309  " clock_gettime"
1310 #else
1311  " gettimeofday"
1312 #endif
1313  " evdev"
1314 #if defined(_GLFW_BUILD_DLL)
1315  " shared"
1316 #endif
1317  ;
1318 }
#define GLFW_KEY_SCROLL_LOCK
Definition: glfw3.h:427
#define GLFW_KEY_KP_1
Definition: glfw3.h:457
static const struct wl_registry_listener registryListener
Definition: wl_init.c:895
static void dataDeviceHandleMotion(void *data, struct wl_data_device *dataDevice, uint32_t time, wl_fixed_t x, wl_fixed_t y)
Definition: wl_init.c:744
static void dataDeviceHandleDrop(void *data, struct wl_data_device *dataDevice)
Definition: wl_init.c:752
#define GLFW_KEY_F6
Definition: glfw3.h:436
#define GLFW_KEY_F14
Definition: glfw3.h:444
uint32_t height
Definition: wl_platform.h:83
struct wl_cursor *(* PFN_wl_cursor_theme_get_cursor)(struct wl_cursor_theme *, const char *)
Definition: wl_platform.h:95
#define wl_cursor_theme_destroy
Definition: wl_platform.h:98
#define GLFW_KEY_RIGHT_CONTROL
Definition: glfw3.h:478
static const struct wl_data_device_listener dataDeviceListener
Definition: wl_init.c:763
static const struct xdg_wm_base_listener wmBaseListener
Definition: wl_init.c:779
#define GLFW_KEY_INSERT
Definition: glfw3.h:416
GLint y
#define GLFW_KEY_KP_DIVIDE
Definition: glfw3.h:467
#define GLFW_KEY_UNKNOWN
Definition: glfw3.h:357
struct xkb_context *(* PFN_xkb_context_new)(enum xkb_context_flags)
Definition: wl_platform.h:109
GLenum GLsizei const void * pointer
#define GLFW_KEY_LEFT
Definition: glfw3.h:419
#define GLFW_KEY_I
Definition: glfw3.h:386
#define GLFW_MOD_CONTROL
If this bit is set one or more Control keys were held down.
Definition: glfw3.h:504
GLuint const GLchar * name
#define GLFW_KEY_F
Definition: glfw3.h:383
GLFWwindowcontentscalefun scale
Definition: internal.h:405
static void wmBaseHandlePing(void *data, struct xdg_wm_base *wmBase, uint32_t serial)
Definition: wl_init.c:772
#define GLFW_KEY_KP_5
Definition: glfw3.h:461
static void keyboardHandleEnter(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface, struct wl_array *keys)
Definition: wl_init.c:463
#define _GLFW_VERSION_NUMBER
Definition: internal.h:199
static GLFWbool inputChar(_GLFWwindow *window, uint32_t key)
Definition: wl_init.c:531
#define wl_cursor_theme_get_cursor
Definition: wl_platform.h:99
#define GLFW_KEY_SEMICOLON
Definition: glfw3.h:376
void(* PFN_xkb_state_unref)(struct xkb_state *)
Definition: wl_platform.h:116
static void keyboardHandleLeave(void *data, struct wl_keyboard *keyboard, uint32_t serial, struct wl_surface *surface)
Definition: wl_init.c:486
#define GLFW_KEY_KP_3
Definition: glfw3.h:459
#define xkb_state_update_mask
Definition: wl_platform.h:129
#define GLFW_KEY_PERIOD
Definition: glfw3.h:364
static void keyboardHandleModifiers(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t modsDepressed, uint32_t modsLatched, uint32_t modsLocked, uint32_t group)
Definition: wl_init.c:601
static void keyboardHandleKey(void *data, struct wl_keyboard *keyboard, uint32_t serial, uint32_t time, uint32_t key, uint32_t state)
Definition: wl_init.c:560
void _glfwInputChar(_GLFWwindow *window, unsigned int codepoint, int mods, GLFWbool plain)
Definition: input.c:290
GLenum GLenum GLenum GLenum GLenum scale
Definition: glext.h:10806
static GLFWwindow * window
Definition: joysticks.c:55
#define GLFW_KEY_UP
Definition: glfw3.h:421
void _glfwPlatformTerminate(void)
Definition: wl_init.c:1212
#define GLFW_KEY_KP_6
Definition: glfw3.h:462
#define GLFW_KEY_X
Definition: glfw3.h:401
#define GLFW_KEY_6
Definition: glfw3.h:372
GLfloat value
GLint GLuint mask
#define GLFW_KEY_GRAVE_ACCENT
Definition: glfw3.h:407
_GLFWctxconfig context
Definition: internal.h:520
#define GLFW_KEY_SPACE
Definition: glfw3.h:360
#define GLFW_KEY_PAUSE
Definition: glfw3.h:430
#define GLFW_KEY_KP_2
Definition: glfw3.h:458
#define GLFW_KEY_F7
Definition: glfw3.h:437
void _glfwInitTimerPOSIX(void)
Definition: posix_time.c:40
static void registryHandleGlobalRemove(void *data, struct wl_registry *registry, uint32_t name)
Definition: wl_init.c:876
#define GLFW_KEY_LEFT_SHIFT
Definition: glfw3.h:473
#define GLFW_FALSE
Zero.
Definition: glfw3.h:287
void _glfwAddOutputWayland(uint32_t name, uint32_t version)
Definition: wl_monitor.c:112
#define _glfw_dlopen(name)
#define GLFW_KEY_F8
Definition: glfw3.h:438
#define GLFW_KEY_8
Definition: glfw3.h:374
struct wl_cursor_image ** images
Definition: wl_platform.h:90
static void seatHandleCapabilities(void *data, struct wl_seat *seat, enum wl_seat_capability caps)
Definition: wl_init.c:670
struct wl_egl_window *(* PFN_wl_egl_window_create)(struct wl_surface *, int, int)
Definition: wl_platform.h:102
#define xkb_keymap_unref
Definition: wl_platform.h:123
static void pointerHandleButton(void *data, struct wl_pointer *pointer, uint32_t serial, uint32_t time, uint32_t button, uint32_t state)
Definition: wl_init.c:231
#define GLFW_KEY_P
Definition: glfw3.h:393
#define GLFW_KEY_PAGE_DOWN
Definition: glfw3.h:423
#define GLFW_KEY_F2
Definition: glfw3.h:432
#define GLFW_KEY_LEFT_BRACKET
Definition: glfw3.h:404
#define GLFW_KEY_HOME
Definition: glfw3.h:424
#define GLFW_KEY_K
Definition: glfw3.h:388
#define _GLFW_DECORATION_WIDTH
Definition: wl_platform.h:149
#define xkb_state_serialize_mods
Definition: wl_platform.h:130
#define GLFW_KEY_E
Definition: glfw3.h:382
#define GLFW_KEY_PAGE_UP
Definition: glfw3.h:422
_GLFWwindow * windowListHead
Definition: internal.h:526
int GLFWbool
Definition: internal.h:61
GLenum GLfloat * buffer
static int toGLFWKeyCode(uint32_t key)
Definition: wl_init.c:501
#define GLFW_KEY_Z
Definition: glfw3.h:403
#define GLFW_KEY_B
Definition: glfw3.h:379
#define GLFW_KEY_7
Definition: glfw3.h:373
#define GLFW_KEY_BACKSPACE
Definition: glfw3.h:415
#define GLFW_KEY_H
Definition: glfw3.h:385
void * handle
Definition: internal.h:547
void(* PFN_wl_egl_window_resize)(struct wl_egl_window *, int, int, int, int)
Definition: wl_platform.h:104
GLenum GLuint id
GLenum GLenum GLsizei void * image
void _glfwInputCursorEnter(_GLFWwindow *window, GLFWbool entered)
Definition: input.c:352
#define GLFW_KEY_A
Definition: glfw3.h:378
static _GLFWwindow * findWindowFromDecorationSurface(struct wl_surface *surface, int *which)
Definition: wl_init.c:47
#define GLFW_KEY_F15
Definition: glfw3.h:445
static void dataOfferHandleOffer(void *data, struct wl_data_offer *dataOffer, const char *mimeType)
Definition: wl_init.c:708
char * name
Definition: internal.h:424
#define GLFW_KEY_V
Definition: glfw3.h:399
void _glfwInputScroll(_GLFWwindow *window, double xoffset, double yoffset)
Definition: input.c:310
static void pointerHandleMotion(void *data, struct wl_pointer *pointer, uint32_t time, wl_fixed_t sx, wl_fixed_t sy)
Definition: wl_init.c:172
#define GLFW_RELEASE
The key or mouse button was released.
Definition: glfw3.h:297
GLuint64 key
Definition: glext.h:8966
#define GLFW_CURSOR_DISABLED
Definition: glfw3.h:1008
#define GLFW_KEY_F13
Definition: glfw3.h:443
static const struct wl_seat_listener seatListener
Definition: wl_init.c:703
#define GLFW_DISCONNECTED
Definition: glfw3.h:1059
#define GLFW_KEY_KP_DECIMAL
Definition: glfw3.h:466
#define GLFW_KEY_F5
Definition: glfw3.h:435
#define GLFW_KEY_F20
Definition: glfw3.h:450
#define _glfw_dlclose(handle)
#define GLFW_KEY_F9
Definition: glfw3.h:439
uint32_t hotspot_x
Definition: wl_platform.h:84
#define GLFW_KEY_F10
Definition: glfw3.h:440
int _glfwPlatformInit(void)
Definition: wl_init.c:1039
#define GLFW_KEY_T
Definition: glfw3.h:397
#define GLFW_KEY_KP_9
Definition: glfw3.h:465
#define GLFW_KEY_1
Definition: glfw3.h:367
GLuint GLenum * rate
Definition: glext.h:10991
struct wl_cursor_theme *(* PFN_wl_cursor_theme_load)(const char *, int, struct wl_shm *)
Definition: wl_platform.h:93
#define GLFW_KEY_RIGHT_SUPER
Definition: glfw3.h:480
static void dataDeviceHandleEnter(void *data, struct wl_data_device *dataDevice, uint32_t serial, struct wl_surface *surface, wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *id)
Definition: wl_init.c:729
const char * _glfwPlatformGetVersionString(void)
Definition: wl_init.c:1305
GLsizeiptr size
#define xkb_state_unref
Definition: wl_platform.h:127
#define GLFW_KEY_KP_ADD
Definition: glfw3.h:470
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
Definition: glfw3.h:726
#define GLFW_KEY_END
Definition: glfw3.h:425
_GLFWlibrary _glfw
Definition: init.c:44
#define xkb_state_new
Definition: wl_platform.h:126
uint32_t hotspot_y
Definition: wl_platform.h:85
void _glfwInputWindowFocus(_GLFWwindow *window, GLFWbool focused)
Definition: window.c:43
#define GLFW_KEY_F11
Definition: glfw3.h:441
#define GLFW_MOD_SUPER
If this bit is set one or more Super keys were held down.
Definition: glfw3.h:514
static void registryHandleGlobal(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version)
Definition: wl_init.c:783
#define GLFW_KEY_KP_7
Definition: glfw3.h:463
GLdouble x
static const struct wl_data_offer_listener dataOfferListener
Definition: wl_init.c:714
static void seatHandleName(void *data, struct wl_seat *seat, const char *name)
Definition: wl_init.c:697
int monitorCount
Definition: internal.h:529
unsigned int uint32_t
Definition: stdint.h:80
xkb_mod_mask_t(* PFN_xkb_state_serialize_mods)(struct xkb_state *, enum xkb_state_component)
Definition: wl_platform.h:119
#define GLFW_KEY_EQUAL
Definition: glfw3.h:377
#define GLFW_MOD_SHIFT
If this bit is set one or more Shift keys were held down.
Definition: glfw3.h:499
int cursorMode
Definition: internal.h:388
GLboolean GLuint group
Definition: glext.h:5688
#define GLFW_KEY_CAPS_LOCK
Definition: glfw3.h:426
#define GLFW_KEY_DELETE
Definition: glfw3.h:417
#define GLFW_KEY_ESCAPE
Definition: glfw3.h:412
static void dataDeviceHandleDataOffer(void *data, struct wl_data_device *dataDevice, struct wl_data_offer *id)
Definition: wl_init.c:718
#define GLFW_KEY_KP_MULTIPLY
Definition: glfw3.h:468
#define GLFW_KEY_S
Definition: glfw3.h:396
#define GLFW_KEY_F1
Definition: glfw3.h:431
void _glfwTerminateEGL(void)
Definition: egl_context.c:432
#define GLFW_KEY_0
Definition: glfw3.h:366
#define GLFW_KEY_NUM_LOCK
Definition: glfw3.h:428
static void pointerHandleAxis(void *data, struct wl_pointer *pointer, uint32_t time, uint32_t axis, wl_fixed_t value)
Definition: wl_init.c:326
#define xkb_keymap_key_repeats
Definition: wl_platform.h:125
GLint GLint GLsizei GLint GLenum format
#define GLFW_KEY_TAB
Definition: glfw3.h:414
struct _GLFWwindow * next
Definition: internal.h:367
void(* PFN_wl_cursor_theme_destroy)(struct wl_cursor_theme *)
Definition: wl_platform.h:94
#define GLFW_KEY_W
Definition: glfw3.h:400
static void pointerHandleLeave(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface)
Definition: wl_init.c:111
#define GLFW_KEY_U
Definition: glfw3.h:398
#define GLFW_KEY_4
Definition: glfw3.h:370
#define GLFW_KEY_N
Definition: glfw3.h:391
#define GLFW_KEY_F12
Definition: glfw3.h:442
#define GLFW_KEY_F17
Definition: glfw3.h:447
#define GLFW_KEY_KP_4
Definition: glfw3.h:460
#define GLFW_KEY_2
Definition: glfw3.h:368
void _glfwInputKey(_GLFWwindow *window, int key, int scancode, int action, int mods)
Definition: input.c:259
struct wl_buffer *(* PFN_wl_cursor_image_get_buffer)(struct wl_cursor_image *)
Definition: wl_platform.h:96
#define GLFW_KEY_3
Definition: glfw3.h:369
#define GLFW_KEY_MENU
Definition: glfw3.h:481
#define xkb_context_new
Definition: wl_platform.h:120
#define GLFW_KEY_ENTER
Definition: glfw3.h:413
void(* PFN_xkb_context_unref)(struct xkb_context *)
Definition: wl_platform.h:110
void _glfwInputError(int code, const char *format,...)
Definition: init.c:129
void _glfwInputMonitor(_GLFWmonitor *monitor, int action, int placement)
Definition: monitor.c:91
#define GLFW_KEY_G
Definition: glfw3.h:384
#define GLFW_KEY_D
Definition: glfw3.h:381
long _glfwKeySym2Unicode(unsigned int keysym)
Definition: xkb_unicode.c:908
#define GLFW_MOD_ALT
If this bit is set one or more Alt keys were held down.
Definition: glfw3.h:509
action
Definition: enums.py:62
void(* PFN_xkb_keymap_unref)(struct xkb_keymap *)
Definition: wl_platform.h:112
#define GLFW_MOD_CAPS_LOCK
If this bit is set the Caps Lock key is enabled.
Definition: glfw3.h:520
struct xkb_state *(* PFN_xkb_state_new)(struct xkb_keymap *)
Definition: wl_platform.h:115
#define xkb_keymap_mod_get_index
Definition: wl_platform.h:124
#define GLFW_KEY_F23
Definition: glfw3.h:453
#define GLFW_KEY_M
Definition: glfw3.h:390
#define GLFW_TRUE
One.
Definition: glfw3.h:279
#define GLFW_KEY_F4
Definition: glfw3.h:434
void _glfwInputCursorPos(_GLFWwindow *window, double xpos, double ypos)
Definition: input.c:338
#define GLFW_KEY_RIGHT_BRACKET
Definition: glfw3.h:406
#define GLFW_KEY_DOWN
Definition: glfw3.h:420
static void keyboardHandleKeymap(void *data, struct wl_keyboard *keyboard, uint32_t format, int fd, uint32_t size)
Definition: wl_init.c:361
#define GLFW_KEY_J
Definition: glfw3.h:387
#define xkb_context_unref
Definition: wl_platform.h:121
static const struct wl_keyboard_listener keyboardListener
Definition: wl_init.c:659
#define GLFW_KEY_L
Definition: glfw3.h:389
#define GLFW_KEY_KP_ENTER
Definition: glfw3.h:471
#define GLFW_KEY_KP_SUBTRACT
Definition: glfw3.h:469
static void pointerHandleEnter(void *data, struct wl_pointer *pointer, uint32_t serial, struct wl_surface *surface, wl_fixed_t sx, wl_fixed_t sy)
Definition: wl_init.c:81
#define GLFW_KEY_9
Definition: glfw3.h:375
int(* PFN_xkb_state_key_get_syms)(struct xkb_state *, xkb_keycode_t, const xkb_keysym_t **)
Definition: wl_platform.h:117
#define GLFW_KEY_COMMA
Definition: glfw3.h:362
static void createKeyTables(void)
Definition: wl_init.c:902
#define GLFW_KEY_RIGHT_ALT
Definition: glfw3.h:479
#define GLFW_KEY_F19
Definition: glfw3.h:449
#define GLFW_KEY_SLASH
Definition: glfw3.h:365
#define GLFW_KEY_PRINT_SCREEN
Definition: glfw3.h:429
struct xkb_keymap *(* PFN_xkb_keymap_new_from_string)(struct xkb_context *, const char *, enum xkb_keymap_format, enum xkb_keymap_compile_flags)
Definition: wl_platform.h:111
#define GLFW_KEY_F22
Definition: glfw3.h:452
enum xkb_state_component(* PFN_xkb_state_update_mask)(struct xkb_state *, xkb_mod_mask_t, xkb_mod_mask_t, xkb_mod_mask_t, xkb_layout_index_t, xkb_layout_index_t, xkb_layout_index_t)
Definition: wl_platform.h:118
#define wl_cursor_theme_load
Definition: wl_platform.h:97
#define GLFW_KEY_LEFT_CONTROL
Definition: glfw3.h:474
void _glfwTerminateJoysticksLinux(void)
#define GLFW_KEY_KP_8
Definition: glfw3.h:464
#define GLFW_KEY_Q
Definition: glfw3.h:394
#define GLFW_KEY_KP_0
Definition: glfw3.h:456
uint32_t width
Definition: wl_platform.h:82
static int min(int n1, int n2)
Definition: wl_init.c:42
#define GLFW_KEY_KP_EQUAL
Definition: glfw3.h:472
static void dataDeviceHandleLeave(void *data, struct wl_data_device *dataDevice)
Definition: wl_init.c:739
#define NULL
Definition: tinycthread.c:47
int i
_GLFWmonitor ** monitors
Definition: internal.h:528
#define GLFW_KEY_LEFT_ALT
Definition: glfw3.h:475
static void setCursor(_GLFWwindow *window, const char *name)
Definition: wl_init.c:128
#define _glfw_dlsym(handle, name)
signed int int32_t
Definition: stdint.h:77
#define xkb_state_key_get_syms
Definition: wl_platform.h:128
#define GLFW_KEY_F3
Definition: glfw3.h:433
void _glfwInputMouseClick(_GLFWwindow *window, int button, int action, int mods)
Definition: input.c:318
GLuint64 GLenum GLint fd
Definition: glext.h:7768
void(* PFN_wl_egl_window_destroy)(struct wl_egl_window *)
Definition: wl_platform.h:103
#define GLFW_KEY_F21
Definition: glfw3.h:451
#define GLFW_KEY_RIGHT_SHIFT
Definition: glfw3.h:477
#define GLFW_KEY_R
Definition: glfw3.h:395
#define GLFW_KEY_F16
Definition: glfw3.h:446
#define GLFW_KEY_RIGHT
Definition: glfw3.h:418
#define GLFW_KEY_Y
Definition: glfw3.h:402
GLFWbool _glfwInitJoysticksLinux(void)
#define GLFW_KEY_BACKSLASH
Definition: glfw3.h:405
#define GLFW_KEY_F18
Definition: glfw3.h:448
#define GLFW_KEY_O
Definition: glfw3.h:392
#define GLFW_KEY_APOSTROPHE
Definition: glfw3.h:361
#define GLFW_PRESS
The key or mouse button was pressed.
Definition: glfw3.h:304
#define GLFW_KEY_MINUS
Definition: glfw3.h:363
xkb_mod_index_t(* PFN_xkb_keymap_mod_get_index)(struct xkb_keymap *, const char *)
Definition: wl_platform.h:113
#define GLFW_KEY_F24
Definition: glfw3.h:454
#define wl_cursor_image_get_buffer
Definition: wl_platform.h:100
void _glfwPlatformSetCursor(_GLFWwindow *window, _GLFWcursor *cursor)
Definition: null_window.c:279
int(* PFN_xkb_keymap_key_repeats)(struct xkb_keymap *, xkb_keycode_t)
Definition: wl_platform.h:114
GLFWwindowfocusfun focus
Definition: internal.h:401
Definition: parser.hpp:150
#define GLFW_KEY_5
Definition: glfw3.h:371
#define GLFW_KEY_LEFT_SUPER
Definition: glfw3.h:476
#define GLFW_MOD_NUM_LOCK
If this bit is set the Num Lock key is enabled.
Definition: glfw3.h:526
#define GLFW_KEY_C
Definition: glfw3.h:380
#define xkb_keymap_new_from_string
Definition: wl_platform.h:122
static void dataDeviceHandleSelection(void *data, struct wl_data_device *dataDevice, struct wl_data_offer *id)
Definition: wl_init.c:757
static const struct wl_pointer_listener pointerListener
Definition: wl_init.c:353


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:50:23