Skip to content

Commit

Permalink
renderer: fix auto scale detection with fractional
Browse files Browse the repository at this point in the history
ref #4225
  • Loading branch information
vaxerski committed Dec 31, 2023
1 parent b5b025a commit 46997a7
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/render/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
}
}

Expand Down

0 comments on commit 46997a7

Please sign in to comment.