Thai XIM not filters when NumLock or CapsLock is on

The Thai XIM component in libx11 activated on 'th*' locales normally filters
input sequence according to orthographic rules. However, when NumLock/CapsLock
is on, this stops working. All sequences are passed through.

This is caused by missing masks in _XimThaiFilter(), which normally screens out
certain special keys from entering orthographic rules. Unfortunately, this
included events with NumLock/CapsLock on. Negating the masks from the check
allows the events to be tested by the rules.

X.Org Bug 12517 <http://bugs.freedesktop.org/show_bug.cgi?id=12517>

Signed-off-by: Theppitak Karoonboonyanan <thep@linux.thai.net>
Signed-off-by: Julien Cristau <jcristau@debian.org>
This commit is contained in:
Theppitak Karoonboonyanan 2009-04-09 11:47:55 +07:00 committed by Julien Cristau
parent d108d3c706
commit e09f0d227f

View file

@ -1236,6 +1236,22 @@ ThaiFltReplaceInput(Xic ic, unsigned char new_char, KeySym symbol)
return True;
}
Private unsigned
NumLockMask(Display *d)
{
int i;
XModifierKeymap *map = XGetModifierMapping (d);
KeyCode numlock_keycode = XKeysymToKeycode (d, XK_Num_Lock);
if (numlock_keycode == NoSymbol)
return 0;
for (i = 0; i < 8; i++) {
if (map->modifiermap[map->max_keypermod * i] == numlock_keycode)
return 1 << i;
}
return 0;
}
/*
* Filter function for TACTIS
*/
@ -1267,7 +1283,7 @@ _XimThaiFilter(Display *d, Window w, XEvent *ev, XPointer client_data)
XwcLookupString((XIC)ic, &ev->xkey, wbuf, sizeof(wbuf) / sizeof(wbuf[0]),
&symbol, NULL);
if ((ev->xkey.state & (AllMods & ~ShiftMask)) ||
if ((ev->xkey.state & (AllMods & ~(ShiftMask|LockMask|NumLockMask(d)))) ||
((symbol >> 8 == 0xFF) &&
((XK_BackSpace <= symbol && symbol <= XK_Clear) ||
(symbol == XK_Return) ||