diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-12-14 17:57:18 +0000 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2022-12-14 17:57:45 +0000 |
| commit | 374571da96ea65f810387c5ff1872d3950076d08 (patch) | |
| tree | 66711e52976b4d10f1cfdd7d2ec28d50c1abe282 /src/helpers/Monitor.cpp | |
| parent | f8188ed7f8adf67febb75215f23a55b32018438c (diff) | |
add auto scale
Diffstat (limited to 'src/helpers/Monitor.cpp')
| -rw-r--r-- | src/helpers/Monitor.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/helpers/Monitor.cpp b/src/helpers/Monitor.cpp index d7daa355..d322cee5 100644 --- a/src/helpers/Monitor.cpp +++ b/src/helpers/Monitor.cpp @@ -394,3 +394,21 @@ void CMonitor::setMirror(const std::string& mirrorOf) { g_pCompositor->setActiveMonitor(g_pCompositor->m_vMonitors.front().get()); } } + +float CMonitor::getDefaultScale() { + if (!m_bEnabled) + return 1; + + static constexpr double MMPERINCH = 25.4; + + const auto DIAGONALPX = sqrt(pow(vecPixelSize.x, 2) + pow(vecPixelSize.y, 2)); + const auto DIAGONALIN = sqrt(pow(output->phys_width / MMPERINCH, 2) + pow(output->phys_height / MMPERINCH, 2)); + + const auto PPI = DIAGONALPX / DIAGONALIN; + + if (PPI > 200 /* High PPI, 2x*/) + return 2; + else if (PPI > 125 /* Medium PPI, 1.5x*/) + return 1.5; + return 1; +} |
