mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-09 16:25:59 +01:00
renderer: deny invalid scales and suggest a replacement
ref #4225 #3511
This commit is contained in:
parent
79ef29d6e0
commit
6b6f3396cf
1 changed files with 35 additions and 25 deletions
|
@ -1951,7 +1951,13 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
float searchScale = std::round(pMonitor->scale * 360.0);
|
float searchScale = std::round(pMonitor->scale * 360.0);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
for (size_t i = 0; i < 90; ++i) {
|
double scaleZero = searchScale / 360.0;
|
||||||
|
|
||||||
|
Vector2D logicalZero = pMonitor->vecPixelSize / scaleZero;
|
||||||
|
if (logicalZero == logicalZero.round()) {
|
||||||
|
pMonitor->scale = scaleZero;
|
||||||
|
} else {
|
||||||
|
for (size_t i = 1; i < 90; ++i) {
|
||||||
double scaleUp = (searchScale + i) / 360.0;
|
double scaleUp = (searchScale + i) / 360.0;
|
||||||
double scaleDown = (searchScale - i) / 360.0;
|
double scaleDown = (searchScale - i) / 360.0;
|
||||||
|
|
||||||
|
@ -1974,8 +1980,12 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR
|
||||||
Debug::log(ERR, "Invalid scale passed to monitor, {} failed to find a clean divisor", pMonitor->scale);
|
Debug::log(ERR, "Invalid scale passed to monitor, {} failed to find a clean divisor", pMonitor->scale);
|
||||||
g_pConfigManager->addParseError("Invalid scale passed to monitor " + pMonitor->szName + ", failed to find a clean divisor");
|
g_pConfigManager->addParseError("Invalid scale passed to monitor " + pMonitor->szName + ", failed to find a clean divisor");
|
||||||
} else {
|
} else {
|
||||||
Debug::log(WARN, "Invalid scale ({}) passed to monitor, adjusting to {}", pMonitor->scale, searchScale);
|
Debug::log(ERR, "Invalid scale passed to monitor, {} found suggestion {}", pMonitor->scale, searchScale);
|
||||||
pMonitor->scale = searchScale;
|
g_pConfigManager->addParseError(
|
||||||
|
std::format("Invalid scale passed to monitor {}, failed to find a clean divisor. Suggested nearest scale: {:4f}", pMonitor->szName, searchScale));
|
||||||
|
}
|
||||||
|
|
||||||
|
pMonitor->scale = pMonitor->getDefaultScale();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue