Skip to content

Commit

Permalink
Fix wzGetMaximumDisplayScaleForWindowSize
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Apr 11, 2019
1 parent e1e991c commit c89a299
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/sdl/main_sdl.cpp
Expand Up @@ -1446,7 +1446,7 @@ float wzGetMaximumDisplayScaleFactorForWindowSize(unsigned int windowWidth, unsi
return std::min(maxHorizScaleFactor, maxVertScaleFactor);
}

// returns: the maximum display scale percentage (sourced from wzAvailableDisplayScales), or 0 if window is below the minimum required size for the minimum support display scale
// returns: the maximum display scale percentage (sourced from wzAvailableDisplayScales), or 0 if window is below the minimum required size for the minimum supported display scale
unsigned int wzGetMaximumDisplayScaleForWindowSize(unsigned int windowWidth, unsigned int windowHeight)
{
float maxDisplayScaleFactor = wzGetMaximumDisplayScaleFactorForWindowSize(windowWidth, windowHeight);
Expand All @@ -1458,10 +1458,16 @@ unsigned int wzGetMaximumDisplayScaleForWindowSize(unsigned int windowWidth, uns
auto maxDisplayScale = std::lower_bound(availableDisplayScales.begin(), availableDisplayScales.end(), maxDisplayScalePercentage);
if (maxDisplayScale == availableDisplayScales.end())
{
return 0;
// return the largest available display scale
return availableDisplayScales.back();
}
if (*maxDisplayScale != maxDisplayScalePercentage)
{
if (maxDisplayScale == availableDisplayScales.begin())
{
// no lower display scale to return
return 0;
}
--maxDisplayScale;
}
return *maxDisplayScale;
Expand Down

0 comments on commit c89a299

Please sign in to comment.