kcms/rules: Use window class and role with original casing

The window rules kcm uses lower-case window class and role, but kwin can
use window class and role with other casing, which will break the ExactMatch
match rule.

BUG: 464190
This commit is contained in:
Vlad Zahorodnii 2023-01-16 13:20:48 +02:00
parent ecf3fa9f10
commit 5963790b21
2 changed files with 13 additions and 13 deletions

View file

@ -324,9 +324,9 @@ void KCMKWinRules::importFromFile(const QUrl &path)
// Code adapted from original `findRule()` method in `kwin_rules_dialog::main.cpp`
QModelIndex KCMKWinRules::findRuleWithProperties(const QVariantMap &info, bool wholeApp) const
{
const QString wmclass_class = info.value("resourceClass").toString().toLower();
const QString wmclass_name = info.value("resourceName").toString().toLower();
const QString role = info.value("role").toString().toLower();
const QString wmclass_class = info.value("resourceClass").toString();
const QString wmclass_name = info.value("resourceName").toString();
const QString role = info.value("role").toString();
const NET::WindowType type = static_cast<NET::WindowType>(info.value("type").toInt());
const QString title = info.value("caption").toString();
const QString machine = info.value("clientMachine").toString();
@ -409,9 +409,9 @@ QModelIndex KCMKWinRules::findRuleWithProperties(const QVariantMap &info, bool w
// Code adapted from original `findRule()` method in `kwin_rules_dialog::main.cpp`
void KCMKWinRules::fillSettingsFromProperties(RuleSettings *settings, const QVariantMap &info, bool wholeApp) const
{
const QString wmclass_class = info.value("resourceClass").toString().toLower();
const QString wmclass_name = info.value("resourceName").toString().toLower();
const QString role = info.value("role").toString().toLower();
const QString wmclass_class = info.value("resourceClass").toString();
const QString wmclass_name = info.value("resourceName").toString();
const QString role = info.value("role").toString();
const NET::WindowType type = static_cast<NET::WindowType>(info.value("type").toInt());
const QString title = info.value("caption").toString();
const QString machine = info.value("clientMachine").toString();

View file

@ -120,9 +120,9 @@ void Rules::readFromSettings(const RuleSettings *settings)
if (description.isEmpty()) {
description = settings->descriptionLegacy();
}
READ_MATCH_STRING(wmclass, .toLower());
READ_MATCH_STRING(wmclass, );
wmclasscomplete = settings->wmclasscomplete();
READ_MATCH_STRING(windowrole, .toLower());
READ_MATCH_STRING(windowrole, );
READ_MATCH_STRING(title, );
READ_MATCH_STRING(clientmachine, .toLower());
types = NET::WindowTypeMask(settings->types());
@ -345,10 +345,10 @@ bool Rules::matchWMClass(const QString &match_class, const QString &match_name)
if (wmclassmatch == RegExpMatch && !QRegularExpression(wmclass).match(cwmclass).hasMatch()) {
return false;
}
if (wmclassmatch == ExactMatch && wmclass != cwmclass) {
if (wmclassmatch == ExactMatch && cwmclass.compare(wmclass, Qt::CaseInsensitive) != 0) { // TODO Plasma 6: Make it case sensitive
return false;
}
if (wmclassmatch == SubstringMatch && !cwmclass.contains(wmclass)) {
if (wmclassmatch == SubstringMatch && !cwmclass.contains(wmclass, Qt::CaseInsensitive)) { // TODO Plasma 6: Make it case sensitive
return false;
}
}
@ -361,10 +361,10 @@ bool Rules::matchRole(const QString &match_role) const
if (windowrolematch == RegExpMatch && !QRegularExpression(windowrole).match(match_role).hasMatch()) {
return false;
}
if (windowrolematch == ExactMatch && windowrole != match_role) {
if (windowrolematch == ExactMatch && match_role.compare(windowrole, Qt::CaseInsensitive) != 0) { // TODO Plasma 6: Make it case sensitive
return false;
}
if (windowrolematch == SubstringMatch && !match_role.contains(windowrole)) {
if (windowrolematch == SubstringMatch && !match_role.contains(windowrole, Qt::CaseInsensitive)) { // TODO Plasma 6: Make it case sensitive
return false;
}
}
@ -420,7 +420,7 @@ bool Rules::match(const Window *c) const
if (!matchWMClass(c->resourceClass(), c->resourceName())) {
return false;
}
if (!matchRole(c->windowRole().toLower())) {
if (!matchRole(c->windowRole())) {
return false;
}
if (!matchClientMachine(c->clientMachine()->hostName(), c->clientMachine()->isLocal())) {