From 582751ae42bccf316404549c41159444367bddc8 Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Thu, 29 Sep 2022 03:39:03 -0400 Subject: [PATCH 1/2] Resolution change detection. Makes sure that automatic resolution changes resulting from canvas mode switches are applied. --- Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript index 2c01e62c5..8722f9902 100644 --- a/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript +++ b/Templates/BaseGame/game/data/UI/guis/optionsMenu.tscript @@ -106,6 +106,7 @@ function OptionsMenu::onOpen(%this) } %this.unappliedChanges.empty(); + $pref::Video::displayDeviceId = ""; OptionsMenuCategoryList.setAsActiveMenuList(); @@ -442,6 +443,11 @@ function populateDisplaySettingsList() %resolution = _makePrettyResString(%resolution); OptionsMenuSettingsList.addOptionRow("Resolution", "$pref::Video::Resolution", %resolutionList, false, "", true, "Resolution of the game window", %resolution); + + // If the requested resolution could not be set, mark the control and pref as changed. + %resControl = OptionsMenuSettingsList.getObject(OptionsMenuSettingsList.getCount()-1); + if (%resControl.getCurrentOption() !$= %resolution) + %resControl.onChange(); } OptionsMenuSettingsList.addOptionBoolRow("VSync", "$pref::Video::enableVerticalSync", $YesNoList, false, "", true, "", ""); From 640af98807d5ab30afbbb79c05827984833f4b35 Mon Sep 17 00:00:00 2001 From: OTHGMars Date: Thu, 29 Sep 2022 03:45:25 -0400 Subject: [PATCH 2/2] Monitor DeviceId setting. The SDL_WINDOWEVENT_DISPLAY_CHANGED event reports an incorrect DeviceId when changed via command. The resolution sanity check that is applied when changing monitors is moved to the SDL_WINDOWEVENT_MOVED event where DeviceId is properly detected. --- Engine/source/windowManager/sdl/sdlWindow.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Engine/source/windowManager/sdl/sdlWindow.cpp b/Engine/source/windowManager/sdl/sdlWindow.cpp index 67b636a2a..c64da01be 100644 --- a/Engine/source/windowManager/sdl/sdlWindow.cpp +++ b/Engine/source/windowManager/sdl/sdlWindow.cpp @@ -646,7 +646,11 @@ void PlatformWindowSDL::_processSDLEvent(SDL_Event &evt) break; case SDL_WINDOWEVENT_MOVED: { + S32 oldDisplay = Con::getIntVariable("pref::Video::deviceId", 0); _updateMonitorFromMove(evt); + // If display device has changed, make sure window params are compatible with the new device. + if (oldDisplay != Con::getIntVariable("pref::Video::deviceId", 0)) + Con::evaluate("configureCanvas();"); break; } case SDL_WINDOWEVENT_RESIZED: @@ -672,11 +676,6 @@ void PlatformWindowSDL::_processSDLEvent(SDL_Event &evt) case SDL_WINDOWEVENT_RESTORED: Con::setBoolVariable("pref::Video::isMaximized", false); break; - case SDL_WINDOWEVENT_DISPLAY_CHANGED: - Con::printf("Window moved to display #%d", evt.window.data1); - Con::setIntVariable("pref::Video::deviceId", evt.window.data1); - Con::evaluate("configureCanvas();"); - break; default: break;