summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/xcb/qxcbscreen.cpp
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-01-08 13:55:32 +0100
committerPaul Olav Tvete <paul.tvete@theqtcompany.com>2015-01-12 09:50:36 +0100
commit3f0b8a9f198cd1e0e8ae9150561f93fb1b931b7e (patch)
tree338a1b1a963bb78fe21fbeb6a8354aaa4c5e2ab1 /src/plugins/platforms/xcb/qxcbscreen.cpp
parent075ae987c48ce732e6a22c1eba71023fa0ea1775 (diff)
Multi-screen DPI support for X11
Calculate the logical DPI independently per screen, but only when auto dpr is enabled. Using a constant DPI value for all screens, based on the combined geometry is arguably incorrect, but changing this now will cause pixel-size fonts to behave visibly different from point-size fonts when moving the window to a different screen. However, with QT_DEVICE_PIXEL_RATIO=auto, the pixel size fonts are already changing when the devicePixelRatio changes. Without this change, the point-size fonts will *not* adapt, which is a clear bug. Task-number: QTBUG-43713 Change-Id: I3e71618f9d55b7828ccd70b69a7b7ce656c69d65 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Jørgen Lind <jorgen.lind@theqtcompany.com> Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbscreen.cpp')
-rw-r--r--src/plugins/platforms/xcb/qxcbscreen.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp
index f8d68c68f0..6559a0bdba 100644
--- a/src/plugins/platforms/xcb/qxcbscreen.cpp
+++ b/src/plugins/platforms/xcb/qxcbscreen.cpp
@@ -317,8 +317,14 @@ QDpi QXcbScreen::logicalDpi() const
if (m_forcedDpi > 0)
return QDpi(m_forcedDpi/dpr, m_forcedDpi/dpr);
- return QDpi(Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width() / dpr,
- Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height() / dpr);
+ static const bool auto_dpr = qgetenv("QT_DEVICE_PIXEL_RATIO").toLower() == "auto";
+ if (auto_dpr) {
+ return QDpi(Q_MM_PER_INCH * m_geometry.width() / m_sizeMillimeters.width(),
+ Q_MM_PER_INCH * m_geometry.height() / m_sizeMillimeters.height());
+ } else {
+ return QDpi(Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width() / dpr,
+ Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height() / dpr);
+ }
}