home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / evbl0627.zip / everblue_20010627.zip / x11 / Xim_LcFlt.c < prev    next >
C/C++ Source or Header  |  1999-11-02  |  3KB  |  91 lines

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