Only precompute the geometry restore when m_interactiveMoveResize.initialQuickTileMode is None

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 <liujie01@kylinos.cn>
This commit is contained in:
Jie Liu 2024-01-08 17:04:49 +08:00 committed by Liu Jie
parent fd2e77317f
commit 1a1eaee13f
2 changed files with 14 additions and 1 deletions

View file

@ -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<quint32>());
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<quint32>());
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);

View file

@ -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());