Commit Graph

13316 Commits (efd2023a72b2ed2444beaaba989ebc02cd13cee7)

Author SHA1 Message Date
Sam Lantinga 7602a3181e Allow declarations after statements
The SDL coding standard is C89 plus C++ style comments and mixed code and declarations.
2023-05-26 08:19:04 -07:00
Ryan C. Gordon 35292d7dba pulseaudio: Redesigned to use pa_threaded_mainloop.
We weren't meant to have multiple contexts and mainloops, but we had one
for each opened device and the hotplug detection thread. Instead, use
pa_threaded_mainloop, which can be shared between threads and objects, and
a single context (which, according to the PulseAudio documentation, is
usually meant to be a singleton that represents a global server connection,
possibly with multiple streams hung on it).

Now instead of polling in a loop, threads will block until the
threaded_mainloop runs a callback, and the callback will fire a signal to
unblock the thread.

Prior to this, the code upset ThreadSanitizer, as Pulse has some unprotected
global resource that each mainloop/context would touch.

Reference Issue #7427.
2023-05-26 09:07:33 -04:00
Ryan C. Gordon 81fe505c31 audio: remove is_in_audio_device_thread()
SDL mutexes are always recursive in modern times, so no need to check this,
plus the test triggers a false-positive on ThreadSanitizer.

Reference Issue #7427.
2023-05-26 09:07:33 -04:00
Ryan C. Gordon d4bc393efe
video: Only specify some GL context attributes if not the explicit default.
Just in case it upsets some OpenGL drivers unnecessarily.

Fixes #7730.
2023-05-25 10:04:44 -04:00
David Edmundson a6bb00f399 x11: Use XResources font DPI as a fallback for X11 content scale
There are many toolkit specific ways to set a font DPI in X11 desktop
environments. The primary approach of reading a Gnome specific setting
from the portal is ok, it will work on Gnome and on Plasma most the
time.

The current fallback GDK_SCALE is less great; it's an internal GTK
setting relating to the mapping of logical pixels to device pixels
within the toolkit, it's a developer setting for GTK devs. We were
instructed within Plasma to not set this as it caused issues.

Xft.dpi in xresources is a good universal fallback, it's very dated to
the point that it works in clients like xterm, Qt on X11 uses it in our
font DPI path.
2023-05-24 13:58:42 -07:00
Sam Lantinga 65180804c4 Disable unused local typedefs warning
This triggers on gcc 4.8.4 for compile time asserts inside of functions

Fixes https://github.com/libsdl-org/SDL/issues/7732
2023-05-23 17:23:30 -07:00
Sam Lantinga a9c988b2a9 Fixed building on 32-bit Linux 2023-05-23 14:36:25 -07:00
Sam Lantinga 06d5989157 Fixed crash if video isn't initialized in SDL_CreatePopupWindow() 2023-05-23 13:41:34 -07:00
Sam Lantinga e92e4d8b50 Save waitable timers in thread local storage instead of continuously allocating and freeing them
Fixes https://github.com/libsdl-org/SDL/issues/6597
2023-05-23 11:32:40 -07:00
Sam Lantinga ddbdd73258 Updated source to match SDL function prototype style 2023-05-23 11:29:41 -07:00
Sam Lantinga 737aa881fa Updated source to match SDL function prototype style 2023-05-23 09:37:07 -07:00
Simon McVittie a828f5897e testevdev: Add some driving sim controllers from Proton issue reports
Ideally we'd detect these as "joysticks" (or more generally, gaming
controllers), but in most cases their evdev flags are indistinguishable
from an accelerometer or gyro, so the only way to achieve this would be
a table of known devices that doesn't currently exist.

One exception is the one that reports a THROTTLE axis and TRIGGER, THUMB
buttons, which would be reasonable to detect via the joystick heuristic.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-23 08:53:19 -07:00
Simon McVittie c88b1d1ca0 testevdev: Add the ability to mark a device entry as unimplemented
There are some devices for which SDL's device classification heuristic
is known not to give the ideal result. Add a way to incorporate these
into our test data, so that when the heuristic is improved we can
detect them as their intended device type, without making the test fail
before that has been implemented.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-23 08:53:19 -07:00
Simon McVittie 22e6319fed testevdev: Add data for some game controllers submitted to steam-devices
This will ensure that detection of these devices doesn't regress.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-05-23 08:52:53 -07:00
Linus Probert da3fefc65c x11: Adds support for generic clipboard data in X11
Re-writes clipboard data handling in X11 to an on demand approach where
data can be produced on request instead of storing it in X11 properties
on the window.
Primary selection has been changed to mimic this behavior even though
it's only possible to use it for text as of now.
2023-05-23 08:51:56 -07:00
Sam Lantinga b48b1ce500 Document the Android SDK versions checked in Java code 2023-05-23 08:44:49 -07:00
Sam Lantinga 61ef4efdfa Fixed duplicate Joy-Con controllers on macOS
If both Apple and HIDAPI drivers see the controller, HIDAPI will be preferred.

