From d7cc5eb3bd5bb9960b6d709f9a5731fca370d327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sun, 14 Jan 2018 09:45:02 +0100 Subject: [PATCH] Add support for apply initial keep above/below window rules Summary: This implements these set rules for ShellClient. Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #plasma Differential Revision: https://phabricator.kde.org/D9870 --- .../integration/shell_client_rules_test.cpp | 64 +++++++++++++++++++ shell_client.cpp | 2 + 2 files changed, 66 insertions(+) diff --git a/autotests/integration/shell_client_rules_test.cpp b/autotests/integration/shell_client_rules_test.cpp index 1f86e90bef..4bfd1788b3 100644 --- a/autotests/integration/shell_client_rules_test.cpp +++ b/autotests/integration/shell_client_rules_test.cpp @@ -51,6 +51,10 @@ private Q_SLOTS: void testApplyInitialSkipPager(); void testApplyInitialSkipSwitcher_data(); void testApplyInitialSkipSwitcher(); + void testApplyInitialKeepAbove_data(); + void testApplyInitialKeepAbove(); + void testApplyInitialKeepBelow_data(); + void testApplyInitialKeepBelow(); }; void TestShellClientRules::initTestCase() @@ -129,6 +133,8 @@ void TestShellClientRules::testApplyInitialDesktop() QCOMPARE(c->skipTaskbar(), false); QCOMPARE(c->skipPager(), false); QCOMPARE(c->skipSwitcher(), false); + QCOMPARE(c->keepAbove(), false); + QCOMPARE(c->keepBelow(), false); } TEST_DATA(testApplyInitialMinimize) @@ -154,6 +160,8 @@ void TestShellClientRules::testApplyInitialMinimize() QCOMPARE(c->skipTaskbar(), false); QCOMPARE(c->skipPager(), false); QCOMPARE(c->skipSwitcher(), false); + QCOMPARE(c->keepAbove(), false); + QCOMPARE(c->keepBelow(), false); } TEST_DATA(testApplyInitialSkipTaskbar) @@ -177,6 +185,8 @@ void TestShellClientRules::testApplyInitialSkipTaskbar() QCOMPARE(c->skipTaskbar(), true); QCOMPARE(c->skipPager(), false); QCOMPARE(c->skipSwitcher(), false); + QCOMPARE(c->keepAbove(), false); + QCOMPARE(c->keepBelow(), false); } TEST_DATA(testApplyInitialSkipPager) @@ -200,6 +210,8 @@ void TestShellClientRules::testApplyInitialSkipPager() QCOMPARE(c->skipTaskbar(), false); QCOMPARE(c->skipPager(), true); QCOMPARE(c->skipSwitcher(), false); + QCOMPARE(c->keepAbove(), false); + QCOMPARE(c->keepBelow(), false); } TEST_DATA(testApplyInitialSkipSwitcher) @@ -223,6 +235,58 @@ void TestShellClientRules::testApplyInitialSkipSwitcher() QCOMPARE(c->skipTaskbar(), false); QCOMPARE(c->skipPager(), false); QCOMPARE(c->skipSwitcher(), true); + QCOMPARE(c->keepAbove(), false); + QCOMPARE(c->keepBelow(), false); +} + +TEST_DATA(testApplyInitialKeepAbove) + +void TestShellClientRules::testApplyInitialKeepAbove() +{ + // install the temporary rule + QFETCH(int, ruleNumber); + QString rule = QStringLiteral("above=true\naboverule=%1").arg(ruleNumber); + QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule)); + + QScopedPointer surface(Test::createSurface()); + QFETCH(Test::ShellSurfaceType, type); + QScopedPointer shellSurface(Test::createShellSurface(type, surface.data())); + + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); + QVERIFY(c); + QCOMPARE(c->desktop(), 1); + QCOMPARE(c->isMinimized(), false); + QCOMPARE(c->isActive(), true); + QCOMPARE(c->skipTaskbar(), false); + QCOMPARE(c->skipPager(), false); + QCOMPARE(c->skipSwitcher(), false); + QCOMPARE(c->keepAbove(), true); + QCOMPARE(c->keepBelow(), false); +} + +TEST_DATA(testApplyInitialKeepBelow) + +void TestShellClientRules::testApplyInitialKeepBelow() +{ + // install the temporary rule + QFETCH(int, ruleNumber); + QString rule = QStringLiteral("below=true\nbelowrule=%1").arg(ruleNumber); + QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule)); + + QScopedPointer surface(Test::createSurface()); + QFETCH(Test::ShellSurfaceType, type); + QScopedPointer shellSurface(Test::createShellSurface(type, surface.data())); + + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); + QVERIFY(c); + QCOMPARE(c->desktop(), 1); + QCOMPARE(c->isMinimized(), false); + QCOMPARE(c->isActive(), true); + QCOMPARE(c->skipTaskbar(), false); + QCOMPARE(c->skipPager(), false); + QCOMPARE(c->skipSwitcher(), false); + QCOMPARE(c->keepAbove(), false); + QCOMPARE(c->keepBelow(), true); } WAYLANDTEST_MAIN(TestShellClientRules) diff --git a/shell_client.cpp b/shell_client.cpp index a2938ca5ad..21e83fdfc9 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -322,6 +322,8 @@ void ShellClient::init() setSkipTaskbar(rules()->checkSkipTaskbar(m_plasmaShellSurface ? m_plasmaShellSurface->skipTaskbar() : false, true)); setSkipPager(rules()->checkSkipPager(false, true)); setSkipSwitcher(rules()->checkSkipSwitcher(false, true)); + setKeepAbove(rules()->checkKeepAbove(false, true)); + setKeepBelow(rules()->checkKeepBelow(false, true)); // setup shadow integration getShadow();