diff --git a/autotests/integration/maximize_test.cpp b/autotests/integration/maximize_test.cpp index 50e4e3c2d8..a13f0fc547 100644 --- a/autotests/integration/maximize_test.cpp +++ b/autotests/integration/maximize_test.cpp @@ -51,6 +51,7 @@ private Q_SLOTS: void testMaximizedPassedToDeco(); void testInitiallyMaximized(); + void testBorderlessMaximizedWindow(); }; void TestMaximized::initTestCase() @@ -63,6 +64,8 @@ void TestMaximized::initTestCase() QMetaObject::invokeMethod(kwinApp()->platform(), "setOutputCount", Qt::DirectConnection, Q_ARG(int, 2)); QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); + kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); + kwinApp()->start(); QVERIFY(workspaceCreatedSpy.wait()); QCOMPARE(screens()->count(), 2); @@ -82,6 +85,13 @@ void TestMaximized::init() void TestMaximized::cleanup() { Test::destroyWaylandConnection(); + + // adjust config + auto group = kwinApp()->config()->group("Windows"); + group.writeEntry("BorderlessMaximizedWindows", false); + group.sync(); + Workspace::self()->slotReconfigure(); + QCOMPARE(options->borderlessMaximizedWindows(), false); } void TestMaximized::testMaximizedPassedToDeco() @@ -161,5 +171,50 @@ void TestMaximized::testInitiallyMaximized() QVERIFY(client->shellSurface()->isMaximized()); } +void TestMaximized::testBorderlessMaximizedWindow() +{ + // test case verifies that borderless maximized window works + // see BUG 370982 + + // adjust config + auto group = kwinApp()->config()->group("Windows"); + group.writeEntry("BorderlessMaximizedWindows", true); + group.sync(); + Workspace::self()->slotReconfigure(); + QCOMPARE(options->borderlessMaximizedWindows(), true); + QScopedPointer surface(Test::createSurface()); + QScopedPointer shellSurface(Test::createShellSurface(surface.data())); + QScopedPointer ssd(Test::waylandServerSideDecoration()->create(surface.data())); + + auto client = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); + QVERIFY(client->isDecorated()); + const QRect origGeo = client->geometry(); + + QSignalSpy sizeChangedSpy(shellSurface.data(), &ShellSurface::sizeChanged); + QVERIFY(sizeChangedSpy.isValid()); + + // go to maximized + shellSurface->setMaximized(); + QVERIFY(sizeChangedSpy.wait()); + QCOMPARE(shellSurface->size(), QSize(1280, 1024)); + QSignalSpy geometryChangedSpy(client, &ShellClient::geometryChanged); + QVERIFY(geometryChangedSpy.isValid()); + Test::render(surface.data(), shellSurface->size(), Qt::red); + QVERIFY(geometryChangedSpy.wait()); + QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeFull); + QCOMPARE(client->geometry(), QRect(0, 0, 1280, 1024)); + QCOMPARE(client->isDecorated(), false); + + // go back to normal + shellSurface->setToplevel(); + QVERIFY(sizeChangedSpy.wait()); + QCOMPARE(shellSurface->size(), QSize(100, 50)); + Test::render(surface.data(), QSize(100, 50), Qt::red); + QVERIFY(geometryChangedSpy.wait()); + QCOMPARE(client->maximizeMode(), MaximizeMode::MaximizeRestore); + QCOMPARE(client->geometry(), origGeo); + QCOMPARE(client->isDecorated(), true); +} + WAYLANDTEST_MAIN(TestMaximized) #include "maximize_test.moc" diff --git a/shell_client.cpp b/shell_client.cpp index 74ed7d54f3..85ecfffa9f 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -695,7 +695,13 @@ void ShellClient::changeMaximize(bool horizontal, bool vertical, bool adjust) changeMaximizeRecursion = false; } - // TODO: borderless maximized windows + if (options->borderlessMaximizedWindows()) { + // triggers a maximize change. + // The next setNoBorder interation will exit since there's no change but the first recursion pullutes the restore geometry + changeMaximizeRecursion = true; + setNoBorder(rules()->checkNoBorder(m_maximizeMode == MaximizeFull)); + changeMaximizeRecursion = false; + } // Conditional quick tiling exit points const auto oldQuickTileMode = quickTileMode();