Fixes https://github.com/libsdl-org/SDL/issues/7479
2023-05-22 13:54:15 -07:00
Sam Lantinga cf0abf9911 Fixed handling the Saitek P3600, which doesn't use the Xbox 360 controller protocol 2023-05-22 12:41:03 -07:00
Sam Lantinga c971795954 Fixed reporting backspace key if there is no text in the edit buffer (thanks @312937!)
This workaround isn't necessary at API 30 and above.

Fixes https://github.com/libsdl-org/SDL/issues/7039
2023-05-22 11:54:46 -07:00
Sam Lantinga 3f6b2d1a61 Use numeric codes for Android versions, to avoid SDK dependencies 2023-05-22 11:51:32 -07:00
Frank Praznik 1cadf4bab9 wayland: Validate surfaces and window data before sending touch events
Ensure that incoming touch events originate from valid surfaces owned by SDL and have proper window data before forwarding them to the touch subsystem, or the window focus pointer that is sent with the event may not be a pointer to an SDL window.

Additionally, ensure that allocated touch events are always cleaned up on exit.
2023-05-22 14:40:09 -04:00
Sam Lantinga 4dd9f61bfd Don't map the top keyboard row to numbers when using the one-handed DVORAK layouts (thanks @tormol!)
Fixes https://github.com/libsdl-org/SDL/pull/5127

(cherry picked from commit a2f4783e753e499c7f6660bf34e337618239a72f)
2023-05-22 11:33:47 -07:00
Caleb Cornett 376a3cd100 Fix Xbox link error from IsRectEmpty 2023-05-21 19:09:28 -07:00
Sam Lantinga d7a56b93d5 Revert "Popups don't accept first focus clicks"
This reverts commit 9d40d619709ce830372835ca29f516b73a685317.
2023-05-21 08:18:46 -07:00
Sam Lantinga e1a28bc16f Popups don't accept first focus clicks
I'm not sure if this is is what we want, but it matches Windows behavior
2023-05-21 08:17:42 -07:00
M. P. Halpin bbf38bbbc3 Stop beep when running iOS apps on ARM-based Macs 2023-05-20 11:20:38 -07:00
Sam Lantinga a6a222095e Added the hint SDL_HINT_ENABLE_SCREEN_KEYBOARD to control whether the on-screen keyboard should be shown when text input is active
Fixes https://github.com/libsdl-org/SDL/issues/7160
2023-05-20 11:14:34 -07:00
Sam Lantinga f005106d1b Make sure the sentinel is at the end of the current event pump cycle
If we're waiting, it's possible to not get any events, then add the sentinel, then pump again and then add another sentinel. We want to make sure we only have one sentinel and that it's at the end of the currently pumped events.

Testing:
* Verified test case in https://github.com/libsdl-org/SDL/issues/6539
* Verified test case in https://github.com/libsdl-org/SDL/issues/5350

Fixes https://github.com/libsdl-org/SDL/issues/6539

(cherry picked from commit 00b87f1ded0a4fdb6a0bab611171f37eeb0b2ebb)
2023-05-20 10:37:40 -07:00
Sam Lantinga 1a3b713524 Added support for the PowerA MOGA XP-Ultra Controller 2023-05-19 14:39:30 -07:00
Sam Lantinga 517a2afcbd Added support for the PowerA MOGA XP-Ultra Controller 2023-05-19 14:38:50 -07:00
Sam Lantinga f60622c510 Undo name change for the controller list 2023-05-19 14:26:37 -07:00
Sam Lantinga 24007b00b2 Moved the controller list out so it can be included elsewhere 2023-05-19 14:22:35 -07:00
Sam Lantinga 4e9cfad558 Cache window manipulation calls while an SDL_Window is hidden and replay them when the window is set visible
- SDL_MaximizeWindow, MinimizeWindow, SetFullScreenWindow, etc are not meant to show the window if it isn't currently visible, but on some platforms
  (e.g. Windows) it isn't possible to set this state without also showing the window so cache the flags in a pending_flags field until SDL_ShowWindow is
  called. Then replay the pending flags through ApplyPendingFlags (hoisted out from SDL_FinishWindowCreation).
