Commit 42b09935 authored by Martin Flöser's avatar Martin Flöser

Add support for initial apply rules for skip (taskbar|pager|switcher)

Summary: This adds support for those set rules in ShellClient.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9866
parent 85ef2831
......@@ -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<Test::ShellSurfaceType>("type");
QTest::addColumn<int>("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<Test::ShellSurfaceType>("type"); \
QTest::addColumn<int>("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 @@ 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()
TEST_DATA(testApplyInitialMinimize)
void TestShellClientRules::testApplyInitialMinimize()
{
QTest::addColumn<Test::ShellSurfaceType>("type");
QTest::addColumn<int>("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> surface(Test::createSurface());
QFETCH(Test::ShellSurfaceType, type);
QScopedPointer<QObject> 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> 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(), 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> 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(), 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> surface(Test::createSurface());
......@@ -159,10 +218,11 @@ void TestShellClientRules::testApplyInitialMinimize()
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)
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment