Fixed bug #116 - certain characters not working with de keyboard layout

This commit is contained in:
Albert Weichselbraun 2013-11-17 07:48:25 +01:00
parent 4a870f61f1
commit d25e883983
2 changed files with 14 additions and 3 deletions

View File

@ -551,6 +551,9 @@ void AutoTypePlatformX11::ReadKeymap()
m_altgrMask = 0; m_altgrMask = 0;
m_altgrKeysym = NoSymbol; m_altgrKeysym = NoSymbol;
modifiers = XGetModifierMapping(m_dpy); modifiers = XGetModifierMapping(m_dpy);
/* default value, used if we do not find a mapping */
inx_altgr = 3;
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
for (pos = 0; pos < modifiers->max_keypermod; pos++) { for (pos = 0; pos < modifiers->max_keypermod; pos++) {
keycode = modifiers->modifiermap[i * modifiers->max_keypermod + pos]; keycode = modifiers->modifiermap[i * modifiers->max_keypermod + pos];
@ -567,12 +570,18 @@ void AutoTypePlatformX11::ReadKeymap()
m_altgrMask = 0x0101 << i; m_altgrMask = 0x0101 << i;
/* I don't know why, but 0x2000 was required for mod3 on my Linux box */ /* I don't know why, but 0x2000 was required for mod3 on my Linux box */
m_altgrKeysym = keysym; m_altgrKeysym = keysym;
/* set the index of the XGetKeyboardMapping for the AltGr key */
inx_altgr = i;
} }
} else if (keysym == XK_ISO_Level3_Shift) { } else if (keysym == XK_ISO_Level3_Shift) {
/* if no Mode_switch, try to use ISO_Level3_Shift instead */ /* if no Mode_switch, try to use ISO_Level3_Shift instead */
/* however, it may not work as intended - I don't know why */ /* however, it may not work as intended - I don't know why */
m_altgrMask = 1 << i; m_altgrMask = 1 << i;
m_altgrKeysym = keysym; m_altgrKeysym = keysym;
/* set the index of the XGetKeyboardMapping for the AltGr key */
inx_altgr = i;
} }
} }
} }
@ -631,15 +640,15 @@ void AutoTypePlatformX11::SendKeyPressedEvent(KeySym keysym, unsigned int shift)
break; break;
} }
} }
if (!found && m_altgrMask && 3 <= m_keysymPerKeycode) { if (!found && m_altgrMask && inx_altgr + 1 <= m_keysymPerKeycode) {
for (keycode = m_minKeycode; !found && (keycode <= m_maxKeycode); keycode++) { for (keycode = m_minKeycode; !found && (keycode <= m_maxKeycode); keycode++) {
inx = (keycode - m_minKeycode) * m_keysymPerKeycode; inx = (keycode - m_minKeycode) * m_keysymPerKeycode;
if (m_keysymTable[inx + 2] == keysym) { if (m_keysymTable[inx + inx_altgr] == keysym) {
shift &= ~ShiftMask; shift &= ~ShiftMask;
shift |= m_altgrMask; shift |= m_altgrMask;
found = TRUE; found = TRUE;
break; break;
} else if (4 <= m_keysymPerKeycode && m_keysymTable[inx + 3] == keysym) { } else if (inx_altgr + 2 <= m_keysymPerKeycode && m_keysymTable[inx + inx_altgr + 1] == keysym) {
shift |= ShiftMask | m_altgrMask; shift |= ShiftMask | m_altgrMask;
found = TRUE; found = TRUE;
break; break;

View File

@ -98,6 +98,8 @@ private:
int m_altMask; int m_altMask;
int m_metaMask; int m_metaMask;
int m_altgrMask; int m_altgrMask;
/* index of the XGetKeyboardMapping for the AltGr key */
int inx_altgr;
KeySym m_altgrKeysym; KeySym m_altgrKeysym;
}; };