Commit Graph

5101 Commits

Author SHA1 Message Date
Frank Praznik
9aae258aeb wayland: Adjust DnD coordinates when dragging over a mask subsurface 2026-05-17 11:52:10 -04:00
Frank Praznik
336d07c2b7 wayland: Implement Wayland_AcceptDragAndDrop()
This simply toggles a flag that rejects DnD offers if false. Events were previously dropped silently, but rejecting the offer makes some desktops display a proper icon when the drop will not work.
2026-05-17 11:52:10 -04:00
Ozkan Sezer
4aeac49311 update openxr headers from khronos. 2026-05-17 16:29:03 +03:00
Ozkan Sezer
322dfd3ada update vulkan headers from khronos. 2026-05-17 16:29:03 +03:00
Ozkan Sezer
968b0c6910 update gl/egl headers from khronos. 2026-05-17 16:29:03 +03:00
Ozkan Sezer
75c94e9b31 SDL_opengl_glext.h, src/video/directx/d3d12.h: revert unintended changes from commit d70578b9aa 2026-05-17 16:28:29 +03:00
Ozkan Sezer
b24feafaa2 cygwin: patch vulkan headers for VKAPI_CALL and enable vulkan in cmake 2026-05-17 09:55:31 +03:00
Ozkan Sezer
2cd5cd2a42 cygwin: patch egl/opengles headers for EGLAPIENTRY 2026-05-17 09:55:31 +03:00
Anonymous Maarten
2038005657 video: don't use NEON blitters when SDL_HasNEON returns false 2026-05-17 04:41:56 +02:00
Cameron Gutman
060b74a664 mouse: Restrict GCMouse to macOS Sonoma and later 2026-05-16 15:43:33 -07:00
stahta01
6586bebfec Fix Cygwin building and add CI (#15566)
Co-authored-by: TrueCat17 <truecat17@gmail.com>
Co-authored-by: Anonymous Maarten <anonymous.maarten@gmail.com>
Co-authored-by: Ozkan Sezer <sezeroz@gmail.com>
2026-05-15 08:48:24 -07:00
Anonymous Maarten
d5af35e3fb surface: cannot set a palette to a non-indexed surface
This fixes a UBSAN warning later in this function where it calculates
(1 << SDL_BITSPERPIXEL(surface->format)). The bpp might be >= 32 and
out of range for a bit shift.
2026-05-14 20:53:45 -07:00
Cameron Cawley
a3376acc2e Replace custom NEON cast macros with vreinterpret_*_* 2026-05-14 09:16:25 -07:00
Gabriel Wang
0f175891a6 Add SVE2 SIMD Alpha-Blending Blitter (#15504)
SVE/SVE2 is a new SIMD extension for AArch64. Compared to NEON, SVE/SVE2 brings the following benefits that are good for SDL projects:

- Lane prediction: we don't have to treat the tail part of a stride separately when the width is n times the hardware vector size
- Although the performance is almost no difference from NEON when the hardware vector size is 128bits, when the hardware provides a longer vector size, e.g. 256, 512, ... 2048, we can enjoy the large performance gain without modifying the source code or recompiling a library.

The functional correctness is validated in a dedicated [qemu project](https://github.com/GorgonMeducer/aarch64_qemu_mac_template/tree/SDL-SVE2-Acceleration-Validation).

The performance is tested on [Radxa Orion 6 N](https://radxa.com/products/orion/o6n/), which provides 4x A720 and 4x A520 processors. Since the vector size is 128 bits, which is the same as NEON, the performance is almost the same (or no worse than) the NEON acceleration.
2026-05-13 23:37:46 -07:00
Sam Lantinga
0e5e772ba9 Fixed windows getting the wrong size when setting size and aspect ratio back to back 2026-05-13 20:39:38 -07:00
Cameron Cawley
e50faf4e6a Support the full set of standard CSS cursors 2026-05-13 20:24:44 -07:00
Cameron Cawley
c6b232f5d4 Support loading JPEG images through SDL_LoadSurface() 2026-05-13 16:11:53 -07:00
Eddy Jansson
4eb221881a DOS: Replace SDL_memset() with SDL_zero*() 2026-05-13 11:28:54 -07:00
Cameron Cawley
b1f390255a Allow formats with alpha channels for window textures
Because the blend mode is explicitly set to SDL_BLENDMODE_NONE, it doesn't matter if there's a transparency channel in the texture format or not for opaque windows. This ensures that a 32-bit format is used with Metal instead of SDL_PIXELFORMAT_RGB565.
2026-05-13 08:52:30 -07:00
Ozkan Sezer
36e1efccb4 revert parts of CodeSpell commit d870911202 from 3rd party sources 2026-05-13 18:00:02 +03:00
Cameron Cawley
7071efb6a3 Fix switching modes on RISC OS 2026-05-12 20:18:02 -07:00
Sam Lantinga
5cf16e4522 Added curved window mode on visionOS 26 (#15298) 2026-05-12 16:48:06 -07:00
Frank Praznik
f48525aa70 x11: Store the mouse button serial for emulated pointer events as well
Otherwise, filtered emulated button events, such as for mouse wheels, can slip through the core event handler.
2026-05-10 14:16:49 -04:00
Frank Praznik
04d8a654d8 wayland: Ensure the viewport size is always non-zero
A viewport size of zero is a protocol error, so guard against it when adjusting the aspect ratio.
2026-05-07 13:16:50 -04:00
Frank Praznik
ba3577f584 wayland: Ensure window dimensions are greater than zero after adjusting for aspect
Resizing to zero can cause a bad viewport size error.
2026-05-07 13:16:50 -04:00
Frank Praznik
e3393e6304 wayland: Queue the surface frame callback after the initial commit
Some compositors may dispatch this too early, during the initial empty commit, when subsurfaces are attached to a toplevel window, but a buffer has yet to be committed to the parent surface. Don't set the frame callback until the initial empty commit is done, so it will be called when the actual parent surface frame is committed.
2026-05-06 12:27:41 -04:00
Sam Lantinga
702f9d94cd Use SDL_HasWindows() 2026-05-06 09:12:10 -07:00
Frank Praznik
1ac0ae9224 wayland: Unconditionally send an exposure event on window shown status
Some compositors send the frame callback as part of the initial configuration sequence, so the window may already be past the "waiting for frame" state. Ensure that the exposure event is always sent.
2026-05-05 18:32:15 -04:00
Frank Praznik
b8545fce54 x11: Disable the X Synchronization Extension by default
Under the right conditions, this extension can result is smoother resizing when rendering with OpenGL, however, it is known to cause problems in certain cases, such as when handling presentation externally.

Gate it behind a hint, and disable it by default. Developers can selectively enable it when they verify that they meet the criteria for using it, and that it behaves correctly in their apps/games.
2026-05-05 13:46:21 -04:00
Sam Lantinga
f6f4664ed1 Fixed rare cursor corruption on Windows
If the cursor was created with a temporary surface that was pointing at external memory, then when the cursor is used it might be referencing memory that had already been freed.
2026-05-05 08:55:28 -07:00
Frank Praznik
3ee0439ae5 wayland: Pass the inverted flag for horizontal scroll events
Natural scrolling affects both axes, and the compositor may not send the vertical axis orientation if the frame has no vertical scroll motion, so purely horizontal events need to be flagged as inverted as well.
2026-05-03 17:41:08 -04:00
Igor
e70f1bfc29 X11TK: fix late null-check causing segfault
The code is using `controls.window` before checking if it isn't null.

I found this bug by accident when I tried to run `SDL_ShowSimpleMessageBox`. 

It first tried using Wayland with `zenity`, but since I don't have `zenity`, it fallbacked to `X11_ShowMessageBoxImpl`.

For some reason it couldn't create a window, maybe something related to XWayland, so `controls.window` was `NULL`.
2026-05-01 19:12:44 -04:00
Sam Lantinga
b7726026f8 Fixed double-backspace with hardware keyboard on iOS 2026-04-27 10:54:03 -07:00
Sam Lantinga
dcf05165d3 Use SDL_SendScreenKeyboardShown() and SDL_SendScreenKeyboardHidden() on iOS
We now have events for on-screen keyboard visibility, so we should use these instead of starting and stopping text input.

Fixes https://github.com/libsdl-org/SDL/issues/15437
Confirmed not to regress the fix in https://github.com/libsdl-org/SDL/pull/11845
2026-04-27 10:54:03 -07:00
Ryan C. Gordon
0bf2fa8978 internal: Replace SDL_PUSH_ERROR with SDL_PushError.
Reference Issue #15458.
2026-04-27 09:33:46 -04:00
Ozkan Sezer
3308183dfa video, dos: silence -Wdangling-pointer warnings 2026-04-27 05:30:14 +03:00
Ozkan Sezer
1023f48b5a add missing newlines at end of dos sources. 2026-04-26 21:12:14 +03:00
Frank Praznik
c65c809337 wayland: Use manual masking on KDE for non-native aspect fullscreen modes
KDE doesn't automatically center and mask fullscreen windows that don't match the display aspect ratio, so they are masked manually.

Can be removed when https://invent.kde.org/plasma/kwin/-/merge_requests/6953 is merged.
2026-04-26 11:54:31 -04:00
Frank Praznik
80a5905075 wayland: Change the non-native fullscreen mode scaling default to 'aspect' 2026-04-26 11:54:31 -04:00
Sam Lantinga
3c02de2f7c Ignore the first hover event with a stale position on iOS
Fixes https://github.com/libsdl-org/SDL/issues/15450
2026-04-25 07:24:53 -07:00
Frank Praznik
01a7588f8e wayland: Avoid excessive exposure events during interactive resizes
Only send the unblocking exposure event once per frame, so that clients using an event watcher won't redraw excessively.

Also ensure that the unblocking exposure is always sent on the libdecor path.
2026-04-24 13:19:05 -04:00
Anders Jenbo
a8ecd677ed Add DOS platform support (DJGPP) (#15377)
* dos: Some initial work.

* dos: Turn off buffer on stdio SDL_IOStreams.

Seeking breaks otherwise. We might be able to just fflush() before or seeking
instead?

* dos: Audio implementation using the Sound Blaster 16.

* dos: remove audio Pump interface.

Turns out DosBox-X was having trouble with the Sound Blaster or something;
standard DosBox works correctly directly from the interrupt handler, and
without doubling the buffer size.

* dos: just dump and restore the stdio buffer when seeking.

This is MUCH faster than just leaving buffering disabled, and also works
around getting bogus reads after an fseek. SDL_LoadWAV on test/sample.wav
no longer takes several seconds to finish, and comes up with the correct
data.

I wonder if we're triggering this in LoadWAV because we're malloc'ing data
between seeks/reads, and it's causing the djgpp transfer buffer to change. Or
maybe the Fat DS trick is confusing it? I don't know, I haven't had time to
debug it, it might just be a legit libc bug in djgpp too, for all I know.

* dos: Protect audio device "thread" iterations when streams are locked.

This uses an old trick we used in SDL 1.2 for MacOS Classic, which did its
audio callback in a hardware interrupt. If the audio is locked when the
interrupt fires, make a note of it and return immediately. When the lock is
released, if the interrupt has been fired, run the audio device iteration
right then.

Since there isn't a big device lock in SDL3 (available to the app, at least),
this keeps a counter of when any SDL_AudioStream is locked, which is probably
good enough.

* dos: Implemented initial video subsystem.

This uses VESA interfaces to manage the display and works with the software
renderer.

Events aren't hooked up yet, so prepare to close DosBox on each run.  :)

* dos: Whoops, forgot to add these to revision control. Core and Main support.

* dos: Wired up basic filesystem support.

This gets most of the rendering examples, which use SDL_GetBasePath() to
find textures to load, working.

* dos: Fixed compiler warning.

* dos: Initial mouse support!

* dos: Move interrupt hooking code into core/dos.

* dos: Initial keyboard support!

* dos: Use a simple ring buffer for keyboard events.

Of course Quake 1 solved this better, haha. It's smart: less memory, dirt
simple, and you don't even have to worry about synchronizing with the
interrupt handler, because it's safe for both sides no matter when an
interrupt fires.

* ci: add djgpp job

[sdl-ci-filter djgpp]
[sdl-ci-artifacts]

* dos: Fix build issues after rebase onto current main

- SDL_runapp.c: Add SDL_PLATFORM_DOS to the exclusion list so the
  generic
  SDL_RunApp() is disabled when the DOS-specific one is compiled.
- SDL.c: Exclude SDL_Gtk_Quit() on DOS. DJGPP defines __unix__ which
  sets
  SDL_PLATFORM_UNIX, but DOS has no GTK/display server. The GTK source
  is not compiled (CMake UNIX is false for DOS) so this was a link
  error.
- sdlplatform.cmake: Add DOS case to SDL_DetectCMakePlatform so the
  platform is properly detected from CMAKE_SYSTEM_NAME=DOS.
- i586-pc-msdosdjgpp.cmake: Add i386-pc-msdosdjgpp-gcc as a fallback
  compiler name, since some DJGPP toolchain builds use the i386 prefix.

* Add 8-bit palette support to DOS VESA driver

* Add VBE page-flipping, state restore, and robust keyboard handling

- Implement double-buffered page-flipping for VBE modes with >1 image
  page
- Save and restore full VBE state on video init/quit for clean mode
  switching
- Improve DOS keyboard handling: support extended scancodes and Pause
  key
- Lock ISR code/data to prevent page faults during interrupts
- Always vsync when blitting in single-buffered modes to reduce tearing

* Refactor Sound Blaster audio mixing to main loop

Move audio mixing out of IRQ handler to main loop for improved
stability and to avoid reentrancy issues. Add SDL_DOS_PumpAudio
function, update DMA buffer handling, and adjust sample rate to 22050
Hz.
Silence stale DMA buffer halves to prevent stutter during load.

* Add DOS timer support and update build config

* Add support for pre-SB16 8-bit mono Sound Blaster audio

Detect SB version and select 8-bit mono or 16-bit stereo mode.
Handle DMA and DSP setup for both SB16 and pre-SB16 hardware.
Add FORCE_SB_8BIT option for testing in DOSBox.

* Add SB Pro stereo support and simplify IRQ handler

* Add DOS joystick driver support

* Improve DOS hardware handling and clarify memory allocation

- Poll Sound Blaster DSP status instead of fixed delay after speaker-on
- Clarify DPMI conventional memory is always locked; update comments
- Document and justify DMA memory allocation strategy
- Free IRET wrapper after restoring interrupt vector to avoid leaks
- Throttle joystick axis polling to ~60 Hz to reduce BIOS timing loop
  cost
- Always poll joystick buttons directly for responsiveness

* Query and use mouse sensitivity from INT 33h function 0x1B

* Add support for VESA banked framebuffer modes

Implement banked framebuffer access for VBE 1.2+ modes without LFB.
Detect and initialize banked modes, copy framebuffer data using bank
switching, and blank the framebuffer on mode set. Page-flipping is
disabled in banked mode.

* Add optional vsync to page flipping in DOS VESA driver

* Add cooperative threading support for DOS platform

* Move SoundBlaster audio mixing to SDL audio thread

* Fix DOS platform comments and workarounds for DJGPP support

* Fix SoundBlaster IRQ handling and DMA setup for DOS

- Pass IRQ number to DOS_EndOfInterrupt and handle slave PIC EOI
- Validate DMA channel from BLASTER variable
- Correct DMA page register selection for SB16
- Improve BLASTER variable parsing and error messages
- Unmask/mask IRQs on correct PIC in DOS_HookInterrupt
- Rename SDL_dosjoystick.c to SDL_sysjoystick.c
- Include SDL_main_callbacks.h in SDL_sysmain_runapp.c
- Add include guard to SDL_systhread_c.h

* Add DOS platform options and preseed cache for DJGPP

Disable unsupported SDL features when building for DOS. Add
PreseedDOSCache.cmake to pre-populate CMake cache variables for DJGPP.

* cmake: use a 8.3 naming scheme for tests on DOS

* Apply code style

* Update include/SDL3/SDL_platform_defines.h

Co-authored-by: Anonymous Maarten <madebr@users.noreply.github.com>

* Code review clean up

- Split DOS VESA mode-setting into its own file
- Replace magic numbers with named constants
- Update copyright dates to 2026
- Substract time taken by other threads form delays

* Fix DOS bugs and improve compatibility

- Disable fseeko64 for DJGPP due to broken implementation
- Refactor DOS timer delay to always yield and avoid busy-waiting
- Fix animated cursor rendering in DOS VESA backend
- Always set display mode when creating DOS VESA window
- Work around DJGPP allowing invalid file access in testfile.c
- Bump max threads to 16
- Apply workarounds for threading tests

* Add DOS platform documentation and fix a few issues

- Fix fullscreen default resolution
- Improve best mode matching
- Fix builds on GCC older than 7.0
- Fix text input events

* Fix keyboard mapping of "*"

* Fix running, and existing, under PCem

* Apply suggestions from code review

Co-authored-by: Cameron Cawley <ccawley2011@gmail.com>

* Pre-mix audio in ring buffer and copy to DMA via IRQ thread

* Video fixes and optimizations

* DOS: Fix Intel 740 and VGA compatability

* DOS: Update readme

* DOS: Fix thread ID, get GPU name

* DOS: Cap mouse range

* DOS: Map test resources to 8.3 names

* DOS: Skip unsupported WM color modes

* Fix "windowed" resolution selection

* DOS: Hide INDEX8 modes behind SDL_DOS_ALLOW_INDEX8_MODES

* Remove SDL_HINT_DOS_ALLOW_INDEX8_MODES and order modes logically

* Don't convert cursor if dest is not INDEX8

---------

Co-authored-by: Ryan C. Gordon <icculus@icculus.org>
Co-authored-by: Anonymous Maarten <anonymous.maarten@gmail.com>
Co-authored-by: Cameron Cawley <ccawley2011@gmail.com>
Co-authored-by: Gleb Mazovetskiy <glex.spb@gmail.com>
Co-authored-by: Jay Petacat <jay@jayschwa.net>
Tested-by: Cameron Cawley <ccawley2011@gmail.com>
2026-04-23 19:54:49 -04:00
Anders Jenbo
9fa9edeadb Prefer higher color depths in SDL_GetClosestFullscreenDisplayMode() 2026-04-23 18:32:09 -04:00
Sam Lantinga
7b23cd62ca Revert "(video) fix SDL_GetClosestFullscreenDisplayMode aspect ratio & refresh rate picking logic"
This reverts commit 0231ff03de.

This causes SDL to return 1024x768 when asking for a best fit to 640x480 (thanks @AJenbo), so I'm reverting this until we can investigate more.
2026-04-23 13:23:49 -07:00
Marco Burato
85b36937a9 macOS mouse scroll fix (#15404)
* macOS: fix vertical/horizontal scrolling on GCMouse API
* macOS: use AppKit events for mouse scrolling as GCMouse scroll events are buggy
2026-04-20 10:53:25 -07:00
som3a-dev
0231ff03de (video) fix SDL_GetClosestFullscreenDisplayMode aspect ratio & refresh rate picking logic 2026-04-20 07:51:29 -10:00
Frank Praznik
03f1a84302 wayland: Fix scaled cursor image selection
When the pointer isn't being scaled, make sure the cursor scale factor is set to that of the window to avoid blurry cursors on high-DPI desktops, and use the inverse of the pointer scale value when selecting buffers for size-adjusted cursors. Fixes a regression from adjusting custom cursor sizes when using scale to display mode, and ensures that the best buffer size for the scaled cursor is always selected.
2026-04-20 10:19:04 -04:00
Frank Praznik
03ceaca19c wayland: Calculate the fullscreen exclusive pointer scale from the viewport dimensions
Fixes the pointer scale when using the aspect-correct scaling mode.
2026-04-19 23:31:00 -04:00
Cameron Cawley
43c928ee86 Improve constness with Clipboard APIs 2026-04-19 07:05:46 -04:00
Frank Praznik
b181eb4ed0 x11: Fix #define name 2026-04-17 10:28:50 -04:00