diff --git a/autotests/integration/shell_client_rules_test.cpp b/autotests/integration/shell_client_rules_test.cpp index 7f6fd6c937..1f86e90bef 100644 --- a/autotests/integration/shell_client_rules_test.cpp +++ b/autotests/integration/shell_client_rules_test.cpp @@ -45,6 +45,12 @@ private Q_SLOTS: void testApplyInitialDesktop(); void testApplyInitialMinimize_data(); void testApplyInitialMinimize(); + void testApplyInitialSkipTaskbar_data(); + void testApplyInitialSkipTaskbar(); + void testApplyInitialSkipPager_data(); + void testApplyInitialSkipPager(); + void testApplyInitialSkipSwitcher_data(); + void testApplyInitialSkipSwitcher(); }; void TestShellClientRules::initTestCase() @@ -79,28 +85,27 @@ void TestShellClientRules::cleanup() Test::destroyWaylandConnection(); } -void TestShellClientRules::testApplyInitialDesktop_data() -{ - QTest::addColumn("type"); - QTest::addColumn("ruleNumber"); - - QTest::newRow("wlShell|Force") << Test::ShellSurfaceType::WlShell << 2; - QTest::newRow("xdgShellV5|Force") << Test::ShellSurfaceType::XdgShellV5 << 2; - QTest::newRow("xdgShellV6|Force") << Test::ShellSurfaceType::XdgShellV6 << 2; - - QTest::newRow("wlShell|Apply") << Test::ShellSurfaceType::WlShell << 3; - QTest::newRow("xdgShellV5|Apply") << Test::ShellSurfaceType::XdgShellV5 << 3; - QTest::newRow("xdgShellV6|Apply") << Test::ShellSurfaceType::XdgShellV6 << 3; - - QTest::newRow("wlShell|ApplyNow") << Test::ShellSurfaceType::WlShell << 5; - QTest::newRow("xdgShellV5|ApplyNow") << Test::ShellSurfaceType::XdgShellV5 << 5; - QTest::newRow("xdgShellV6|ApplyNow") << Test::ShellSurfaceType::XdgShellV6 << 5; - - QTest::newRow("wlShell|ForceTemporarily") << Test::ShellSurfaceType::WlShell << 6; - QTest::newRow("xdgShellV5|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV5 << 6; - QTest::newRow("xdgShellV6|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV6 << 6; +#define TEST_DATA( name ) \ +void TestShellClientRules::name##_data() \ +{ \ + QTest::addColumn("type"); \ + QTest::addColumn("ruleNumber"); \ + QTest::newRow("wlShell|Force") << Test::ShellSurfaceType::WlShell << 2; \ + QTest::newRow("xdgShellV5|Force") << Test::ShellSurfaceType::XdgShellV5 << 2; \ + QTest::newRow("xdgShellV6|Force") << Test::ShellSurfaceType::XdgShellV6 << 2; \ + QTest::newRow("wlShell|Apply") << Test::ShellSurfaceType::WlShell << 3; \ + QTest::newRow("xdgShellV5|Apply") << Test::ShellSurfaceType::XdgShellV5 << 3; \ + QTest::newRow("xdgShellV6|Apply") << Test::ShellSurfaceType::XdgShellV6 << 3; \ + QTest::newRow("wlShell|ApplyNow") << Test::ShellSurfaceType::WlShell << 5; \ + QTest::newRow("xdgShellV5|ApplyNow") << Test::ShellSurfaceType::XdgShellV5 << 5; \ + QTest::newRow("xdgShellV6|ApplyNow") << Test::ShellSurfaceType::XdgShellV6 << 5; \ + QTest::newRow("wlShell|ForceTemporarily") << Test::ShellSurfaceType::WlShell << 6; \ + QTest::newRow("xdgShellV5|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV5 << 6; \ + QTest::newRow("xdgShellV6|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV6 << 6; \ } +TEST_DATA(testApplyInitialDesktop) + void TestShellClientRules::testApplyInitialDesktop() { // ensure we have two desktops and are on first desktop @@ -121,29 +126,12 @@ void TestShellClientRules::testApplyInitialDesktop() QCOMPARE(c->desktop(), 2); QCOMPARE(c->isMinimized(), false); QCOMPARE(c->isActive(), true); + QCOMPARE(c->skipTaskbar(), false); + QCOMPARE(c->skipPager(), false); + QCOMPARE(c->skipSwitcher(), false); } -void TestShellClientRules::testApplyInitialMinimize_data() -{ - QTest::addColumn("type"); - QTest::addColumn("ruleNumber"); - - QTest::newRow("wlShell|Force") << Test::ShellSurfaceType::WlShell << 2; - QTest::newRow("xdgShellV5|Force") << Test::ShellSurfaceType::XdgShellV5 << 2; - QTest::newRow("xdgShellV6|Force") << Test::ShellSurfaceType::XdgShellV6 << 2; - - QTest::newRow("wlShell|Apply") << Test::ShellSurfaceType::WlShell << 3; - QTest::newRow("xdgShellV5|Apply") << Test::ShellSurfaceType::XdgShellV5 << 3; - QTest::newRow("xdgShellV6|Apply") << Test::ShellSurfaceType::XdgShellV6 << 3; - - QTest::newRow("wlShell|ApplyNow") << Test::ShellSurfaceType::WlShell << 5; - QTest::newRow("xdgShellV5|ApplyNow") << Test::ShellSurfaceType::XdgShellV5 << 5; - QTest::newRow("xdgShellV6|ApplyNow") << Test::ShellSurfaceType::XdgShellV6 << 5; - - QTest::newRow("wlShell|ForceTemporarily") << Test::ShellSurfaceType::WlShell << 6; - QTest::newRow("xdgShellV5|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV5 << 6; - QTest::newRow("xdgShellV6|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV6 << 6; -} +TEST_DATA(testApplyInitialMinimize) void TestShellClientRules::testApplyInitialMinimize() { @@ -163,6 +151,78 @@ void TestShellClientRules::testApplyInitialMinimize() QCOMPARE(c->isActive(), false); c->setMinimized(false); QCOMPARE(c->isMinimized(), false); + QCOMPARE(c->skipTaskbar(), false); + QCOMPARE(c->skipPager(), false); + QCOMPARE(c->skipSwitcher(), false); +} + +TEST_DATA(testApplyInitialSkipTaskbar) + +void TestShellClientRules::testApplyInitialSkipTaskbar() +{ + // install the temporary rule + QFETCH(int, ruleNumber); + QString rule = QStringLiteral("skiptaskbar=true\nskiptaskbarrule=%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(), true); + QCOMPARE(c->skipPager(), false); + QCOMPARE(c->skipSwitcher(), false); +} + +TEST_DATA(testApplyInitialSkipPager) + +void TestShellClientRules::testApplyInitialSkipPager() +{ + // install the temporary rule + QFETCH(int, ruleNumber); + QString rule = QStringLiteral("skippager=true\nskippagerrule=%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(), true); + QCOMPARE(c->skipSwitcher(), false); +} + +TEST_DATA(testApplyInitialSkipSwitcher) + +void TestShellClientRules::testApplyInitialSkipSwitcher() +{ + // install the temporary rule + QFETCH(int, ruleNumber); + QString rule = QStringLiteral("skipswitcher=true\nskipswitcherrule=%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(), true); } WAYLANDTEST_MAIN(TestShellClientRules) diff --git a/shell_client.cpp b/shell_client.cpp index 36752058c1..a2938ca5ad 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -319,6 +319,9 @@ void ShellClient::init() if (rules()->checkMinimize(false, true)) { minimize(true); // No animation } + setSkipTaskbar(rules()->checkSkipTaskbar(m_plasmaShellSurface ? m_plasmaShellSurface->skipTaskbar() : false, true)); + setSkipPager(rules()->checkSkipPager(false, true)); + setSkipSwitcher(rules()->checkSkipSwitcher(false, true)); // setup shadow integration getShadow();