Atlas - SDL_waylandevents_c.h
Home / ext / SDL / src / video / wayland Lines: 1 | Size: 9359 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)][FILE BEGIN]1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 Sam Lantinga <[email protected]> 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 "../../events/SDL_keymap_c.h" 28#include "../../events/SDL_mouse_c.h" 29#include "../../events/SDL_pen_c.h" 30 31#include "SDL_waylandvideo.h" 32#include "SDL_waylandwindow.h" 33#include "SDL_waylanddatamanager.h" 34 35enum SDL_WaylandAxisEvent 36{ 37 SDL_WAYLAND_AXIS_EVENT_CONTINUOUS = 0, 38 SDL_WAYLAND_AXIS_EVENT_DISCRETE, 39 SDL_WAYLAND_AXIS_EVENT_VALUE120 40}; 41 42typedef struct 43{ 44 Sint32 repeat_rate; // Repeat rate in range of [1, 1000] character(s) per second 45 Sint32 repeat_delay_ms; // Time to first repeat event in milliseconds 46 Uint32 keyboard_id; // ID of the source keyboard. 47 bool is_initialized; 48 49 bool is_key_down; 50 Uint32 key; 51 Uint32 wl_press_time_ms; // Key press time as reported by the Wayland API in milliseconds 52 Uint64 base_time_ns; // Key press time as reported by the Wayland API in nanoseconds 53 Uint64 sdl_press_time_ns; // Key press time expressed in SDL ticks 54 Uint64 next_repeat_ns; // Next repeat event in nanoseconds 55 Uint32 scancode; 56 char text[8]; 57} SDL_WaylandKeyboardRepeat; 58 59typedef struct SDL_WaylandCursorState 60{ 61 SDL_CursorData *current_cursor; 62 struct wp_cursor_shape_device_v1 *cursor_shape; 63 struct wl_surface *surface; 64 struct wp_viewport *viewport; 65 66 double scale; 67 68 // Pointer to the internal data for system cursors. 69 void *system_cursor_handle; 70 71 // The cursor animation thread lock must be held when modifying this. 72 struct wl_callback *frame_callback; 73 74 Uint64 last_frame_callback_time_ms; 75 Uint32 current_frame_time_ms; 76 int current_frame; 77 SDL_HitTestResult hit_test_result; 78} SDL_WaylandCursorState; 79 80typedef struct SDL_WaylandPenTool // a stylus, etc, on a tablet. 81{ 82 SDL_PenID instance_id; 83 SDL_PenInfo info; 84 SDL_WindowData *focus; 85 struct zwp_tablet_tool_v2 *wltool; 86 Uint32 proximity_serial; 87 88 struct 89 { 90 float x; 91 float y; 92 93 float axes[SDL_PEN_AXIS_COUNT]; 94 Uint32 axes_set; 95 96 enum 97 { 98 WAYLAND_TABLET_TOOL_BUTTON_NONE = 0, 99 WAYLAND_TABLET_TOOL_BUTTON_DOWN, 100 WAYLAND_TABLET_TOOL_BUTTON_UP 101 } buttons[3]; 102 103 enum 104 { 105 WAYLAND_TABLET_TOOL_STATE_NONE = 0, 106 WAYLAND_TABLET_TOOL_STATE_DOWN, 107 WAYLAND_TABLET_TOOL_STATE_UP 108 } tool_state; 109 110 bool in_proximity; 111 112 bool have_motion; 113 bool have_proximity; 114 } frame; 115 116 SDL_WaylandCursorState cursor_state; 117 struct wl_list link; 118} SDL_WaylandPenTool; 119 120typedef struct SDL_WaylandSeat 121{ 122 SDL_VideoData *display; 123 struct wl_seat *wl_seat; 124 SDL_WaylandDataDevice *data_device; 125 SDL_WaylandPrimarySelectionDevice *primary_selection_device; 126 char *name; 127 struct wl_list link; 128 129 Uint32 last_implicit_grab_serial; // The serial of the last implicit grab event for window activation and selection data. 130 Uint32 registry_id; // The ID of the Wayland seat object, 131 132 struct 133 { 134 struct wl_keyboard *wl_keyboard; 135 struct zwp_input_timestamps_v1 *timestamps; 136 struct zwp_keyboard_shortcuts_inhibitor_v1 *key_inhibitor; 137 SDL_WindowData *focus; 138 SDL_Keymap **sdl_keymap; 139 char *current_locale; 140 141 SDL_WaylandKeyboardRepeat repeat; 142 Uint64 highres_timestamp_ns; 143 144 // Current SDL modifier flags 145 SDL_Keymod pressed_modifiers; 146 SDL_Keymod locked_modifiers; 147 148 SDL_KeyboardID sdl_id; 149 bool is_virtual; 150 151 struct 152 { 153 struct xkb_keymap *keymap; 154 struct xkb_state *state; 155 struct xkb_compose_table *compose_table; 156 struct xkb_compose_state *compose_state; 157 158 // Current keyboard layout (aka 'group') 159 xkb_layout_index_t num_layouts; 160 xkb_layout_index_t current_layout; 161 162 // Modifier bitshift values 163 xkb_mod_mask_t shift_mask; 164 xkb_mod_mask_t ctrl_mask; 165 xkb_mod_mask_t alt_mask; 166 xkb_mod_mask_t gui_mask; 167 xkb_mod_mask_t level3_mask; 168 xkb_mod_mask_t level5_mask; 169 xkb_mod_mask_t num_mask; 170 xkb_mod_mask_t caps_mask; 171 172 // Current system modifier flags 173 xkb_mod_mask_t wl_pressed_modifiers; 174 xkb_mod_mask_t wl_latched_modifiers; 175 xkb_mod_mask_t wl_locked_modifiers; 176 } xkb; 177 } keyboard; 178 179 struct 180 { 181 struct wl_pointer *wl_pointer; 182 struct zwp_relative_pointer_v1 *relative_pointer; 183 struct zwp_input_timestamps_v1 *timestamps; 184 struct zwp_locked_pointer_v1 *locked_pointer; 185 struct zwp_confined_pointer_v1 *confined_pointer; 186 struct zwp_pointer_gesture_pinch_v1 *gesture_pinch; 187 188 SDL_WindowData *focus; 189 SDL_CursorData *current_cursor; 190 191 // According to the spec, a seat can only have one active gesture of any type at a time. 192 SDL_WindowData *gesture_focus; 193 194 Uint64 highres_timestamp_ns; 195 Uint32 enter_serial; 196 SDL_MouseButtonFlags buttons_pressed; 197 SDL_Point last_motion; 198 bool is_confined; 199 200 SDL_MouseID sdl_id; 201 202 // Information about axis events on the current frame 203 struct 204 { 205 bool have_absolute; 206 bool have_relative; 207 bool have_axis; 208 bool have_enter; 209 210 struct 211 { 212 wl_fixed_t sx; 213 wl_fixed_t sy; 214 } absolute; 215 216 struct 217 { 218 wl_fixed_t dx; 219 wl_fixed_t dy; 220 wl_fixed_t dx_unaccel; 221 wl_fixed_t dy_unaccel; 222 } relative; 223 224 struct 225 { 226 enum SDL_WaylandAxisEvent x_axis_type; 227 float x; 228 229 enum SDL_WaylandAxisEvent y_axis_type; 230 float y; 231 232 SDL_MouseWheelDirection direction; 233 } axis; 234 235 // Event timestamp in nanoseconds 236 Uint64 timestamp_ns; 237 } pending_frame; 238 239 SDL_WaylandCursorState cursor_state; 240 } pointer; 241 242 struct 243 { 244 struct wl_touch *wl_touch; 245 struct zwp_input_timestamps_v1 *timestamps; 246 Uint64 highres_timestamp_ns; 247 struct wl_list points; 248 } touch; 249 250 struct 251 { 252 struct zwp_text_input_v3 *zwp_text_input; 253 SDL_Rect text_input_rect; 254 int text_input_cursor; 255 bool enabled; 256 bool has_preedit; 257 } text_input; 258 259 struct 260 { 261 struct zwp_tablet_seat_v2 *wl_tablet_seat; 262 struct wl_list tool_list; 263 } tablet; 264} SDL_WaylandSeat; 265 266 267extern Uint64 Wayland_GetTouchTimestamp(struct SDL_WaylandSeat *seat, Uint32 wl_timestamp_ms); 268 269extern void Wayland_PumpEvents(SDL_VideoDevice *_this); 270extern void Wayland_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window); 271extern int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS); 272 273extern void Wayland_DisplayInitInputTimestampManager(SDL_VideoData *display); 274extern void Wayland_DisplayInitCursorShapeManager(SDL_VideoData *display); 275extern void Wayland_DisplayInitPointerGestureManager(SDL_VideoData *display); 276extern void Wayland_DisplayInitTabletManager(SDL_VideoData *display); 277extern void Wayland_DisplayInitDataDeviceManager(SDL_VideoData *display); 278extern void Wayland_DisplayInitPrimarySelectionDeviceManager(SDL_VideoData *display); 279 280extern void Wayland_DisplayInitTextInputManager(SDL_VideoData *d, uint32_t id); 281 282extern void Wayland_DisplayCreateSeat(SDL_VideoData *display, struct wl_seat *wl_seat, Uint32 id); 283extern void Wayland_SeatDestroy(SDL_WaylandSeat *seat, bool shutting_down); 284 285extern void Wayland_SeatUpdatePointerGrab(SDL_WaylandSeat *seat); 286extern void Wayland_DisplayUpdatePointerGrabs(SDL_VideoData *display, SDL_WindowData *window); 287extern void Wayland_DisplayUpdateKeyboardGrabs(SDL_VideoData *display, SDL_WindowData *window); 288extern void Wayland_DisplayRemoveWindowReferencesFromSeats(SDL_VideoData *display, SDL_WindowData *window); 289 290/* The implicit grab serial needs to be updated on: 291 * - Keyboard key down/up 292 * - Mouse button down 293 * - Touch event down 294 * - Tablet tool down 295 * - Tablet tool button down/up 296 */ 297extern void Wayland_UpdateImplicitGrabSerial(struct SDL_WaylandSeat *seat, Uint32 serial); 298 299#endif // SDL_waylandevents_h_ 300[FILE END](C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.