From c9dbc3d97dd6e36c1b71a1516bde57927b9c30a0 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Sat, 6 Sep 2014 00:26:20 +0300 Subject: [PATCH] Fix QWaylandScreen geometry and physical size The wl_output.geometry event carries the physical size of the output, not the logical one. This happened to work only because the geometry event was sent before the mode event, which carries the logical size. Moreover, use the done event to send only one geometry change event instead of one per advertized mode. Change-Id: I5b09d56654aac149d90692bb5a3e050cc0d60cb6 Reviewed-by: Laszlo Agocs --- .../platforms/wayland/qwaylandscreen.cpp | 28 +++++++++++-------- .../platforms/wayland/qwaylandscreen_p.h | 3 ++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandscreen.cpp b/src/plugins/platforms/wayland/qwaylandscreen.cpp index 2cc719776ea..6213da87f4e 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen.cpp +++ b/src/plugins/platforms/wayland/qwaylandscreen.cpp @@ -95,6 +95,11 @@ QImage::Format QWaylandScreen::format() const return mFormat; } +QSizeF QWaylandScreen::physicalSize() const +{ + return mPhysicalSize; +} + QDpi QWaylandScreen::logicalDpi() const { static int force_dpi = !qgetenv("QT_WAYLAND_FORCE_DPI").isEmpty() ? qgetenv("QT_WAYLAND_FORCE_DPI").toInt() : -1; @@ -153,16 +158,11 @@ void QWaylandScreen::output_mode(uint32_t flags, int width, int height, int refr QSize size(width, height); - if (size != mGeometry.size()) { + if (size != mGeometry.size()) mGeometry.setSize(size); - QWindowSystemInterface::handleScreenGeometryChange(screen(), mGeometry); - QWindowSystemInterface::handleScreenAvailableGeometryChange(screen(), mGeometry); - } - if (refresh != mRefreshRate) { + if (refresh != mRefreshRate) mRefreshRate = refresh; - QWindowSystemInterface::handleScreenRefreshRateChange(screen(), refreshRate()); - } } void QWaylandScreen::output_geometry(int32_t x, int32_t y, @@ -202,14 +202,18 @@ void QWaylandScreen::output_geometry(int32_t x, int32_t y, if (!model.isEmpty()) mOutputName = model; - QRect geom(x, y, width, height); + mPhysicalSize = QSize(width, height); + mGeometry.moveTopLeft(QPoint(x, y)); +} - if (mGeometry == geom) - return; - - mGeometry = geom; +void QWaylandScreen::output_done() +{ + // the done event is sent after all the geometry and the mode events are sent, + // and the last mode event to be sent is the active one, so we can trust the + // values of mGeometry and mRefreshRate here QWindowSystemInterface::handleScreenGeometryChange(screen(), mGeometry); QWindowSystemInterface::handleScreenAvailableGeometryChange(screen(), mGeometry); + QWindowSystemInterface::handleScreenRefreshRateChange(screen(), refreshRate()); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/wayland/qwaylandscreen_p.h b/src/plugins/platforms/wayland/qwaylandscreen_p.h index 90b8fc903ee..866ac26ea2c 100644 --- a/src/plugins/platforms/wayland/qwaylandscreen_p.h +++ b/src/plugins/platforms/wayland/qwaylandscreen_p.h @@ -65,6 +65,8 @@ public: int depth() const; QImage::Format format() const; + QSizeF physicalSize() const Q_DECL_OVERRIDE; + QDpi logicalDpi() const Q_DECL_OVERRIDE; void setOrientationUpdateMask(Qt::ScreenOrientations mask); @@ -93,6 +95,7 @@ private: const QString &make, const QString &model, int32_t transform) Q_DECL_OVERRIDE; + void output_done() Q_DECL_OVERRIDE; int m_outputId; QWaylandDisplay *mWaylandDisplay;