Commit 78a2732a authored by Martin Flöser's avatar Martin Flöser
Browse files

Fix shortcut triggering with shift+letter

A shortcut with e.g. shift+w could not be triggered as shift is
considered as consumed. It transforms the keysym to an uppercase variant
thus it is consumed.

This change checks for the condition that shift is pressed and is the
only consumed modifier. If the current keysym is a letter the shift is
removed from the consumed modifier again to still support the shortcut.

BUG: 370341
FIXED-IN: 5.8.2

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision:
parent db95b968
......@@ -174,7 +174,7 @@ void GlobalShortcutsTest::testMetaShiftW()
// BUG 370341
QScopedPointer<QAction> action(new QAction(nullptr));
action->setProperty("componentName", QStringLiteral(KWIN_NAME));
QSignalSpy triggeredSpy(, &QAction::triggered);
KGlobalAccel::self()->setShortcut(, QList<QKeySequence>{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++);
......@@ -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);
......@@ -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;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment