Fix geometryRestore() handling with maximize quick tile mode

geometryRestore() is no longer updated after mapping the window, so
setQuickTileMode() has to update geometryRestore() explicitly to the
correct value.

With this change, geometryRestore() will be updated as follows:

* if the window is tiled, geometryRestore() is valid, nothing to do
* the window has been dragged to the top edge, set geometryRestore() to
  the geometry that the window had when starting move
* otherwise, use the current move resize geometry
This commit is contained in:
Vlad Zahorodnii 2022-01-14 12:34:48 +02:00
parent ef3ba9b4e8
commit ab824959f6
2 changed files with 16 additions and 8 deletions

View file

@ -262,7 +262,7 @@ void QuickTilingTest::testQuickMaximizing()
QCOMPARE(c->frameGeometry(), QRect(0, 0, 100, 50));
// but quick tile mode already changed
QCOMPARE(c->quickTileMode(), QuickTileFlag::Maximize);
QCOMPARE(c->geometryRestore(), QRect());
QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50));
// but we got requested a new geometry
QVERIFY(surfaceConfigureRequestedSpy.wait());
@ -276,7 +276,7 @@ void QuickTilingTest::testQuickMaximizing()
QVERIFY(frameGeometryChangedSpy.wait());
QCOMPARE(frameGeometryChangedSpy.count(), 1);
QCOMPARE(c->frameGeometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(c->geometryRestore(), QRect());
QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50));
// client is now set to maximised
QCOMPARE(maximizeChangedSpy1.count(), 1);
@ -295,11 +295,11 @@ void QuickTilingTest::testQuickMaximizing()
QCOMPARE(quickTileChangedSpy.count(), 2);
// geometry not yet changed
QCOMPARE(c->frameGeometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(c->geometryRestore(), QRect());
QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50));
// we got requested a new geometry
QVERIFY(surfaceConfigureRequestedSpy.wait());
QCOMPARE(surfaceConfigureRequestedSpy.count(), 3);
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(0, 0));
QCOMPARE(toplevelConfigureRequestedSpy.last().at(0).toSize(), QSize(100, 50));
// render again
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
@ -308,7 +308,7 @@ void QuickTilingTest::testQuickMaximizing()
QVERIFY(frameGeometryChangedSpy.wait());
QCOMPARE(frameGeometryChangedSpy.count(), 2);
QCOMPARE(c->frameGeometry(), QRect(0, 0, 100, 50));
QCOMPARE(c->geometryRestore(), QRect());
QCOMPARE(c->geometryRestore(), QRect(0, 0, 100, 50));
QCOMPARE(maximizeChangedSpy1.count(), 2);
QCOMPARE(maximizeChangedSpy1.last().first().value<KWin::AbstractClient*>(), c);
QCOMPARE(maximizeChangedSpy1.last().last().value<KWin::MaximizeMode>(), MaximizeRestore);

View file

@ -3080,14 +3080,22 @@ void AbstractClient::setQuickTileMode(QuickTileMode mode, bool keyboard)
GeometryUpdatesBlocker blocker(this);
if (mode == QuickTileMode(QuickTileFlag::Maximize)) {
m_quickTileMode = int(QuickTileFlag::None);
if (maximizeMode() == MaximizeFull) {
m_quickTileMode = int(QuickTileFlag::None);
setMaximize(false, false);
} else {
QRect prev_geom_restore = geometryRestore(); // setMaximize() would set moveResizeGeom as geom_restore
// If the window is tiled, geometryRestore() already has a good value.
QRect effectiveGeometryRestore = geometryRestore();
if (m_quickTileMode == QuickTileMode(QuickTileFlag::None)) {
if (isElectricBorderMaximizing()) {
effectiveGeometryRestore = initialInteractiveMoveResizeGeometry();
} else {
effectiveGeometryRestore = moveResizeGeometry();
}
}
m_quickTileMode = int(QuickTileFlag::Maximize);
setMaximize(true, true);
setGeometryRestore(prev_geom_restore);
setGeometryRestore(effectiveGeometryRestore);
}
doSetQuickTileMode();
Q_EMIT quickTileModeChanged();