The window may not have keyboard focus when using remote control tools, so drop the keyboard focus requirement. Tested not to regress clickthrough suppression.
This is a better fix for https://github.com/libsdl-org/SDL/issues/16227.
The original problem was that the newly created texture didn't have any palette, so when the surface data was set, colors couldn't be mapped to pixel index values. The old fix temporarily set the texture palette to the surface palette, copied the surface data, and then set the texture palette to a copy of the surface palette. This caused Vulkan validation errors because we were deleting the original palette which was still referenced by the active command buffer. Instead, we'll create the palette that we want the texture to have to start with, then copy the surface data once that's set.
By convention, PNNN YUV formats are bi-planar, and SDL was using them to refer to 3 plane YUV formats.
These have been replaced with I444 and I4FL, which are the most standard FOURCC values for these that I could find.
Reference: https://github.com/videolan/vlc/blob/master/src/misc/fourcc_list.h
The output integer scale may not be re-sent if the display geometry changed, but the scale factor didn't. Cache and restore it on the integer path, to prevent an old value from being used, and possibly rounded to zero if the old value was less than 1.0.
Clear the internal X11 clipboard selection data when updating the clipboard during SelectionNotify events, as it is invalid after the update. Otherwise, an out-of-date SelectionRequest can end up attempting to read the invalid data, and cause a crash.
Once the lock is released, another thread can clean up the completed
command buffer, return it to the pool and resubmit it with a different
fence before we read d3d12CommandBuffer->inFlightFence, handing the
caller a fence it doesn't own (or NULL).
METAL_ReleaseFence cleared the fence's MTLCommandBuffer without holding
submitLock, while METAL_Submit's cleanup loop may still be polling it
through submittedCommandBuffers. It also did so before the DecRef, so
any non-final release broke later waits on a still-owned fence.
Once the lock is released, another thread can clean up the completed
command buffer, return it to the pool and resubmit it with a different
fence before we read metalCommandBuffer->fence, handing the caller a
fence it doesn't own.
When handing a SelectionRequest event, XChangeProperty can generate a BadWindow error if the requesting window was already destroyed. Register an error handler to catch this, and prevent it from being fatal.
This was a pending question from the atomic merge. Not only does this function
need to be called, it needs to be called in the SwapWindow* functions first,
like the legacy (non-atomic) path does.
Reference Issue #16136.
* Indexed textures are now used for <8bpp surfaces and for indexed surfaces with transparency.
* If the software renderer is using RGB565 or BGR565, it now successfully detects a suitable 32-bit alpha format for converting the colour key.
* Matching pixel layouts are prioritized rather than just the number of bytes per pixel.
Entering fullscreen and moving the window can be a racy operation on some desktops, and isn't needed when the window is already on the target display, so only do it when necessary.