diff --git a/autotests/integration/globalshortcuts_test.cpp b/autotests/integration/globalshortcuts_test.cpp --- a/autotests/integration/globalshortcuts_test.cpp +++ b/autotests/integration/globalshortcuts_test.cpp @@ -174,7 +174,7 @@ // 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 @@ 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.h b/keyboard_input.h --- a/keyboard_input.h +++ b/keyboard_input.h @@ -65,7 +65,7 @@ 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; diff --git a/keyboard_input.cpp b/keyboard_input.cpp --- a/keyboard_input.cpp +++ b/keyboard_input.cpp @@ -449,7 +449,18 @@ 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 @@ 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);