From 2f2bfc4e59cecfdd210663fbf81c000ecddfb822 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Mon, 25 Jun 2018 10:50:12 +0200 Subject: widgets: fix QWidget::save/restoreGeometry() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QWidget::restoreGeometry() is calling QWidget::move() with restoredFrameGeometry, which internally calls setGeometry() and sets positionPolicy = QWindowPrivate::WindowFrameExclusive, which is invalid: restoredFrameGeometry is WindowFrameInclusive geometry. QPA plugins rely on correctly set policies when interpreting x,y. QWidget::move() was not designed for this AFAICT, so making it to accept frame geometry is no-op. It is widely used legacy code, changing it could cause regressions. Save/restore API was introduced in Qt 4.2, at that time we did not have APIs like QWindow::setFramePosition(), so its unclear why geometry() was not stored instead. The documentation also is somewhat unclear: "[..] save the geometry when the window closes [..]" Frame or client geometry? It does not specify. And from the code we see that frame geometry was passed as client geometry, not making the original intention clearer. Besides that, restoreGeometry() is full of other undocumented assumptions where to place windows and when to fail (fortunately its easy to write your own save/restore logic). Added a Qt 6 note in the source code. What this patch changes: Now we store geometry() in saveGeometry() and use that value in restoreGeometry() by setGeometry(). This does not cause any behavior difference in window positioning (tst_QWidget::saveRestoreGeometry still works). Geometry restored from data saved with earlier versions of saveGeometry() might be positioned at: x + leftMargin, y + topMargin. This patch makes tst_QWidget::saveRestoreGeometry to always fail instead of being flaky. Blacklisting for XCB instead of selected distros. Also enabled excluded code paths for XCB on tst_QDockWidget::restoreDockWidget(). It does not seem to be flaky, maybe it was in 2015, but lot of things have changed since then. Task-number: QTBUG-66708 Change-Id: Ic86a6fd091e2c71b7550b2f476386da704253cd4 Reviewed-by: Tor Arne Vestbø --- tests/auto/widgets/kernel/qwidget/BLACKLIST | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/auto/widgets/kernel/qwidget/BLACKLIST') diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index c86dcfb782..86c196f773 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -2,10 +2,9 @@ [normalGeometry] ubuntu-16.04 [saveRestoreGeometry] -ubuntu-16.04 b2qt # QTBUG-66708 -opensuse +xcb [restoreVersion1Geometry] xcb osx -- cgit v1.2.3