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 @@ -27,6 +27,7 @@ #include "workspace.h" #include +#include using namespace KWin; using namespace KWayland::Client; @@ -62,6 +63,7 @@ void testApplyInitialDesktopfile(); void testOpacityActive_data(); void testOpacityActive(); + void testMatchAfterNameChange(); }; void TestShellClientRules::initTestCase() @@ -416,5 +418,37 @@ QCOMPARE(c2->opacity(), 0.8); } +void TestShellClientRules::testMatchAfterNameChange() +{ + KSharedConfig::Ptr config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); + config->group("General").writeEntry("count", 1); + + auto group = config->group("1"); + group.writeEntry("above", true); + group.writeEntry("aboverule", 2); + group.writeEntry("wmclass", "org.kde.foo"); + group.writeEntry("wmclasscomplete", false); + group.writeEntry("wmclassmatch", 1); + group.sync(); + + RuleBook::self()->setConfig(config); + workspace()->slotReconfigure(); + + QScopedPointer surface(Test::createSurface()); + QScopedPointer shellSurface(Test::createXdgShellV6Surface(surface.data())); + + auto c = Test::renderAndWaitForShown(surface.data(), QSize(100, 50), Qt::blue); + QVERIFY(c); + QVERIFY(c->isActive()); + QCOMPARE(c->keepAbove(), false); + + QSignalSpy desktopFileNameSpy(c, &AbstractClient::desktopFileNameChanged); + QVERIFY(desktopFileNameSpy.isValid()); + + shellSurface->setAppId(QByteArrayLiteral("org.kde.foo")); + QVERIFY(desktopFileNameSpy.wait()); + QCOMPARE(c->keepAbove(), true); +} + WAYLANDTEST_MAIN(TestShellClientRules) #include "shell_client_rules_test.moc" diff --git a/shell_client.cpp b/shell_client.cpp --- a/shell_client.cpp +++ b/shell_client.cpp @@ -138,6 +138,10 @@ connect(shellSurface, &T::windowClassChanged, this, [this, resourceName] (const QByteArray &windowClass) { setResourceClass(resourceName, windowClass); + if (!m_internal) { + setupWindowRules(true); + applyWindowRules(); + } setDesktopFileName(windowClass); } );