diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-06-19 18:02:48 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-06-19 18:02:48 +0200 |
commit | 121692e5408561f486cad5cd170ac8bcd2557eb2 (patch) | |
tree | 3b3f2822e2cb7eff0095366f62a04270f24fb16a /src/plugins | |
parent | 29670528d880d81cdd9eb55221b439a832437a6a (diff) |
Use Xft DPI as basis for HiDPI scaling
GNOME indicates DPI modes by setting high DPI values in Xft.DPI, so
we need to use the forced DPI setting instead of the real DPI, as basis
for QPA pixel density.
Change-Id: I6f25636383b16b89a3d5fe4c904afd079fe001aa
Fixes: QTBUG-74836
Task-number: QTBUG-65424
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbscreen.cpp | 20 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbscreen.h | 1 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 57dbdc9bec..39e83e0451 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -658,16 +658,24 @@ QImage::Format QXcbScreen::format() const return format; } -QDpi QXcbScreen::logicalDpi() const +int QXcbScreen::forcedDpi() const { static const int overrideDpi = qEnvironmentVariableIntValue("QT_FONT_DPI"); if (overrideDpi) - return QDpi(overrideDpi, overrideDpi); + return overrideDpi; const int forcedDpi = m_virtualDesktop->forcedDpi(); - if (forcedDpi > 0) { + if (forcedDpi > 0) + return forcedDpi; + return 0; +} + +QDpi QXcbScreen::logicalDpi() const +{ + const int forcedDpi = this->forcedDpi(); + if (forcedDpi > 0) return QDpi(forcedDpi, forcedDpi); - } + return m_virtualDesktop->dpi(); } @@ -739,7 +747,9 @@ void QXcbScreen::updateGeometry(const QRect &geometry, uint8_t rotation) if (m_sizeMillimeters.isEmpty()) m_sizeMillimeters = sizeInMillimeters(geometry.size(), m_virtualDesktop->dpi()); - qreal dpi = geometry.width() / physicalSize().width() * qreal(25.4); + qreal dpi = forcedDpi(); + if (dpi <= 0) + dpi = geometry.width() / physicalSize().width() * qreal(25.4); // Use 128 as a reference DPI on small screens. This favors "small UI" over "large UI". qreal referenceDpi = physicalSize().width() <= 320 ? 128 : 96; diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index be6c45e415..ec3b07bfb7 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -208,6 +208,7 @@ public: private: void sendStartupMessage(const QByteArray &message) const; + int forcedDpi() const; QByteArray getOutputProperty(xcb_atom_t atom) const; QByteArray getEdid() const; |