fix Alt+` shortcut on non-US layouts
Make it possible for non-letter-keys with Latin 1 symbols (`, !, @ etc.) to participate in shortcuts also, when the keys generate national symbols on non-Latin layout. For example, in Russian layout, "`" key generates cyrillic "ё" letter of national alphabet, so shortcuts with the key should still work regardless of the actual layout. Fixes: QTBUG-90611 Change-Id: Id9a505210ff33a94b82511b88c30ef79f3d03913 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
parent
cbdce59cd2
commit
62e697fd56
@ -469,7 +469,7 @@ QList<xkb_keysym_t> QXkbCommon::toKeysym(QKeyEvent *event)
|
|||||||
} else if (event->modifiers() & Qt::KeypadModifier) {
|
} else if (event->modifiers() & Qt::KeypadModifier) {
|
||||||
if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
|
if (qtKey >= Qt::Key_0 && qtKey <= Qt::Key_9)
|
||||||
keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
|
keysyms.append(XKB_KEY_KP_0 + (qtKey - Qt::Key_0));
|
||||||
} else if (isLatin(qtKey) && event->text().isUpper()) {
|
} else if (isLatin1(qtKey) && event->text().isUpper()) {
|
||||||
keysyms.append(qtKey);
|
keysyms.append(qtKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -521,7 +521,7 @@ int QXkbCommon::keysymToQtKey(xkb_keysym_t keysym, Qt::KeyboardModifiers modifie
|
|||||||
// With standard shortcuts we should prefer a latin character, this is
|
// With standard shortcuts we should prefer a latin character, this is
|
||||||
// for checks like "some qkeyevent == QKeySequence::Copy" to work even
|
// for checks like "some qkeyevent == QKeySequence::Copy" to work even
|
||||||
// when using for example 'russian' keyboard layout.
|
// when using for example 'russian' keyboard layout.
|
||||||
if (!QXkbCommon::isLatin(keysym)) {
|
if (!QXkbCommon::isLatin1(keysym)) {
|
||||||
xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
|
xkb_keysym_t latinKeysym = QXkbCommon::lookupLatinKeysym(state, code);
|
||||||
if (latinKeysym != XKB_KEY_NoSymbol)
|
if (latinKeysym != XKB_KEY_NoSymbol)
|
||||||
keysym = latinKeysym;
|
keysym = latinKeysym;
|
||||||
@ -544,7 +544,7 @@ static int keysymToQtKey_internal(xkb_keysym_t keysym, Qt::KeyboardModifiers mod
|
|||||||
} else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
|
} else if (keysym >= XKB_KEY_KP_0 && keysym <= XKB_KEY_KP_9) {
|
||||||
// numeric keypad keys
|
// numeric keypad keys
|
||||||
qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
|
qtKey = Qt::Key_0 + (keysym - XKB_KEY_KP_0);
|
||||||
} else if (QXkbCommon::isLatin(keysym)) {
|
} else if (QXkbCommon::isLatin1(keysym)) {
|
||||||
qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
|
qtKey = QXkbCommon::qxkbcommon_xkb_keysym_to_upper(keysym);
|
||||||
} else {
|
} else {
|
||||||
// check if we have a direct mapping
|
// check if we have a direct mapping
|
||||||
@ -677,7 +677,7 @@ QList<int> QXkbCommon::possibleKeys(xkb_state *state, const QKeyEvent *event,
|
|||||||
Qt::KeyboardModifiers neededMods = ModsTbl[i];
|
Qt::KeyboardModifiers neededMods = ModsTbl[i];
|
||||||
if ((modifiers & neededMods) == neededMods) {
|
if ((modifiers & neededMods) == neededMods) {
|
||||||
if (i == 8) {
|
if (i == 8) {
|
||||||
if (isLatin(baseQtKey))
|
if (isLatin1(baseQtKey))
|
||||||
continue;
|
continue;
|
||||||
// add a latin key as a fall back key
|
// add a latin key as a fall back key
|
||||||
sym = lookupLatinKeysym(state, keycode);
|
sym = lookupLatinKeysym(state, keycode);
|
||||||
@ -732,7 +732,7 @@ void QXkbCommon::verifyHasLatinLayout(xkb_keymap *keymap)
|
|||||||
for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
|
for (xkb_layout_index_t layout = 0; layout < layoutCount; ++layout) {
|
||||||
for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
|
for (xkb_keycode_t code = minKeycode; code < maxKeycode; ++code) {
|
||||||
xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
|
xkb_keymap_key_get_syms_by_level(keymap, code, layout, 0, &keysyms);
|
||||||
if (keysyms && isLatin(keysyms[0]))
|
if (keysyms && isLatin1(keysyms[0]))
|
||||||
nrLatinKeys++;
|
nrLatinKeys++;
|
||||||
if (nrLatinKeys > 10) // arbitrarily chosen threshold
|
if (nrLatinKeys > 10) // arbitrarily chosen threshold
|
||||||
return;
|
return;
|
||||||
@ -765,7 +765,7 @@ xkb_keysym_t QXkbCommon::lookupLatinKeysym(xkb_state *state, xkb_keycode_t keyco
|
|||||||
xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
|
xkb_level_index_t level = xkb_state_key_get_level(state, keycode, layout);
|
||||||
if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
|
if (xkb_keymap_key_get_syms_by_level(keymap, keycode, layout, level, &syms) != 1)
|
||||||
continue;
|
continue;
|
||||||
if (isLatin(syms[0])) {
|
if (isLatin1(syms[0])) {
|
||||||
sym = syms[0];
|
sym = syms[0];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -94,8 +94,8 @@ public:
|
|||||||
static void verifyHasLatinLayout(xkb_keymap *keymap);
|
static void verifyHasLatinLayout(xkb_keymap *keymap);
|
||||||
static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
|
static xkb_keysym_t lookupLatinKeysym(xkb_state *state, xkb_keycode_t keycode);
|
||||||
|
|
||||||
static bool isLatin(xkb_keysym_t sym) {
|
static bool isLatin1(xkb_keysym_t sym) {
|
||||||
return ((sym >= 'a' && sym <= 'z') || (sym >= 'A' && sym <= 'Z'));
|
return sym <= 0xff;
|
||||||
}
|
}
|
||||||
static bool isKeypad(xkb_keysym_t sym) {
|
static bool isKeypad(xkb_keysym_t sym) {
|
||||||
return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
|
return sym >= XKB_KEY_KP_Space && sym <= XKB_KEY_KP_9;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user