From c2d4cb8846a2c44be37732501a63dcf2f73294a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Fl=C3=B6ser?= Date: Sat, 7 Oct 2017 17:57:10 +0200 Subject: [PATCH] Support initial minimize rule in ShellClient Summary: Honors the rules for minimizing a window on initial show. Reviewers: #kwin, #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D8182 --- .../integration/shell_client_rules_test.cpp | 47 +++++++++++++++++++ shell_client.cpp | 4 ++ workspace.cpp | 2 +- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/autotests/integration/shell_client_rules_test.cpp b/autotests/integration/shell_client_rules_test.cpp index c79290b642..7f6fd6c937 100644 --- a/autotests/integration/shell_client_rules_test.cpp +++ b/autotests/integration/shell_client_rules_test.cpp @@ -43,6 +43,8 @@ private Q_SLOTS: void testApplyInitialDesktop_data(); void testApplyInitialDesktop(); + void testApplyInitialMinimize_data(); + void testApplyInitialMinimize(); }; void TestShellClientRules::initTestCase() @@ -66,6 +68,7 @@ void TestShellClientRules::initTestCase() void TestShellClientRules::init() { + VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktops().first()); QVERIFY(Test::setupWaylandConnection(Test::AdditionalWaylandInterface::Decoration)); screens()->setCurrent(0); @@ -116,6 +119,50 @@ void TestShellClientRules::testApplyInitialDesktop() auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); QVERIFY(c); QCOMPARE(c->desktop(), 2); + QCOMPARE(c->isMinimized(), false); + QCOMPARE(c->isActive(), true); +} + +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; +} + +void TestShellClientRules::testApplyInitialMinimize() +{ + // 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)); + + 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(), true); + QCOMPARE(c->isActive(), false); + c->setMinimized(false); + QCOMPARE(c->isMinimized(), false); } WAYLANDTEST_MAIN(TestShellClientRules) diff --git a/shell_client.cpp b/shell_client.cpp index 8eaeeaf364..6d6d3d53e9 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -315,6 +315,10 @@ void ShellClient::init() // set initial desktop setDesktop(rules()->checkDesktop(m_internal ? int(NET::OnAllDesktops) : VirtualDesktopManager::self()->current(), true)); + // TODO: merge in checks from Client::manage? + if (rules()->checkMinimize(false, true)) { + minimize(true); // No animation + } // setup shadow integration getShadow(); diff --git a/workspace.cpp b/workspace.cpp index be0ec80b46..7bb57a1bc9 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -282,7 +282,7 @@ void Workspace::init() markXStackingOrderAsDirty(); updateStackingOrder(true); updateClientArea(); - if (c->wantsInput()) { + if (c->wantsInput() && !c->isMinimized()) { activateClient(c); } connect(c, &ShellClient::windowShown, this,