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
This commit is contained in:
Martin Flöser 2018-01-14 09:45:02 +01:00
parent 434a657234
commit d7cc5eb3bd
2 changed files with 66 additions and 0 deletions

View file

@ -51,6 +51,10 @@ private Q_SLOTS:
void testApplyInitialSkipPager(); void testApplyInitialSkipPager();
void testApplyInitialSkipSwitcher_data(); void testApplyInitialSkipSwitcher_data();
void testApplyInitialSkipSwitcher(); void testApplyInitialSkipSwitcher();
void testApplyInitialKeepAbove_data();
void testApplyInitialKeepAbove();
void testApplyInitialKeepBelow_data();
void testApplyInitialKeepBelow();
}; };
void TestShellClientRules::initTestCase() void TestShellClientRules::initTestCase()
@ -129,6 +133,8 @@ void TestShellClientRules::testApplyInitialDesktop()
QCOMPARE(c->skipTaskbar(), false); QCOMPARE(c->skipTaskbar(), false);
QCOMPARE(c->skipPager(), false); QCOMPARE(c->skipPager(), false);
QCOMPARE(c->skipSwitcher(), false); QCOMPARE(c->skipSwitcher(), false);
QCOMPARE(c->keepAbove(), false);
QCOMPARE(c->keepBelow(), false);
} }
TEST_DATA(testApplyInitialMinimize) TEST_DATA(testApplyInitialMinimize)
@ -154,6 +160,8 @@ void TestShellClientRules::testApplyInitialMinimize()
QCOMPARE(c->skipTaskbar(), false); QCOMPARE(c->skipTaskbar(), false);
QCOMPARE(c->skipPager(), false); QCOMPARE(c->skipPager(), false);
QCOMPARE(c->skipSwitcher(), false); QCOMPARE(c->skipSwitcher(), false);
QCOMPARE(c->keepAbove(), false);
QCOMPARE(c->keepBelow(), false);
} }
TEST_DATA(testApplyInitialSkipTaskbar) TEST_DATA(testApplyInitialSkipTaskbar)
@ -177,6 +185,8 @@ void TestShellClientRules::testApplyInitialSkipTaskbar()
QCOMPARE(c->skipTaskbar(), true); QCOMPARE(c->skipTaskbar(), true);
QCOMPARE(c->skipPager(), false); QCOMPARE(c->skipPager(), false);
QCOMPARE(c->skipSwitcher(), false); QCOMPARE(c->skipSwitcher(), false);
QCOMPARE(c->keepAbove(), false);
QCOMPARE(c->keepBelow(), false);
} }
TEST_DATA(testApplyInitialSkipPager) TEST_DATA(testApplyInitialSkipPager)
@ -200,6 +210,8 @@ void TestShellClientRules::testApplyInitialSkipPager()
QCOMPARE(c->skipTaskbar(), false); QCOMPARE(c->skipTaskbar(), false);
QCOMPARE(c->skipPager(), true); QCOMPARE(c->skipPager(), true);
QCOMPARE(c->skipSwitcher(), false); QCOMPARE(c->skipSwitcher(), false);
QCOMPARE(c->keepAbove(), false);
QCOMPARE(c->keepBelow(), false);
} }
TEST_DATA(testApplyInitialSkipSwitcher) TEST_DATA(testApplyInitialSkipSwitcher)
@ -223,6 +235,58 @@ void TestShellClientRules::testApplyInitialSkipSwitcher()
QCOMPARE(c->skipTaskbar(), false); QCOMPARE(c->skipTaskbar(), false);
QCOMPARE(c->skipPager(), false); QCOMPARE(c->skipPager(), false);
QCOMPARE(c->skipSwitcher(), true); 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> surface(Test::createSurface());
QFETCH(Test::ShellSurfaceType, type);
QScopedPointer<QObject> 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> surface(Test::createSurface());
QFETCH(Test::ShellSurfaceType, type);
QScopedPointer<QObject> 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) WAYLANDTEST_MAIN(TestShellClientRules)

View file

@ -322,6 +322,8 @@ void ShellClient::init()
setSkipTaskbar(rules()->checkSkipTaskbar(m_plasmaShellSurface ? m_plasmaShellSurface->skipTaskbar() : false, true)); setSkipTaskbar(rules()->checkSkipTaskbar(m_plasmaShellSurface ? m_plasmaShellSurface->skipTaskbar() : false, true));
setSkipPager(rules()->checkSkipPager(false, true)); setSkipPager(rules()->checkSkipPager(false, true));
setSkipSwitcher(rules()->checkSkipSwitcher(false, true)); setSkipSwitcher(rules()->checkSkipSwitcher(false, true));
setKeepAbove(rules()->checkKeepAbove(false, true));
setKeepBelow(rules()->checkKeepBelow(false, true));
// setup shadow integration // setup shadow integration
getShadow(); getShadow();