diff --git a/autotests/integration/shell_client_rules_test.cpp b/autotests/integration/shell_client_rules_test.cpp index ed75bd4f33..250d97c4de 100644 --- a/autotests/integration/shell_client_rules_test.cpp +++ b/autotests/integration/shell_client_rules_test.cpp @@ -27,6 +27,7 @@ along with this program. If not, see . #include "workspace.h" #include +#include using namespace KWin; using namespace KWayland::Client; @@ -62,6 +63,7 @@ private Q_SLOTS: void testApplyInitialDesktopfile(); void testOpacityActive_data(); void testOpacityActive(); + void testMatchAfterNameChange(); }; void TestShellClientRules::initTestCase() @@ -416,5 +418,37 @@ void TestShellClientRules::testOpacityActive() 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 index 65ab9e27b5..9b63f451c0 100644 --- a/shell_client.cpp +++ b/shell_client.cpp @@ -138,6 +138,10 @@ void ShellClient::initSurface(T *shellSurface) connect(shellSurface, &T::windowClassChanged, this, [this, resourceName] (const QByteArray &windowClass) { setResourceClass(resourceName, windowClass); + if (!m_internal) { + setupWindowRules(true); + applyWindowRules(); + } setDesktopFileName(windowClass); } );