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>
bb10
Paul Olav Tvete 2015-01-08 13:55:32 +01:00
parent 075ae987c4
commit 3f0b8a9f19
1 changed files with 8 additions and 2 deletions

View File

@ -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);
}
}