Commit Graph

9599 Commits

Author SHA1 Message Date
Sam Lantinga
d95f5bad24 Updated to version 3.1.2 for the preview release 2024-05-01 09:34:25 -07:00
Petar Popovic
dec872bdd9 Fix SDL_GetDaysInMonth() num days in january 2024-04-30 18:06:41 -07:00
Semphris
b9d3d746a0 Add trailing path separator to SDL_GetUserFolder() 2024-04-30 18:01:16 -07:00
Semphris
c6a70d6898 Add support for modal windows to more platforms
- Adds support for modal windows to Win32, Mac, and Haiku, and enhances functionality on Wayland and X11, which previous set only the parent window, but not the modal state.
- Windows can be declared modal at creation time, and the modal state can be toggled at any time via SDL_SetWindowModalFor() (tested with UE5 through sdl2-compat).
- Allows dynamic unparenting/reparenting of windows.
- Includes a modal window test.
2024-04-30 13:47:57 -04:00
Sam Lantinga
97f7b4620a Fixed building with GDK (thanks @Romans-I-XVI!)
(cherry picked from commit 1caa427035)
2024-04-30 10:22:56 -07:00
Austin Sojka
42d7225a62 Added GDK app constrained/unconstrained events (#9608)
(cherry picked from commit 7554e82ec3)
2024-04-30 10:21:59 -07:00
Semphris
2b7af6636f Fix dialogs on Windows
This fixes a bunch of issues with dialogs on Windows.

- Removed lpstrFileTitle assignation, which overwrote the buffer
- Increased the memory size available for long file selections
- Removed seemingly unused `default_folder` in win_Args struct
- Properly handle the case where only one file is selected in multiselect mode
- Properly handle the initial folder, which would fail in specific conditions

The details for the last entry are explained in a comment in the code.
2024-04-30 10:17:46 -07:00
Petar Popovic
7bfecacc02 Removing function macro SDL_TABLESIZE() 2024-04-29 13:52:48 -07:00
Tyson Whitehead
0ab5a8a413 Initialize udev before joystick manual scan so class lookup works
LINUX_JoystickInit does a manual scan first so devices are sorted.
If SDL_UDEV_Init hasn't run by then, then the product info cannot
be looked up by SDL_UDEV_GetProductInfo and the initial-plugged-
in-device classification falls back to heuristic guessing.

(cherry picked from commit 0963c11af8)
2024-04-26 12:16:24 -07:00
Sam Lantinga
14f584a94b SDL_CreateWindowAndRenderer() takes the window title as the first parameter
Fixes https://github.com/libsdl-org/SDL/issues/9626
2024-04-25 20:00:14 -07:00
Sam Lantinga
2d7cc6ded0 Fixed getting the renderer info when creating a window texture 2024-04-25 17:32:56 -07:00
Sam Lantinga
ca61bf682a Make sure output parameters are zeroed in the case of an error 2024-04-25 16:46:44 -07:00
Sam Lantinga
04f1901751 Fixed window flashing under X11 when creating a window and OpenGL renderer 2024-04-25 16:42:43 -07:00
Ethan Lee
26b71d14e9 storage: Static analysis fix 2024-04-25 19:40:07 -04:00
Sam Lantinga
ac5a61cd60 Fixed build error (thanks @sezero!) 2024-04-25 09:45:10 -07:00
Tyson Whitehead
391b8c0c07 Avoid opening non-joystick devices if possible to speedup scanning
Closing a device file takes 0.01 to 0.5s, which can add up to
significant startup delays. The udev classification does not
require opening the actual device files, so, use it if possible,
and only fall back to opening the device and probing otherwise.

(cherry picked from commit 45b804c158)
2024-04-25 08:49:48 -07:00
Ozkan Sezer
3959765b81 SDL_waylandvulkan.c: fix type redefinition errors.
Fixes https://github.com/libsdl-org/SDL/issues/9620
2024-04-25 03:50:00 +03:00
Sam Lantinga
e56f05bac1 Fixed unclipping the mouse when a monitor is placed left of the primary one on Windows.
There is now a desktop bounds variable that could potentially be exposed in the API if we wanted.
2024-04-24 12:06:00 -07:00
Frank Praznik
b41699e9c4 event: Always clear the mouse capture flag, even if the backend capture function isn't implemented.
Some backends, such as Wayland, don't support explicit mouse capture, and thus don't implement the backend function to do so, but do set/unset the capture flag on button events to handle cases where a button is pressed and the pointer is dragged outside the window.

If the backend doesn't support explicitly setting the mouse capture mode, manually clear the capture flag when the window has had the focus forcibly removed, to avoid sending bogus motion events as well as an assert condition.
2024-04-24 12:40:56 -04:00
Sam Lantinga
98582dca02 Fixed Win+V handling (pasting from clipboard history) on Windows
Fixes https://github.com/libsdl-org/SDL/issues/9613
2024-04-24 09:35:19 -07:00
Ryan C. Gordon
be6b8dead4 CaseFoldUtf8String: Fixed to actually work with Unicode values.
I think this started off as a UTF-32 output, and I forgot to actually
finish this off to encode back to UTF-8.

Fixes #9607.
2024-04-23 18:57:48 -04:00
Sam Lantinga
8acb91936a Fixed warning, needs more work by @icculus 2024-04-23 14:35:55 -07:00
Sam Lantinga
bcd2807065 Fixed warning C4244: 'initializing': conversion from 'int' to 'SDL_AudioFormat', possible loss of data 2024-04-23 14:12:05 -07:00
Frank Praznik
7729a8b5c3 x11: Don't try to capture mouse input via X when XInput2 is in use
Trying to capture the pointer via XGrabPointer() when XInput2 is in use will always fail with 'AlreadyGrabbed', since the pointer is already grabbed by XInput2.
2024-04-23 11:59:36 -04:00
Sam Lantinga
42f8e94d11 mac: Fix SDLWindow nswindow member no longer being cleaned up in Cocoa_DestroyWindow
- A refactor changed how SetupWindowData handled external windows where previously it was tracked
  in a field of SDL_CocoaWindowData but now it is tracked by setting SDL_WINDOW_EXTERNAL in the
  window flags. Removed the now unused field and updated the external window check in DestroyWindow.
2024-04-23 06:20:30 -07:00
Brick
c9cfc681b9 Workaround GCC bug in audio resampler 2024-04-22 18:38:55 -04:00
Ryan C. Gordon
acf811a06b Revert "dynapi: Remove unused ENABLE_SDL_CALL_LOGGING code."
This reverts commit 9128f92f38.

Apparently this is useful for debugging from time to time!
2024-04-22 17:01:07 -04:00
yassineimounachen
5ffb2f47d1 Add USB IDs for the Thrustmaster TS-XW racing wheel
To be of use, this depends on https://github.com/berarma/oversteer/pull/200 and https://github.com/Kimplul/hid-tmff2/pull/94.
2024-04-22 11:35:31 -07:00
Ryan C. Gordon
39d0e62ef5 dynapi: Remove DISABLE_JUMP_MAGIC.
The "jump magic" codepath was never written, and would have involved a lot
of low-level and platform/processor/compiler specific work.

A better solution is for compilers to treat the function call in the jump
table functions as a tail call, which would effectively produce the same
result in a portable way.

Clang already has a way to do this that we could add later. But this wouldn't
need a separate "jump magic" section.
2024-04-21 22:16:48 -04:00
Ryan C. Gordon
9128f92f38 dynapi: Remove unused ENABLE_SDL_CALL_LOGGING code.
This was hardcoded to disabled, since building it in bloated the binary
massively for little gain (one could probably accomplish this same thing
with ltrace or something).

If we need it, we'll pull it out of revision control.
2024-04-21 22:13:43 -04:00
Ryan C. Gordon
7a36504952 storage: SDL_WriteStorageFile() wasn't marked as SDLCALL.
Fixes #9594.
2024-04-21 09:26:07 -04:00
Frank Praznik
fb4c15319e pipewire: Raise minimum build version to 0.3.44 2024-04-19 12:34:22 -04:00
Ryan C. Gordon
cab3defc18 render: SDL_DestroyWindow hollows out its renderer but doesn't free it.
This allows apps to destroy the window and renderer in either order, but
makes sure that the renderer can properly clean up its resources while OpenGL
contexts and libraries are still loaded, etc.

If the window is destroyed first, the renderer is (mostly) destroyed but its
pointer remains valid. Attempts to use the renderer will return an error,
but it can still be explicitly destroyed, at which time the struct is free'd.

If the renderer is destroyed first, everything works as before, and a new
renderer can still be created on the existing window.

Fixes #9540.
2024-04-19 00:25:59 -04:00
Ryan C. Gordon
39c8434f5f render: Manage memory for SDL_Renderer* at higher level.
Previously, each backend would allocate and free the renderer struct. Now
the higher level does it, so the backends only manage their private resources.

This removes some boilerplate and avoids some potential accidents.
2024-04-19 00:25:59 -04:00
Frank Praznik
09e32faa68 x11: Ensure that a configure event was received before sending the final window size and coordinates
Headless display servers might not send an initial configure event, so don't assume that one has arrived and send garbage size/position values when showing a window.
2024-04-18 14:28:16 -04:00
devon-artmeier
9c65738926 dialog: Use size_t for length variables (#9572)
Shuts up a warning about size differences.
2024-04-18 09:09:10 -07:00
bootrako
1de8a53015 windows hidapi: fix header compilation 2024-04-18 09:00:49 -07:00
Frank Praznik
0bda7e22cf wayland: Print an error when the display connection is closed by the server
Otherwise, it isn't immediately clear to the client application as to why its windows suddenly disappeared, and it received a quit event out of nowhere.
2024-04-18 11:23:58 -04:00
Frank Praznik
a923db9d0a pipewire: Use the core version info for the preferred version check
When running in a container, the underlying Pipewire version may not match the library version, so retrieve and check the core version info to see if it meets the preferred version requirements.
2024-04-17 22:34:26 -04:00
Ryan C. Gordon
bc6ad3ee43 dialog: convert_ext_list had parameter names in wrong order in header. 2024-04-17 21:45:51 -04:00
Frank Praznik
b1e47704ee audio: Prefer Pipewire if at least version 1.0.0
Checking for the pipewire-pulse service is unreliable when used in containers such as Flatpak, so simply use a minimum version check instead and prefer it over the Pulseaudio backend if at least version 1.0.0.
2024-04-17 17:16:28 -04:00
Mathieu Eyraud
cac1434295 Close pipe in Wayland_ShowMessageBox
When closing message box by pressing escape, Zenity does not write to the pipe and fgets() get stuck waiting for EOF.
2024-04-17 15:27:34 -04:00
Frank Praznik
a2eb2697a3 x11: Fix mode switching when running under XWayland
XWayland emulates the XRandR interface, so it still needs the actual mode switch call to trigger the mode switching emulation.

There is also no need to wait when using XWayland mode switching emulation, as it is handled via viewport scaling and thus instantaneous.
2024-04-17 11:39:49 -04:00
Frank Praznik
bed6c5b81f x11: Wait for mode switches to complete when synchronizing a window
Otherwise, the sync can timeout due to mode switching taking several seconds.
2024-04-17 11:39:49 -04:00
Sam Lantinga
e632ed23ad Fixed compilation with C89 (thanks @d-s-a!)
Closes https://github.com/libsdl-org/SDL/pull/9564

(cherry picked from commit 4e29be814e)
2024-04-17 07:49:19 -07:00
DevonArtmeier
65a04a772e dialog: Allocate space for terminator when building filter string 2024-04-16 14:09:18 -07:00
Ryan C. Gordon
fdcc3e1151 thread: make generic SDL_Condition a no-op if built with SDL_THREADS_DISABLED.
Otherwise, when you call SDL_CreateCondition() in something that can otherwise
survive in a single-threaded build, you'll get an error that seems fatal.

We already do this for mutexes and rwlocks (but not semaphores!)

Fixes #9558.
2024-04-16 15:07:56 -04:00
Ryan C. Gordon
12b371679f audio: Code defensively to placate static analyzers, don't disabling warnings. 2024-04-15 23:53:56 -04:00
Sam Lantinga
bdd47f7770 Fixed warning: no previous extern declaration for non-static variable 'ResamplerFilter'
Fixes https://github.com/libsdl-org/SDL/issues/9556
2024-04-15 16:16:32 -07:00
Sam Lantinga
57a5b26d77 Updated to the latest version of the Vulkan SDK 2024-04-15 16:05:32 -07:00