tiling: Don't put maximized windows in tile

After !5532 existing behavior in public scripting API was changed for maximized Windows.
Maximized Windows didn't have a tile on purpose.
This behaviour was changed, as after refactoring separate members for storing QuickTileMode in Window and tile itself were unified
Previously QuickTileMode::Maximize was only set in the Window itself in m_quickTileMode, while tile itself was removed (by setTile(nullptr)).

Current QuickTileMod for current Window isn't part of public scripting API, so it's okay to break it.

This restores compatability with scripts created for KWin 6.0.5 and earlier

BUG: 489463

Signed-off-by: Alik Aslanyan <inline0@pm.me>
This commit is contained in:
Alik Aslanyan 2024-06-30 16:54:44 -04:00 committed by Vlad Zahorodnii
parent 230e456ffd
commit 3b34e9309b
4 changed files with 64 additions and 36 deletions

View file

@ -821,14 +821,22 @@ void MoveResizeWindowTest::testCancelInteractiveMoveResize()
} else {
window->setQuickTileMode(quickTileMode, true);
}
QCOMPARE(window->requestedQuickTileMode(), quickTileMode);
if (quickTileMode == QuickTileFlag::Maximize) {
QCOMPARE(window->requestedQuickTileMode(), QuickTileFlag::None);
} else {
QCOMPARE(window->requestedQuickTileMode(), quickTileMode);
}
QCOMPARE(window->requestedMaximizeMode(), maximizeMode);
QVERIFY(surfaceConfigureRequestedSpy.wait());
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().first().toSize(), Qt::blue);
QVERIFY(frameGeomtryChangedSpy.wait());
QCOMPARE(window->quickTileMode(), quickTileMode);
if (quickTileMode == QuickTileFlag::Maximize) {
QCOMPARE(window->quickTileMode(), QuickTileFlag::None);
} else {
QCOMPARE(window->quickTileMode(), quickTileMode);
}
const QRectF geometry = window->moveResizeGeometry();
const QRectF geometryRestore = window->geometryRestore();
@ -861,7 +869,11 @@ void MoveResizeWindowTest::testCancelInteractiveMoveResize()
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().first().toSize(), Qt::blue);
QVERIFY(frameGeomtryChangedSpy.wait());
QCOMPARE(window->moveResizeGeometry(), geometry);
QCOMPARE(window->quickTileMode(), quickTileMode);
if (quickTileMode == QuickTileFlag::Maximize) {
QCOMPARE(window->quickTileMode(), QuickTileFlag::None);
} else {
QCOMPARE(window->quickTileMode(), quickTileMode);
}
QCOMPARE(window->requestedMaximizeMode(), maximizeMode);
QCOMPARE(window->geometryRestore(), geometryRestore);
}

View file

