summaryrefslogtreecommitdiff
path: root/src/helpers/Monitor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers/Monitor.cpp')
-rw-r--r--src/helpers/Monitor.cpp18
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;
+}