imLcFlt.c revision b4ee4795
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#define NEED_EVENTS 33#ifdef HAVE_CONFIG_H 34#include <config.h> 35#endif 36#include "Xlibint.h" 37#include <X11/keysym.h> 38#include "Xlcint.h" 39#include "Ximint.h" 40 41Bool 42_XimLocalFilter(Display *d, Window w, XEvent *ev, XPointer client_data) 43{ 44 Xic ic = (Xic)client_data; 45 KeySym keysym; 46 static char buf[256]; 47 DefTree *b = ic->private.local.base.tree; 48 DTIndex t; 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 } else { 63 if(!ic->private.local.brl_committing 64 || ev->xkey.time - ic->private.local.brl_release_start > 300) { 65 ic->private.local.brl_committing = ic->private.local.brl_pressed; 66 ic->private.local.brl_release_start = ev->xkey.time; 67 } 68 ic->private.local.brl_pressed &= ~(1<<(keysym-XK_braille_dot_1)); 69 if(!ic->private.local.brl_pressed) { 70 if(ic->private.local.brl_committing) { 71 ic->private.local.brl_committed = 72 ic->private.local.brl_committing; 73 ic->private.local.composed = 0; 74 ev->type = KeyPress; 75 ev->xkey.keycode = 0; 76 _XPutBackEvent(d, ev); 77 } 78 } 79 } 80 return(True); 81 } 82 83 if( (ev->type != KeyPress) 84 || (((Xim)ic->core.im)->private.local.top == 0 ) ) 85 return(False); 86 87 for(t = ic->private.local.context; t; t = b[t].next) { 88 if(((ev->xkey.state & b[t].modifier_mask) == b[t].modifier) && 89 (keysym == b[t].keysym)) 90 break; 91 } 92 93 if(t) { /* Matched */ 94 if(b[t].succession) { /* Intermediate */ 95 ic->private.local.context = b[t].succession; 96 return(True); 97 } else { /* Terminate (reached to leaf) */ 98 ic->private.local.composed = t; 99 ic->private.local.brl_committed = 0; 100 /* return back to client KeyPressEvent keycode == 0 */ 101 ev->xkey.keycode = 0; 102 XPutBackEvent(d, ev); 103 /* initialize internal state for next key sequence */ 104 ic->private.local.context = ((Xim)ic->core.im)->private.local.top; 105 return(True); 106 } 107 } else { /* Unmatched */ 108 if(ic->private.local.context == ((Xim)ic->core.im)->private.local.top) { 109 return(False); 110 } 111 /* Error (Sequence Unmatch occured) */ 112 /* initialize internal state for next key sequence */ 113 ic->private.local.context = ((Xim)ic->core.im)->private.local.top; 114 return(True); 115 } 116} 117