Implement borderlessMaximizedWindows for Wayland windows

Summary:
Maximize code was not yet adjusted to support decorations. Code is as
much as possible similar to the X11 Client implementation.

BUG: 370982

Test Plan: Added auto test and run a nested KWin/Wayland with the setting enabled

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3508
This commit is contained in:
Martin Gräßlin 2016-11-25 16:45:40 +01:00
parent 9934f5b575
commit f32e655031
2 changed files with 62 additions and 1 deletions

View file

@ -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> surface(Test::createSurface());
QScopedPointer<ShellSurface> shellSurface(Test::createShellSurface(surface.data()));
QScopedPointer<ServerSideDecoration> 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"

View file

@ -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();