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.
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>
Otherwise we'll miss it when XWarpPointer() is used. x11vnc may do this to
manage mouse input in some circumstances, so it can be possible for _all_
mouse motion to go through this path, breaking SDL_GetGlobalMouseState().
Thanks to @chrismile for all the detective work to figure this out!
Fixes#8827.
(cherry picked from commit cc7fe8c255)
- If a window being destroyed is a child of an inactive window and was the last keyboard focus of the window, that window will be left with a stale pointer
to the destroyed window that it will attempt to restore the next time that window is focused. SDL_DestroyWindow will have already taken care of moving
focus if this window is the current SDL keyboard focus so this change intentionally does not set focus.
- Like Cocoa_HideWindow, this attempts to move the focus to the closest parent window that is not hidden or destroying.
- We intentionally don't raise the application when raising a child window to allow raising a child window to the top without setting the application active but the
child window should still be set as key window for the application if desired.