From 86e1305e809343706520cdfa6b4ff0ca5fa9d50b Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Fri, 10 Mar 2023 14:17:35 +0200 Subject: [PATCH] rules: Make wmclass matching case sensitive WM_CLASS is case sensitive. --- autotests/integration/window_rules_test.cpp | 11 +---------- src/rules.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/autotests/integration/window_rules_test.cpp b/autotests/integration/window_rules_test.cpp index aca701b7c8..8ba767854d 100644 --- a/autotests/integration/window_rules_test.cpp +++ b/autotests/integration/window_rules_test.cpp @@ -33,7 +33,6 @@ private Q_SLOTS: void initTestCase(); void init(); void cleanup(); - void testApplyInitialMaximizeVert_data(); void testApplyInitialMaximizeVert(); void testWindowClassChange(); }; @@ -76,14 +75,6 @@ struct XcbConnectionDeleter } }; -void WindowRuleTest::testApplyInitialMaximizeVert_data() -{ - QTest::addColumn("role"); - - QTest::newRow("lowercase") << QByteArrayLiteral("mainwindow"); - QTest::newRow("CamelCase") << QByteArrayLiteral("MainWindow"); -} - void WindowRuleTest::testApplyInitialMaximizeVert() { // this test creates the situation of BUG 367554: creates a window and initial apply maximize vertical @@ -113,7 +104,7 @@ void WindowRuleTest::testApplyInitialMaximizeVert() xcb_icccm_set_wm_normal_hints(c.get(), windowId, &hints); xcb_icccm_set_wm_class(c.get(), windowId, 9, "kpat\0kpat"); - QFETCH(QByteArray, role); + const QByteArray role = QByteArrayLiteral("mainwindow"); xcb_change_property(c.get(), XCB_PROP_MODE_REPLACE, windowId, atoms->wm_window_role, XCB_ATOM_STRING, 8, role.length(), role.constData()); NETWinInfo info(c.get(), windowId, rootWindow(), NET::WMAllProperties, NET::WM2AllProperties); diff --git a/src/rules.cpp b/src/rules.cpp index 38f271e2fa..fc441212e4 100644 --- a/src/rules.cpp +++ b/src/rules.cpp @@ -326,10 +326,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 && cwmclass.compare(wmclass, Qt::CaseInsensitive) != 0) { // TODO Plasma 6: Make it case sensitive + if (wmclassmatch == ExactMatch && cwmclass != wmclass) { return false; } - if (wmclassmatch == SubstringMatch && !cwmclass.contains(wmclass, Qt::CaseInsensitive)) { // TODO Plasma 6: Make it case sensitive + if (wmclassmatch == SubstringMatch && !cwmclass.contains(wmclass)) { return false; } } @@ -342,10 +342,10 @@ bool Rules::matchRole(const QString &match_role) const if (windowrolematch == RegExpMatch && !QRegularExpression(windowrole).match(match_role).hasMatch()) { return false; } - if (windowrolematch == ExactMatch && match_role.compare(windowrole, Qt::CaseInsensitive) != 0) { // TODO Plasma 6: Make it case sensitive + if (windowrolematch == ExactMatch && match_role != windowrole) { return false; } - if (windowrolematch == SubstringMatch && !match_role.contains(windowrole, Qt::CaseInsensitive)) { // TODO Plasma 6: Make it case sensitive + if (windowrolematch == SubstringMatch && !match_role.contains(windowrole)) { return false; } }