diff --git a/xkb.cpp b/xkb.cpp index 4b99630f84..e21618dab2 100644 --- a/xkb.cpp +++ b/xkb.cpp @@ -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; diff --git a/xkb_qt_mapping.h b/xkb_qt_mapping.h index d927b49374..3c87f4804e 100644 --- a/xkb_qt_mapping.h +++ b/xkb_qt_mapping.h @@ -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; } }