Skip to content

Commit

Permalink
frontend.cpp: updateSelectedIndex should not trigger a resolution change
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Nov 2, 2022
1 parent 698a7d4 commit cb89085
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,16 @@ class ResolutionDropdown : public DropdownWidget
}

dropdown->setOnChange([screenResolutionsModel](DropdownWidget& dropdown) {
if (auto selectedIndex = dropdown.getSelectedIndex())
auto pResolutionDropdown = std::dynamic_pointer_cast<ResolutionDropdown>(dropdown.shared_from_this());
if (!pResolutionDropdown)
{
return;
}
if (pResolutionDropdown->skipActualResolutionChange)
{
return;
}
if (auto selectedIndex = pResolutionDropdown->getSelectedIndex())
{
screenResolutionsModel.selectAt(selectedIndex.value());
}
Expand All @@ -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()
Expand Down

0 comments on commit cb89085

Please sign in to comment.