[wayland] Make sure fullscreen windows aren't repositioned

Summary:
on X11, setFullScreen is always called after Placement::place()
so they always have the correct geometry.
on wayland, the window if is shown directly as fullscren,
is set fullscreen in init() then place() is evecuted, potentially
moving it to a wrong position and potentially even size (which happens
with maximiziong placement strategy)
so instead of place() the client needs to be explicitly set at
fullscreen geometry

Test Plan:
fullscreen windows always appear with the proper geometry
autotests still pass

Reviewers: #kwin, #plasma, davidedmundson

Reviewed By: #kwin, #plasma, davidedmundson

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24542
This commit is contained in:
Marco Martin 2019-10-11 10:46:08 +02:00
parent 08d0c6a3bc
commit 10ace126be
3 changed files with 67 additions and 0 deletions

View file

@ -58,6 +58,7 @@ private Q_SLOTS:
void testPlaceSmart();
void testPlaceZeroCornered();
void testPlaceMaximized();
void testPlaceMaximizedLeavesFullscreen();
void testPlaceCentered();
void testPlaceUnderMouse();
void testPlaceCascaded();
@ -204,6 +205,41 @@ void TestPlacement::testPlaceMaximized()
}
}
void TestPlacement::testPlaceMaximizedLeavesFullscreen()
{
setPlacementPolicy(Placement::Maximizing);
// add a top panel
QScopedPointer<Surface> panelSurface(Test::createSurface());
QScopedPointer<QObject> panelShellSurface(Test::createXdgShellStableSurface(panelSurface.data()));
QScopedPointer<PlasmaShellSurface> 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);
QScopedPointer<QObject> testParent(new QObject);
// all windows should be initially fullscreen with an initial configure size sent, despite the policy
for (int i = 0; i < 4; i++) {
auto surface = Test::createSurface(testParent.data());
auto shellSurface = Test::createXdgShellStableSurface(surface, surface, Test::CreationSetup::CreateOnly);
shellSurface->setFullscreen(true);
QSignalSpy configSpy(shellSurface, &XdgShellSurface::configureRequested);
surface->commit(Surface::CommitFlag::None);
configSpy.wait();
auto initiallyConfiguredSize = configSpy[0][0].toSize();
auto initiallyConfiguredStates = configSpy[0][1].value<KWayland::Client::XdgShellSurface::States>();
shellSurface->ackConfigure(configSpy[0][2].toUInt());
auto c = Test::renderAndWaitForShown(surface, initiallyConfiguredSize, Qt::red);
QVERIFY(initiallyConfiguredStates & XdgShellSurface::State::Fullscreen);
QCOMPARE(initiallyConfiguredSize, QSize(1280, 1024 ));
QCOMPARE(c->frameGeometry(), QRect(0, 0, 1280, 1024));
}
}
void TestPlacement::testPlaceCentered()
{
// This test verifies that Centered placement policy works.

View file

@ -112,6 +112,7 @@ private Q_SLOTS:
void testXdgNeverCommitted();
void testXdgInitialState();
void testXdgInitiallyMaximised();
void testXdgInitiallyFullscreen();
void testXdgInitiallyMinimized();
void testXdgWindowGeometry();
};
@ -1243,6 +1244,32 @@ void TestXdgShellClient::testXdgInitiallyMaximised()
QCOMPARE(c->size(), QSize(1280, 1024));
}
void TestXdgShellClient::testXdgInitiallyFullscreen()
{
QScopedPointer<Surface> surface(Test::createSurface());
QScopedPointer<XdgShellSurface> shellSurface(Test::createXdgShellStableSurface(surface.data(), nullptr, Test::CreationSetup::CreateOnly));
QSignalSpy configureRequestedSpy(shellSurface.data(), &XdgShellSurface::configureRequested);
shellSurface->setFullscreen(true);
surface->commit(Surface::CommitFlag::None);
configureRequestedSpy.wait();
QCOMPARE(configureRequestedSpy.count(), 1);
const auto size = configureRequestedSpy.first()[0].value<QSize>();
const auto state = configureRequestedSpy.first()[1].value<KWayland::Client::XdgShellSurface::States>();
QCOMPARE(size, QSize(1280, 1024));
QVERIFY(state & KWayland::Client::XdgShellSurface::State::Fullscreen);
shellSurface->ackConfigure(configureRequestedSpy.first()[2].toUInt());
auto c = Test::renderAndWaitForShown(surface.data(), size, Qt::blue);
QCOMPARE(c->isFullScreen(), true);
QCOMPARE(c->size(), QSize(1280, 1024));
}
void TestXdgShellClient::testXdgInitiallyMinimized()
{
QScopedPointer<Surface> surface(Test::createSurface());

View file

@ -222,6 +222,10 @@ void XdgShellClient::finishInit()
updateWindowRules(Rules::All);
}
if (isFullScreen()) {
needsPlacement = false;
}
if (needsPlacement) {
const QRect area = workspace()->clientArea(PlacementArea, Screens::self()->current(), desktop());
placeIn(area);