summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/kernel/qplatformwindow.cpp15
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp8
2 files changed, 19 insertions, 4 deletions
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index dda7cc94fe..a26a23243d 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -105,10 +105,17 @@ QSurfaceFormat QPlatformWindow::format() const
}
/*!
- This function is called by Qt whenever a window is moved or the window is resized. The resize
- can happen programatically(from ie. user application) or by the window manager. This means that
- there is no need to call this function specifically from the window manager callback, instead
- call QWindowSystemInterface::handleGeometryChange(QWindow *w, const QRect &newRect);
+ This function is called by Qt whenever a window is moved or resized using the QWindow API.
+
+ Unless you also override QPlatformWindow::geometry(), you need to call the baseclass
+ implementation of this function in any override of QPlatformWindow::setGeometry(), as
+ QWindow::geometry() is expected to report back the set geometry until a confirmation
+ (or rejection) of the new geometry comes back from the window manager and is reported
+ via handleGeometryChange().
+
+ Window move/resizes can also be triggered spontaneously by the window manager, or as a
+ response to an earlier requested move/resize via the Qt APIs. There is no need to call
+ this function from the window manager callback, instead call QPA::handleGeometryChange.
The position(x, y) part of the rect might be inclusive or exclusive of the window frame
as returned by frameMargins(). You can detect this in the plugin by checking
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index fd9c627506..0be130a40d 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -278,7 +278,15 @@ void QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState
*/
QT_DEFINE_QPA_EVENT_HANDLER(void, handleGeometryChange, QWindow *window, const QRect &newRect, const QRect &oldRect)
{
+ Q_ASSERT(window);
QWindowSystemInterfacePrivate::GeometryChangeEvent *e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(window, QHighDpi::fromNativePixels(newRect, window), QHighDpi::fromNativePixels(oldRect, window));
+ if (window->handle()) {
+ // Persist the new geometry so that QWindow::geometry() can be queried in the resize event
+ window->handle()->QPlatformWindow::setGeometry(newRect);
+ // FIXME: This does not work during platform window creation, where the QWindow does not
+ // have its handle set up yet. Platforms that deliver events during window creation need
+ // to handle the persistence manually, e.g. by overriding geometry().
+ }
QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
}