Commit 514a95f1 authored by Roman Gilg's avatar Roman Gilg
Browse files

Set Qt::KeypadModifier depending on current keysym

Summary:
The Qt::KeypadModifier should only accompany a keysym when this specific keysym
originates from the keypad not in general for every keysym while numlock is
engaged.

BUG: 400658
FIXED-IN: 5.18.0

Test Plan: Manually with the Thumbnail Grid task switcher and numlock enabled.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26283
parent 1e3128b0
......@@ -369,7 +369,7 @@ void Xkb::updateModifiers()
if (xkb_state_mod_index_is_active(m_state, m_metaModifier, XKB_STATE_MODS_EFFECTIVE) == 1) {
mods |= Qt::MetaModifier;
}
if (xkb_state_mod_index_is_active(m_state, m_numModifier, XKB_STATE_MODS_EFFECTIVE) == 1) {
if (isKeypadKey(m_keysym)) {
mods |= Qt::KeypadModifier;
}
m_modifiers = mods;
......
......@@ -273,6 +273,11 @@ static inline Qt::Key xkbToQtKey(xkb_keysym_t keySym)
return key;
}
static inline bool isKeypadKey(xkb_keysym_t keySym)
{
return keySym >= XKB_KEY_KP_Space && keySym <= XKB_KEY_KP_9;
}
static inline xkb_keysym_t qtKeyToXkb(Qt::Key qtKey, Qt::KeyboardModifiers modifiers)
{
xkb_keysym_t sym = XKB_KEY_NoSymbol;
......@@ -298,11 +303,11 @@ static inline xkb_keysym_t qtKeyToXkb(Qt::Key qtKey, Qt::KeyboardModifiers modif
for (auto match : possibleMatches) {
// is the current match better than existing?
if (modifiers.testFlag(Qt::KeypadModifier)) {
if (match >= XKB_KEY_KP_Space && match <= XKB_KEY_KP_9) {
if (isKeypadKey(match)) {
sym = match;
}
} else {
if (sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9) {
if (isKeypadKey(sym)) {
sym = match;
}
}
......
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