Fix Meta+... shortcuts on XCB
If the window contains a widget that accepts text input, a Meta+... shortcut will be interpreted as if no modifier was pressed. This fix enables the usage of Meta+... shortcuts for the XCB platform plugin. Change-Id: I80034b7e6bbbf18471c86fc77320d5038f5740be Task-number: QTBUG-43572 Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org> Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: David Edmundson <davidedmundson@kde.org> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
parent
b444769840
commit
0d990b9ca1
@ -933,7 +933,7 @@ xkb_keysym_t QXcbKeyboard::lookupLatinKeysym(xkb_keycode_t keycode) const
|
|||||||
QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
|
QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
|
||||||
{
|
{
|
||||||
// turn off the modifier bits which doesn't participate in shortcuts
|
// turn off the modifier bits which doesn't participate in shortcuts
|
||||||
Qt::KeyboardModifiers notNeeded = Qt::MetaModifier | Qt::KeypadModifier | Qt::GroupSwitchModifier;
|
Qt::KeyboardModifiers notNeeded = Qt::KeypadModifier | Qt::GroupSwitchModifier;
|
||||||
Qt::KeyboardModifiers modifiers = event->modifiers() &= ~notNeeded;
|
Qt::KeyboardModifiers modifiers = event->modifiers() &= ~notNeeded;
|
||||||
// create a fresh kb state and test against the relevant modifier combinations
|
// create a fresh kb state and test against the relevant modifier combinations
|
||||||
struct xkb_state *kb_state = xkb_state_new(xkb_keymap);
|
struct xkb_state *kb_state = xkb_state_new(xkb_keymap);
|
||||||
@ -963,10 +963,12 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
|
|||||||
xkb_mod_index_t shiftMod = xkb_keymap_mod_get_index(xkb_keymap, "Shift");
|
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 altMod = xkb_keymap_mod_get_index(xkb_keymap, "Alt");
|
||||||
xkb_mod_index_t controlMod = xkb_keymap_mod_get_index(xkb_keymap, "Control");
|
xkb_mod_index_t controlMod = xkb_keymap_mod_get_index(xkb_keymap, "Control");
|
||||||
|
xkb_mod_index_t metaMod = xkb_keymap_mod_get_index(xkb_keymap, "Meta");
|
||||||
|
|
||||||
Q_ASSERT(shiftMod < 32);
|
Q_ASSERT(shiftMod < 32);
|
||||||
Q_ASSERT(altMod < 32);
|
Q_ASSERT(altMod < 32);
|
||||||
Q_ASSERT(controlMod < 32);
|
Q_ASSERT(controlMod < 32);
|
||||||
|
Q_ASSERT(metaMod < 32);
|
||||||
|
|
||||||
xkb_mod_mask_t depressed;
|
xkb_mod_mask_t depressed;
|
||||||
int qtKey = 0;
|
int qtKey = 0;
|
||||||
@ -987,6 +989,8 @@ QList<int> QXcbKeyboard::possibleKeys(const QKeyEvent *event) const
|
|||||||
depressed |= (1 << shiftMod);
|
depressed |= (1 << shiftMod);
|
||||||
if (neededMods & Qt::ControlModifier)
|
if (neededMods & Qt::ControlModifier)
|
||||||
depressed |= (1 << controlMod);
|
depressed |= (1 << controlMod);
|
||||||
|
if (neededMods & Qt::MetaModifier)
|
||||||
|
depressed |= (1 << metaMod);
|
||||||
xkb_state_update_mask(kb_state, depressed, latchedMods, lockedMods, 0, 0, lockedLayout);
|
xkb_state_update_mask(kb_state, depressed, latchedMods, lockedMods, 0, 0, lockedLayout);
|
||||||
sym = xkb_state_key_get_one_sym(kb_state, keycode);
|
sym = xkb_state_key_get_one_sym(kb_state, keycode);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user