SDL: Use the current screen resolution when switching to fullscreen

Previously we used the resolution of the first screen. Fixes being
unable to switch to fullscreen when using two screens with different
resolutions.
This commit is contained in:
Bastien Bouclet 2019-11-01 13:29:01 +01:00
parent 99c7d96991
commit 93929be2c1

View File

@ -72,6 +72,24 @@ Common::Rect ResVmSdlGraphicsManager::getPreferredFullscreenResolution() {
uint preferredWidth = _capabilities.desktopWidth;
uint preferredHeight = _capabilities.desktopHeight;
#if SDL_VERSION_ATLEAST(2, 0, 0)
// When using SDL2, we can query the desktop resolution for the screen our window sits in
int displayIndex = -1;
SDL_Window *sdlWindow = _window->getSDLWindow();
if (sdlWindow) {
displayIndex = SDL_GetWindowDisplayIndex(sdlWindow);
}
if (displayIndex >= 0) {
SDL_DisplayMode displayMode;
if (!SDL_GetDesktopDisplayMode(displayIndex, &displayMode)) {
preferredWidth = displayMode.w;
preferredHeight = displayMode.h;
}
}
#endif
// ... unless the user has set a resolution in the configuration file
const Common::String &fsres = ConfMan.get("fullscreen_res");
if (fsres != "desktop") {