diff --git a/client.cpp b/client.cpp index dbadafee98..248831747d 100644 --- a/client.cpp +++ b/client.cpp @@ -1520,6 +1520,12 @@ void Client::updateCaption() setCaption(cap_normal, true); } +void Client::evaluateWindowRules() +{ + setupWindowRules(true); + applyWindowRules(); +} + void Client::fetchIconicName() { QString s; diff --git a/client.h b/client.h index 4fbaa5ffbc..f22e6908f4 100644 --- a/client.h +++ b/client.h @@ -410,6 +410,7 @@ public: public Q_SLOTS: void closeWindow() override; void updateCaption(); + void evaluateWindowRules(); private Q_SLOTS: void shadeHover(); diff --git a/rules.cpp b/rules.cpp index 7ab6fa724d..fe449e6427 100644 --- a/rules.cpp +++ b/rules.cpp @@ -449,10 +449,15 @@ bool Rules::match(const Client* c) const return false; if (!matchRole(c->windowRole())) return false; - if (!matchTitle(c->caption(false))) - return false; if (!matchClientMachine(c->clientMachine()->hostName(), c->clientMachine()->isLocal())) return false; + if (titlematch != UnimportantMatch) // track title changes to rematch rules + QObject::connect(c, &Client::captionChanged, c, &Client::evaluateWindowRules, + // QueuedConnection, because title may change before + // the client is ready (could segfault!) + static_cast(Qt::QueuedConnection|Qt::UniqueConnection)); + if (!matchTitle(c->caption(false))) + return false; return true; } @@ -862,6 +867,7 @@ CHECK_FORCE_RULE(DisableGlobalShortcuts, bool) void Client::setupWindowRules(bool ignore_temporary) { + disconnect(this, &Client::captionChanged, this, &Client::evaluateWindowRules); client_rules = RuleBook::self()->find(this, ignore_temporary); // check only after getting the rules, because there may be a rule forcing window type }