From 1a1eaee13f28c789843bac742dea992b352c01e6 Mon Sep 17 00:00:00 2001 From: Jie Liu Date: Mon, 8 Jan 2024 17:04:49 +0800 Subject: [PATCH] Only precompute the geometry restore when m_interactiveMoveResize.initialQuickTileMode is None MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the user wants to move a tiled window but changes their mind and tiles the window back to the previous position, quickTileGeometryRestore() will return an error value beacause m_electricMaximizing is true and the m_electricGeometryRestore is the same as the geometry of the window in the last tiled mode. Now the geometry restore of the tiled window is true when starting interactive move, so we no longer need to precompute it. Changes for testQuickTilingPointerMove: We need to attach a new image after the tiling window, so that updateElectricGeometryRestore can obtain the same framegeometry as the framegeometry obtained during actual runtime. Now testQuickTilingPointerMove can detect the error:If the user wants to move a tiled window but changes their mind and tiles the window back to the previous position, quickTileGeometryRestore() will return an error value beacause m_electricMaximizing is true and the m_electricGeometryRestore is the same as the geometry of the window in the last tiled mode. Signed-off-by: Jie Liu --- autotests/integration/quick_tiling_test.cpp | 13 +++++++++++++ src/window.cpp | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/autotests/integration/quick_tiling_test.cpp b/autotests/integration/quick_tiling_test.cpp index d4466b7bb9..26e0760073 100644 --- a/autotests/integration/quick_tiling_test.cpp +++ b/autotests/integration/quick_tiling_test.cpp @@ -389,6 +389,7 @@ void QuickTilingTest::testQuickTilingPointerMove() // we have to receive a configure event when the window becomes active QSignalSpy toplevelConfigureRequestedSpy(shellSurface.get(), &Test::XdgToplevel::configureRequested); QSignalSpy surfaceConfigureRequestedSpy(shellSurface->xdgSurface(), &Test::XdgSurface::configureRequested); + QSignalSpy frameGeometryChangedSpy(window, &Window::frameGeometryChanged); QVERIFY(surfaceConfigureRequestedSpy.wait()); QCOMPARE(surfaceConfigureRequestedSpy.count(), 1); @@ -412,6 +413,12 @@ void QuickTilingTest::testQuickTilingPointerMove() QCOMPARE(surfaceConfigureRequestedSpy.count(), 2); QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), tileSize); + // attach a new image + shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value()); + Test::render(surface.get(), tileSize, Qt::red); + QVERIFY(frameGeometryChangedSpy.wait()); + QCOMPARE(window->frameGeometry().size(), tileSize); + // verify that geometry restore is correct after user untiles the window, but changes // their mind and tiles the window again while still holding left button workspace()->performWindowOperation(window, Options::UnrestrictedMoveOp); @@ -425,6 +432,12 @@ void QuickTilingTest::testQuickTilingPointerMove() QCOMPARE(surfaceConfigureRequestedSpy.count(), 3); QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(100, 50)); + // attach a new image + shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value()); + Test::render(surface.get(), QSize(100, 50), Qt::red); + QVERIFY(frameGeometryChangedSpy.wait()); + QCOMPARE(window->frameGeometry().size(), QSize(100, 50)); + Test::pointerMotion(pointerPos, timestamp++); // tile the window again Test::pointerButtonReleased(BTN_LEFT, timestamp++); QCOMPARE(quickTileChangedSpy.count(), 3); diff --git a/src/window.cpp b/src/window.cpp index 0982649be4..f5699225a2 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -3392,7 +3392,7 @@ QRectF Window::quickTileGeometry(QuickTileMode mode, const QPointF &pos) const void Window::updateElectricGeometryRestore() { m_electricGeometryRestore = geometryRestore(); - if (quickTileMode() == QuickTileMode(QuickTileFlag::None)) { + if (m_interactiveMoveResize.initialQuickTileMode == QuickTileMode(QuickTileFlag::None)) { if (!(requestedMaximizeMode() & MaximizeHorizontal)) { m_electricGeometryRestore.setX(x()); m_electricGeometryRestore.setWidth(width());