diff --git a/autotests/integration/maximize_test.cpp b/autotests/integration/maximize_test.cpp --- a/autotests/integration/maximize_test.cpp +++ b/autotests/integration/maximize_test.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,7 @@ void testInitiallyMaximized(); void testBorderlessMaximizedWindow(); void testBorderlessMaximizedWindowNoClientSideDecoration(); + void testMaximizePlacementStrategy(); }; void TestMaximized::initTestCase() @@ -80,7 +82,8 @@ void TestMaximized::init() { QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration | - Test::AdditionalWaylandInterface::XdgDecoration)); + Test::AdditionalWaylandInterface::XdgDecoration | + Test::AdditionalWaylandInterface::PlasmaShell)); screens()->setCurrent(0); KWin::Cursor::setPos(QPoint(1280, 512)); @@ -294,5 +297,39 @@ QCOMPARE(deco->mode(), XdgDecoration::Mode::ServerSide); } +void TestMaximized::testMaximizePlacementStrategy() +{ + // adjust config + auto group = kwinApp()->config()->group("Windows"); + group.writeEntry("Placement", "Maximizing"); + group.sync(); + Workspace::self()->slotReconfigure(); + + // add a top panel + QScopedPointer panelSurface(Test::createSurface()); + QScopedPointer panelShellSurface(Test::createXdgShellStableSurface(panelSurface.data())); + QScopedPointer plasmaSurface(Test::waylandPlasmaShell()->createSurface(panelSurface.data())); + plasmaSurface->setRole(PlasmaShellSurface::Role::Panel); + plasmaSurface->setPosition(QPoint(0, 0)); + Test::renderAndWaitForShown(panelSurface.data(), QSize(1280, 20), Qt::blue); + + // create a new window - it should be maximised on the first configure and positioned beneath the strut + QScopedPointer surface(Test::createSurface()); + auto shellSurface = Test::createXdgShellStableSurface(surface.data(), surface.data(), Test::CreationSetup::CreateOnly); + QSignalSpy configSpy(shellSurface, &XdgShellSurface::configureRequested); + surface->commit(Surface::CommitFlag::None); + QVERIFY(configSpy.wait()); + + const auto size = configSpy[0][0].toSize(); + const auto states = configureRequestedSpy[0][1].value(); + QVERIFY(state & XdgShellSurface::State::Maximized); + shellSurface->ackConfigure(configSpy[0][2].toUInt()); + QCOMPARE(size, QSize(1280, 1024 - 20)); + + auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::red); + QVERIFY(c); + QCOMPARE(c->geometry(), QRect(0, 20, 1280, 1024 - 20)); +} + WAYLANDTEST_MAIN(TestMaximized) #include "maximize_test.moc" diff --git a/shell_client.cpp b/shell_client.cpp --- a/shell_client.cpp +++ b/shell_client.cpp @@ -372,7 +372,7 @@ SurfaceInterface *s = surface(); disconnect(s, &SurfaceInterface::committed, this, &ShellClient::finishInit); - if (m_xdgShellPopup) { + if (!isInitialPositionSet()) { QRect area = workspace()->clientArea(PlacementArea, Screens::self()->current(), desktop()); placeIn(area); }