diff --git a/autotests/integration/shell_client_rules_test.cpp b/autotests/integration/shell_client_rules_test.cpp --- a/autotests/integration/shell_client_rules_test.cpp +++ b/autotests/integration/shell_client_rules_test.cpp @@ -45,6 +45,12 @@ 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 @@ 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,35 +126,89 @@ 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() +TEST_DATA(testApplyInitialMinimize) + +void TestShellClientRules::testApplyInitialMinimize() { - QTest::addColumn("type"); - QTest::addColumn("ruleNumber"); + // install the temporary rule + QFETCH(int, ruleNumber); + QString rule = QStringLiteral("minimize=1\nminimizerule=%1").arg(ruleNumber); + QMetaObject::invokeMethod(RuleBook::self(), "temporaryRulesMessage", Q_ARG(QString, rule)); - QTest::newRow("wlShell|Force") << Test::ShellSurfaceType::WlShell << 2; - QTest::newRow("xdgShellV5|Force") << Test::ShellSurfaceType::XdgShellV5 << 2; - QTest::newRow("xdgShellV6|Force") << Test::ShellSurfaceType::XdgShellV6 << 2; + QScopedPointer surface(Test::createSurface()); + QFETCH(Test::ShellSurfaceType, type); + QScopedPointer shellSurface(Test::createShellSurface(type, surface.data())); - QTest::newRow("wlShell|Apply") << Test::ShellSurfaceType::WlShell << 3; - QTest::newRow("xdgShellV5|Apply") << Test::ShellSurfaceType::XdgShellV5 << 3; - QTest::newRow("xdgShellV6|Apply") << Test::ShellSurfaceType::XdgShellV6 << 3; + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); + QVERIFY(c); + QCOMPARE(c->desktop(), 1); + QCOMPARE(c->isMinimized(), true); + QCOMPARE(c->isActive(), false); + c->setMinimized(false); + QCOMPARE(c->isMinimized(), false); + QCOMPARE(c->skipTaskbar(), false); + QCOMPARE(c->skipPager(), false); + QCOMPARE(c->skipSwitcher(), false); +} - QTest::newRow("wlShell|ApplyNow") << Test::ShellSurfaceType::WlShell << 5; - QTest::newRow("xdgShellV5|ApplyNow") << Test::ShellSurfaceType::XdgShellV5 << 5; - QTest::newRow("xdgShellV6|ApplyNow") << Test::ShellSurfaceType::XdgShellV6 << 5; +TEST_DATA(testApplyInitialSkipTaskbar) - QTest::newRow("wlShell|ForceTemporarily") << Test::ShellSurfaceType::WlShell << 6; - QTest::newRow("xdgShellV5|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV5 << 6; - QTest::newRow("xdgShellV6|ForceTemporarily") << Test::ShellSurfaceType::XdgShellV6 << 6; +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); } -void TestShellClientRules::testApplyInitialMinimize() +TEST_DATA(testApplyInitialSkipPager) + +void TestShellClientRules::testApplyInitialSkipPager() { // install the temporary rule QFETCH(int, ruleNumber); - QString rule = QStringLiteral("minimize=1\nminimizerule=%1").arg(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()); @@ -159,10 +218,11 @@ auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); QVERIFY(c); QCOMPARE(c->desktop(), 1); - QCOMPARE(c->isMinimized(), true); - QCOMPARE(c->isActive(), false); - c->setMinimized(false); 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 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -319,6 +319,9 @@ 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();