From b8a59d0bd9ac7c57fe0f4d66164cbec3fa3d4fbe Mon Sep 17 00:00:00 2001 From: Yifan Zhu Date: Sun, 10 Mar 2024 16:52:51 -0700 Subject: [PATCH] plugins/buttonrebinds: choose keysym based on KeypadModifier status Use keysyms from the keypad if and only if KeypadModifier is set. --- src/plugins/buttonrebinds/buttonrebindsfilter.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/buttonrebinds/buttonrebindsfilter.cpp b/src/plugins/buttonrebinds/buttonrebindsfilter.cpp index 8e3d2905da..2feb0c751c 100644 --- a/src/plugins/buttonrebinds/buttonrebindsfilter.cpp +++ b/src/plugins/buttonrebinds/buttonrebindsfilter.cpp @@ -301,7 +301,16 @@ bool ButtonRebindsFilter::sendKeySequence(const QKeySequence &keys, bool pressed } QKeyEvent ev(QEvent::KeyPress, keys[0] & ~Qt::KeyboardModifierMask, Qt::NoModifier); - const QList syms(QXkbCommon::toKeysym(&ev)); + QList syms(QXkbCommon::toKeysym(&ev)); + // Use keysyms from the keypad if and only if KeypadModifier is set + syms.erase(std::remove_if(syms.begin(), syms.end(), [keys](int sym) { + bool onKeyPad = sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_Equal; + if (keys[0] & Qt::KeypadModifier) { + return !onKeyPad; + } else { + return onKeyPad; + } + }), syms.end()); if (syms.empty()) { qCWarning(KWIN_BUTTONREBINDS) << "Could not convert" << keys << "to keysym"; return false;