imLcFlt.c revision 57f47464
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 Bool braille = False; 49 50 if(ev->xkey.keycode == 0) 51 return (False); 52 53 XLookupString((XKeyEvent *)ev, buf, sizeof(buf), &keysym, NULL); 54 55 if(IsModifierKey(keysym)) 56 return (False); 57 58 if(keysym >= XK_braille_dot_1 && keysym <= XK_braille_dot_8) { 59 if(ev->type == KeyPress) { 60 ic->private.local.brl_pressed |= 61 1<<(keysym-XK_braille_dot_1); 62 return(True); 63 } else { 64 if(!ic->private.local.brl_committing 65 || ev->xkey.time - ic->private.local.brl_release_start > 300) { 66 ic->private.local.brl_committing = ic->private.local.brl_pressed; 67 ic->private.local.brl_release_start = ev->xkey.time; 68 } 69 ic->private.local.brl_pressed &= ~(1<<(keysym-XK_braille_dot_1)); 70 if(!ic->private.local.brl_pressed && ic->private.local.brl_committing) { 71 /* Commited a braille pattern, let it go through compose tree */ 72 keysym = XK_braille_blank | ic->private.local.brl_committing; 73 ev->type = KeyPress; 74 braille = True; 75 } else { 76 return(True); 77 } 78 } 79 } 80 81 if( (ev->type != KeyPress) 82 || (((Xim)ic->core.im)->private.local.top == 0 ) ) 83 goto emit_braille; 84 85 for(t = ic->private.local.context; t; t = b[t].next) { 86 if(((ev->xkey.state & b[t].modifier_mask) == b[t].modifier) && 87 (keysym == b[t].keysym)) 88 break; 89 } 90 91 if(t) { /* Matched */ 92 if(b[t].succession) { /* Intermediate */ 93 ic->private.local.context = b[t].succession; 94 return(True); 95 } else { /* Terminate (reached to leaf) */ 96 ic->private.local.composed = t; 97 ic->private.local.brl_committed = 0; 98 /* return back to client KeyPressEvent keycode == 0 */ 99 ev->xkey.keycode = 0; 100 XPutBackEvent(d, ev); 101 /* initialize internal state for next key sequence */ 102 ic->private.local.context = ((Xim)ic->core.im)->private.local.top; 103 return(True); 104 } 105 } else { /* Unmatched */ 106 if(ic->private.local.context == ((Xim)ic->core.im)->private.local.top) { 107 goto emit_braille; 108 } 109 /* Error (Sequence Unmatch occured) */ 110 /* initialize internal state for next key sequence */ 111 ic->private.local.context = ((Xim)ic->core.im)->private.local.top; 112 return(True); 113 } 114 115emit_braille: 116 if(braille) { 117 /* Braille pattern is not in compose tree, emit alone */ 118 ic->private.local.brl_committed = ic->private.local.brl_committing; 119 ic->private.local.composed = 0; 120 ev->xkey.keycode = 0; 121 _XPutBackEvent(d, ev); 122 return(True); 123 } 124 return(False); 125} 126