1 | /* |
2 | Simple DirectMedia Layer |
3 | Copyright (C) 1997-2021 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 | #ifndef SDL_waylandevents_h_ |
25 | #define SDL_waylandevents_h_ |
26 | |
27 | #include "SDL_waylandvideo.h" |
28 | #include "SDL_waylandwindow.h" |
29 | #include "SDL_waylanddatamanager.h" |
30 | |
31 | typedef struct { |
32 | // repeat_rate in range of [1, 1000] |
33 | int32_t repeat_rate; |
34 | int32_t repeat_delay; |
35 | SDL_bool is_initialized; |
36 | |
37 | SDL_bool is_key_down; |
38 | uint32_t next_repeat_ms; |
39 | uint32_t scancode; |
40 | char text[8]; |
41 | } SDL_WaylandKeyboardRepeat; |
42 | |
43 | struct SDL_WaylandInput { |
44 | SDL_VideoData *display; |
45 | struct wl_seat *seat; |
46 | struct wl_pointer *pointer; |
47 | struct wl_touch *touch; |
48 | struct wl_keyboard *keyboard; |
49 | SDL_WaylandDataDevice *data_device; |
50 | struct zwp_relative_pointer_v1 *relative_pointer; |
51 | struct zwp_confined_pointer_v1 *confined_pointer; |
52 | SDL_Window *confined_pointer_window; |
53 | SDL_WindowData *pointer_focus; |
54 | SDL_WindowData *keyboard_focus; |
55 | uint32_t pointer_enter_serial; |
56 | |
57 | /* Last motion location */ |
58 | wl_fixed_t sx_w; |
59 | wl_fixed_t sy_w; |
60 | |
61 | double dx_frac; |
62 | double dy_frac; |
63 | |
64 | struct { |
65 | struct xkb_keymap *keymap; |
66 | struct xkb_state *state; |
67 | struct xkb_compose_table *compose_table; |
68 | struct xkb_compose_state *compose_state; |
69 | } xkb; |
70 | |
71 | /* information about axis events on current frame */ |
72 | struct { |
73 | SDL_bool is_x_discrete; |
74 | float x; |
75 | |
76 | SDL_bool is_y_discrete; |
77 | float y; |
78 | } pointer_curr_axis_info; |
79 | |
80 | SDL_WaylandKeyboardRepeat keyboard_repeat; |
81 | }; |
82 | |
83 | extern void Wayland_PumpEvents(_THIS); |
84 | |
85 | extern void Wayland_add_data_device_manager(SDL_VideoData *d, uint32_t id, uint32_t version); |
86 | |
87 | extern void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version); |
88 | extern void Wayland_display_destroy_input(SDL_VideoData *d); |
89 | |
90 | extern void Wayland_display_add_pointer_constraints(SDL_VideoData *d, uint32_t id); |
91 | extern void Wayland_display_destroy_pointer_constraints(SDL_VideoData *d); |
92 | |
93 | extern int Wayland_input_lock_pointer(struct SDL_WaylandInput *input); |
94 | extern int Wayland_input_unlock_pointer(struct SDL_WaylandInput *input); |
95 | |
96 | extern int Wayland_input_confine_pointer(SDL_Window *window, struct SDL_WaylandInput *input); |
97 | extern int Wayland_input_unconfine_pointer(struct SDL_WaylandInput *input); |
98 | |
99 | extern void Wayland_display_add_relative_pointer_manager(SDL_VideoData *d, uint32_t id); |
100 | extern void Wayland_display_destroy_relative_pointer_manager(SDL_VideoData *d); |
101 | |
102 | extern int Wayland_input_grab_keyboard(SDL_Window *window, struct SDL_WaylandInput *input); |
103 | extern int Wayland_input_ungrab_keyboard(SDL_Window *window); |
104 | |
105 | #endif /* SDL_waylandevents_h_ */ |
106 | |
107 | /* vi: set ts=4 sw=4 expandtab: */ |
108 | |