Some tiling compositors will set the maximized state and set their own, preferred dimensions, even if the window is flagged as non-resizable, and the min/max limits are properly set. The spec says that the configure size must be obeyed in the maximized state, so, in these odd cases, use a viewport to make the content fit within the configure dimensions.
When HAVE_GETRESUID/HAVE_GETRESGID are not defined, SDL_waylandvideo.c defines
static inline fallbacks using the libc names. glibc declares both functions
non-static in <unistd.h>, so on a toolchain where the feature checks fail while
those declarations are still visible the file fails to compile:
error: static declaration of 'getresuid' follows non-static declaration
Give the fallbacks SDL-private names and call those, so a fallback can never
collide with a libc declaration. Also fixes the fallback getresgid() taking
uid_t* parameters where it should take gid_t*.
Ensure that references to the clipboard being held by other seats are cleared when new data is being set, or some seats may hold references to invalid data and callbacks.
Sending a nil selection followed by immediately destroying the selection offer is redundant, and avoiding intermediate nil offers helps some clipboard managers avoid potential race conditions.
The clipboard code often had excessive and unnecessary error checking (e.g. checking if the video backed was initialized, when there is no way that path would be hit if it wasn't), overly complicated some operations, and had several cases where things can be C99-ified. Clean things up a bit to make it easier to read and debug.
Note that we don't account for vertex color here. If HDR10 content needs to be tinted by vertex color, it can't use the simple shader. I'm assuming that the use case for this will be video content which generally won't use vertex color and this optimization is fine.
On some Wayland configurations, the SDR white level is 203 nits and the max luminance is 10000 nits, and HDR content in the PQ range is mapped by the compositor into the actual display capabilities. We don't want to show an HDR gradient up to 10000 nits, so let's cap it to ~1000 nits in this case.