diff options
author | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2014-09-06 00:26:20 +0300 |
---|---|---|
committer | Giulio Camuffo <giulio.camuffo@jollamobile.com> | 2014-09-08 14:06:08 +0200 |
commit | 929b4f03a67ec9577dcc9ed8981f69489b1e49a4 (patch) | |
tree | 057e5f9651fb491ece393f1703c53fa1c2273eb6 | |
parent | 374cb3b2872652317baec299712d7dfde6d9c896 (diff) | |
download | qtwayland-929b4f03a67ec9577dcc9ed8981f69489b1e49a4.tar.gz |
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 <laszlo.agocs@digia.com>
-rw-r--r-- | src/client/qwaylandscreen.cpp | 28 | ||||
-rw-r--r-- | src/client/qwaylandscreen_p.h | 3 | ||||
-rw-r--r-- | src/compositor/wayland_wrapper/qwloutput.cpp | 2 | ||||
-rw-r--r-- | tests/auto/compositor/mockclient.cpp | 17 | ||||
-rw-r--r-- | tests/auto/compositor/mockclient.h | 1 |
5 files changed, 34 insertions, 17 deletions
diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp index 2cc71977..6213da87 100644 --- a/src/client/qwaylandscreen.cpp +++ b/src/client/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); - - if (mGeometry == geom) - return; + mPhysicalSize = QSize(width, height); + mGeometry.moveTopLeft(QPoint(x, y)); +} - 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/client/qwaylandscreen_p.h b/src/client/qwaylandscreen_p.h index 90b8fc90..866ac26e 100644 --- a/src/client/qwaylandscreen_p.h +++ b/src/client/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; diff --git a/src/compositor/wayland_wrapper/qwloutput.cpp b/src/compositor/wayland_wrapper/qwloutput.cpp index b8045213..d2d5b13b 100644 --- a/src/compositor/wayland_wrapper/qwloutput.cpp +++ b/src/compositor/wayland_wrapper/qwloutput.cpp @@ -70,6 +70,7 @@ void OutputGlobal::output_bind_resource(Resource *resource) wl_output_send_mode(resource->handle, WL_OUTPUT_MODE_CURRENT|WL_OUTPUT_MODE_PREFERRED, size().width(), size().height(), refreshRate()); + wl_output_send_done(resource->handle); } void OutputGlobal::setGeometry(const QRect &geometry) @@ -107,6 +108,7 @@ void OutputGlobal::sendOutputOrientation(Qt::ScreenOrientation orientation) foreach (Resource *res, resourceMap()) { wl_output_send_geometry(res->handle, 0, 0, size().width(), size().height(), 0, "", "", m_transform); + wl_output_send_done(res->handle); } } diff --git a/tests/auto/compositor/mockclient.cpp b/tests/auto/compositor/mockclient.cpp index 2ee997ed..9bbe5651 100644 --- a/tests/auto/compositor/mockclient.cpp +++ b/tests/auto/compositor/mockclient.cpp @@ -89,7 +89,8 @@ MockClient::MockClient() const wl_output_listener MockClient::outputListener = { MockClient::outputGeometryEvent, - MockClient::outputModeEvent + MockClient::outputModeEvent, + MockClient::outputDone }; MockClient::~MockClient() @@ -103,12 +104,18 @@ void MockClient::outputGeometryEvent(void *data, wl_output *, int, const char *, const char *, int32_t ) { - resolve(data)->geometry = QRect(x, y, width, height); + resolve(data)->geometry.moveTopLeft(QPoint(x, y)); } -void MockClient::outputModeEvent(void *, wl_output *, uint32_t, - int, int, int) +void MockClient::outputModeEvent(void *data, wl_output *, uint32_t, + int w, int h, int) { + resolve(data)->geometry.setSize(QSize(w, h)); +} + +void MockClient::outputDone(void *, wl_output *) +{ + } void MockClient::readEvents() @@ -132,7 +139,7 @@ void MockClient::handleGlobal(uint32_t id, const QByteArray &interface) if (interface == "wl_compositor") { compositor = static_cast<wl_compositor *>(wl_registry_bind(registry, id, &wl_compositor_interface, 1)); } else if (interface == "wl_output") { - output = static_cast<wl_output *>(wl_registry_bind(registry, id, &wl_output_interface, 1)); + output = static_cast<wl_output *>(wl_registry_bind(registry, id, &wl_output_interface, 2)); wl_output_add_listener(output, &outputListener, this); } else if (interface == "wl_shm") { shm = static_cast<wl_shm *>(wl_registry_bind(registry, id, &wl_shm_interface, 1)); diff --git a/tests/auto/compositor/mockclient.h b/tests/auto/compositor/mockclient.h index 9f7c89d5..de1084ab 100644 --- a/tests/auto/compositor/mockclient.h +++ b/tests/auto/compositor/mockclient.h @@ -103,6 +103,7 @@ private: int width, int height, int refresh); + static void outputDone(void *data, wl_output *output); void handleGlobal(uint32_t id, const QByteArray &interface); |