diff options
author | vaxerski <[email protected]> | 2023-12-31 13:54:24 +0100 |
---|---|---|
committer | vaxerski <[email protected]> | 2023-12-31 13:54:24 +0100 |
commit | 46997a764304366d772456c20b1c719960927aa7 (patch) | |
tree | 8a875a1ebd3078ef7d73daa30e8f78b850162e53 | |
parent | b5b025a1ed6cfa2b94ad0eff38a247223edd95bb (diff) | |
download | Hyprland-46997a764304366d772456c20b1c719960927aa7.tar.gz Hyprland-46997a764304366d772456c20b1c719960927aa7.zip |
renderer: fix auto scale detection with fractional
ref #4225
-rw-r--r-- | src/render/Renderer.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index a6d58866..88320139 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -1747,10 +1747,12 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR // Needed in case we are switching from a custom modeline to a standard mode pMonitor->customDrmMode = {}; + bool autoScale = false; if (pMonitorRule->scale > 0.1) { pMonitor->scale = pMonitorRule->scale; } else { + autoScale = true; const auto DEFAULTSCALE = pMonitor->getDefaultScale(); pMonitor->scale = DEFAULTSCALE; } @@ -2008,15 +2010,22 @@ bool CHyprRenderer::applyMonitorRule(CMonitor* pMonitor, SMonitorRule* pMonitorR } if (!found) { - 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"); + if (autoScale) + pMonitor->scale = std::round(scaleZero); + else { + 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"); + pMonitor->scale = pMonitor->getDefaultScale(); + } } else { - Debug::log(ERR, "Invalid scale passed to monitor, {} found suggestion {}", pMonitor->scale, searchScale); - g_pConfigManager->addParseError( - std::format("Invalid scale passed to monitor {}, failed to find a clean divisor. Suggested nearest scale: {:5f}", pMonitor->szName, searchScale)); + if (!autoScale) { + Debug::log(ERR, "Invalid scale passed to monitor, {} found suggestion {}", pMonitor->scale, searchScale); + g_pConfigManager->addParseError( + std::format("Invalid scale passed to monitor {}, failed to find a clean divisor. Suggested nearest scale: {:5f}", pMonitor->szName, searchScale)); + pMonitor->scale = pMonitor->getDefaultScale(); + } else + pMonitor->scale = searchScale; } - - pMonitor->scale = pMonitor->getDefaultScale(); } } |