imLcFlt.c revision e9fcaa8a
1/****************************************************************** 2 3 Copyright 1992 by Fuji Xerox Co., Ltd. 4 Copyright 1992, 1994 by FUJITSU LIMITED 5 6Permission to use, copy, modify, distribute, and sell this software 7and its documentation for any purpose is hereby granted without fee, 8provided that the above copyright notice appear in all copies and 9that both that copyright notice and this permission notice appear 10in supporting documentation, and that the name of Fuji Xerox, 11FUJITSU LIMITED not be used in advertising or publicity pertaining 12to distribution of the software without specific, written prior 13permission. Fuji Xerox, FUJITSU LIMITED make no representations 14about the suitability of this software for any purpose. 15It is provided "as is" without express or implied warranty. 16 17FUJI XEROX, FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH 18REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF 19MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJI XEROX, 20FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 21DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA 22OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 23TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 24PERFORMANCE OF THIS SOFTWARE. 25 26 Author : Kazunori Nishihara Fuji Xerox 27 Modifier : Takashi Fujiwara FUJITSU LIMITED 28 fujiwara@a80.tech.yk.fujitsu.co.jp 29 30******************************************************************/ 31 32#ifdef HAVE_CONFIG_H 33#include <config.h> 34#endif 35#include "Xlibint.h" 36#include <X11/keysym.h> 37#include "Xlcint.h" 38#include "Ximint.h" 39 40Bool 41_XimLocalFilter(Display *d, Window w, XEvent *ev, XPointer client_data) 42{ 43 Xic ic = (Xic)client_data; 44 KeySym keysym; 45 static char buf[256]; 46 DefTree *b = ic->private.local.base.tree; 47 DTIndex t; 48 49 if(ev->xkey.keycode == 0) 50 return (False); 51 52 XLookupString((XKeyEvent *)ev, buf, sizeof(buf), &keysym, NULL); 53 54 if(IsModifierKey(keysym)) 55 return (False); 56 57 if(keysym >= XK_braille_dot_1 && keysym <= XK_braille_dot_8) { 58 if(ev->type == KeyPress) { 59 ic->private.local.brl_pressed |= 60 1<<(keysym-XK_braille_dot_1); 61 } else { 62 if(!ic->private.local.brl_committing 63 || ev->xkey.time - ic->private.local.brl_release_start > 300) { 64 ic->private.local.brl_committing = ic->private.local.brl_pressed; 65 ic->private.local.brl_release_start = ev->xkey.time; 66 } 67 ic->private.local.brl_pressed &= ~(1<<(keysym-XK_braille_dot_1)); 68 if(!ic->private.local.brl_pressed) { 69 if(ic->private.local.brl_committing) { 70 ic->private.local.brl_committed = 71 ic->private.local.brl_committing; 72 ic->private.local.composed = 0; 73 ev->type = KeyPress; 74 ev->xkey.keycode = 0; 75 _XPutBackEvent(d, ev); 76 } 77 } 78 } 79 return(True); 80 } 81 82 if( (ev->type != KeyPress) 83 || (((Xim)ic->core.im)->private.local.top == 0 ) ) 84 return(False); 85 86 for(t = ic->private.local.context; t; t = b[t].next) { 87 if(((ev->xkey.state & b[t].modifier_mask) == b[t].modifier) && 88 (keysym == b[t].keysym)) 89 break; 90 } 91 92 if(t) { /* Matched */ 93 if(b[t].succession) { /* Intermediate */ 94 ic->private.local.context = b[t].succession; 95 return(True); 96 } else { /* Terminate (reached to leaf) */ 97 ic->private.local.composed = t; 98 ic->private.local.brl_committed = 0; 99 /* return back to client KeyPressEvent keycode == 0 */ 100 ev->xkey.keycode = 0; 101 XPutBackEvent(d, ev); 102 /* initialize internal state for next key sequence */ 103 ic->private.local.context = ((Xim)ic->core.im)->private.local.top; 104 return(True); 105 } 106 } else { /* Unmatched */ 107 if(ic->private.local.context == ((Xim)ic->core.im)->private.local.top) { 108 return(False); 109 } 110 /* Error (Sequence Unmatch occured) */ 111 /* initialize internal state for next key sequence */ 112 ic->private.local.context = ((Xim)ic->core.im)->private.local.top; 113 return(True); 114 } 115} 116