diff mbox series

[2/4] kernel-shark: Have correct screen geometry on high-resolution screens

Message ID 20200916065007.9755-2-y.karadz@gmail.com (mailing list archive)
State Deferred
Headers show
Series [1/4] kernel-shark :Fix all build warnings for gcc 10.2.1 | expand

Commit Message

Yordan Karadzhov Sept. 16, 2020, 6:50 a.m. UTC
A scale factor (also called "Device Pixel Ratio") is often applied in
the display settings when running on laptops having high-resolution
screens. Take this scale factor into consideration when calculating
the screen size.

Note that the size of some widget is set to be a fractions of the total
size of the screen.

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 kernel-shark/src/KsUtils.hpp | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shark/src/KsUtils.hpp b/kernel-shark/src/KsUtils.hpp
index 2772b84..a07af1a 100644
--- a/kernel-shark/src/KsUtils.hpp
+++ b/kernel-shark/src/KsUtils.hpp
@@ -25,10 +25,18 @@ 
 #include "KsPlotTools.hpp"
 
 /** Macro providing the height of the screen in pixels. */
-#define SCREEN_HEIGHT  QGuiApplication::screens()[0]->geometry().height()
+#define SCREEN_HEIGHT \
+	( \
+	QGuiApplication::screens()[0]->geometry().height() / \
+	QApplication::desktop()->devicePixelRatio() \
+	)
 
 /** Macro providing the width of the screen in pixels. */
-#define SCREEN_WIDTH   QGuiApplication::screens()[0]->geometry().width()
+#define SCREEN_WIDTH \
+	( \
+	QGuiApplication::screens()[0]->geometry().width() / \
+	QApplication::desktop()->devicePixelRatio() \
+	)
 
 //! @cond Doxygen_Suppress