From 5021c1d977c7f29379c049e57316364236f91aab Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 12 Oct 2012 17:33:51 +0200 Subject: [PATCH] xcb: notify when the logical DPI changes; add Q_MM_PER_INCH constant MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I15696bf45ae99cc5b0fd95dab4884fc85cbfc6da Reviewed-by: Samuel Rødal --- src/gui/painting/qmath_p.h | 1 + src/plugins/platforms/xcb/qxcbscreen.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qmath_p.h b/src/gui/painting/qmath_p.h index c710ee462a1..bc7bb320b72 100644 --- a/src/gui/painting/qmath_p.h +++ b/src/gui/painting/qmath_p.h @@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE static const qreal Q_PI = qreal(3.14159265358979323846); // pi static const qreal Q_2PI = qreal(6.28318530717958647693); // 2*pi static const qreal Q_PI2 = qreal(1.57079632679489661923); // pi/2 +static const qreal Q_MM_PER_INCH = 25.4; inline int qIntSqrtInt(int v) { diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 6452186bbf7..4f0c3ba6bb7 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -50,6 +50,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -242,8 +243,8 @@ QImage::Format QXcbScreen::format() const QDpi QXcbScreen::logicalDpi() const { - return QDpi(25.4 * m_virtualSize.width() / m_virtualSizeMillimeters.width(), - 25.4 * m_virtualSize.height() / m_virtualSizeMillimeters.height()); + return QDpi(Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width(), + Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height()); } QPlatformCursor *QXcbScreen::cursor() const @@ -315,6 +316,9 @@ void QXcbScreen::handleScreenChange(xcb_randr_screen_change_notify_event_t *chan QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), geometry()); QWindowSystemInterface::handleScreenAvailableGeometryChange(QPlatformScreen::screen(), availableGeometry()); QWindowSystemInterface::handleScreenOrientationChange(QPlatformScreen::screen(), m_orientation); + QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(QPlatformScreen::screen(), + Q_MM_PER_INCH * m_virtualSize.width() / m_virtualSizeMillimeters.width(), + Q_MM_PER_INCH * m_virtualSize.height() / m_virtualSizeMillimeters.height()); } void QXcbScreen::updateGeometry(xcb_timestamp_t timestamp)