__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)
Someone mentioned that Claude sees this file's previous text and adds "look at
AGENTS.md" to it's TODO list instead of treating it as the thing it should do
first.
If everything decides to prefer AGENTS.md at some point, we'll delete this
file.
A symlink would apparently also work, but it would be the only symlink in the
SDL git repo, so it seemed less disruptive to just copy the file over for now.
(cherry picked from commit 847fc72b1b)
Apparently Claude Code won't read AGENTS.md by default at this moment, but
since that's the direction we're moving, let's just add the file Claude
currently looks for and tell it that the actual instructions are in AGENTS.md.
I thought these things were supposed to be less complicated that interacting
with humans, lol.
(cherry picked from commit 1124e44e4c)
Even without the text input protocol, basic text can still be obtained from individual keys and the composition system.
(cherry picked from commit dd6d49afbd)
All locked front buffers must be released prior to destroying
the EGL surface to avoid causing a UAF in libnvidia-egl-gbm.so.
(cherry picked from commit 463b6be133)
When a window has the pointer grabbed, the X server will grab all master device events, and XInput2 will continue to deliver slave events to the window immediately under the pointer, regardless of grab status. Only send slave pointer events to the focused window, and fall back to the core X events to catch button presses missed when the pointer is over another window.
(cherry picked from commit 0fc9db9b82)
Previously we weren't doing drawing, but we were enqueuing viewport commands and so forth, which were causing GPU permission errors on iOS. We really don't want to be sending any work to the GPU when we're in the background.
(cherry picked from commit 57f3d2ea0a)
On Android, backgrounding and foregrounding an app causes the Vulkan
surface to be destroyed. vkAcquireNextImageKHR returns
VK_ERROR_SURFACE_LOST_KHR, but the acquire while(true) loop only calls
RecreateSwapchain which doesn't recreate the surface, resulting in an
infinite retry loop and a black screen.
Handle VK_ERROR_SURFACE_LOST_KHR by setting both needsSurfaceRecreate
and needsSwapchainRecreate, then returning to let the existing
recreation path handle it on the next call.
Fixes#15322
(cherry picked from commit c98b36ff03)
This works inside of containers, and supports passing an activation token with the request, which is needed on Wayland to transfer focus to the browser.
(cherry picked from commit 682da4ee98)
CMAKE_COMPILER_IS_GNUCC is obsolete variable and can be replaced with
CMAKE_C_COMPILER_ID (also available since early CMake versions).
In the past CMake versions also LCC and QCC compilers had this varible
set to boolean true but these aren't relevant here.
(cherry picked from commit 25aa1c643f)
navigator.getGamepads() can return null for a slot if the gamepad
disconnects between the gamepadconnected event and the proxied
MAIN_THREAD_EM_ASM_INT call. This causes a TypeError when accessing
gamepad.id. Add null guards matching the pattern already used in
EMSCRIPTEN_JoystickOpen and EMSCRIPTEN_JoystickRumble.
(cherry picked from commit 59602fb473)
The three EM_JS functions (SDL_GetEmscriptenJoystickVendor,
SDL_GetEmscriptenJoystickProduct, SDL_IsEmscriptenJoystickXInput)
call navigator.getGamepads() which is only available on the main
browser thread. With PROXY_TO_PTHREAD, the joystick callbacks are
dispatched to a worker where the Gamepad API is not available,
causing a TypeError.
Convert these from EM_JS to static functions using
MAIN_THREAD_EM_ASM_INT, which proxies the JavaScript execution to
the main browser thread. This matches the pattern already used by
other navigator.getGamepads() calls in the same file.
(cherry picked from commit be8643f739)
The rest of the atomic codepath is still enabled and usable.
This fixes missing and weird mouse cursors. We'll debug this code later on.
Reference Issue #15242.
(cherry picked from commit f423a2ae34)
Apparently this _can_ happen under load, or maybe some other weird condition.
Hopefully this will encourage PipeWire to fire output_callback again, and
we'll just try again later.
Reference Issue #14916.
(cherry picked from commit 32ef82caaf)