Commit Graph

702 Commits

Author SHA1 Message Date
Sam Lantinga
bddf6d3e2a Guarantee that pens are in proximity before motion and button events
This also delays pen proximity out events to make sure that the pen is really gone before delivering them. On Android, you get a HOVER_EXIT event when the pen contacts the surface, which we don't want to treat as the pen leaving proximity.
2026-02-05 10:24:04 -08:00
Ryan C. Gordon
dd18d7ff52 pen: Fixed incorrect comment. 2026-02-03 19:44:29 -05:00
Thour
124c5922aa Fix incorrect type in SDL_GetMice() and SDL_GetKeyboards() allocation (#14870) 2026-01-19 15:23:55 -08:00
Frank Praznik
34b620c3f8 event: Only consider topmost windows when generating SDL_QUIT
Otherwise, the quit event can be sent prematurely. The topmost status must be queried and cached before sending the close request event, as the window may be destroyed in an event handler.
2026-01-17 15:52:04 -05:00
Frank Praznik
e62d6a95b9 events: Raise keyboard keys before sending the focus lost message
Otherwise, the key raises may end up being ignored.
2026-01-15 15:02:43 -05:00
Ethan Lee
5b009640fe events: Buildfix for targets with C++ build units 2026-01-09 14:50:56 -05:00
Sam Lantinga
5f086e7623 Updated copyright for 2026 2026-01-01 09:40:08 -08:00
Frank Praznik
5b572638b8 video: Handle window destruction in event handlers
Windows may be destroyed in event handlers, so check the window validity after pushing window events onto the queue to ensure that the window and its properties are still valid.
2025-12-09 14:10:43 -05:00
milkmull
70c2f576c8 fixed issue where video events could be posted while system was quitting (#14572) 2025-12-03 14:17:11 -08:00
Sam Lantinga
e1edeab0c9 Added touch subsystem locking
Fixes https://github.com/libsdl-org/SDL/issues/14563
2025-12-02 01:11:38 -08:00
Sam Lantinga
22decf4783 Fixed some clang thread-safety warnings 2025-12-02 01:11:38 -08:00
Cameron Gutman
6d99204a82 quit: don't call signal() if we're using sigaction()
At best, this is a no-op.

At worst, it might:
 - Clobber a signal handler someone registered after us
 - Overwrite the signal mask or flags
 - Cause unregistration to fail (sigaction() isn't guaranteed to return the exact pointer passed to signal())
2025-12-01 17:31:55 -06:00
Sam Lantinga
778f70c906 Clarify which thread is the main thread
If video is initialized, the main thread is the one that initialized video, otherwise if events are initialized, the main thread is the thread that initialized events, otherwise the main thread is the one that called the main function.

Fixes https://github.com/libsdl-org/SDL/issues/14511
2025-11-30 12:15:48 -08:00
Sam Lantinga
b9d794bb37 Fixed pen mouse motion when SDL_HINT_PEN_MOUSE_EVENTS is off (thanks @frenzibyte!)
Fixes https://github.com/libsdl-org/SDL/issues/14554
2025-11-30 10:55:47 -08:00
Amelia Clarke
defd7895da events: fix SDL_PeepEvents() returning 0 on error
Signed-off-by: Amelia Clarke <selene@perilune.dev>
2025-11-28 07:41:30 -08:00
Ryan C. Gordon
99d7dad7e6 pen: Dramatic improvements to proximity information.
Now everything will attempt to track pens through proximity changes (instead
of removing the pen entirely). testpen.c has been updated to reflect this.

Some platforms and devices are better at this than others, but this seems like
a significant usability improvement across the board.

Fixes #12992.
2025-11-21 08:13:16 -05:00
William Horvath
a7ab3a604b Print the full 64-bit timestamp in SDL_GetEventDescription().
Instead of wrapping at UINT_MAX.
2025-11-20 13:35:28 -08:00
Frank Praznik
d058781f71 mouse: Fix memory leak if events are sent after shutdown
Only allocate memory for source events if the mouse system is in the initialized state, otherwise, spurious events during shutdown can cause a leak.
2025-11-17 13:28:05 -05:00
Ryan C. Gordon
367c8d7c7b touch: don't compare mouse_touch_events to zero; it's a bool. 2025-11-14 10:28:16 -05:00
Sam Lantinga
379c47cc75 Revert "Fix lost KEY_UP events with multiple keyboards using shared scancode state (#14446)"
This reverts commit 3dab15d3b4.

With this commit any repeated key will be reported as held down indefinitely.
2025-11-12 11:51:34 -08:00
Chris Burrows
3dab15d3b4 Fix lost KEY_UP events with multiple keyboards using shared scancode state (#14446) 2025-11-11 23:36:08 -08:00
Ryan C. Gordon
25ab8c99df pen: Offer the current window during promixity events on most platforms.
Fixes #12356.
2025-11-11 16:34:22 -05:00
Sam Lantinga
49134ecf25 Pass the error through from the SetRelativeMouseMode() implementation 2025-11-03 13:07:17 -08:00
Sam Lantinga
05887f2087 Return false from SDL_SetWindowRelativeMouseMode() if relative mode isn't available
Fixes https://github.com/libsdl-org/SDL/issues/14388
2025-11-03 13:01:41 -08:00
Sam Lantinga
2d14a237dc Fixed trying to grab the mouse when losing keyboard focus
Fixes https://github.com/libsdl-org/SDL/issues/14350
2025-10-28 07:15:43 -07:00
Frank Praznik
39aedcef64 events: Pump DBus messages in the main event loop
DBus does not require a video backend, and DBus messages still need to be processed even when a video backend is not initialized. Move the DBus pump call to the main event message pump function so that DBus events are still dispatched, even when a video backend has not been initialized.
2025-10-23 21:03:09 -04:00
Sam Lantinga
23fcf53c53 Treat a single frame animated cursor as a normal color cursor 2025-10-19 23:03:54 -07:00
Sam Lantinga
bd86e85249 Added fallback support for animated cursors 2025-10-19 22:53:10 -07:00
Sam Lantinga
0e87ba163f Fixed crash if the animated cursor had a NULL frame 0 2025-10-19 22:53:10 -07:00
Frank Praznik
dcb8a6521c Add animated cursor support
Adds support for animated cursors on Cocoa, Wayland, Win32, and X11.

testcursor can take a semicolon separated list of filenames and load an animated cursor from them.
2025-10-15 14:41:15 -04:00
Susko3
e2bbbdc515 Implement SDL_GetPenDeviceType() for Android 2025-10-13 18:43:16 -04:00
Sylvain Becker
71bf56c9e4 Add SDL Pinch events (#9445) 2025-10-12 14:44:23 -07:00
Sam Lantinga
1871b998cd Added SDL_EVENT_SCREEN_KEYBOARD_SHOWN and SDL_EVENT_SCREEN_KEYBOARD_HIDDEN
Fixes https://github.com/libsdl-org/SDL/issues/13049
2025-10-10 10:14:07 -07:00
Sam Lantinga
6677fad1c8 Added SDL_EVENT_DISPLAY_USABLE_BOUNDS_CHANGED
Fixes https://github.com/libsdl-org/SDL/issues/12785
2025-10-09 19:15:45 -07:00
Frank Praznik
ce4af658ba events: Periodically poll tray events on *nix platforms
Tray events on *nix platforms usually run over DBus, and the events subsequently aren't delivered via the window event queue. As a result, SDL_WaitEvent() won't unblock when tray events arrive, particularly if there is no currently active window.

Wake up periodically to poll when tray items are active to avoid blocking the delivery and processing of tray events.
2025-10-07 12:32:12 -04:00
Sam Lantinga
baae2a628d Store the current window display ID on the window 2025-10-03 12:38:47 -07:00
Sam Lantinga
bae34c3e34 Fixed SDL_RunOnMainThread() on Android
If the application is waiting in SDL_WaitEvent(), we still need to run event loop maintenance in between calls to Android_PumpEvents().

Fixes the testautomation events_mainThreadCallbacks() test on Android.
2025-09-21 13:46:11 -07:00
Sam Lantinga
6a9ac1cacd Always poll udev on supported platforms
Fixes https://github.com/libsdl-org/SDL/issues/13995
2025-09-20 11:13:39 -07:00
Sam Lantinga
25b2d2c821 Use new parameter validation macro 2025-09-18 20:58:32 -07:00
Frank Praznik
cf646af707 Clean up old-style null check 2025-09-15 10:59:36 -04:00
Sam Lantinga
0f2cb0a3f8 Fixed to match window event order 2025-09-14 11:38:09 -07:00
Sam Lantinga
00812d13b0 The names of keyboards and mice are valid after they've been removed
Fixes https://github.com/libsdl-org/SDL/issues/12816
2025-09-11 20:07:55 -07:00
Sam Lantinga
3ddc3f1146 Send events for mice and keyboards detected during initialization
Fixes https://github.com/libsdl-org/SDL/issues/12815
2025-09-11 20:07:55 -07:00
Frank Praznik
5a06ef5c8f keyboard: Don't clear the keymap when it is set to auto release
Don't unset the keymap when it is set to auto release, or it will infinitely recurse.
2025-08-26 22:16:21 -04:00
Frank Praznik
6516f7a9e8 keyboard: Release bound keymaps during the destruction process
If a bound keymap is being destroyed, unbind it to ensure that the keyboard state won't be left pointing to an invalid keymap. Backends now no longer need to manually do this when destroying keymaps during keyboard removal and shutdown.
2025-08-26 12:56:29 -04:00
Sam Lantinga
aab95894a6 Fixed crash if mouse functions are used after video quit 2025-08-25 08:54:43 -07:00
Sam Lantinga
20df88a85b Fixed spacing 2025-08-14 14:44:56 -07:00
Frank Praznik
33c8998598 video: Use additional checks for determining on which display a window should be fullscreen
Trying to determine where a window should be made fullscreen from the size and position can be unreliable if the window exceeds the display bounds. Add additional checks with the following priority:

- If the window was positioned with a macro that explicitly passes a display ID, store and use the requested display as the explicit fullscreen target.
- Check if the window position is an exact match for any display origins, and use that display if found, as positioning a fullscreen window by moving it to the origin of the destination display is common behavior.
- Fall back to the existing center point check if the previous checks were not successful, as it is known behavior, and won't risk breaking existing clients that rely on it.
2025-08-07 14:30:39 -04:00
Sam Lantinga
31ba7efa48 x11: Refactor dpi hooks, removing GTK dependency and fixing XSettings watcher
- Removed GTK signal handler in x11settings. XSettings events are now properly dispatched to X11_XsettingsNotify.
  Previously events were not being passed to xsettings-client as no SDL xsettings_window was created. Now all events
  are filtered through xsettings_client_process_event allowing it to process the external window events that are selected.
  Global content scale is updated for changes to any recognized dpi settings.

- X11_GetGlobalContent now reads the current RESOURCE_MANAGER prop off of the root window to ensure it sees the
  current value. XResourceManagerString is now only used if getting the current prop fails as it caches the current resource
  manager value per-display connection.

- Clean up some warnings in SDL_gtk.
2025-08-06 09:22:15 -07:00
Sam Lantinga
26c41f3f9a Fix Android build
- Android defines SDL_PLATFORM_UNIX but does not compile core/unix sources
  so add checks for SDL_PLATFORM_ANDROID where SDL_gtk is used.

- Fix missing void parameter list in SDL_Gtk_EnterContext.

- Remove unneeded SDL_gtk.h include in SDL_events.c
2025-07-31 08:49:40 -07:00