Fix T47300: SHIFT TAB, CTRL SHIFT TAB shortcuts does not toggle snap, snap mode on off anymore.

Regression from rB12c71508c2d7.

Now, we systematically first try keycode from `XLookupKeysym()`, and only fall back to
the one from `XLookupString()` if it failed to convert to a valid gkey.
This commit is contained in:
Bastien Montagne 2016-02-02 21:27:33 +01:00
parent e3f48bdb48
commit b80c07321b
Notes: blender-bot 2023-02-14 08:15:59 +01:00
Referenced by issue #47304, Loop selection alt shift
Referenced by issue #47300, SHIFT TAB, CTRL SHIFT TAB shortcuts does not toggle snap, snap mode on off anymore.
1 changed files with 10 additions and 7 deletions

View File

@ -765,7 +765,8 @@ GHOST_SystemX11::processEvent(XEvent *xe)
case KeyRelease:
{
XKeyEvent *xke = &(xe->xkey);
KeySym key_sym = 0;
KeySym key_sym;
KeySym key_sym_str;
char ascii;
#if defined(WITH_X11_XINPUT) && defined(X_HAVE_UTF8_STRING)
/* utf8_array[] is initial buffer used for Xutf8LookupString().
@ -810,18 +811,20 @@ GHOST_SystemX11::processEvent(XEvent *xe)
if ((xke->keycode >= 10 && xke->keycode < 20)) {
key_sym = XLookupKeysym(xke, ShiftMask);
if (!((key_sym >= XK_0) && (key_sym <= XK_9))) {
key_sym = XLookupKeysym(xke, 0);
}
if (!((key_sym >= XK_0) && (key_sym <= XK_9))) {
key_sym = 0; /* Get current-keymap valid key_sym. */
key_sym = XLookupKeysym(xke, 0);
}
}
else {
key_sym = XLookupKeysym(xke, 0);
}
if (!XLookupString(xke, &ascii, 1, (key_sym == 0) ? &key_sym : NULL, NULL)) {
if (!XLookupString(xke, &ascii, 1, &key_sym_str, NULL)) {
ascii = '\0';
}
gkey = convertXKey(key_sym);
if ((gkey = convertXKey(key_sym)) == GHOST_kKeyUnknown) {
gkey = convertXKey(key_sym_str);
}
#else
/* In keyboards like latin ones,
* numbers needs a 'Shift' to be accessed but key_sym