This was added so that the new thread definitely has its threadid set, via
SDL_GetCurrentThreadID(), before SDL_CreatThread returns, but this broke
Emscripten, which can't wait on a newly-created thread, since the thread won't
start until a later mainloop iteration.
Now we have the creating thread set this id in SDL_SYS_CreateThread, where
platform-specific logic can figure out how to calculate the new thread's ID
from the parent thread, without using SDL_GetCurrentThreadID().
Fixes#15509.
(cherry picked from commit 922b872b4f)
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.
(cherry picked from commit 3ee0439ae5)
controller.vendorName returns a generic name for Xbox controllers ("Controller"), so we have to give them proper names.
(cherry picked from commit c805a4d632)
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`.
(cherry picked from commit e70f1bfc29)
Without this lock, a concurrent call to SDL_ReleaseGPUBuffer, SDL_ReleaseGPUTransferBuffer or SDL_ReleaseGPUTexture can cause one of the arrays to be reallocated while METAL_INTERNAL_PerformPendingDestroys is iterating over it, causing a bad day all around.
(cherry picked from commit 1492911c7d)
Only parse when necessary, which it isn't when opening a file, so this is now
separated from creating the cached AAssetManager object.
(cherry picked from commit 9235ac4efd)
The AAssetManager won't supply this information to us, but it's just a zip
file, so we can read its central directory ourselves. We can still use
AAssetManager for file i/o to the APK's assets, so we don't have to deal with
compression and other zipfile features.
Fixes#15220.
Reference Issue #15347.
(cherry picked from commit bb4332bdc2)
- Add missing SDL_MemoryBarrierRelease() in the generic codepath
- Remove MSVC x86/x64 case which is now identical to the generic codepath
- Fix Solaris barrier to ensure prior stores are visible before unlocking
(cherry picked from commit 95ae0c194e)
If a size change occurs, the sdl2-compat event handler will flush the renderer, which will cause the software renderer to re-acquire a surface that was invalidated due to the size change. However, if the OnWindowPixelSizeChanged handler is called afterward, the invalid flag will be set on the surface, causing presentation to fail.
Check both for a null surface pointer and an invalid surface flag when checking surface validity in the software renderer.
(cherry picked from commit 73fc274ef7)
This way you can always safely use SDL_GetError() in your formatted string:
```c
SDL_SetError("Couldn't open '%s': %s", filename, SDL_GetError());
```
This problem was hidden on platforms that use the dynamic API, because it
would format the new error string to a separate buffer first, to deal with
the varargs entry point.
Fixes#15456.
(cherry picked from commit 559d226fc6)
The OS reports the button state as of macOS 11.0, iOS 14.0, and tvOS 14.0, so use that instead of the deprecated pause handler.
(cherry picked from commit 1146ea484a)
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.
(cherry picked from commit 01a7588f8e)
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.
(cherry picked from commit 7b23cd62ca)
This PR modifies the Emscripten joystick backend to detect the user's OS and store its ID in the GUID, because different OSes might need different mappings for the same controllers.
I'm not sure if different browsers on the same OS can also have different mappings, but if they can, browser detection can be added to the GUID too if needed.
This PR also makes the GUID use `SDL_HARDWARE_BUS_USB` instead of `SDL_HARDWARE_BUS_UNKNOWN`, similarly to how Android and MFI backends always use `SDL_HARDWARE_BUS_BLUETOOTH` and GameInput, XInput, and RawInput backends always use `SDL_HARDWARE_BUS_USB`.
(cherry picked from commit 60a59fa557)
On most implementations, filter pattern matching is case-sensitive. For case-insensitive matching of a pattern such as '*.png', the pattern *.[pP][nN][gG]' must be used.
(cherry picked from commit 387439d009)
Returning true with an unavailable interface in no-op cases can prevent fallback to other inhibition methods. If the inhibitor interface was previously tried and marked as unavailable, just return false.
(cherry picked from commit 125ed508c2)
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.
(cherry picked from commit 03f1a84302)
__sync_lock_test_and_set() is designed for creating locks, not as
a general atomic exchange function. As a result, it only provides
an acquire memory barrier and isn't guaranteed to actually store
the provided value (though it does on architectures we care about).
__atomic_exchange_n() is supported on GCC/Clang for the last ~10
years, so let's use that instead if available. We will keep the
__sync_lock_test_and_set() fallback around for ancient platforms,
but add a full memory barrier to match the documented behavior.
(cherry picked from commit 509a36db16)