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
icc-effect-5.14.5
Martin Flöser 2018-01-13 19:58:43 +01:00
parent 85ef2831db
commit 42b099355c
2 changed files with 104 additions and 41 deletions

View File

@ -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,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<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(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> 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);
}
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> 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());
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(), true);
}
WAYLANDTEST_MAIN(TestShellClientRules)

View File

@ -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();