2023-05-19 10:23:16 -07:00
Ozkan Sezer 5c019bc97e style fixes for SDL_PROC macros. 2023-05-19 14:10:02 +03:00
Frank Praznik d5f07730be x11: Dynamically update the scale factor
If the text-scaling-factor setting is available via D-Bus, add a listener and update the content scale values for the displays if the value is changed during runtime.

Factors out the D-Bus message pump from the system theme detection code to the general D-Bus code, as it's now used for more purposes than just the system theme.
2023-05-18 16:16:00 -07:00
Sam Lantinga 068d3da366 Fixed window and backbuffer size on Android 2023-05-18 16:11:57 -07:00
Sam Lantinga a66cad79c1 SDL_GetClosestFullscreenDisplayMode() now takes a boolean whether to include high density modes
Also changed the match to prioritize resolution over refresh rate
2023-05-18 12:15:23 -07:00
Frank Praznik 32ab1183c7 x11: Expose the text/global scaling factor as the display content scale
Expose the text scaling factor (aka the global scale factor on KDE) as the display content scale value so applications can scale themselves as necessary.

If D-Bus is unavailable or retrieving the setting fails, fall back to trying the legacy GDK_SCALE envvar before reverting to the default 1.0 value.
2023-05-18 14:34:25 -04:00
Sam Lantinga 87186a893c Integrate 8067023 and 8067041 to SDL3:
Change 8067023 by mikela:
	Add SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED to SDL_RaiseWindow

	- When set to false, this allows SDL_RaiseWindow to bring a chosen window to the top of the stack but not force input focus to it

Change 8067041 by mikela:
	Rename SDL_HINT_WINDOW_NO_ACTIVATION_WHEN_SHOWN to SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN
2023-05-18 09:21:29 -07:00
Sam Lantinga e61b5ceefe The SDL_WINDOW_ALLOW_HIGHDPI flag has been renamed SDL_WINDOW_HIGH_PIXEL_DENSITY 2023-05-18 07:34:45 -07:00
Sam Lantinga d1ee44b65e Add the pixel density to the display mode list in testwm 2023-05-18 07:34:16 -07:00
Sam Lantinga 887a1b5969 Print some newly added window flags 2023-05-18 07:33:49 -07:00
SDL Wiki Bot f9ecc841ca Sync SDL3 wiki -> header 2023-05-18 00:55:15 +00:00
Sam Lantinga cc94f600fd Officially added the concept of window pixel density
The SDL_WINDOW_ALLOW_HIGHDPI flag has been renamed SDL_WINDOW_HIGH_PIXEL_DENSITY, and added the function SDL_GetWindowPixelDensity()
2023-05-17 17:54:03 -07:00
Sam Lantinga e708674416 Always expose the high density video modes in the mode list
The SDL_HINT_VIDEO_ENABLE_HIGH_PIXEL_DENSITY hint is going away, so this matches the macOS logic
2023-05-17 17:40:16 -07:00
Ryan C. Gordon 2e646c7141
audio: Load .WAV files with format->blockalign==0.
In theory this is illegal, but legit wavefiles in the field do it, and
it's easy to bump it to 1 for general purposes.

Formats with more specific alignment requirements already check for them
separately.

Fixes #7714.
2023-05-17 20:06:58 -04:00
Ryan C. Gordon d05639a626
dynapi: Accept a comma-separated list of libraries to attempt to load.
First one to load and have the necessary symbol is the one we accept,
if any. Once we accept one, we won't try loading others.

Fixes #7613.

(cherry picked from commit 32999798e0232cdeda777a32ce2fe6b78ec2bb4e)
2023-05-17 20:03:36 -04:00
Frank Praznik 68edc72ae8 wayland: Fixups for new DPI code
Add support for the pixel density hint and fix integer scaling to assume that exclusive fullscreen pixel density values are always 1.
2023-05-17 19:01:14 -04:00
Sam Lantinga a3ce0d03e3 Fixed building with older macOS SDK 2023-05-17 13:32:21 -07:00
SDL Wiki Bot 5836e057de Sync SDL3 wiki -> header 2023-05-17 19:59:14 +00:00