From 3bfc750a79f967a93612385def636dced1ed1337 Mon Sep 17 00:00:00 2001 From: Ismael Asensio Date: Wed, 17 Jun 2020 21:22:06 +0200 Subject: [PATCH] [kcm/kwinrules] Fix detection of wmclass property Property `wmclass` of a window rule works in a special way, as it can have two meanings depending on `wmclasscomplete` flag: - false: only matches `resourceClass` - true: matches `resourceName` and `resourceClass` This MR fixes two subtle bugs when detecting the properties of a window: In the first case, `resourceName` was being wrongly set instead, which prevented window matching for windows where those two values differ. Also, the `wmclass` field was always set to `resourceName` independently of `wmclasscomplete` property. BUG: 423138 FIXED-IN: 5.19.3 --- kcmkwin/kwinrules/rulesmodel.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kcmkwin/kwinrules/rulesmodel.cpp b/kcmkwin/kwinrules/rulesmodel.cpp index e4ba5087aa..0044837f1a 100644 --- a/kcmkwin/kwinrules/rulesmodel.cpp +++ b/kcmkwin/kwinrules/rulesmodel.cpp @@ -233,7 +233,6 @@ QString RulesModel::warningMessage() const return QString(); } - bool RulesModel::wmclassWarning() const { const bool no_wmclass = !m_rules["wmclass"]->isEnabled() @@ -625,11 +624,6 @@ void RulesModel::populateRuleList() const QHash RulesModel::x11PropertyHash() { static const auto propertyToRule = QHash { - /* The original detection dialog allows to choose depending on "Match complete window class": - * if Match Complete == false: wmclass = "resourceClass" - * if Match Complete == true: wmclass = "resourceName" + " " + "resourceClass" - */ - { "resourceName", "wmclass" }, { "caption", "title" }, { "role", "windowrole" }, { "clientMachine", "clientmachine" }, @@ -668,6 +662,13 @@ void RulesModel::setWindowProperties(const QVariantMap &info, bool forceValue) } m_rules["types"]->setSuggestedValue(1 << window_type, forceValue); + const QString wmsimpleclass = info.value("resourceClass").toString(); + const QString wmcompleteclass = QStringLiteral("%1 %2").arg(info.value("resourceName").toString(), + info.value("resourceClass").toString()); + const bool isComplete = m_rules.value("wmclasscomplete")->value().toBool(); + + m_rules["wmclass"]->setSuggestedValue(isComplete ? wmcompleteclass : wmsimpleclass, forceValue); + const auto ruleForProperty = x11PropertyHash(); for (QString &property : info.keys()) { if (!ruleForProperty.contains(property)) {