From cb89085319e66e41261edb4e74f1791440898fc2 Mon Sep 17 00:00:00 2001 From: past-due <30942300+past-due@users.noreply.github.com> Date: Wed, 2 Nov 2022 17:11:53 -0400 Subject: [PATCH] frontend.cpp: updateSelectedIndex should not trigger a resolution change --- src/frontend.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/frontend.cpp b/src/frontend.cpp index 766293e35a7..c31e4618a71 100644 --- a/src/frontend.cpp +++ b/src/frontend.cpp @@ -1651,7 +1651,16 @@ class ResolutionDropdown : public DropdownWidget } dropdown->setOnChange([screenResolutionsModel](DropdownWidget& dropdown) { - if (auto selectedIndex = dropdown.getSelectedIndex()) + auto pResolutionDropdown = std::dynamic_pointer_cast(dropdown.shared_from_this()); + if (!pResolutionDropdown) + { + return; + } + if (pResolutionDropdown->skipActualResolutionChange) + { + return; + } + if (auto selectedIndex = pResolutionDropdown->getSelectedIndex()) { screenResolutionsModel.selectAt(selectedIndex.value()); } @@ -1665,11 +1674,14 @@ class ResolutionDropdown : public DropdownWidget auto closestResolution = screenResolutionsModel.findResolutionClosestToCurrent(); if (closestResolution != screenResolutionsModel.end()) { + skipActualResolutionChange = true; setSelectedIndex(closestResolution - screenResolutionsModel.begin()); + skipActualResolutionChange = false; } } private: ScreenResolutionsModel screenResolutionsModel; + bool skipActualResolutionChange = false; }; void refreshCurrentVideoOptionsValues()