SDL  2.0
SDL_waylandevents.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 #include "../../SDL_internal.h"
23 
24 #if SDL_VIDEO_DRIVER_WAYLAND
25 
26 #include "SDL_stdinc.h"
27 #include "SDL_assert.h"
28 #include "SDL_log.h"
29 
30 #include "../../core/unix/SDL_poll.h"
31 #include "../../events/SDL_sysevents.h"
32 #include "../../events/SDL_events_c.h"
33 #include "../../events/scancodes_xfree86.h"
34 
35 #include "SDL_waylandvideo.h"
36 #include "SDL_waylandevents_c.h"
37 #include "SDL_waylandwindow.h"
38 
39 #include "SDL_waylanddyn.h"
40 
45 
46 #include <linux/input.h>
47 #include <sys/select.h>
48 #include <sys/mman.h>
49 #include <poll.h>
50 #include <unistd.h>
51 #include <xkbcommon/xkbcommon.h>
52 
53 struct SDL_WaylandInput {
54  SDL_VideoData *display;
55  struct wl_seat *seat;
56  struct wl_pointer *pointer;
57  struct wl_touch *touch;
58  struct wl_keyboard *keyboard;
59  SDL_WaylandDataDevice *data_device;
60  struct zwp_relative_pointer_v1 *relative_pointer;
61  SDL_WindowData *pointer_focus;
62  SDL_WindowData *keyboard_focus;
63 
64  /* Last motion location */
65  wl_fixed_t sx_w;
66  wl_fixed_t sy_w;
67 
68  double dx_frac;
69  double dy_frac;
70 
71  struct {
72  struct xkb_keymap *keymap;
73  struct xkb_state *state;
74  } xkb;
75 
76  /* information about axis events on current frame */
77  struct {
78  SDL_bool is_x_discrete;
79  float x;
80 
81  SDL_bool is_y_discrete;
82  float y;
83  } pointer_curr_axis_info;
84 };
85 
86 struct SDL_WaylandTouchPoint {
88  float x;
89  float y;
90  struct wl_surface* surface;
91 
92  struct SDL_WaylandTouchPoint* prev;
93  struct SDL_WaylandTouchPoint* next;
94 };
95 
96 struct SDL_WaylandTouchPointList {
97  struct SDL_WaylandTouchPoint* head;
98  struct SDL_WaylandTouchPoint* tail;
99 };
100 
101 static struct SDL_WaylandTouchPointList touch_points = {NULL, NULL};
102 
103 static void
104 touch_add(SDL_TouchID id, float x, float y, struct wl_surface *surface)
105 {
106  struct SDL_WaylandTouchPoint* tp = SDL_malloc(sizeof(struct SDL_WaylandTouchPoint));
107 
108  tp->id = id;
109  tp->x = x;
110  tp->y = y;
111  tp->surface = surface;
112 
113  if (touch_points.tail) {
114  touch_points.tail->next = tp;
115  tp->prev = touch_points.tail;
116  } else {
117  touch_points.head = tp;
118  tp->prev = NULL;
119  }
120 
121  touch_points.tail = tp;
122  tp->next = NULL;
123 }
124 
125 static void
126 touch_update(SDL_TouchID id, float x, float y)
127 {
128  struct SDL_WaylandTouchPoint* tp = touch_points.head;
129 
130  while (tp) {
131  if (tp->id == id) {
132  tp->x = x;
133  tp->y = y;
134  }
135 
136  tp = tp->next;
137  }
138 }
139 
140 static void
141 touch_del(SDL_TouchID id, float* x, float* y, struct wl_surface **surface)
142 {
143  struct SDL_WaylandTouchPoint* tp = touch_points.head;
144 
145  while (tp) {
146  if (tp->id == id) {
147  *x = tp->x;
148  *y = tp->y;
149  *surface = tp->surface;
150 
151  if (tp->prev) {
152  tp->prev->next = tp->next;
153  } else {
154  touch_points.head = tp->next;
155  }
156 
157  if (tp->next) {
158  tp->next->prev = tp->prev;
159  } else {
160  touch_points.tail = tp->prev;
161  }
162 
163  {
164  struct SDL_WaylandTouchPoint *next = tp->next;
165  SDL_free(tp);
166  tp = next;
167  }
168  } else {
169  tp = tp->next;
170  }
171  }
172 }
173 
174 static struct wl_surface*
175 touch_surface(SDL_TouchID id)
176 {
177  struct SDL_WaylandTouchPoint* tp = touch_points.head;
178 
179  while (tp) {
180  if (tp->id == id) {
181  return tp->surface;
182  }
183 
184  tp = tp->next;
185  }
186 
187  return NULL;
188 }
189 
190 void
192 {
194  int err;
195 
196  WAYLAND_wl_display_flush(d->display);
197 
198  if (SDL_IOReady(WAYLAND_wl_display_get_fd(d->display), SDL_FALSE, 0)) {
199  err = WAYLAND_wl_display_dispatch(d->display);
200  } else {
201  err = WAYLAND_wl_display_dispatch_pending(d->display);
202  }
203  if (err == -1 && !d->display_disconnected) {
204  /* Something has failed with the Wayland connection -- for example,
205  * the compositor may have shut down and closed its end of the socket,
206  * or there is a library-specific error. No recovery is possible. */
207  d->display_disconnected = 1;
208  /* Only send a single quit message, as application shutdown might call
209  * SDL_PumpEvents */
210  SDL_SendQuit();
211  }
212 }
213 
214 static void
215 pointer_handle_enter(void *data, struct wl_pointer *pointer,
216  uint32_t serial, struct wl_surface *surface,
217  wl_fixed_t sx_w, wl_fixed_t sy_w)
218 {
219  struct SDL_WaylandInput *input = data;
221 
222  if (!surface) {
223  /* enter event for a window we've just destroyed */
224  return;
225  }
226 
227  /* This handler will be called twice in Wayland 1.4
228  * Once for the window surface which has valid user data
229  * and again for the mouse cursor surface which does not have valid user data
230  * We ignore the later
231  */
232 
234 
235  if (window) {
236  input->pointer_focus = window;
237  SDL_SetMouseFocus(window->sdlwindow);
238  }
239 }
240 
241 static void
242 pointer_handle_leave(void *data, struct wl_pointer *pointer,
243  uint32_t serial, struct wl_surface *surface)
244 {
245  struct SDL_WaylandInput *input = data;
246 
247  if (input->pointer_focus) {
249  input->pointer_focus = NULL;
250  }
251 }
252 
253 static void
254 pointer_handle_motion(void *data, struct wl_pointer *pointer,
255  uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w)
256 {
257  struct SDL_WaylandInput *input = data;
258  SDL_WindowData *window = input->pointer_focus;
259  input->sx_w = sx_w;
260  input->sy_w = sy_w;
261  if (input->pointer_focus) {
262  const int sx = wl_fixed_to_int(sx_w);
263  const int sy = wl_fixed_to_int(sy_w);
264  SDL_SendMouseMotion(window->sdlwindow, 0, 0, sx, sy);
265  }
266 }
267 
268 static SDL_bool
269 ProcessHitTest(struct SDL_WaylandInput *input, uint32_t serial)
270 {
271  SDL_WindowData *window_data = input->pointer_focus;
272  SDL_Window *window = window_data->sdlwindow;
273 
274  if (window->hit_test) {
275  const SDL_Point point = { wl_fixed_to_int(input->sx_w), wl_fixed_to_int(input->sy_w) };
276  const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data);
277 
278  static const uint32_t directions_wl[] = {
283  };
284 
285  /* the names are different (ZXDG_TOPLEVEL_V6_RESIZE_EDGE_* vs
286  WL_SHELL_SURFACE_RESIZE_*), but the values are the same. */
287  const uint32_t *directions_zxdg = directions_wl;
288 
289  switch (rc) {
291  if (input->display->shell.xdg) {
292  xdg_toplevel_move(window_data->shell_surface.xdg.roleobj.toplevel, input->seat, serial);
293  } else if (input->display->shell.zxdg) {
294  zxdg_toplevel_v6_move(window_data->shell_surface.zxdg.roleobj.toplevel, input->seat, serial);
295  } else {
296  wl_shell_surface_move(window_data->shell_surface.wl, input->seat, serial);
297  }
298  return SDL_TRUE;
299 
308  if (input->display->shell.xdg) {
309  xdg_toplevel_resize(window_data->shell_surface.xdg.roleobj.toplevel, input->seat, serial, directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
310  } else if (input->display->shell.zxdg) {
311  zxdg_toplevel_v6_resize(window_data->shell_surface.zxdg.roleobj.toplevel, input->seat, serial, directions_zxdg[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
312  } else {
313  wl_shell_surface_resize(window_data->shell_surface.wl, input->seat, serial, directions_wl[rc - SDL_HITTEST_RESIZE_TOPLEFT]);
314  }
315  return SDL_TRUE;
316 
317  default: return SDL_FALSE;
318  }
319  }
320 
321  return SDL_FALSE;
322 }
323 
324 static void
325 pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_t serial,
327 {
328  SDL_WindowData *window = input->pointer_focus;
329  enum wl_pointer_button_state state = state_w;
330  uint32_t sdl_button;
331 
332  if (input->pointer_focus) {
333  switch (button) {
334  case BTN_LEFT:
335  sdl_button = SDL_BUTTON_LEFT;
336  if (ProcessHitTest(input, serial)) {
337  return; /* don't pass this event on to app. */
338  }
339  break;
340  case BTN_MIDDLE:
341  sdl_button = SDL_BUTTON_MIDDLE;
342  break;
343  case BTN_RIGHT:
344  sdl_button = SDL_BUTTON_RIGHT;
345  break;
346  case BTN_SIDE:
347  sdl_button = SDL_BUTTON_X1;
348  break;
349  case BTN_EXTRA:
350  sdl_button = SDL_BUTTON_X2;
351  break;
352  default:
353  return;
354  }
355 
356  Wayland_data_device_set_serial(input->data_device, serial);
357 
358  SDL_SendMouseButton(window->sdlwindow, 0,
359  state ? SDL_PRESSED : SDL_RELEASED, sdl_button);
360  }
361 }
362 
363 static void
364 pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial,
366 {
367  struct SDL_WaylandInput *input = data;
368 
369  pointer_handle_button_common(input, serial, time, button, state_w);
370 }
371 
372 static void
373 pointer_handle_axis_common_v1(struct SDL_WaylandInput *input,
374  uint32_t time, uint32_t axis, wl_fixed_t value)
375 {
376  SDL_WindowData *window = input->pointer_focus;
377  enum wl_pointer_axis a = axis;
378  float x, y;
379 
380  if (input->pointer_focus) {
381  switch (a) {
383  x = 0;
384  y = 0 - (float)wl_fixed_to_double(value);
385  break;
387  x = 0 - (float)wl_fixed_to_double(value);
388  y = 0;
389  break;
390  default:
391  return;
392  }
393 
395  }
396 }
397 
398 static void
399 pointer_handle_axis_common(struct SDL_WaylandInput *input, SDL_bool discrete,
400  uint32_t axis, wl_fixed_t value)
401 {
402  enum wl_pointer_axis a = axis;
403 
404  if (input->pointer_focus) {
405  switch (a) {
407  if (discrete) {
408  /* this is a discrete axis event so we process it and flag
409  * to ignore future continuous axis events in this frame */
410  input->pointer_curr_axis_info.is_y_discrete = SDL_TRUE;
411  } else if(input->pointer_curr_axis_info.is_y_discrete) {
412  /* this is a continuous axis event and we have already
413  * processed a discrete axis event before so we ignore it */
414  break;
415  }
416  input->pointer_curr_axis_info.y = 0 - (float)wl_fixed_to_double(value);
417  break;
419  if (discrete) {
420  /* this is a discrete axis event so we process it and flag
421  * to ignore future continuous axis events in this frame */
422  input->pointer_curr_axis_info.is_x_discrete = SDL_TRUE;
423  } else if(input->pointer_curr_axis_info.is_x_discrete) {
424  /* this is a continuous axis event and we have already
425  * processed a discrete axis event before so we ignore it */
426  break;
427  }
428  input->pointer_curr_axis_info.x = 0 - (float)wl_fixed_to_double(value);
429  break;
430  }
431  }
432 }
433 
434 static void
435 pointer_handle_axis(void *data, struct wl_pointer *pointer,
436  uint32_t time, uint32_t axis, wl_fixed_t value)
437 {
438  struct SDL_WaylandInput *input = data;
439 
440  if(wl_seat_interface.version >= 5)
441  pointer_handle_axis_common(input, SDL_FALSE, axis, value);
442  else
443  pointer_handle_axis_common_v1(input, time, axis, value);
444 }
445 
446 static void
447 pointer_handle_frame(void *data, struct wl_pointer *pointer)
448 {
449  struct SDL_WaylandInput *input = data;
450  SDL_WindowData *window = input->pointer_focus;
451  float x = input->pointer_curr_axis_info.x, y = input->pointer_curr_axis_info.y;
452 
453  /* clear pointer_curr_axis_info for next frame */
454  memset(&input->pointer_curr_axis_info, 0, sizeof input->pointer_curr_axis_info);
455 
456  if(x == 0.0f && y == 0.0f)
457  return;
458  else
460 }
461 
462 static void
463 pointer_handle_axis_source(void *data, struct wl_pointer *pointer,
464  uint32_t axis_source)
465 {
466  /* unimplemented */
467 }
468 
469 static void
470 pointer_handle_axis_stop(void *data, struct wl_pointer *pointer,
472 {
473  /* unimplemented */
474 }
475 
476 static void
477 pointer_handle_axis_discrete(void *data, struct wl_pointer *pointer,
478  uint32_t axis, int32_t discrete)
479 {
480  struct SDL_WaylandInput *input = data;
481 
482  pointer_handle_axis_common(input, SDL_TRUE, axis, wl_fixed_from_int(discrete));
483 }
484 
485 
486 static const struct wl_pointer_listener pointer_listener = {
487  pointer_handle_enter,
488  pointer_handle_leave,
489  pointer_handle_motion,
490  pointer_handle_button,
491  pointer_handle_axis,
492  pointer_handle_frame, // Version 5
493  pointer_handle_axis_source, // Version 5
494  pointer_handle_axis_stop, // Version 5
495  pointer_handle_axis_discrete, // Version 5
496 };
497 
498 static void
499 touch_handler_down(void *data, struct wl_touch *touch, unsigned int serial,
500  unsigned int timestamp, struct wl_surface *surface,
501  int id, wl_fixed_t fx, wl_fixed_t fy)
502 {
504  const double dblx = wl_fixed_to_double(fx);
505  const double dbly = wl_fixed_to_double(fy);
506  const float x = dblx / window_data->sdlwindow->w;
507  const float y = dbly / window_data->sdlwindow->h;
508 
509  touch_add(id, x, y, surface);
510 
511  SDL_SendTouch(1, (SDL_FingerID)id, window_data->sdlwindow, SDL_TRUE, x, y, 1.0f);
512 }
513 
514 static void
515 touch_handler_up(void *data, struct wl_touch *touch, unsigned int serial,
516  unsigned int timestamp, int id)
517 {
518  float x = 0, y = 0;
519  struct wl_surface *surface = NULL;
521 
522  touch_del(id, &x, &y, &surface);
523 
524  if (surface) {
526  window = window_data->sdlwindow;
527  }
528 
529  SDL_SendTouch(1, (SDL_FingerID)id, window, SDL_FALSE, x, y, 0.0f);
530 }
531 
532 static void
533 touch_handler_motion(void *data, struct wl_touch *touch, unsigned int timestamp,
534  int id, wl_fixed_t fx, wl_fixed_t fy)
535 {
536  SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(touch_surface(id));
537  const double dblx = wl_fixed_to_double(fx);
538  const double dbly = wl_fixed_to_double(fy);
539  const float x = dblx / window_data->sdlwindow->w;
540  const float y = dbly / window_data->sdlwindow->h;
541 
542  touch_update(id, x, y);
543  SDL_SendTouchMotion(1, (SDL_FingerID)id, window_data->sdlwindow, x, y, 1.0f);
544 }
545 
546 static void
547 touch_handler_frame(void *data, struct wl_touch *touch)
548 {
549 
550 }
551 
552 static void
553 touch_handler_cancel(void *data, struct wl_touch *touch)
554 {
555 
556 }
557 
558 static const struct wl_touch_listener touch_listener = {
559  touch_handler_down,
560  touch_handler_up,
561  touch_handler_motion,
562  touch_handler_frame,
563  touch_handler_cancel,
564  NULL, /* shape */
565  NULL, /* orientation */
566 };
567 
568 static void
569 keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
571 {
572  struct SDL_WaylandInput *input = data;
573  char *map_str;
574 
575  if (!data) {
576  close(fd);
577  return;
578  }
579 
581  close(fd);
582  return;
583  }
584 
585  map_str = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
586  if (map_str == MAP_FAILED) {
587  close(fd);
588  return;
589  }
590 
591  input->xkb.keymap = WAYLAND_xkb_keymap_new_from_string(input->display->xkb_context,
592  map_str,
593  XKB_KEYMAP_FORMAT_TEXT_V1,
594  0);
595  munmap(map_str, size);
596  close(fd);
597 
598  if (!input->xkb.keymap) {
599  fprintf(stderr, "failed to compile keymap\n");
600  return;
601  }
602 
603  input->xkb.state = WAYLAND_xkb_state_new(input->xkb.keymap);
604  if (!input->xkb.state) {
605  fprintf(stderr, "failed to create XKB state\n");
606  WAYLAND_xkb_keymap_unref(input->xkb.keymap);
607  input->xkb.keymap = NULL;
608  return;
609  }
610 }
611 
612 static void
613 keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
614  uint32_t serial, struct wl_surface *surface,
615  struct wl_array *keys)
616 {
617  struct SDL_WaylandInput *input = data;
619 
620  if (!surface) {
621  /* enter event for a window we've just destroyed */
622  return;
623  }
624 
626 
627  if (window) {
628  input->keyboard_focus = window;
629  window->keyboard_device = input;
630  SDL_SetKeyboardFocus(window->sdlwindow);
631  }
632 }
633 
634 static void
635 keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
636  uint32_t serial, struct wl_surface *surface)
637 {
639 }
640 
641 static void
642 keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
643  uint32_t serial, uint32_t time, uint32_t key,
644  uint32_t state_w)
645 {
646  struct SDL_WaylandInput *input = data;
647  SDL_WindowData *window = input->keyboard_focus;
648  enum wl_keyboard_key_state state = state_w;
649  const xkb_keysym_t *syms;
650  uint32_t scancode;
651  char text[8];
652  int size;
653 
655  scancode = xfree86_scancode_table2[key];
656 
657  // TODO when do we get WL_KEYBOARD_KEY_STATE_REPEAT?
658  if (scancode != SDL_SCANCODE_UNKNOWN)
660  SDL_PRESSED : SDL_RELEASED, scancode);
661  }
662 
663  if (!window || window->keyboard_device != input || !input->xkb.state)
664  return;
665 
666  // TODO can this happen?
667  if (WAYLAND_xkb_state_key_get_syms(input->xkb.state, key + 8, &syms) != 1)
668  return;
669 
670  if (state) {
671  size = WAYLAND_xkb_keysym_to_utf8(syms[0], text, sizeof text);
672 
673  if (size > 0) {
674  text[size] = 0;
675 
676  Wayland_data_device_set_serial(input->data_device, serial);
677 
679  }
680  }
681 }
682 
683 static void
684 keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,
685  uint32_t serial, uint32_t mods_depressed,
686  uint32_t mods_latched, uint32_t mods_locked,
687  uint32_t group)
688 {
689  struct SDL_WaylandInput *input = data;
690 
691  WAYLAND_xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched,
692  mods_locked, 0, 0, group);
693 }
694 
695 static void
696 keyboard_handle_repeat_info(void *data, struct wl_keyboard *wl_keyboard,
697  int32_t rate, int32_t delay)
698 {
699  /* unimplemented */
700 }
701 
702 static const struct wl_keyboard_listener keyboard_listener = {
703  keyboard_handle_keymap,
704  keyboard_handle_enter,
705  keyboard_handle_leave,
706  keyboard_handle_key,
707  keyboard_handle_modifiers,
708  keyboard_handle_repeat_info, // Version 4
709 };
710 
711 static void
712 seat_handle_capabilities(void *data, struct wl_seat *seat,
713  enum wl_seat_capability caps)
714 {
715  struct SDL_WaylandInput *input = data;
716 
717  if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) {
718  input->pointer = wl_seat_get_pointer(seat);
719  memset(&input->pointer_curr_axis_info, 0, sizeof input->pointer_curr_axis_info);
720  input->display->pointer = input->pointer;
722  wl_pointer_add_listener(input->pointer, &pointer_listener,
723  input);
724  } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) {
725  wl_pointer_destroy(input->pointer);
726  input->pointer = NULL;
727  input->display->pointer = NULL;
728  }
729 
730  if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !input->touch) {
731  SDL_AddTouch(1, SDL_TOUCH_DEVICE_DIRECT, "wayland_touch");
732  input->touch = wl_seat_get_touch(seat);
734  wl_touch_add_listener(input->touch, &touch_listener,
735  input);
736  } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->touch) {
737  SDL_DelTouch(1);
738  wl_touch_destroy(input->touch);
739  input->touch = NULL;
740  }
741 
742  if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) {
743  input->keyboard = wl_seat_get_keyboard(seat);
745  wl_keyboard_add_listener(input->keyboard, &keyboard_listener,
746  input);
747  } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) {
748  wl_keyboard_destroy(input->keyboard);
749  input->keyboard = NULL;
750  }
751 }
752 
753 static void
754 seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name)
755 {
756  /* unimplemented */
757 }
758 
759 static const struct wl_seat_listener seat_listener = {
760  seat_handle_capabilities,
761  seat_handle_name, // Version 2
762 };
763 
764 static void
765 data_source_handle_target(void *data, struct wl_data_source *wl_data_source,
766  const char *mime_type)
767 {
768 }
769 
770 static void
771 data_source_handle_send(void *data, struct wl_data_source *wl_data_source,
772  const char *mime_type, int32_t fd)
773 {
775 }
776 
777 static void
778 data_source_handle_cancelled(void *data, struct wl_data_source *wl_data_source)
779 {
781 }
782 
783 static void
784 data_source_handle_dnd_drop_performed(void *data, struct wl_data_source *wl_data_source)
785 {
786 }
787 
788 static void
789 data_source_handle_dnd_finished(void *data, struct wl_data_source *wl_data_source)
790 {
791 }
792 
793 static void
794 data_source_handle_action(void *data, struct wl_data_source *wl_data_source,
795  uint32_t dnd_action)
796 {
797 }
798 
799 static const struct wl_data_source_listener data_source_listener = {
800  data_source_handle_target,
801  data_source_handle_send,
802  data_source_handle_cancelled,
803  data_source_handle_dnd_drop_performed, // Version 3
804  data_source_handle_dnd_finished, // Version 3
805  data_source_handle_action, // Version 3
806 };
807 
810 {
811  SDL_WaylandDataSource *data_source = NULL;
812  SDL_VideoData *driver_data = NULL;
813  struct wl_data_source *id = NULL;
814 
815  if (_this == NULL || _this->driverdata == NULL) {
816  SDL_SetError("Video driver uninitialized");
817  } else {
818  driver_data = _this->driverdata;
819 
820  if (driver_data->data_device_manager != NULL) {
822  driver_data->data_device_manager);
823  }
824 
825  if (id == NULL) {
826  SDL_SetError("Wayland unable to create data source");
827  } else {
828  data_source = SDL_calloc(1, sizeof *data_source);
829  if (data_source == NULL) {
830  SDL_OutOfMemory();
832  } else {
833  WAYLAND_wl_list_init(&(data_source->mimes));
834  data_source->source = id;
835  wl_data_source_set_user_data(id, data_source);
836  wl_data_source_add_listener(id, &data_source_listener,
837  data_source);
838  }
839  }
840  }
841  return data_source;
842 }
843 
844 static void
845 data_offer_handle_offer(void *data, struct wl_data_offer *wl_data_offer,
846  const char *mime_type)
847 {
848  SDL_WaylandDataOffer *offer = data;
849  Wayland_data_offer_add_mime(offer, mime_type);
850 }
851 
852 static void
853 data_offer_handle_source_actions(void *data, struct wl_data_offer *wl_data_offer,
854  uint32_t source_actions)
855 {
856 }
857 
858 static void
859 data_offer_handle_actions(void *data, struct wl_data_offer *wl_data_offer,
860  uint32_t dnd_action)
861 {
862 }
863 
864 static const struct wl_data_offer_listener data_offer_listener = {
865  data_offer_handle_offer,
866  data_offer_handle_source_actions, // Version 3
867  data_offer_handle_actions, // Version 3
868 };
869 
870 static void
871 data_device_handle_data_offer(void *data, struct wl_data_device *wl_data_device,
872  struct wl_data_offer *id)
873 {
874  SDL_WaylandDataOffer *data_offer = NULL;
875 
876  data_offer = SDL_calloc(1, sizeof *data_offer);
877  if (data_offer == NULL) {
878  SDL_OutOfMemory();
879  } else {
880  data_offer->offer = id;
881  data_offer->data_device = data;
882  WAYLAND_wl_list_init(&(data_offer->mimes));
883  wl_data_offer_set_user_data(id, data_offer);
884  wl_data_offer_add_listener(id, &data_offer_listener, data_offer);
885  }
886 }
887 
888 static void
889 data_device_handle_enter(void *data, struct wl_data_device *wl_data_device,
890  uint32_t serial, struct wl_surface *surface,
891  wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *id)
892 {
893  SDL_WaylandDataDevice *data_device = data;
894  SDL_bool has_mime = SDL_FALSE;
896 
897  data_device->drag_serial = serial;
898 
899  if (id != NULL) {
900  data_device->drag_offer = wl_data_offer_get_user_data(id);
901 
902  /* TODO: SDL Support more mime types */
903  has_mime = Wayland_data_offer_has_mime(
904  data_device->drag_offer, FILE_MIME);
905 
906  /* If drag_mime is NULL this will decline the offer */
907  wl_data_offer_accept(id, serial,
908  (has_mime == SDL_TRUE) ? FILE_MIME : NULL);
909 
910  /* SDL only supports "copy" style drag and drop */
911  if (has_mime == SDL_TRUE) {
913  }
914  if (wl_data_offer_get_version(data_device->drag_offer->offer) >= 3) {
916  dnd_action, dnd_action);
917  }
918  }
919 }
920 
921 static void
922 data_device_handle_leave(void *data, struct wl_data_device *wl_data_device)
923 {
924  SDL_WaylandDataDevice *data_device = data;
926 
927  if (data_device->selection_offer != NULL) {
928  data_device->selection_offer = NULL;
930  }
931 }
932 
933 static void
934 data_device_handle_motion(void *data, struct wl_data_device *wl_data_device,
935  uint32_t time, wl_fixed_t x, wl_fixed_t y)
936 {
937 }
938 
939 static void
940 data_device_handle_drop(void *data, struct wl_data_device *wl_data_device)
941 {
942  SDL_WaylandDataDevice *data_device = data;
943  void *buffer = NULL;
944  size_t length = 0;
945 
946  const char *current_uri = NULL;
947  const char *last_char = NULL;
948  char *current_char = NULL;
949 
950  if (data_device->drag_offer != NULL) {
951  /* TODO: SDL Support more mime types */
954 
955  /* uri-list */
956  current_uri = (const char *)buffer;
957  last_char = (const char *)buffer + length;
958  for (current_char = buffer; current_char < last_char; ++current_char) {
959  if (*current_char == '\n' || *current_char == 0) {
960  if (*current_uri != 0 && *current_uri != '#') {
961  *current_char = 0;
962  SDL_SendDropFile(NULL, current_uri);
963  }
964  current_uri = (const char *)current_char + 1;
965  }
966  }
967 
968  SDL_free(buffer);
969  }
970 }
971 
972 static void
973 data_device_handle_selection(void *data, struct wl_data_device *wl_data_device,
974  struct wl_data_offer *id)
975 {
976  SDL_WaylandDataDevice *data_device = data;
978 
979  if (id != NULL) {
981  }
982 
983  if (data_device->selection_offer != offer) {
985  data_device->selection_offer = offer;
986  }
987 
989 }
990 
991 static const struct wl_data_device_listener data_device_listener = {
992  data_device_handle_data_offer,
993  data_device_handle_enter,
994  data_device_handle_leave,
995  data_device_handle_motion,
996  data_device_handle_drop,
997  data_device_handle_selection
998 };
999 
1000 void
1002 {
1003  struct SDL_WaylandInput *input;
1004  SDL_WaylandDataDevice *data_device = NULL;
1005 
1006  input = SDL_calloc(1, sizeof *input);
1007  if (input == NULL)
1008  return;
1009 
1010  input->display = d;
1011  if (wl_seat_interface.version >= 5)
1012  input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, 5);
1013  else
1014  input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, 1);
1015  input->sx_w = wl_fixed_from_int(0);
1016  input->sy_w = wl_fixed_from_int(0);
1017  d->input = input;
1018 
1019  if (d->data_device_manager != NULL) {
1020  data_device = SDL_calloc(1, sizeof *data_device);
1021  if (data_device == NULL) {
1022  return;
1023  }
1024 
1026  d->data_device_manager, input->seat
1027  );
1028  data_device->video_data = d;
1029 
1030  if (data_device->data_device == NULL) {
1031  SDL_free(data_device);
1032  } else {
1033  wl_data_device_set_user_data(data_device->data_device, data_device);
1035  &data_device_listener, data_device);
1036  input->data_device = data_device;
1037  }
1038  }
1039 
1040  wl_seat_add_listener(input->seat, &seat_listener, input);
1042 
1043  WAYLAND_wl_display_flush(d->display);
1044 }
1045 
1047 {
1048  struct SDL_WaylandInput *input = d->input;
1049 
1050  if (!input)
1051  return;
1052 
1053  if (input->data_device != NULL) {
1055  if (input->data_device->selection_offer != NULL) {
1056  Wayland_data_offer_destroy(input->data_device->selection_offer);
1057  }
1058  if (input->data_device->drag_offer != NULL) {
1059  Wayland_data_offer_destroy(input->data_device->drag_offer);
1060  }
1061  if (input->data_device->data_device != NULL) {
1062  wl_data_device_release(input->data_device->data_device);
1063  }
1064  SDL_free(input->data_device);
1065  }
1066 
1067  if (input->keyboard)
1068  wl_keyboard_destroy(input->keyboard);
1069 
1070  if (input->pointer)
1071  wl_pointer_destroy(input->pointer);
1072 
1073  if (input->touch) {
1074  SDL_DelTouch(1);
1075  wl_touch_destroy(input->touch);
1076  }
1077 
1078  if (input->seat)
1079  wl_seat_destroy(input->seat);
1080 
1081  if (input->xkb.state)
1082  WAYLAND_xkb_state_unref(input->xkb.state);
1083 
1084  if (input->xkb.keymap)
1085  WAYLAND_xkb_keymap_unref(input->xkb.keymap);
1086 
1087  SDL_free(input);
1088  d->input = NULL;
1089 }
1090 
1091 SDL_WaylandDataDevice* Wayland_get_data_device(struct SDL_WaylandInput *input)
1092 {
1093  if (input == NULL) {
1094  return NULL;
1095  }
1096 
1097  return input->data_device;
1098 }
1099 
1100 /* !!! FIXME: just merge these into display_handle_global(). */
1102 {
1103  d->relative_pointer_manager =
1104  wl_registry_bind(d->registry, id,
1106 }
1107 
1109 {
1110  if (d->relative_pointer_manager)
1111  zwp_relative_pointer_manager_v1_destroy(d->relative_pointer_manager);
1112 }
1113 
1115 {
1116  d->pointer_constraints =
1117  wl_registry_bind(d->registry, id,
1119 }
1120 
1122 {
1123  if (d->pointer_constraints)
1124  zwp_pointer_constraints_v1_destroy(d->pointer_constraints);
1125 }
1126 
1127 static void
1128 relative_pointer_handle_relative_motion(void *data,
1129  struct zwp_relative_pointer_v1 *pointer,
1130  uint32_t time_hi,
1131  uint32_t time_lo,
1132  wl_fixed_t dx_w,
1133  wl_fixed_t dy_w,
1134  wl_fixed_t dx_unaccel_w,
1135  wl_fixed_t dy_unaccel_w)
1136 {
1137  struct SDL_WaylandInput *input = data;
1138  SDL_VideoData *d = input->display;
1139  SDL_WindowData *window = input->pointer_focus;
1140  double dx_unaccel;
1141  double dy_unaccel;
1142  double dx;
1143  double dy;
1144 
1145  dx_unaccel = wl_fixed_to_double(dx_unaccel_w);
1146  dy_unaccel = wl_fixed_to_double(dy_unaccel_w);
1147 
1148  /* Add left over fraction from last event. */
1149  dx_unaccel += input->dx_frac;
1150  dy_unaccel += input->dy_frac;
1151 
1152  input->dx_frac = modf(dx_unaccel, &dx);
1153  input->dy_frac = modf(dy_unaccel, &dy);
1154 
1155  if (input->pointer_focus && d->relative_mouse_mode) {
1156  SDL_SendMouseMotion(window->sdlwindow, 0, 1, (int)dx, (int)dy);
1157  }
1158 }
1159 
1160 static const struct zwp_relative_pointer_v1_listener relative_pointer_listener = {
1161  relative_pointer_handle_relative_motion,
1162 };
1163 
1164 static void
1165 locked_pointer_locked(void *data,
1166  struct zwp_locked_pointer_v1 *locked_pointer)
1167 {
1168 }
1169 
1170 static void
1171 locked_pointer_unlocked(void *data,
1172  struct zwp_locked_pointer_v1 *locked_pointer)
1173 {
1174 }
1175 
1176 static const struct zwp_locked_pointer_v1_listener locked_pointer_listener = {
1177  locked_pointer_locked,
1178  locked_pointer_unlocked,
1179 };
1180 
1181 static void
1182 lock_pointer_to_window(SDL_Window *window,
1183  struct SDL_WaylandInput *input)
1184 {
1185  SDL_WindowData *w = window->driverdata;
1186  SDL_VideoData *d = input->display;
1187  struct zwp_locked_pointer_v1 *locked_pointer;
1188 
1189  if (w->locked_pointer)
1190  return;
1191 
1192  locked_pointer =
1193  zwp_pointer_constraints_v1_lock_pointer(d->pointer_constraints,
1194  w->surface,
1195  input->pointer,
1196  NULL,
1198  zwp_locked_pointer_v1_add_listener(locked_pointer,
1199  &locked_pointer_listener,
1200  window);
1201 
1202  w->locked_pointer = locked_pointer;
1203 }
1204 
1205 int Wayland_input_lock_pointer(struct SDL_WaylandInput *input)
1206 {
1208  SDL_VideoData *d = input->display;
1209  SDL_Window *window;
1210  struct zwp_relative_pointer_v1 *relative_pointer;
1211 
1212  if (!d->relative_pointer_manager)
1213  return -1;
1214 
1215  if (!d->pointer_constraints)
1216  return -1;
1217 
1218  if (!input->pointer)
1219  return -1;
1220 
1221  if (!input->relative_pointer) {
1222  relative_pointer =
1224  d->relative_pointer_manager,
1225  input->pointer);
1226  zwp_relative_pointer_v1_add_listener(relative_pointer,
1227  &relative_pointer_listener,
1228  input);
1229  input->relative_pointer = relative_pointer;
1230  }
1231 
1232  for (window = vd->windows; window; window = window->next)
1233  lock_pointer_to_window(window, input);
1234 
1235  d->relative_mouse_mode = 1;
1236 
1237  return 0;
1238 }
1239 
1240 int Wayland_input_unlock_pointer(struct SDL_WaylandInput *input)
1241 {
1243  SDL_VideoData *d = input->display;
1244  SDL_Window *window;
1245  SDL_WindowData *w;
1246 
1247  for (window = vd->windows; window; window = window->next) {
1248  w = window->driverdata;
1249  if (w->locked_pointer)
1250  zwp_locked_pointer_v1_destroy(w->locked_pointer);
1251  w->locked_pointer = NULL;
1252  }
1253 
1254  zwp_relative_pointer_v1_destroy(input->relative_pointer);
1255  input->relative_pointer = NULL;
1256 
1257  d->relative_mouse_mode = 0;
1258 
1259  return 0;
1260 }
1261 
1262 #endif /* SDL_VIDEO_DRIVER_WAYLAND */
1263 
1264 /* vi: set ts=4 sw=4 expandtab: */
SDL_HITTEST_DRAGGABLE
@ SDL_HITTEST_DRAGGABLE
Definition: SDL_video.h:1022
wl_data_offer_get_user_data
static void * wl_data_offer_get_user_data(struct wl_data_offer *wl_data_offer)
Definition: wayland-client-protocol.h:1920
SDL_zxdg_shell_surface::toplevel
struct zxdg_toplevel_v6 * toplevel
Definition: SDL_waylandwindow.h:38
SDL_TOUCH_DEVICE_DIRECT
@ SDL_TOUCH_DEVICE_DIRECT
Definition: SDL_touch.h:47
wl_data_offer_set_user_data
static void wl_data_offer_set_user_data(struct wl_data_offer *wl_data_offer, void *user_data)
Definition: wayland-client-protocol.h:1913
SDL_waylandvideo.h
wl_data_offer_add_listener
static int wl_data_offer_add_listener(struct wl_data_offer *wl_data_offer, const struct wl_data_offer_listener *listener, void *data)
Definition: wayland-client-protocol.h:1864
format
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: SDL_opengl.h:1572
SDL_waylandevents_c.h
WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1
@ WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1
Definition: wayland-client-protocol.h:4482
wl_seat_destroy
static void wl_seat_destroy(struct wl_seat *wl_seat)
Definition: wayland-client-protocol.h:3883
wl_shell_surface_resize
wl_shell_surface_resize
Definition: wayland-client-protocol.h:2782
SDL_VideoDevice::driverdata
void * driverdata
Definition: SDL_sysvideo.h:389
SDL_WaylandDataDevice::data_device
struct wl_data_device * data_device
Definition: SDL_waylanddatamanager.h:52
wl_seat_get_keyboard
static struct wl_keyboard * wl_seat_get_keyboard(struct wl_seat *wl_seat)
Definition: wayland-client-protocol.h:3922
wl_pointer_axis
wl_pointer_axis
Definition: wayland-client-protocol.h:4008
WL_SHELL_SURFACE_RESIZE_TOP_RIGHT
@ WL_SHELL_SURFACE_RESIZE_TOP_RIGHT
Definition: wayland-client-protocol.h:2814
tail
SDL_EventEntry * tail
Definition: SDL_events.c:88
time
EGLSurface EGLnsecsANDROID time
Definition: eglext.h:518
Wayland_data_offer_receive
void * Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, size_t *length, const char *mime_type, SDL_bool null_terminate)
zxdg_toplevel_v6_resize
static void zxdg_toplevel_v6_resize(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_seat *seat, uint32_t serial, uint32_t edges)
Definition: xdg-shell-unstable-v6-client-protocol.h:1377
Wayland_get_data_device
SDL_WaylandDataDevice * Wayland_get_data_device(struct SDL_WaylandInput *input)
WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT
@ WL_SHELL_SURFACE_RESIZE_BOTTOM_RIGHT
Definition: wayland-client-protocol.h:2818
WL_SEAT_CAPABILITY_KEYBOARD
@ WL_SEAT_CAPABILITY_KEYBOARD
Definition: wayland-client-protocol.h:3759
NULL
#define NULL
Definition: begin_code.h:167
surface
EGLSurface surface
Definition: eglext.h:248
wl_data_source_add_listener
static int wl_data_source_add_listener(struct wl_data_source *wl_data_source, const struct wl_data_source_listener *listener, void *data)
Definition: wayland-client-protocol.h:2202
zwp_pointer_constraints_v1_destroy
static void zwp_pointer_constraints_v1_destroy(struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1)
Definition: pointer-constraints-unstable-v1-client-protocol.h:296
SDL_BUTTON_RIGHT
#define SDL_BUTTON_RIGHT
Definition: SDL_mouse.h:284
SDL_log.h
SDL_WindowData
Definition: SDL_androidwindow.h:38
wl_touch_set_user_data
static void wl_touch_set_user_data(struct wl_touch *wl_touch, void *user_data)
Definition: wayland-client-protocol.h:4903
SDL_FingerID
Sint64 SDL_FingerID
Definition: SDL_touch.h:42
zwp_relative_pointer_v1_listener
Definition: relative-pointer-unstable-v1-client-protocol.h:182
FILE_MIME
#define FILE_MIME
Definition: SDL_waylanddatamanager.h:31
WL_SHELL_SURFACE_RESIZE_LEFT
@ WL_SHELL_SURFACE_RESIZE_LEFT
Definition: wayland-client-protocol.h:2798
Wayland_display_add_input
void Wayland_display_add_input(SDL_VideoData *d, uint32_t id)
SDL_SendTouch
int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, SDL_bool down, float x, float y, float pressure)
Definition: SDL_touch.c:242
wl_surface_get_user_data
static void * wl_surface_get_user_data(struct wl_surface *wl_surface)
Definition: wayland-client-protocol.h:3375
SDL_TouchID
Sint64 SDL_TouchID
Definition: SDL_touch.h:41
WL_KEYBOARD_KEY_STATE_PRESSED
@ WL_KEYBOARD_KEY_STATE_PRESSED
Definition: wayland-client-protocol.h:4502
Wayland_data_source_destroy
void Wayland_data_source_destroy(SDL_WaylandDataSource *source)
wl_seat_set_user_data
static void wl_seat_set_user_data(struct wl_seat *wl_seat, void *user_data)
Definition: wayland-client-protocol.h:3863
SDL_SetKeyboardFocus
void SDL_SetKeyboardFocus(SDL_Window *window)
Definition: SDL_keyboard.c:630
SDL_WindowData::wl
struct wl_shell_surface * wl
Definition: SDL_waylandwindow.h:60
zwp_locked_pointer_v1_destroy
static void zwp_locked_pointer_v1_destroy(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1)
Definition: pointer-constraints-unstable-v1-client-protocol.h:476
wl_keyboard_listener
Definition: wayland-client-protocol.h:4510
zwp_relative_pointer_v1_destroy
static void zwp_relative_pointer_v1_destroy(struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1)
Definition: relative-pointer-unstable-v1-client-protocol.h:283
SDL_HITTEST_RESIZE_TOPLEFT
@ SDL_HITTEST_RESIZE_TOPLEFT
Definition: SDL_video.h:1023
input
GLenum GLenum GLenum input
Definition: SDL_opengl_glext.h:9377
wl_seat_capability
wl_seat_capability
Definition: wayland-client-protocol.h:3751
a
GLboolean GLboolean GLboolean GLboolean a
Definition: SDL_opengl_glext.h:1112
Wayland_PumpEvents
void Wayland_PumpEvents(_THIS)
pointer
GLsizei const void * pointer
Definition: SDL_opengl_glext.h:381
SDL_RELEASED
#define SDL_RELEASED
Definition: SDL_events.h:49
Wayland_display_destroy_input
void Wayland_display_destroy_input(SDL_VideoData *d)
wl_pointer_button_state
wl_pointer_button_state
Definition: wayland-client-protocol.h:3988
WL_SHELL_SURFACE_RESIZE_BOTTOM
@ WL_SHELL_SURFACE_RESIZE_BOTTOM
Definition: wayland-client-protocol.h:2794
SDL_VideoData::data_device_manager
struct wl_data_device_manager * data_device_manager
Definition: SDL_waylandvideo.h:64
wl_data_device_listener
Definition: wayland-client-protocol.h:2337
SDL_WaylandDataDevice::drag_serial
uint32_t drag_serial
Definition: SDL_waylanddatamanager.h:56
length
GLuint GLsizei GLsizei * length
Definition: SDL_opengl_glext.h:672
Wayland_data_device_clear_selection
int Wayland_data_device_clear_selection(SDL_WaylandDataDevice *device)
SDL_SetMouseFocus
void SDL_SetMouseFocus(SDL_Window *window)
Definition: SDL_mouse.c:203
wl_pointer_destroy
static void wl_pointer_destroy(struct wl_pointer *wl_pointer)
Definition: wayland-client-protocol.h:4400
SDL_SendKeyboardKey
int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
Definition: SDL_keyboard.c:679
SDL_WaylandDataOffer::mimes
struct wl_list mimes
Definition: SDL_waylanddatamanager.h:47
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
SDL_BUTTON_X1
#define SDL_BUTTON_X1
Definition: SDL_mouse.h:285
SDL_Window
The type used to identify a window.
Definition: SDL_sysvideo.h:74
SDL_SendClipboardUpdate
int SDL_SendClipboardUpdate(void)
Definition: SDL_clipboardevents.c:31
wl_registry_bind
static void * wl_registry_bind(struct wl_registry *wl_registry, uint32_t name, const struct wl_interface *interface, uint32_t version)
Definition: wayland-client-protocol.h:1075
xdg-shell-unstable-v6-client-protocol.h
wl_data_device_add_listener
static int wl_data_device_add_listener(struct wl_data_device *wl_data_device, const struct wl_data_device_listener *listener, void *data)
Definition: wayland-client-protocol.h:2441
SDL_SendKeyboardText
int SDL_SendKeyboardText(const char *text)
Definition: SDL_keyboard.c:789
wl_data_device_set_user_data
static void wl_data_device_set_user_data(struct wl_data_device *wl_data_device, void *user_data)
Definition: wayland-client-protocol.h:2492
SDL_Window::w
int w
Definition: SDL_sysvideo.h:81
xdg_toplevel_move
static void xdg_toplevel_move(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial)
Definition: xdg-shell-client-protocol.h:1361
SDL_PRESSED
#define SDL_PRESSED
Definition: SDL_events.h:50
wl_data_offer_get_version
static uint32_t wl_data_offer_get_version(struct wl_data_offer *wl_data_offer)
Definition: wayland-client-protocol.h:1926
zwp_relative_pointer_manager_v1_destroy
static void zwp_relative_pointer_manager_v1_destroy(struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1)
Definition: relative-pointer-unstable-v1-client-protocol.h:153
SDL_HITTEST_RESIZE_BOTTOMRIGHT
@ SDL_HITTEST_RESIZE_BOTTOMRIGHT
Definition: SDL_video.h:1027
SDL_FALSE
@ SDL_FALSE
Definition: SDL_stdinc.h:163
buffer
GLuint buffer
Definition: SDL_opengl_glext.h:536
SDL_AddTouch
int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name)
Definition: SDL_touch.c:155
WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE
@ WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE
Definition: wayland-client-protocol.h:2618
wl_data_source_set_user_data
static void wl_data_source_set_user_data(struct wl_data_source *wl_data_source, void *user_data)
Definition: wayland-client-protocol.h:2253
SDL_HITTEST_RESIZE_TOPRIGHT
@ SDL_HITTEST_RESIZE_TOPRIGHT
Definition: SDL_video.h:1025
_this
static SDL_VideoDevice * _this
Definition: SDL_video.c:121
SDL_BUTTON_LEFT
#define SDL_BUTTON_LEFT
Definition: SDL_mouse.h:282
zwp_locked_pointer_v1_add_listener
static int zwp_locked_pointer_v1_add_listener(struct zwp_locked_pointer_v1 *zwp_locked_pointer_v1, const struct zwp_locked_pointer_v1_listener *listener, void *data)
Definition: pointer-constraints-unstable-v1-client-protocol.h:416
SDL_HitTestResult
SDL_HitTestResult
Possible return values from the SDL_HitTest callback.
Definition: SDL_video.h:1019
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
SDL_IOReady
int SDL_IOReady(int fd, SDL_bool forWrite, int timeoutMS)
Definition: SDL_poll.c:38
window
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
wl_shell_surface_move
static void wl_shell_surface_move(struct wl_shell_surface *wl_shell_surface, struct wl_seat *seat, uint32_t serial)
Definition: wayland-client-protocol.h:3050
WL_SHELL_SURFACE_RESIZE_RIGHT
@ WL_SHELL_SURFACE_RESIZE_RIGHT
Definition: wayland-client-protocol.h:2810
int32_t
signed int int32_t
Definition: SDL_config_windows.h:62
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT
@ ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT
Definition: pointer-constraints-unstable-v1-client-protocol.h:247
SDL_free
#define SDL_free
Definition: SDL_dynapi_overrides.h:377
group
GLboolean GLuint group
Definition: SDL_opengl_glext.h:4999
wl_seat_get_pointer
static struct wl_pointer * wl_seat_get_pointer(struct wl_seat *wl_seat)
Definition: wayland-client-protocol.h:3900
f
GLfloat f
Definition: SDL_opengl_glext.h:1873
SDL_WaylandDataDevice::drag_offer
SDL_WaylandDataOffer * drag_offer
Definition: SDL_waylanddatamanager.h:57
SDL_HITTEST_RESIZE_BOTTOM
@ SDL_HITTEST_RESIZE_BOTTOM
Definition: SDL_video.h:1028
Wayland_display_destroy_pointer_constraints
void Wayland_display_destroy_pointer_constraints(SDL_VideoData *d)
SDL_waylandwindow.h
name
GLuint const GLchar * name
Definition: SDL_opengl_glext.h:663
wl_pointer_set_user_data
static void wl_pointer_set_user_data(struct wl_pointer *wl_pointer, void *user_data)
Definition: wayland-client-protocol.h:4380
SDL_SendDropFile
int SDL_SendDropFile(SDL_Window *window, const char *file)
Definition: SDL_dropevents.c:80
SDL_HITTEST_RESIZE_LEFT
@ SDL_HITTEST_RESIZE_LEFT
Definition: SDL_video.h:1030
SDL_SendMouseMotion
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
Definition: SDL_mouse.c:293
wl_data_device_release
static void wl_data_device_release(struct wl_data_device *wl_data_device)
Definition: wayland-client-protocol.h:2576
SDL_BUTTON_MIDDLE
#define SDL_BUTTON_MIDDLE
Definition: SDL_mouse.h:283
head
SDL_EventEntry * head
Definition: SDL_events.c:87
WL_SEAT_CAPABILITY_TOUCH
@ WL_SEAT_CAPABILITY_TOUCH
Definition: wayland-client-protocol.h:3763
wl_keyboard_key_state
wl_keyboard_key_state
Definition: wayland-client-protocol.h:4494
SDL_assert.h
SDL_WindowData::xdg
SDL_xdg_shell_surface xdg
Definition: SDL_waylandwindow.h:58
wl_touch_add_listener
static int wl_touch_add_listener(struct wl_touch *wl_touch, const struct wl_touch_listener *listener, void *data)
Definition: wayland-client-protocol.h:4858
key
GLuint64 key
Definition: gl2ext.h:2192
WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT
@ WL_SHELL_SURFACE_RESIZE_BOTTOM_LEFT
Definition: wayland-client-protocol.h:2806
WL_POINTER_AXIS_VERTICAL_SCROLL
@ WL_POINTER_AXIS_VERTICAL_SCROLL
Definition: wayland-client-protocol.h:4012
zwp_relative_pointer_manager_v1_get_relative_pointer
static struct zwp_relative_pointer_v1 * zwp_relative_pointer_manager_v1_get_relative_pointer(struct zwp_relative_pointer_manager_v1 *zwp_relative_pointer_manager_v1, struct wl_pointer *pointer)
Definition: relative-pointer-unstable-v1-client-protocol.h:168
SDL_WaylandDataSource::mimes
struct wl_list mimes
Definition: SDL_waylanddatamanager.h:42
_THIS
#define _THIS
Definition: SDL_alsa_audio.h:31
Wayland_input_unlock_pointer
int Wayland_input_unlock_pointer(struct SDL_WaylandInput *input)
text
static char text[MAX_TEXT_LENGTH]
Definition: testime.c:47
Wayland_data_offer_has_mime
SDL_bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, const char *mime_type)
wl_touch_destroy
static void wl_touch_destroy(struct wl_touch *wl_touch)
Definition: wayland-client-protocol.h:4923
wl_data_offer_accept
static void wl_data_offer_accept(struct wl_data_offer *wl_data_offer, uint32_t serial, const char *mime_type)
Definition: wayland-client-protocol.h:1950
wl_keyboard_destroy
static void wl_keyboard_destroy(struct wl_keyboard *wl_keyboard)
Definition: wayland-client-protocol.h:4679
SDL_DelTouch
void SDL_DelTouch(SDL_TouchID id)
Definition: SDL_touch.c:441
zwp_pointer_constraints_v1_interface
const struct wl_interface zwp_pointer_constraints_v1_interface
Definition: pointer-constraints-unstable-v1-protocol.c:60
wl_pointer_add_listener
static int wl_pointer_add_listener(struct wl_pointer *wl_pointer, const struct wl_pointer_listener *listener, void *data)
Definition: wayland-client-protocol.h:4322
axis
SDL_Texture * axis
Definition: testgamecontroller.c:67
SDL_Window::h
int h
Definition: SDL_sysvideo.h:81
Wayland_data_source_send
ssize_t Wayland_data_source_send(SDL_WaylandDataSource *source, const char *mime_type, int fd)
Wayland_display_destroy_relative_pointer_manager
void Wayland_display_destroy_relative_pointer_manager(SDL_VideoData *d)
SDL_WaylandDataOffer::offer
struct wl_data_offer * offer
Definition: SDL_waylanddatamanager.h:46
Wayland_display_add_pointer_constraints
void Wayland_display_add_pointer_constraints(SDL_VideoData *d, uint32_t id)
SDL_VideoDevice
Definition: SDL_sysvideo.h:149
SDL_OutOfMemory
#define SDL_OutOfMemory()
Definition: SDL_error.h:52
size
GLsizeiptr size
Definition: SDL_opengl_glext.h:540
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
SDL_WaylandDataSource::source
struct wl_data_source * source
Definition: SDL_waylanddatamanager.h:41
SDL_SCANCODE_UNKNOWN
@ SDL_SCANCODE_UNKNOWN
Definition: SDL_scancode.h:45
SDL_SendMouseWheel
int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, float x, float y, SDL_MouseWheelDirection direction)
Definition: SDL_mouse.c:600
id
GLuint id
Definition: SDL_opengl_glext.h:531
SDL_HITTEST_RESIZE_RIGHT
@ SDL_HITTEST_RESIZE_RIGHT
Definition: SDL_video.h:1026
SDL_arraysize
#define SDL_arraysize(array)
Definition: SDL_stdinc.h:115
SDL_calloc
#define SDL_calloc
Definition: SDL_dynapi_overrides.h:375
wl_seat_add_listener
static int wl_seat_add_listener(struct wl_seat *wl_seat, const struct wl_seat_listener *listener, void *data)
Definition: wayland-client-protocol.h:3823
Wayland_data_source_create
SDL_WaylandDataSource * Wayland_data_source_create(_THIS)
wl_data_source_destroy
static void wl_data_source_destroy(struct wl_data_source *wl_data_source)
Definition: wayland-client-protocol.h:2291
relative-pointer-unstable-v1-client-protocol.h
xdg_toplevel_resize
static void xdg_toplevel_resize(struct xdg_toplevel *xdg_toplevel, struct wl_seat *seat, uint32_t serial, uint32_t edges)
Definition: xdg-shell-client-protocol.h:1402
uint32_t
unsigned int uint32_t
Definition: SDL_config_windows.h:63
SDL_TRUE
@ SDL_TRUE
Definition: SDL_stdinc.h:164
SDL_WaylandDataSource
Definition: SDL_waylanddatamanager.h:40
xdg-shell-client-protocol.h
SDL_WaylandDataOffer
Definition: SDL_waylanddatamanager.h:45
WL_POINTER_AXIS_HORIZONTAL_SCROLL
@ WL_POINTER_AXIS_HORIZONTAL_SCROLL
Definition: wayland-client-protocol.h:4016
memset
#define memset
Definition: SDL_malloc.c:627
wl_keyboard_set_user_data
static void wl_keyboard_set_user_data(struct wl_keyboard *wl_keyboard, void *user_data)
Definition: wayland-client-protocol.h:4659
zwp_pointer_constraints_v1_lock_pointer
static struct zwp_locked_pointer_v1 * zwp_pointer_constraints_v1_lock_pointer(struct zwp_pointer_constraints_v1 *zwp_pointer_constraints_v1, struct wl_surface *surface, struct wl_pointer *pointer, struct wl_region *region, uint32_t lifetime)
Definition: pointer-constraints-unstable-v1-client-protocol.h:343
wl_data_offer_listener::offer
void(* offer)(void *data, struct wl_data_offer *wl_data_offer, const char *mime_type)
Definition: wayland-client-protocol.h:1796
SDL_Point
The structure that defines a point (integer)
Definition: SDL_rect.h:48
SDL_Window::next
SDL_Window * next
Definition: SDL_sysvideo.h:115
wl_keyboard_add_listener
static int wl_keyboard_add_listener(struct wl_keyboard *wl_keyboard, const struct wl_keyboard_listener *listener, void *data)
Definition: wayland-client-protocol.h:4618
value
GLsizei const GLfloat * value
Definition: SDL_opengl_glext.h:701
SDL_waylanddyn.h
SDL_SetError
#define SDL_SetError
Definition: SDL_dynapi_overrides.h:30
wl_seat_get_touch
static struct wl_touch * wl_seat_get_touch(struct wl_seat *wl_seat)
Definition: wayland-client-protocol.h:3944
pointer-constraints-unstable-v1-client-protocol.h
SDL_WindowData::zxdg
SDL_zxdg_shell_surface zxdg
Definition: SDL_waylandwindow.h:59
wl_seat_listener
Definition: wayland-client-protocol.h:3771
Wayland_data_device_set_serial
int Wayland_data_device_set_serial(SDL_WaylandDataDevice *device, uint32_t serial)
wl_pointer_listener
Definition: wayland-client-protocol.h:4072
xfree86_scancode_table2
static const SDL_Scancode xfree86_scancode_table2[]
Definition: scancodes_xfree86.h:183
SDL_WaylandDataDevice::selection_offer
SDL_WaylandDataOffer * selection_offer
Definition: SDL_waylanddatamanager.h:58
SDL_stdinc.h
zwp_relative_pointer_v1_add_listener
static int zwp_relative_pointer_v1_add_listener(struct zwp_relative_pointer_v1 *zwp_relative_pointer_v1, const struct zwp_relative_pointer_v1_listener *listener, void *data)
Definition: relative-pointer-unstable-v1-client-protocol.h:240
wl_data_device_manager_create_data_source
static struct wl_data_source * wl_data_device_manager_create_data_source(struct wl_data_device_manager *wl_data_device_manager)
Definition: wayland-client-protocol.h:2680
WL_SEAT_CAPABILITY_POINTER
@ WL_SEAT_CAPABILITY_POINTER
Definition: wayland-client-protocol.h:3755
SDL_SendTouchMotion
int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window, float x, float y, float pressure)
Definition: SDL_touch.c:356
Wayland_data_offer_add_mime
int Wayland_data_offer_add_mime(SDL_WaylandDataOffer *offer, const char *mime_type)
Wayland_input_lock_pointer
int Wayland_input_lock_pointer(struct SDL_WaylandInput *input)
SDL_xdg_shell_surface::roleobj
union SDL_xdg_shell_surface::@259 roleobj
SDL_xdg_shell_surface::toplevel
struct xdg_toplevel * toplevel
Definition: SDL_waylandwindow.h:47
SDL_WindowData::shell_surface
union SDL_WindowData::@260 shell_surface
Wayland_data_offer_destroy
void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer)
SDL_zxdg_shell_surface::roleobj
union SDL_zxdg_shell_surface::@258 roleobj
wl_data_source_listener
Definition: wayland-client-protocol.h:2078
WL_SHELL_SURFACE_RESIZE_TOP_LEFT
@ WL_SHELL_SURFACE_RESIZE_TOP_LEFT
Definition: wayland-client-protocol.h:2802
zwp_locked_pointer_v1_listener
Definition: pointer-constraints-unstable-v1-client-protocol.h:389
Wayland_display_add_relative_pointer_manager
void Wayland_display_add_relative_pointer_manager(SDL_VideoData *d, uint32_t id)
wl_data_offer_set_actions
static void wl_data_offer_set_actions(struct wl_data_offer *wl_data_offer, uint32_t dnd_actions, uint32_t preferred_action)
Definition: wayland-client-protocol.h:2054
SDL_MOUSEWHEEL_NORMAL
@ SDL_MOUSEWHEEL_NORMAL
Definition: SDL_mouse.h:68
SDL_GetVideoDevice
SDL_VideoDevice * SDL_GetVideoDevice(void)
Definition: SDL_video.c:586
SDL_WindowData::sdlwindow
SDL_Window * sdlwindow
Definition: SDL_waylandwindow.h:54
SDL_BUTTON_X2
#define SDL_BUTTON_X2
Definition: SDL_mouse.h:286
SDL_WaylandDataDevice
Definition: SDL_waylanddatamanager.h:51
SDL_malloc
#define SDL_malloc
Definition: SDL_dynapi_overrides.h:374
fd
GLuint64 GLenum GLint fd
Definition: gl2ext.h:1508
wl_touch_listener
Definition: wayland-client-protocol.h:4700
wl_data_device_manager_get_data_device
static struct wl_data_device * wl_data_device_manager_get_data_device(struct wl_data_device_manager *wl_data_device_manager, struct wl_seat *seat)
Definition: wayland-client-protocol.h:2696
WL_SHELL_SURFACE_RESIZE_TOP
@ WL_SHELL_SURFACE_RESIZE_TOP
Definition: wayland-client-protocol.h:2790
zxdg_toplevel_v6_move
static void zxdg_toplevel_v6_move(struct zxdg_toplevel_v6 *zxdg_toplevel_v6, struct wl_seat *seat, uint32_t serial)
Definition: xdg-shell-unstable-v6-client-protocol.h:1336
SDL_HITTEST_RESIZE_TOP
@ SDL_HITTEST_RESIZE_TOP
Definition: SDL_video.h:1024
state
struct xkb_state * state
Definition: SDL_waylandsym.h:114
WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY
@ WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY
Definition: wayland-client-protocol.h:2622
SDL_SendQuit
int SDL_SendQuit(void)
Definition: SDL_quit.c:201
wl_seat_interface
const struct wl_interface wl_seat_interface
Definition: wayland-protocol.c:385
button
SDL_Texture * button
Definition: testgamecontroller.c:67
SDL_HITTEST_RESIZE_BOTTOMLEFT
@ SDL_HITTEST_RESIZE_BOTTOMLEFT
Definition: SDL_video.h:1029
SDL_WaylandDataOffer::data_device
void * data_device
Definition: SDL_waylanddatamanager.h:48
SDL_SendMouseButton
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)
Definition: SDL_mouse.c:594
zwp_relative_pointer_manager_v1_interface
const struct wl_interface zwp_relative_pointer_manager_v1_interface
Definition: relative-pointer-unstable-v1-protocol.c:50
SDL_WaylandDataDevice::video_data
SDL_VideoData * video_data
Definition: SDL_waylanddatamanager.h:53
SDL_VideoData
Definition: SDL_androidvideo.h:36
d
const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char int const SDL_PRINTF_FORMAT_STRING char const char const SDL_SCANF_FORMAT_STRING char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 ** d
Definition: SDL_dynapi_procs.h:117
SDL_bool
SDL_bool
Definition: SDL_stdinc.h:161
SDL_VideoDevice::windows
SDL_Window * windows
Definition: SDL_sysvideo.h:325
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:734
wl_data_offer_listener
Definition: wayland-client-protocol.h:1788