Skip to content

Conversation

@DanielGibson
Copy link
Contributor

SDL_CreateWindow() with SDL_WINDOW_FULLSCREEN didn't work on Windows if resolution is higher than desktop resolution.

SDL_SetWindowDisplayMode() on a fullscreen window switches the display resolution, but didn't set window->w and window->h and doesn't adjust the size of the window-surface either.

Description

Setting window->fullscreen.w and .h to a resolution as close as possible to the requested one (using SDL_GetClosestDisplayModeForDisplay()) in SDL_CreateWindow() (if called with SDL_WINDOW_FULLSCREEN) fixes the first issue.

The second issue is fixed by setting window->w and ->h and after setting the new display mode in SDL_SetWindowDisplayMode(), and then calling SDL_OnWindowResized() to make sure it's applied.
(I hope this is the correct/best way?)

Existing Issue(s)

Fixes #3313

.. 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 libsdl-org#3313
Otherwise only the display resolution is changed, but the SDL window size
(and for example the window-surface size) aren't adjusted accordingly
and thus don't fill the whole screen.
See libsdl-org#3313
@slouken slouken self-requested a review July 8, 2021 22:05
@slouken slouken added this to the 2.0.16 milestone Aug 1, 2021
@slouken slouken self-assigned this Aug 1, 2021
@slouken slouken merged commit 0eb6f79 into libsdl-org:main Aug 4, 2021
@DanielGibson
Copy link
Contributor Author

Thanks a lot for merging this! :-)

@slouken
Copy link
Collaborator

slouken commented Aug 4, 2021

You're welcome! Thanks for the research and the good patch! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Creating fullscreen window with higher resolution than desktop broken

3 participants