mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2024-12-25 09:17:12 +01:00
Improve SDL_CreateWindow() fullscreen support on Windows
.. and maybe other platforms as well (though X11 was not affected)? The issue was that passing a higher resolution than the current desktop resolution to SDL_CreateWindow() with SDL_WINDOW_FULLSCREEN didn't switch to that resolution (even though it did switch to lower resolutions). When creating a fullscreen window, window->fullscreen wasn't even set at all (only zeroed out), setting it only happened if the user explicitly called SDL_SetWindowDisplayMode(). So without that, SDL_CreateWindow() -> SDL_UpdateFullscreenMode() -> SDL_GetWindowDisplayMode() used the resolution from window->windowed.w/h which were limited to the desktop size due to some weird combination of WIN_AdjustWindowRectWithStyle() and WIN_WindowProc() being called after a call to SetWindowPos(). fixes #3313
This commit is contained in:
parent
9fdb06450d
commit
72d8128520
@ -1598,6 +1598,22 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags)
|
||||
displayIndex = SDL_GetIndexOfDisplay(display);
|
||||
SDL_GetDisplayBounds(displayIndex, &bounds);
|
||||
|
||||
/* for real fullscreen we might switch the resolution, so get width and height
|
||||
* from closest supported mode and use that instead of current resolution
|
||||
*/
|
||||
if ((flags & SDL_WINDOW_FULLSCREEN_DESKTOP) != SDL_WINDOW_FULLSCREEN_DESKTOP
|
||||
&& (bounds.w != w || bounds.h != h)) {
|
||||
SDL_DisplayMode fullscreen_mode, closest_mode;
|
||||
SDL_zero(fullscreen_mode);
|
||||
fullscreen_mode.w = w;
|
||||
fullscreen_mode.h = h;
|
||||
if(SDL_GetClosestDisplayModeForDisplay(display, &fullscreen_mode, &closest_mode) != NULL) {
|
||||
bounds.w = closest_mode.w;
|
||||
bounds.h = closest_mode.h;
|
||||
}
|
||||
}
|
||||
window->fullscreen_mode.w = bounds.w;
|
||||
window->fullscreen_mode.h = bounds.h;
|
||||
window->x = bounds.x;
|
||||
window->y = bounds.y;
|
||||
window->w = bounds.w;
|
||||
|
Loading…
Reference in New Issue
Block a user