From 87f0a119e1125c20e9196229c563b1423b829130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sun, 14 Jan 2018 14:51:37 +0100 Subject: [PATCH] Add support for apply initial shortcut window rule Summary: Implements the shortcut window rule for ShellClient. Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #plasma Differential Revision: https://phabricator.kde.org/D9876 --- .../integration/shell_client_rules_test.cpp | 36 +++++++++++++++++++ shell_client.cpp | 1 + 2 files changed, 37 insertions(+) diff --git a/autotests/integration/shell_client_rules_test.cpp b/autotests/integration/shell_client_rules_test.cpp index 4bfd1788b3..89659d611e 100644 --- a/autotests/integration/shell_client_rules_test.cpp +++ b/autotests/integration/shell_client_rules_test.cpp @@ -55,6 +55,8 @@ private Q_SLOTS: void testApplyInitialKeepAbove(); void testApplyInitialKeepBelow_data(); void testApplyInitialKeepBelow(); + void testApplyInitialShortcut_data(); + void testApplyInitialShortcut(); }; void TestShellClientRules::initTestCase() @@ -135,6 +137,7 @@ void TestShellClientRules::testApplyInitialDesktop() QCOMPARE(c->skipSwitcher(), false); QCOMPARE(c->keepAbove(), false); QCOMPARE(c->keepBelow(), false); + QCOMPARE(c->shortcut(), QKeySequence()); } TEST_DATA(testApplyInitialMinimize) @@ -162,6 +165,7 @@ void TestShellClientRules::testApplyInitialMinimize() QCOMPARE(c->skipSwitcher(), false); QCOMPARE(c->keepAbove(), false); QCOMPARE(c->keepBelow(), false); + QCOMPARE(c->shortcut(), QKeySequence()); } TEST_DATA(testApplyInitialSkipTaskbar) @@ -187,6 +191,7 @@ void TestShellClientRules::testApplyInitialSkipTaskbar() QCOMPARE(c->skipSwitcher(), false); QCOMPARE(c->keepAbove(), false); QCOMPARE(c->keepBelow(), false); + QCOMPARE(c->shortcut(), QKeySequence()); } TEST_DATA(testApplyInitialSkipPager) @@ -212,6 +217,7 @@ void TestShellClientRules::testApplyInitialSkipPager() QCOMPARE(c->skipSwitcher(), false); QCOMPARE(c->keepAbove(), false); QCOMPARE(c->keepBelow(), false); + QCOMPARE(c->shortcut(), QKeySequence()); } TEST_DATA(testApplyInitialSkipSwitcher) @@ -237,6 +243,7 @@ void TestShellClientRules::testApplyInitialSkipSwitcher() QCOMPARE(c->skipSwitcher(), true); QCOMPARE(c->keepAbove(), false); QCOMPARE(c->keepBelow(), false); + QCOMPARE(c->shortcut(), QKeySequence()); } TEST_DATA(testApplyInitialKeepAbove) @@ -262,6 +269,7 @@ void TestShellClientRules::testApplyInitialKeepAbove() QCOMPARE(c->skipSwitcher(), false); QCOMPARE(c->keepAbove(), true); QCOMPARE(c->keepBelow(), false); + QCOMPARE(c->shortcut(), QKeySequence()); } TEST_DATA(testApplyInitialKeepBelow) @@ -287,6 +295,34 @@ void TestShellClientRules::testApplyInitialKeepBelow() QCOMPARE(c->skipSwitcher(), false); QCOMPARE(c->keepAbove(), false); QCOMPARE(c->keepBelow(), true); + QCOMPARE(c->shortcut(), QKeySequence()); +} + +TEST_DATA(testApplyInitialShortcut) + +void TestShellClientRules::testApplyInitialShortcut() +{ + // install the temporary rule + QFETCH(int, ruleNumber); + const QKeySequence sequence{Qt::ControlModifier + Qt::ShiftModifier + Qt::MetaModifier + Qt::AltModifier + Qt::Key_Space}; + QString rule = QStringLiteral("shortcut=%1\nshortcutrule=%2").arg(sequence.toString()).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(), false); + QCOMPARE(c->shortcut(), sequence); } WAYLANDTEST_MAIN(TestShellClientRules) diff --git a/shell_client.cpp b/shell_client.cpp index 21e83fdfc9..27e9d698b0 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -324,6 +324,7 @@ void ShellClient::init() setSkipSwitcher(rules()->checkSkipSwitcher(false, true)); setKeepAbove(rules()->checkKeepAbove(false, true)); setKeepBelow(rules()->checkKeepBelow(false, true)); + setShortcut(rules()->checkShortcut(QString(), true)); // setup shadow integration getShadow();