Fix a bug in the T34039 hack in case when a modifier key is not mapped.

In order to recover from a transient Focus Out - Focus In disruption
in the middle of a shortcut, which can be caused by certain window
managers, Blender has code that checks which modifier keys are pressed
after Focus In and restores the modifier state based on that.

If one of the Ctrl, Shift, Alt, Super keys is not mapped anywhere
in the active keyboard layout, XKeysymToKeycode returns the invalid
zero keycode, and reading the key state produces garbage, which can
cause an invalid modifier state. Check the return value to avoid this.
This commit is contained in:
Alexander Gavrilov 2019-11-16 11:56:38 +03:00
parent e5b788bad8
commit e385bdb228

@ -700,7 +700,7 @@ bool GHOST_SystemX11::processEvents(bool waitForEvent)
for (int i = 0; i < (sizeof(modifiers) / sizeof(*modifiers)); i++) {
KeyCode kc = XKeysymToKeycode(m_display, modifiers[i]);
if (((xevent.xkeymap.key_vector[kc >> 3] >> (kc & 7)) & 1) != 0) {
if (kc != 0 && ((xevent.xkeymap.key_vector[kc >> 3] >> (kc & 7)) & 1) != 0) {
pushEvent(new GHOST_EventKey(getMilliSeconds(),
GHOST_kEventKeyDown,
window,