At the point that we run this, nothing SDL-specific is set up yet.
__APPLE__ is a compiler predefined macro that forms part of the API on
Apple platforms, so it's fine to rely on it.
This partially reverts commit 31d133db.
Fixes: 31d133db "Define SDL_PLATFORM_* macros instead of underscored ones (#8875)"
Signed-off-by: Simon McVittie <smcv@collabora.com>
These files don't #include SDL headers, so SDL-specific macros will
never be defined here.
This partially reverts commit 31d133db.
Fixes: 31d133db "Define SDL_PLATFORM_* macros instead of underscored ones (#8875)"
Signed-off-by: Simon McVittie <smcv@collabora.com>
These are third-party headers, so it's best if they're identical to the
upstream version rather than using SDL-specific macros or coding style.
This partially reverts commits b6ae281e and 31d133db.
Fixes: 31d133db "Define SDL_PLATFORM_* macros instead of underscored ones (#8875)"
Signed-off-by: Simon McVittie <smcv@collabora.com>
Fixes a crash if no seat was available at initialization, but still allows for one to still be created later if an input device is added.
Removes some unnecessary abstractions in the process.
Mingw seems to have a bad pow implementation in the C runtime:
'Pow(-72.300000,12.000000), expected [20401381050275984310272.000000], got 20401381050275996893184.000000': Failed
Modern C runtimes have well optimized memset and memcpy, so use those instead of dispatching into SDL's versions. In addition, some compilers can analyze memset and memcpy calls and directly turn them into optimized assembly.
Distinguish between and handle fullscreen window moves initiated by the window manager vs the application to avoid cases where the window snaps back to the original display when moved due to the use of old coordinates.
The drawing uses the origin of the viewport as the coordinate origin, so we only need to clip against the size of the viewport.
Also added a unit test to catch this case in the future
- Previously we would skip most of UpdateFullscreenMode if not entering fullscreen and the window was not set as fullscreen for any display
which prevented running this.
This prevents warping the mouse when hiding a non-fullscreen window
These functions historically didn't set the error indicator on overflow.
Before commit 447b508a "error: SDL's allocators now call SDL_OutOfMemory
on error", their callers would call SDL_OutOfMemory() instead, which was
assumed to be close enough in meaning: "that's a silly amount of memory
that would overflow size_t" is similar to "that's more memory than
is available". Now that responsibility for calling SDL_OutOfMemory()
has been pushed down into SDL_calloc() and friends, the functions that
check for overflows might as well set more specific errors.
Signed-off-by: Simon McVittie <smcv@collabora.com>
A surface of width (0x7fff'ffff) / 2 = 0x3fff'ffff is not quite large
enough to make the pitch overflow in the way we wanted to test here:
with a 32-bit format, that makes each row 0xffff'fffc bytes, which
(just) fits in a 32-bit unsigned size_t. Increasing it to 0x4000'0000
pixels per row is enough to trigger the overflow we intended to test.
In SDL 2, this test bug was hidden by the fact that allocating
0xffff'fffc bytes on a 32-bit platform is very likely to fail, and SDL 2
reported both "malloc() failed" and "this amount of memory is too large
for a size_t" with the same error code.
Signed-off-by: Simon McVittie <smcv@collabora.com>