Atlas - SDL_waylandevents_c.h

Home / ext / SDL / src / video / wayland Lines: 1 | Size: 9530 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2026 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 77 // 0 or greater if a buffer is attached, -1 if in the reset state. 78 int current_frame; 79 80 SDL_HitTestResult hit_test_result; 81} SDL_WaylandCursorState; 82 83typedef struct SDL_WaylandPenTool // a stylus, etc, on a tablet. 84{ 85 SDL_PenID instance_id; 86 SDL_PenInfo info; 87 SDL_WindowData *focus; 88 struct zwp_tablet_tool_v2 *wltool; 89 Uint32 proximity_serial; 90 91 struct 92 { 93 float x; 94 float y; 95 96 float axes[SDL_PEN_AXIS_COUNT]; 97 Uint32 axes_set; 98 99 enum 100 { 101 WAYLAND_TABLET_TOOL_BUTTON_NONE = 0, 102 WAYLAND_TABLET_TOOL_BUTTON_DOWN, 103 WAYLAND_TABLET_TOOL_BUTTON_UP 104 } buttons[3]; 105 106 enum 107 { 108 WAYLAND_TABLET_TOOL_STATE_NONE = 0, 109 WAYLAND_TABLET_TOOL_STATE_DOWN, 110 WAYLAND_TABLET_TOOL_STATE_UP 111 } tool_state; 112 113 bool in_proximity; 114 115 bool have_motion; 116 bool have_proximity; 117 } frame; 118 119 SDL_WaylandCursorState cursor_state; 120 struct wl_list link; 121} SDL_WaylandPenTool; 122 123typedef struct SDL_WaylandSeat 124{ 125 SDL_VideoData *display; 126 struct wl_seat *wl_seat; 127 SDL_WaylandDataDevice *data_device; 128 SDL_WaylandPrimarySelectionDevice *primary_selection_device; 129 char *name; 130 struct wl_list link; 131 132 Uint32 last_implicit_grab_serial; // The serial of the last implicit grab event for window activation and selection data. 133 Uint32 registry_id; // The ID of the Wayland seat object, 134 135 struct 136 { 137 struct wl_keyboard *wl_keyboard; 138 struct zwp_input_timestamps_v1 *timestamps; 139 struct zwp_keyboard_shortcuts_inhibitor_v1 *key_inhibitor; 140 SDL_WindowData *focus; 141 SDL_Keymap **sdl_keymap; 142 char *current_locale; 143 144 SDL_WaylandKeyboardRepeat repeat; 145 Uint64 highres_timestamp_ns; 146 147 // Current SDL modifier flags 148 SDL_Keymod pressed_modifiers; 149 SDL_Keymod locked_modifiers; 150 151 SDL_KeyboardID sdl_id; 152 bool is_virtual; 153 154 struct 155 { 156 struct xkb_keymap *keymap; 157 struct xkb_state *state; 158 struct xkb_compose_table *compose_table; 159 struct xkb_compose_state *compose_state; 160 161 // Current keyboard layout (aka 'group') 162 xkb_layout_index_t num_layouts; 163 xkb_layout_index_t current_layout; 164 165 // Modifier bitshift values 166 xkb_mod_mask_t shift_mask; 167 xkb_mod_mask_t ctrl_mask; 168 xkb_mod_mask_t alt_mask; 169 xkb_mod_mask_t gui_mask; 170 xkb_mod_mask_t level3_mask; 171 xkb_mod_mask_t level5_mask; 172 xkb_mod_mask_t num_mask; 173 xkb_mod_mask_t caps_mask; 174 175 // Current system modifier flags 176 xkb_mod_mask_t wl_pressed_modifiers; 177 xkb_mod_mask_t wl_latched_modifiers; 178 xkb_mod_mask_t wl_locked_modifiers; 179 } xkb; 180 } keyboard; 181 182 struct 183 { 184 struct wl_pointer *wl_pointer; 185 struct zwp_relative_pointer_v1 *relative_pointer; 186 struct zwp_input_timestamps_v1 *timestamps; 187 struct zwp_locked_pointer_v1 *locked_pointer; 188 struct zwp_confined_pointer_v1 *confined_pointer; 189 struct zwp_pointer_gesture_pinch_v1 *gesture_pinch; 190 191 SDL_WindowData *focus; 192 193 // According to the spec, a seat can only have one active gesture of any type at a time. 194 SDL_WindowData *gesture_focus; 195 196 Uint64 highres_timestamp_ns; 197 Uint32 enter_serial; 198 SDL_MouseButtonFlags buttons_pressed; 199 SDL_Point last_motion; 200 bool is_confined; 201 202 SDL_MouseID sdl_id; 203 204 // Information about axis events on the current frame 205 struct 206 { 207 bool have_absolute; 208 bool have_relative; 209 bool have_axis; 210 211 Uint32 buttons_pressed; 212 Uint32 buttons_released; 213 214 struct 215 { 216 wl_fixed_t sx; 217 wl_fixed_t sy; 218 } absolute; 219 220 struct 221 { 222 wl_fixed_t dx; 223 wl_fixed_t dy; 224 wl_fixed_t dx_unaccel; 225 wl_fixed_t dy_unaccel; 226 } relative; 227 228 struct 229 { 230 enum SDL_WaylandAxisEvent x_axis_type; 231 float x; 232 233 enum SDL_WaylandAxisEvent y_axis_type; 234 float y; 235 236 SDL_MouseWheelDirection direction; 237 } axis; 238 239 struct wl_surface *enter_surface; 240 struct wl_surface *leave_surface; 241 242 // Event timestamp in nanoseconds 243 Uint64 timestamp_ns; 244 } pending_frame; 245 246 SDL_WaylandCursorState cursor_state; 247 } pointer; 248 249 struct 250 { 251 struct wl_touch *wl_touch; 252 struct zwp_input_timestamps_v1 *timestamps; 253 Uint64 highres_timestamp_ns; 254 struct wl_list points; 255 } touch; 256 257 struct 258 { 259 struct zwp_text_input_v3 *zwp_text_input; 260 SDL_Rect text_input_rect; 261 int text_input_cursor; 262 bool enabled; 263 bool has_preedit; 264 } text_input; 265 266 struct 267 { 268 struct zwp_tablet_seat_v2 *wl_tablet_seat; 269 struct wl_list tool_list; 270 } tablet; 271} SDL_WaylandSeat; 272 273 274extern Uint64 Wayland_GetTouchTimestamp(struct SDL_WaylandSeat *seat, Uint32 wl_timestamp_ms); 275 276extern void Wayland_PumpEvents(SDL_VideoDevice *_this); 277extern void Wayland_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window); 278extern int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS); 279 280extern void Wayland_DisplayInitInputTimestampManager(SDL_VideoData *display); 281extern void Wayland_DisplayInitCursorShapeManager(SDL_VideoData *display); 282extern void Wayland_DisplayInitPointerGestureManager(SDL_VideoData *display); 283extern void Wayland_DisplayInitTabletManager(SDL_VideoData *display); 284extern void Wayland_DisplayInitDataDeviceManager(SDL_VideoData *display); 285extern void Wayland_DisplayInitPrimarySelectionDeviceManager(SDL_VideoData *display); 286 287extern void Wayland_DisplayInitTextInputManager(SDL_VideoData *d, uint32_t id); 288 289extern void Wayland_DisplayCreateSeat(SDL_VideoData *display, struct wl_seat *wl_seat, Uint32 id); 290extern void Wayland_SeatDestroy(SDL_WaylandSeat *seat, bool shutting_down); 291 292extern void Wayland_SeatUpdatePointerGrab(SDL_WaylandSeat *seat); 293extern void Wayland_DisplayUpdatePointerGrabs(SDL_VideoData *display, SDL_WindowData *window); 294extern void Wayland_DisplayUpdateKeyboardGrabs(SDL_VideoData *display, SDL_WindowData *window); 295extern void Wayland_DisplayRemoveWindowReferencesFromSeats(SDL_VideoData *display, SDL_WindowData *window); 296 297/* The implicit grab serial needs to be updated on: 298 * - Keyboard key down/up 299 * - Mouse button down 300 * - Touch event down 301 * - Tablet tool down 302 * - Tablet tool button down/up 303 */ 304extern void Wayland_UpdateImplicitGrabSerial(struct SDL_WaylandSeat *seat, Uint32 serial); 305 306#endif // SDL_waylandevents_h_ 307
[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.