diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 63e8909eeb..859295de2b 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -586,6 +586,10 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv QGuiApplicationPrivate::reportAvailableGeometryChange( static_cast(e)); break; + case QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInch: + QGuiApplicationPrivate::reportLogicalDotsPerInchChange( + static_cast(e)); + break; case QWindowSystemInterfacePrivate::Map: QGuiApplicationPrivate::processMapEvent(static_cast(e)); break; @@ -998,9 +1002,6 @@ void QGuiApplicationPrivate::reportGeometryChange(QWindowSystemInterfacePrivate: emit s->physicalDotsPerInchXChanged(s->physicalDotsPerInchX()); emit s->physicalDotsPerInchYChanged(s->physicalDotsPerInchY()); emit s->physicalDotsPerInchChanged(s->physicalDotsPerInch()); - emit s->logicalDotsPerInchXChanged(s->logicalDotsPerInchX()); - emit s->logicalDotsPerInchYChanged(s->logicalDotsPerInchY()); - emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch()); emit s->availableSizeChanged(s->availableSize()); emit s->availableGeometryChanged(s->availableGeometry()); } @@ -1021,6 +1022,22 @@ void QGuiApplicationPrivate::reportAvailableGeometryChange( emit s->availableGeometryChanged(s->availableGeometry()); } +void QGuiApplicationPrivate::reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e) +{ + // This operation only makes sense after the QGuiApplication constructor runs + if (QCoreApplication::startingUp()) + return; + + if (!e->screen) + return; + + QScreen *s = e->screen.data(); + + emit s->logicalDotsPerInchXChanged(s->logicalDotsPerInchX()); + emit s->logicalDotsPerInchYChanged(s->logicalDotsPerInchY()); + emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch()); +} + void QGuiApplicationPrivate::processMapEvent(QWindowSystemInterfacePrivate::MapEvent *e) { if (!e->mapped) diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 255a1587f5..9c8a2ca642 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -125,6 +125,7 @@ public: static void reportScreenOrientationChange(QWindowSystemInterfacePrivate::ScreenOrientationEvent *e); static void reportGeometryChange(QWindowSystemInterfacePrivate::ScreenGeometryEvent *e); static void reportAvailableGeometryChange(QWindowSystemInterfacePrivate::ScreenAvailableGeometryEvent *e); + static void reportLogicalDotsPerInchChange(QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e); static void processMapEvent(QWindowSystemInterfacePrivate::MapEvent *e); static void processUnmapEvent(QWindowSystemInterfacePrivate::UnmapEvent *e); diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index 17a5bb4eda..979a168c05 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -278,6 +278,13 @@ void QWindowSystemInterface::handleScreenAvailableGeometryChange(QScreen *screen QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); } +void QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(QScreen *screen) +{ + QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent *e = + new QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent(screen); + QWindowSystemInterfacePrivate::queueWindowSystemEvent(e); +} + void QWindowSystemInterface::handleMapEvent(QWindow *tlw) { QWindowSystemInterfacePrivate::MapEvent *e = new QWindowSystemInterfacePrivate::MapEvent(tlw); diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.h b/src/gui/kernel/qwindowsysteminterface_qpa.h index 04e8a6e01c..d00f0af37c 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa.h @@ -117,6 +117,7 @@ public: static void handleScreenOrientationChange(QScreen *screen); static void handleScreenGeometryChange(QScreen *screen); static void handleScreenAvailableGeometryChange(QScreen *screen); + static void handleScreenLogicalDotsPerInchChange(QScreen *screen); // For event dispatcher implementations static bool sendWindowSystemEvents(QAbstractEventDispatcher *eventDispatcher, QEventLoop::ProcessEventsFlags flags); diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h index 44746500aa..7d5455c06b 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h @@ -63,6 +63,7 @@ public: ScreenOrientation, ScreenGeometry, ScreenAvailableGeometry, + ScreenLogicalDotsPerInch, Map, Unmap, Expose @@ -215,6 +216,13 @@ public: QWeakPointer screen; }; + class ScreenLogicalDotsPerInchEvent : public WindowSystemEvent { + public: + ScreenLogicalDotsPerInchEvent(QScreen *s) + : WindowSystemEvent(ScreenLogicalDotsPerInch), screen(s) { } + QWeakPointer screen; + }; + class MapEvent : public WindowSystemEvent { public: MapEvent(QWindow *mapped)