@ -6,7 +6,6 @@
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "effect/globals.h"
#include "kwin_wayland_test.h"
#include "core/output.h"
@ -179,8 +178,12 @@ void QuickTilingTest::testQuickTiling()
// at this point the geometry did not yet change
QCOMPARE(window->frameGeometry(), QRect(0, 0, 100, 50));
// but requested quick tile mode already changed, proper quickTileMode not yet
QCOMPARE(window->requestedQuickTileMode(), mode);
// Manually maximized window is always without a tile
if (mode == QuickTileFlag::Maximize) {
QCOMPARE(window->requestedQuickTileMode(), QuickTileFlag::None);
} else {
QCOMPARE(window->requestedQuickTileMode(), mode);
}
// Actual quickTileMOde didn't change yet
QCOMPARE(window->quickTileMode(), oldQuickTileMode);
@ -196,19 +199,28 @@ void QuickTilingTest::testQuickTiling()
QVERIFY(frameGeometryChangedSpy.wait());
QCOMPARE(frameGeometryChangedSpy.count(), 1);
QCOMPARE(window->frameGeometry(), expectedGeometry);
QCOMPARE(quickTileChangedSpy.count(), 1);
QCOMPARE(window->quickTileMode(), mode);
if (mode == QuickTileFlag::Maximize) {
QCOMPARE(quickTileChangedSpy.count(), 0);
QCOMPARE(window->quickTileMode(), QuickTileFlag::None);
} else {
QCOMPARE(quickTileChangedSpy.count(), 1);
QCOMPARE(window->quickTileMode(), mode);
}
// send window to other screen
QList<Output *> outputs = workspace()->outputs();
QCOMPARE(window->output(), outputs[0]);
window->sendToOutput(outputs[1]);
QCOMPARE(window->output(), outputs[1]);
// quick tile should not be changed
QCOMPARE(window->quickTileMode(), mode);
if (mode == QuickTileFlag::Maximize) {
QCOMPARE(window->quickTileMode(), QuickTileFlag::None);
} else {
// quick tile should not be changed
QCOMPARE(window->quickTileMode(), mode);
}
QTEST(window->frameGeometry(), "secondScreen");
Tile *tile = workspace()->tileManager(outputs[1])->quickTile(mode);
QCOMPARE(window->tile(), tile);
QCOMPARE(window->tile(), mode == QuickTileFlag::Maximize ? nullptr : tile);
// now try to toggle again
window->setQuickTileMode(mode, true);
@ -218,8 +230,13 @@ void QuickTilingTest::testQuickTiling()
shellSurface->xdgSurface()->ack_configure(surfaceConfigureRequestedSpy.last().at(0).value<quint32>());
Test::render(surface.get(), toplevelConfigureRequestedSpy.last().at(0).toSize(), Qt::red);
QVERIFY(quickTileChangedSpy.wait());
QCOMPARE(quickTileChangedSpy.count(), 2);
if (mode == QuickTileFlag::Maximize) {
QVERIFY(!quickTileChangedSpy.wait());
QCOMPARE(quickTileChangedSpy.count(), 0);
} else {
QVERIFY(quickTileChangedSpy.wait());
QCOMPARE(quickTileChangedSpy.count(), 2);
}
QTEST(window->quickTileMode(), "expectedModeAfterToggle");
}
@ -265,8 +282,8 @@ void QuickTilingTest::testQuickMaximizing()
// at this point the geometry did not yet change
QCOMPARE(window->frameGeometry(), QRect(0, 0, 100, 50));
// but requested quick tile mode already changed
QCOMPARE(window->requestedQuickTileMode(), QuickTileFlag::Maximize);
// Manually maximized window is always without a tile
QCOMPARE(window->requestedQuickTileMode(), QuickTileFlag::None);
QCOMPARE(window->quickTileMode(), oldQuickTileMode);
QCOMPARE(window->geometryRestore(), QRect(0, 0, 100, 50));
@ -281,14 +298,15 @@ void QuickTilingTest::testQuickMaximizing()
QVERIFY(frameGeometryChangedSpy.wait());
QCOMPARE(frameGeometryChangedSpy.count(), 1);
QCOMPARE(quickTileChangedSpy.count(), 1);
QCOMPARE(window->quickTileMode(), QuickTileFlag::Maximize);
QCOMPARE(quickTileChangedSpy.count(), 0);
QCOMPARE(window->quickTileMode(), QuickTileFlag::None);
QCOMPARE(window->frameGeometry(), QRect(0, 0, 1280, 1024));
QCOMPARE(window->geometryRestore(), QRect(0, 0, 100, 50));
// window is now set to maximised
QCOMPARE(maximizeChangedSpy.count(), 1);
QCOMPARE(window->maximizeMode(), MaximizeFull);
QCOMPARE(window->tile(), nullptr);
// go back to quick tile none
QFETCH(QuickTileMode, mode);
@ -308,7 +326,7 @@ void QuickTilingTest::testQuickMaximizing()
QVERIFY(frameGeometryChangedSpy.wait());
QCOMPARE(frameGeometryChangedSpy.count(), 2);
QCOMPARE(quickTileChangedSpy.count(), 2);
QCOMPARE(quickTileChangedSpy.count(), 0);
QCOMPARE(window->quickTileMode(), QuickTileMode(QuickTileFlag::None));
QCOMPARE(window->frameGeometry(), QRect(0, 0, 100, 50));
QCOMPARE(window->geometryRestore(), QRect(0, 0, 100, 50));
@ -620,10 +638,15 @@ void QuickTilingTest::testX11QuickTiling()
const QRectF origGeo = window->frameGeometry();
QFETCH(QuickTileMode, mode);
window->setQuickTileMode(mode, true);
QCOMPARE(window->quickTileMode(), mode);
if (mode == QuickTileFlag::Maximize) {
QCOMPARE(quickTileChangedSpy.count(), 0);
QCOMPARE(window->quickTileMode(), QuickTileFlag::None);
} else {
QCOMPARE(quickTileChangedSpy.count(), 1);
QCOMPARE(window->quickTileMode(), mode);
}
QTEST(window->frameGeometry(), "expectedGeometry");
QCOMPARE(window->geometryRestore(), origGeo);
QCOMPARE(quickTileChangedSpy.count(), 1);
// quick tile to same edge again should also act like send to screen
// if screen is on the same edge
@ -706,9 +729,14 @@ void QuickTilingTest::testX11QuickTilingAfterVertMaximize()
QSignalSpy quickTileChangedSpy(window, &Window::quickTileModeChanged);
QFETCH(QuickTileMode, mode);
window->setQuickTileMode(mode, true);
QCOMPARE(window->quickTileMode(), mode);
if (mode == QuickTileFlag::Maximize) {
QCOMPARE(window->quickTileMode(), QuickTileFlag::None);
QCOMPARE(quickTileChangedSpy.count(), 0);
} else {
QCOMPARE(window->quickTileMode(), mode);
QCOMPARE(quickTileChangedSpy.count(), 1);
}
QTEST(window->frameGeometry(), "expectedGeometry");
QCOMPARE(quickTileChangedSpy.count(), 1);
// and destroy the window again
xcb_unmap_window(c.get(), windowId);

View file

@ -4645,11 +4645,7 @@ void X11Window::maximize(MaximizeMode mode)
case MaximizeFull: {
moveResize(clientArea);
if (options->electricBorderMaximize()) {
updateQuickTileMode(QuickTileFlag::Maximize);
} else {
updateQuickTileMode(QuickTileFlag::None);
}
updateQuickTileMode(QuickTileFlag::None);
info->setState(NET::Max, NET::Max);
break;
}

View file

@ -1642,15 +1642,7 @@ void XdgToplevelWindow::maximize(MaximizeMode mode)
}
}
if (m_requestedMaximizeMode == MaximizeFull) {
if (options->electricBorderMaximize()) {
updateQuickTileMode(QuickTileFlag::Maximize);
} else {
updateQuickTileMode(QuickTileFlag::None);
}
} else {
updateQuickTileMode(QuickTileFlag::None);
}
updateQuickTileMode(QuickTileFlag::None);
moveResize(geometry);