diff --git a/autotests/integration/globalshortcuts_test.cpp b/autotests/integration/globalshortcuts_test.cpp index f3968369cb..441822e27d 100644 --- a/autotests/integration/globalshortcuts_test.cpp +++ b/autotests/integration/globalshortcuts_test.cpp @@ -174,7 +174,7 @@ void GlobalShortcutsTest::testMetaShiftW() // BUG 370341 QScopedPointer action(new QAction(nullptr)); action->setProperty("componentName", QStringLiteral(KWIN_NAME)); - action->setObjectName(QStringLiteral("globalshortcuts-test-consumed-shift")); + action->setObjectName(QStringLiteral("globalshortcuts-test-meta-shift-w")); QSignalSpy triggeredSpy(action.data(), &QAction::triggered); QVERIFY(triggeredSpy.isValid()); KGlobalAccel::self()->setShortcut(action.data(), QList{Qt::META + Qt::SHIFT + Qt::Key_W}, KGlobalAccel::NoAutoloading); @@ -187,7 +187,6 @@ void GlobalShortcutsTest::testMetaShiftW() kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTSHIFT, timestamp++); QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier | Qt::MetaModifier); kwinApp()->platform()->keyboardKeyPressed(KEY_W, timestamp++); - QEXPECT_FAIL("", "BUG 370341", Continue); QTRY_COMPARE(triggeredSpy.count(), 1); kwinApp()->platform()->keyboardKeyReleased(KEY_W, timestamp++); diff --git a/keyboard_input.cpp b/keyboard_input.cpp index 52c50df46e..bb6b37739e 100644 --- a/keyboard_input.cpp +++ b/keyboard_input.cpp @@ -449,7 +449,18 @@ Qt::KeyboardModifiers Xkb::modifiersRelevantForGlobalShortcuts() const return mods; } - return mods & ~m_consumedModifiers; + Qt::KeyboardModifiers consumedMods = m_consumedModifiers; + if ((mods & Qt::ShiftModifier) && (consumedMods == Qt::ShiftModifier)) { + // test whether current keysym is a letter + // in that case the shift should be removed from the consumed modifiers again + // otherwise it would not be possible to trigger e.g. Shift+W as a shortcut + // see BUG: 370341 + if (QChar(toQtKey(m_keysym)).isLetter()) { + consumedMods = Qt::KeyboardModifiers(); + } + } + + return mods & ~consumedMods; } xkb_keysym_t Xkb::toKeysym(uint32_t key) @@ -473,7 +484,7 @@ QString Xkb::toString(xkb_keysym_t keysym) return QString::fromUtf8(byteArray.constData()); } -Qt::Key Xkb::toQtKey(xkb_keysym_t keysym) +Qt::Key Xkb::toQtKey(xkb_keysym_t keysym) const { int key = Qt::Key_unknown; KKeyServer::symXToKeyQt(keysym, &key); diff --git a/keyboard_input.h b/keyboard_input.h index 69b35b5592..5b3e6d074e 100644 --- a/keyboard_input.h +++ b/keyboard_input.h @@ -65,7 +65,7 @@ public: return m_keysym; } QString toString(xkb_keysym_t keysym); - Qt::Key toQtKey(xkb_keysym_t keysym); + Qt::Key toQtKey(xkb_keysym_t keysym) const; Qt::KeyboardModifiers modifiers() const; Qt::KeyboardModifiers modifiersRelevantForGlobalShortcuts() const; bool shouldKeyRepeat(quint32 key) const;