From e09f0d227fbf95b6252759af9d426efd57686f9f Mon Sep 17 00:00:00 2001 From: Theppitak Karoonboonyanan Date: Thu, 9 Apr 2009 11:47:55 +0700 Subject: [PATCH] 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 Signed-off-by: Theppitak Karoonboonyanan Signed-off-by: Julien Cristau --- modules/im/ximcp/imThaiFlt.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/im/ximcp/imThaiFlt.c b/modules/im/ximcp/imThaiFlt.c index 368ea5cc..42a30d72 100644 --- a/modules/im/ximcp/imThaiFlt.c +++ b/modules/im/ximcp/imThaiFlt.c @@ -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) ||