From 00d0a530358d40d577578cb1bcb75a978549bd8d Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 7 Sep 2019 23:14:19 +0200 Subject: [PATCH] QDpi: divide the forced DPI by the scaling factor, as Qt 5.13 did MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When setting a DPI in xrdb, it should have the same effect on apps that enable scaling and apps that don't (including Qt4 and GTK applications). That's what happened in Qt 5.13, while the recent changes removed that division, and as a result the fonts were huge in Qt5 apps compared to Qt4/GTK/kwin/plasmashell/krunner (which don't scale, but do honor the font DPI). Change-Id: Icd7be2d15a9b50982ae624e41bd9e546f315d58b Reviewed-by: Friedemann Kleint Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qhighdpiscaling.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp index dcbae4f5c0..ee54fd4fa1 100644 --- a/src/gui/kernel/qhighdpiscaling.cpp +++ b/src/gui/kernel/qhighdpiscaling.cpp @@ -680,8 +680,11 @@ QDpi QHighDpiScaling::logicalDpi(const QScreen *screen) if (!screen || !screen->handle()) return QDpi(96, 96); - if (!m_usePixelDensity) - return QPlatformScreen::overrideDpi(screen->handle()->logicalDpi()); + if (!m_usePixelDensity) { + const qreal screenScaleFactor = screenSubfactor(screen->handle()); + const QDpi dpi = QPlatformScreen::overrideDpi(screen->handle()->logicalDpi()); + return QDpi{ dpi.first / screenScaleFactor, dpi.second / screenScaleFactor }; + } const qreal scaleFactor = rawScaleFactor(screen->handle()); const qreal roundedScaleFactor = roundScaleFactor(scaleFactor);