diff options
author | Gatis Paeglis <gatis.paeglis@digia.com> | 2013-05-14 16:08:14 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-20 10:06:04 +0200 |
commit | b8673b8468e997c687450c664e97098d0ed37abf (patch) | |
tree | 8deb0284a11b4c0a14708d0ff2c9d71a95fcee48 /src/plugins/platforms/xcb/qxcbkeyboard.cpp | |
parent | 208e9a2757ae9146e538fffe399c18ee4259a84a (diff) |
Fix ambiguity in shortcut matching
Comparing to the Qt4 implementation, possibleKeys() should skip records
where qtKeys are equal.
Task-number: QTBUG-31132
Change-Id: I2fb073b4dc7291f909cce616f40f7c2491e7cf26
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbkeyboard.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbkeyboard.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 18270d3cd5..155b327315 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -815,27 +815,27 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const xkb_state_update_mask(kb_state, 0, latchedMods, lockedMods, baseLayout, latchedLayout, lockedLayout); - xkb_keysym_t baseKeysym = xkb_state_key_get_one_sym(kb_state, event->nativeScanCode()); - if (baseKeysym == XKB_KEY_NoSymbol) { + xkb_keysym_t sym = xkb_state_key_get_one_sym(kb_state, event->nativeScanCode()); + if (sym == XKB_KEY_NoSymbol) return QList<int>(); - } QList<int> result; - int qtKey = keysymToQtKey(baseKeysym, modifiers, keysymToUnicode(baseKeysym)); - result += (qtKey + modifiers); // The base key is _always_ valid, of course + int baseQtKey = keysymToQtKey(sym, modifiers, keysymToUnicode(sym)); + result += (baseQtKey + modifiers); // The base key is _always_ valid, of course xkb_mod_index_t shiftMod = xkb_keymap_mod_get_index(xkb_keymap, "Shift"); xkb_mod_index_t altMod = xkb_keymap_mod_get_index(xkb_keymap, "Alt"); xkb_mod_index_t controlMod = xkb_keymap_mod_get_index(xkb_keymap, "Control"); - xkb_keysym_t sym; - xkb_mod_mask_t depressed = 0; + xkb_mod_mask_t depressed; + int qtKey = 0; //obtain a list of possible shortcuts for the given key event for (uint i = 1; i < sizeof(ModsTbl) / sizeof(*ModsTbl) ; ++i) { Qt::KeyboardModifiers neededMods = ModsTbl[i]; if ((modifiers & neededMods) == neededMods) { + depressed = 0; if (neededMods & Qt::AltModifier) depressed |= (1 << altMod); if (neededMods & Qt::ShiftModifier) @@ -848,13 +848,16 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const baseLayout, latchedLayout, lockedLayout); sym = xkb_state_key_get_one_sym(kb_state, event->nativeScanCode()); - if (sym == XKB_KEY_NoSymbol || sym == baseKeysym) - continue; + if (sym == XKB_KEY_NoSymbol) + continue; Qt::KeyboardModifiers mods = modifiers & ~neededMods; qtKey = keysymToQtKey(sym, mods, keysymToUnicode(sym)); + + if (qtKey == baseQtKey) + continue; + result += (qtKey + mods); - depressed = 0; } } |