Track the current window display ID locally so as not to depend on specific behavior of the video layer, which may change the value at times when it isn't expected.
Track the current window display ID locally so as not to depend on specific behavior of the video layer, which may change the value at times when it isn't expected.
When moving a window programmatically, the move event will be deduplicated due to the window x and y coordinates already being updated, so the window's current display ID needs to be explicitly updated.
Update the target display ID and use SDL_UpdateFullscreenMode() when moving a fullscreen window to handle the case where the target display has an existing fullscreen window.
We get audio artifacts if we don't work at the higher precision, but
this is painful on CPUs that have to use a software fallback for this,
so for now (that is, until we have a better solution), get better output
on amd64 chips, where the cost is less painful.
I don't know if we ever actually hit this in practice, but if this isn't
replacing the whole buffer, it needs to slide the end of the existing padding
over to the start before adding in the new data.
On Windows the main thread can be enumerating DirectInput devices while the Windows.Gaming.Input thread is calling back with a new controller available, and in this case HIDAPI_IsDevicePresent() returned false since the controller initialization hadn't completed yet, creating a duplicate controller.
Fixes https://github.com/libsdl-org/SDL/issues/7304
Use the delta of the target refresh rate and the refresh rate of the mode to select the closest matching display mode, as the actual closest mode may have a slightly lower rate than the target by a small fraction of a hz (e.g 59.98 vs 60.0).
Desktops can move windows, even exclusive fullscreen windows, from one display to another. To handle this, windows now hold two fullscreen modes: the desired mode, which is considered mutable only to the application, and the current mode. When a fullscreen request is made, the current mode is initially set to the desired mode for the initial fullscreen transition. If an exclusive fullscreen window is moved to a new display, the new display is checked to see if it has a mode compatible with the desired mode. If it does, the compatible mode is used so the windows will have the same properties on the new display. If no compatible mode is found, the window becomes desktop fullscreen. This occurs whenever the window is moved to ensure that an attempt will always be made to use the application's requested mode, if possible.
Exiting and reentering fullscreen results in the desired mode being restored on the display specified by it.