In some cases, size data set programmatically could be overwritten by old configuration data, particularly when on the display scaling path. This refactors the configuration code to be much more strict and verbose regarding the handling of window sizes, which fixes some scenarios where tests were failing when display scaling was activated.
Video backends that run asynchronously can wind up in a race situation if a mode or position update request queues up a fullscreen enter request while an unprocessed asynchronous leave request is in flight, and the mode switch or position update request is processed after the leave request, causing the window to erroneously return to fullscreen.
Instead of the internal SDL_UpdateFullscreenMode and backend SetWindowFullscreen functions taking a boolean value, use an enum that allows the backends to distinguish between "this is an explicit fullscreen enter/leave request", and "this is an update request to change the mode or position". Communicating the specific intent allows the backend to early-out when required, which prevents windows from erroneously returning to fullscreen due to update requests made after a leave request, and allows for the removal of some internal synchronization previously needed to (attempt to) work around this, which improves overall performance while also increasing robustness.
This is only relevant to the internal functions, and nothing in the public-facing API has been changed.
In some cases, the fullscreen deadline handler can be hit before the associated configure event is received, resulting in the constraints being erroneously restored. The state is doubled buffered, so it shouldn't interfere with the pending fullscreen dimensions, but it isn't correct behavior.
According to the spec, calls to set/unset fullscreen will always have an associated configure event, and the constraints will be reapplied as needed there.
Non-size configuration events are filtered out, so there is no need to enqueue an event when setting the size, as it won't be overwritten in the configure event when only changing state.
Otherwise, this will crash if the app sets its own SDL_malloc allocator, since
SDL_iconv uses SDL_malloc.
WideCharToMultibyte lets us calculate the needed memory for the argv[] string
conversions, and then we use the win32 HeapAlloc() API to get some memory
for it.
Fixes#8967.