re-evaluate rules on title change

If a rule minus the title match matches,
the captionChanged signal is bound to re-evaluate
the rules for that client, ie. the tracking overhead
only exists for those clients where title matching
is relevant and costs rematching all rules when such
client changes its title (yes, the partial matching
rules could be stored for faster re-check, but that
would make the patch bigger and is probably not worth
it; just some string comparisms)

additional tracking of wm_class or wm_role
(what is iirc a netwm violation anyway) would require
to monitor the resp. property for changes (not done atm.)

BUG: 220227
FIXED-IN: 5.5
REVIEW: 125427
This commit is contained in:
Thomas Lübking 2015-09-27 21:15:35 +02:00
parent 3b71411112
commit b2755bcaa7
3 changed files with 15 additions and 2 deletions

View file

@ -1520,6 +1520,12 @@ void Client::updateCaption()
setCaption(cap_normal, true);
}
void Client::evaluateWindowRules()
{
setupWindowRules(true);
applyWindowRules();
}
void Client::fetchIconicName()
{
QString s;

View file

@ -410,6 +410,7 @@ public:
public Q_SLOTS:
void closeWindow() override;
void updateCaption();
void evaluateWindowRules();
private Q_SLOTS:
void shadeHover();

View file

@ -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::ConnectionType>(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
}