From 5f52b6b5082e4845b54ea530aaa3505b25ccad60 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Tue, 21 Jan 2014 17:07:32 +0200 Subject: [PATCH] Allow resizing the Qt window after the buffers swap Some EGL implementations resize the EGL buffers after eglSwapBuffers, so we need to send the geometry change event after the swap, or else the Qt window size and the physical buffer size will be different to each other. Do not force this behavior though, but use it only when the QT_WAYLAND_RESIZE_AFTER_SWAP environment variable is set. Change-Id: I79e39442b3010c563a81d7c94e747a982e158fc1 Reviewed-by: Gunnar Sletta --- .../platforms/wayland/qwaylandwindow.cpp | 24 +++++++++++++------ .../platforms/wayland/qwaylandwindow_p.h | 2 ++ 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 3c7b2eac165..67f122fb4a6 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -80,6 +80,8 @@ QWaylandWindow::QWaylandWindow(QWindow *window) , mFrameCallback(0) , mRequestResizeSent(false) , mCanResize(true) + , mResizeDirty(false) + , mResizeAfterSwap(!qEnvironmentVariableIsSet("QT_WAYLAND_RESIZE_AFTER_SWAP")) , mSentInitialResize(false) , mMouseDevice(0) , mMouseSerial(0) @@ -195,10 +197,11 @@ void QWaylandWindow::setGeometry(const QRect &rect) if (mWindowDecoration && window()->isVisible()) mWindowDecoration->update(); - if (mConfigure.isEmpty()) { + if (mResizeAfterSwap) + mResizeDirty = true; + else QWindowSystemInterface::handleGeometryChange(window(), geometry()); - QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry())); - } + QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry())); } void QWaylandWindow::setVisible(bool visible) @@ -287,7 +290,6 @@ void QWaylandWindow::doResize() setGeometry(geometry); mConfigure.clear(); - QWindowSystemInterface::handleGeometryChange(window(), geometry); } void QWaylandWindow::setCanResize(bool canResize) @@ -295,9 +297,17 @@ void QWaylandWindow::setCanResize(bool canResize) QMutexLocker lock(&mResizeLock); mCanResize = canResize; - if (canResize && !mConfigure.isEmpty()) { - doResize(); - QWindowSystemInterface::handleExposeEvent(window(), geometry()); + if (canResize) { + if (mResizeDirty) { + QWindowSystemInterface::handleGeometryChange(window(), geometry()); + } + if (!mConfigure.isEmpty()) { + doResize(); + QWindowSystemInterface::handleExposeEvent(window(), geometry()); + } else if (mResizeDirty) { + QWindowSystemInterface::handleExposeEvent(window(), geometry()); + mResizeDirty = false; + } } } diff --git a/src/plugins/platforms/wayland/qwaylandwindow_p.h b/src/plugins/platforms/wayland/qwaylandwindow_p.h index e99e31bdf63..fe6f319087b 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow_p.h +++ b/src/plugins/platforms/wayland/qwaylandwindow_p.h @@ -193,6 +193,8 @@ protected: QWaylandWindowConfigure mConfigure; bool mRequestResizeSent; bool mCanResize; + bool mResizeDirty; + bool mResizeAfterSwap; bool mSentInitialResize; QPoint mOffset;