Back to index

im-sdk  12.3.91
Classes | Defines | Typedefs | Enumerations | Functions
composeIM.h File Reference
#include <X11/Xlib.h>
#include "XIMProto.h"
#include "XimpIm.h"
#include "commonIM.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DefTree
struct  _LuRange
struct  _AttribList
struct  _LocalIMState
struct  _XIMComposeIMRec
struct  _XICComposeIMRec
union  _AttribList._attr_u
struct  _AttribList._attr_u.CIstruct
struct  _AttribList._attr_u.LUstruct

Defines

#define XIMP_40
#define COMPOSE_FILE   "Compose"
#define SET_KEYCODEINFO(s)   ((s)->use_keycodeinfo = True)
#define USE_KEYCODEINFO(s)   ((s)->use_keycodeinfo == True)
#define BCF_HDR_SIZE   72
#define BCF_HDR_SIGNATURE   0xffff
#define BCF_HDR_PLATFORM_MSB   0x0000
#define BCF_HDR_PLATFORM_LSB   0x0101
#define BCF_HDR_PLATFORM_UNKNOWN   0x0202
#define BCF_HDR_VERSION   0x0100
#define BCF_HDR_VENDER_STRING   "Sun Microsystems, Inc."
#define BCF_HDR_VENDER_STRING_LEN   64
#define BCF_STATE_SIZE   3
#define BCF_STATE_PTR(b)   (CARD32 *)((CARD8 *)b + BCF_HDR_SIZE)
#define BCF_STATE_LENGTH(p)   (*(CARD32 *)p)
#define BCF_STATE_NAME(p, i)   (*((CARD32 *)p + BCF_STATE_SIZE * (i-1) + 1))
#define BCF_STATE_USE_KEYCODE(p, i)   (*((CARD32 *)p + BCF_STATE_SIZE * (i-1) + 2))
#define BCF_STATE_PARSER(p, i)   (*((CARD32 *)p + BCF_STATE_SIZE * (i-1) + 3))
#define BCF_DEF_SIZE   9
#define BCF_DEF_PTR(b)   (BCF_STATE_PTR(b) + 1 + BCF_STATE_SIZE * BCF_STATE_LENGTH(BCF_STATE_PTR(b)))
#define BCF_DEF_LENGTH(p)   (*(CARD32 *)p)
#define BCF_DEF_NEXT(p, i)   (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 1))
#define BCF_DEF_SUCCESSION(p, i)   (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 2))
#define BCF_DEF_MODIFIER_MASK(p, i)   (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 3))
#define BCF_DEF_MODIFIER(p, i)   (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 4))
#define BCF_DEF_KEYSYM(p, i)   (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 5))
#define BCF_DEF_KEYCODE(p, i)   (*((INT32 *)p + BCF_DEF_SIZE * (i-1) + 6))
#define BCF_DEF_MB(p, i)   (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 7))
#define BCF_DEF_KEYSYM_RETURN(p, i)   (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 8))
#define BCF_DEF_TARGET(p, i)   (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 9))
#define BCF_STR_PTR(b)   (CARD8 *)(BCF_DEF_PTR(b) + 1 + BCF_DEF_SIZE * BCF_DEF_LENGTH(BCF_DEF_PTR(b)))
#define BCF_STR_LENGTH(p)   (*(CARD32 *)p)
#define BCF_STR_STRING(p, i)   (char *)((CARD8 *)p + i + 3)

Typedefs

typedef struct _DefTree DefTree
typedef struct _LuRange LuRange
typedef struct _AttribList StateAttrib
typedef struct _LocalIMState LocalIMState
typedef struct _XIMComposeIMRec XIMComposeIMRec
typedef struct _XICComposeIMRec XICComposeIMRec

Enumerations

enum  ActionType {
  NoAction, SwitchTo, NextPage, PrevPage,
  TopPage, LastPage, NextCand, PrevCand,
  UpCand, DownCand, SelectCand, DoLookup,
  DoConv
}
enum  StateType { ComposeState, CodeInputState, LookupState, RemoteIMState }
enum  InputType { HEX, OCTET }

Functions

Status COMPOSE_OpenIM_SWITCH (XIM xim, XLCd lcd)
Status COMPOSE_CreateIC_SWITCH (XIC xic, XIMArg *arg)
Bool Ximp_Local_KeyFilter (Display *d, Window w, XEvent *ev, XPointer client_data)
XICMethods get_local_ic_methods ()

Class Documentation

struct _DefTree

Definition at line 71 of file composeIM.h.

Collaboration diagram for _DefTree:
Class Members
ActionType action
int keycode
KeySym keysym
KeySym keysym_return
char * mb
unsigned modifier
unsigned modifier_mask
struct _DefTree * next
struct _DefTree * succession
struct _LocalIMState * target
char * target_name
struct _LuRange

Definition at line 98 of file composeIM.h.

Class Members
int end_range
char RangeName
int start_range
struct _AttribList

Definition at line 104 of file composeIM.h.

Class Members
union _AttribList _attr_u
struct _LocalIMState

Definition at line 158 of file composeIM.h.

Collaboration diagram for _LocalIMState:
Class Members
Bool actionflag
StateAttrib * attr
Bool attrflag
char * language
char * name
struct _LocalIMState * next
DefTree * parser
StateType type
Bool use_keycodeinfo
struct _XIMComposeIMRec

Definition at line 171 of file composeIM.h.

Collaboration diagram for _XIMComposeIMRec:
Class Members
XIC current_ic
CARD32 * def_addr
void * map_addr
size_t map_len
CARD32 * state_addr
CARD8 * str_addr
XIMMethods switch_methods
LocalIMState * top_state
Bool use_binary_table
struct _XICComposeIMRec

Definition at line 189 of file composeIM.h.

Collaboration diagram for _XICComposeIMRec:
Class Members
DefTree * composed
DefTree * context
LocalIMState * imstate
void * lookup_ext
void * preedit_ext
void * status_ext
XICMethods switch_methods
void * table_ext
union _AttribList._attr_u

Definition at line 105 of file composeIM.h.

Class Members
_attr_u CIstruct
_attr_u LUstruct
struct _AttribList._attr_u.CIstruct

Definition at line 106 of file composeIM.h.

Class Members
int max_input_len
InputType type_of_input
struct _AttribList._attr_u.LUstruct

Definition at line 110 of file composeIM.h.

Class Members
int nrange
int num_of_cands
int num_of_cols
int num_of_rows
LuRange * range
char * title

Define Documentation

#define BCF_DEF_KEYCODE (   p,
  i 
)    (*((INT32 *)p + BCF_DEF_SIZE * (i-1) + 6))

Definition at line 149 of file composeIM.h.

#define BCF_DEF_KEYSYM (   p,
  i 
)    (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 5))

Definition at line 148 of file composeIM.h.

#define BCF_DEF_KEYSYM_RETURN (   p,
  i 
)    (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 8))

Definition at line 151 of file composeIM.h.

#define BCF_DEF_LENGTH (   p)    (*(CARD32 *)p)

Definition at line 143 of file composeIM.h.

#define BCF_DEF_MB (   p,
  i 
)    (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 7))

Definition at line 150 of file composeIM.h.

#define BCF_DEF_MODIFIER (   p,
  i 
)    (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 4))

Definition at line 147 of file composeIM.h.

#define BCF_DEF_MODIFIER_MASK (   p,
  i 
)    (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 3))

Definition at line 146 of file composeIM.h.

#define BCF_DEF_NEXT (   p,
  i 
)    (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 1))

Definition at line 144 of file composeIM.h.

#define BCF_DEF_PTR (   b)    (BCF_STATE_PTR(b) + 1 + BCF_STATE_SIZE * BCF_STATE_LENGTH(BCF_STATE_PTR(b)))

Definition at line 142 of file composeIM.h.

#define BCF_DEF_SIZE   9

Definition at line 141 of file composeIM.h.

#define BCF_DEF_SUCCESSION (   p,
  i 
)    (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 2))

Definition at line 145 of file composeIM.h.

#define BCF_DEF_TARGET (   p,
  i 
)    (*((CARD32 *)p + BCF_DEF_SIZE * (i-1) + 9))

Definition at line 152 of file composeIM.h.

#define BCF_HDR_PLATFORM_LSB   0x0101

Definition at line 128 of file composeIM.h.

#define BCF_HDR_PLATFORM_MSB   0x0000

Definition at line 127 of file composeIM.h.

#define BCF_HDR_PLATFORM_UNKNOWN   0x0202

Definition at line 129 of file composeIM.h.

#define BCF_HDR_SIGNATURE   0xffff

Definition at line 126 of file composeIM.h.

#define BCF_HDR_SIZE   72

Definition at line 125 of file composeIM.h.

#define BCF_HDR_VENDER_STRING   "Sun Microsystems, Inc."

Definition at line 131 of file composeIM.h.

#define BCF_HDR_VENDER_STRING_LEN   64

Definition at line 132 of file composeIM.h.

#define BCF_HDR_VERSION   0x0100

Definition at line 130 of file composeIM.h.

#define BCF_STATE_LENGTH (   p)    (*(CARD32 *)p)

Definition at line 136 of file composeIM.h.

#define BCF_STATE_NAME (   p,
  i 
)    (*((CARD32 *)p + BCF_STATE_SIZE * (i-1) + 1))

Definition at line 137 of file composeIM.h.

#define BCF_STATE_PARSER (   p,
  i 
)    (*((CARD32 *)p + BCF_STATE_SIZE * (i-1) + 3))

Definition at line 139 of file composeIM.h.

#define BCF_STATE_PTR (   b)    (CARD32 *)((CARD8 *)b + BCF_HDR_SIZE)

Definition at line 135 of file composeIM.h.

#define BCF_STATE_SIZE   3

Definition at line 134 of file composeIM.h.

#define BCF_STATE_USE_KEYCODE (   p,
  i 
)    (*((CARD32 *)p + BCF_STATE_SIZE * (i-1) + 2))

Definition at line 138 of file composeIM.h.

#define BCF_STR_LENGTH (   p)    (*(CARD32 *)p)

Definition at line 155 of file composeIM.h.

#define BCF_STR_PTR (   b)    (CARD8 *)(BCF_DEF_PTR(b) + 1 + BCF_DEF_SIZE * BCF_DEF_LENGTH(BCF_DEF_PTR(b)))

Definition at line 154 of file composeIM.h.

#define BCF_STR_STRING (   p,
  i 
)    (char *)((CARD8 *)p + i + 3)

Definition at line 156 of file composeIM.h.

#define COMPOSE_FILE   "Compose"

Definition at line 53 of file composeIM.h.

#define SET_KEYCODEINFO (   s)    ((s)->use_keycodeinfo = True)

Definition at line 121 of file composeIM.h.

#define USE_KEYCODEINFO (   s)    ((s)->use_keycodeinfo == True)

Definition at line 122 of file composeIM.h.

#define XIMP_40

Definition at line 47 of file composeIM.h.


Typedef Documentation

typedef struct _DefTree DefTree
typedef struct _LocalIMState LocalIMState
typedef struct _LuRange LuRange
typedef struct _AttribList StateAttrib

Enumeration Type Documentation

enum ActionType
Enumerator:
NoAction 
SwitchTo 
NextPage 
PrevPage 
TopPage 
LastPage 
NextCand 
PrevCand 
UpCand 
DownCand 
SelectCand 
DoLookup 
DoConv 

Definition at line 55 of file composeIM.h.

enum InputType
Enumerator:
HEX 
OCTET 

Definition at line 93 of file composeIM.h.

enum StateType
Enumerator:
ComposeState 
CodeInputState 
LookupState 
RemoteIMState 

Definition at line 86 of file composeIM.h.

             {
  ComposeState,
  CodeInputState,
  LookupState,                     /* Table Input */
  RemoteIMState                    /* Remote IM State */
} StateType;

Function Documentation

Status COMPOSE_CreateIC_SWITCH ( XIC  xic,
XIMArg arg 
)

Definition at line 912 of file composeIM.c.

                                              {
  XicCommon ic = (XicCommon)xic;
  XimCommon im = (XimCommon)ic->core.im;
  XimpChangeMaskRec dummy;

  if ((ic->local_icpart = (XICComposeIM)Xmalloc(sizeof(XICComposeIMRec)))
      == (XICComposeIM)NULL) {
    goto Error;
  }
  memset(ic->local_icpart, 0, sizeof(XICComposeIMRec));

  XIC_COMPOSE(ic, switch_methods) = get_switch_ic_methods();

  ic->core.filter_events = KeyPressMask;

  if (XIM_COMPOSE(im, top_state)) {
    if (XIM_COMPOSE(im, use_binary_table) == True)
      ic->local_icpart->context =
       (DefTree *)BCF_STATE_PARSER(XIM_COMPOSE(im, state_addr),
                                (CARD32)XIM_COMPOSE(im, top_state));
    else
      ic->local_icpart->context = XIM_COMPOSE(im, top_state)->parser;
  }
  ic->local_icpart->composed = NULL;
  ic->local_icpart->imstate = ((XimCommon)im)->local_impart->top_state;

  if (!ic->local_icpart->imstate) {
    fprintf(stderr, "The local IM state map is empty.  Compose file may be broken.\n");
    goto Error;
  }

  memset(&dummy, 0, sizeof(dummy));
  if (_Ximp_Local_SetICValueData((Ximp_XIC)ic, arg, XIMP_CREATE_IC, &dummy)) {
    goto Error;
  }
  /* Not Yet */
  if (!(ic->ximp_icpart->value_mask & XIMP_INPUT_STYLE)) 
    goto Error;

  ic->ximp_icpart->input_mode = BEING_BYPASSED;
  Ximp_Local_Status_Set(ic);
  Ximp_Local_Status_Start(ic);
  Ximp_Local_Status_Draw(ic);

  /* switch */
  if (XIM_IS_SWITCH(im)) {
    RegisterSwitchFilter(ic, SwitchFilter,
                      Ximp_Local_KeyFilter,
                      get_local_ic_methods());
  }
  return True;

 Error:
  if (ic->local_icpart) XFree(ic->local_icpart);
  return False;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Status COMPOSE_OpenIM_SWITCH ( XIM  xim,
XLCd  lcd 
)

Definition at line 376 of file composeIM.c.

                                         {
  XimCommon im = (XimCommon)xim;
  XIMComposeIM local_impart = 0;
  char * name;

  local_impart = (XIMComposeIM)Xmalloc(sizeof(XIMComposeIMRec));
  if (!local_impart) goto Set_Error;

  memset(local_impart, 0, sizeof(XIMComposeIMRec));

  im->local_impart = local_impart;

  XIM_COMPOSE(im, switch_methods) = get_switch_im_methods();

  name = _XlcFileName(im->core.lcd, COMPOSE_FILE);
  if (name == (char *)NULL || access(name, R_OK) == -1) {
    Xfree(name);
    goto Set_Error;
  }
  Xfree(name);

  if (!_LocalConnect(im)) goto Set_Error;

  return True;

Set_Error:
  _Ximp_Local_CloseIM((XIM)im);
  return False;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 141 of file composeIM.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Bool Ximp_Local_KeyFilter ( Display *  d,
Window  w,
XEvent *  ev,
XPointer  client_data 
)

Definition at line 508 of file composeIM.c.

{
  XicCommon ic = (XicCommon)client_data;
  KeySym keysym;
  static char buf[128];
  static XComposeStatus     status;
  unsigned int         mod_state;
  LocalIMState *prev_state;

  XimCommon im;
  Bool useUnicode;

#ifdef BACKTRACK_WHEN_UNMATCHED
  static long must_be_through = 0;
#endif

  DefTree *p = NULL;
  Bool returnflag = False;

  TRACE_MESSAGE('k', ("local_Filter\n"));

  if (!ic) {
    return False;
  }
  im = (XimCommon)ic->core.im;

  if (im == 0) {
    /* perhaps XIM instance is aleady closed, and set to NULL */
    _XUnregisterFilter(d, w, Ximp_Local_KeyFilter, (XPointer)ic);
    return False;
  }

  if (ev->type != KeyPress) return (False);
  if (ev->xkey.keycode == XIM_COMPOSE_KEYCODE) return (False);
  if (ic->local_icpart == 0) {
    /* most likely associated ic has been already destroyed */
    _XUnregisterFilter(d, w, Ximp_Local_KeyFilter, (XPointer)ic);
    return False;
  }

  if (((XimCommon)ic->core.im)->local_impart == 0) {
    _XUnregisterFilter(d, w, Ximp_Local_KeyFilter, (XPointer)ic);
    return False;
  }

  if (((XimCommon)ic->core.im)->local_impart->top_state == (LocalIMState *)NULL)
    return (False);
#ifdef BACKTRACK_WHEN_UNMATCHED
  if (must_be_through) {
    must_be_through--;
    return (False);
  }
#endif

  (void)memset((void *)(&status), 0, sizeof(XComposeStatus));
  (void)XLookupString((XKeyEvent *)ev, buf, sizeof(buf), &keysym, &status);
  mod_state = ev->xkey.state;
  mod_state &= ~(ShiftMask | LockMask | Mod2Mask );

  if (IsModifierKey(keysym)) return (False);

    /* use binary table */
  if(((XimCommon)ic->core.im)->local_impart->use_binary_table == True){
    XIMComposeIM lim = ((XimCommon)ic->core.im)->local_impart;
    CARD32    *s_addr = lim->state_addr;
    CARD32    *d_addr = lim->def_addr;
    CARD32    index = 0;
    if(BCF_STATE_USE_KEYCODE(s_addr, (CARD32)(lim->top_state))){
      index = (CARD32)(ic->local_icpart->context);
      while(index){
       if(BCF_DEF_KEYCODE(d_addr, index) != 0){
         if(((mod_state & BCF_DEF_MODIFIER_MASK(d_addr, index)) == BCF_DEF_MODIFIER(d_addr, index)) &&
            (ev->xkey.keycode == BCF_DEF_KEYCODE(d_addr, index)) &&
            (keysym == BCF_DEF_KEYSYM(d_addr, index))){
           break;
         }
       }
       index = BCF_DEF_NEXT(d_addr, index);
      }
    }
    if(index == 0){ /* Unmatched */
      index = (CARD32)(ic->local_icpart->context);
      while(index){
       if(BCF_DEF_KEYCODE(d_addr, index) == 0){
         if(((mod_state & BCF_DEF_MODIFIER_MASK(d_addr, index)) == BCF_DEF_MODIFIER(d_addr, index)) &&
            (keysym == BCF_DEF_KEYSYM(d_addr, index))){
           break;
         }
       }
       index = BCF_DEF_NEXT(d_addr, index);
      }
    }

    if(index){ /* Matched */
      if(BCF_DEF_SUCCESSION(d_addr, index)){ /* Intermediate */
       ic->local_icpart->context = (DefTree *)BCF_DEF_SUCCESSION(d_addr, index);
#ifdef BACKTRACK_WHEN_UNMATCHED
       /* Seve Event */
       bcopy(ev, &ic->ximp_icpart.saved_event[ic->ximp_icpart.num_saved++], sizeof(XKeyEvent));
#endif
      }
      else{ /* Terminate (reached to leaf) */
       if(BCF_DEF_TARGET(d_addr, index) == 0){
         ic->local_icpart->composed = (DefTree *)
           Xmalloc(sizeof(DefTree));
         if (ic->local_icpart->composed == (DefTree *)NULL)
           return(False);
         memset(ic->local_icpart->composed, 0, sizeof(DefTree));
         bcopy((DefTree *)p, ic->local_icpart->composed, sizeof(DefTree));
         if (((DefTree *)p)->mb != NULL) {
           int l;
           l = strlen(p->mb);
           if (l > 0) {
             ic->local_icpart->composed->mb = (char *)Xmalloc(l+1);
             bcopy(((DefTree *)p)->mb, ic->local_icpart->composed->mb, l);
             ic->local_icpart->composed->mb[l] = '\0';
           }
         }

         useUnicode = (XIM_USE_UNICODE(im) &&
                     NULL != ic->commit_string_callback.callback);

         /* private XIC extension */
         if (useUnicode) {
             XIMCallback *cb = &ic->commit_string_callback;
             XIMUnicodeText cbtext;
             size_t len = 256;     /* enough */
             char buffer[256];
             memset(&cbtext, 0, sizeof(XIMUnicodeText));
             cbtext.string.multi_byte = buffer;
             cbtext.length = len;
             IMConvertFromUTF8ToUTF16(p->mb, strlen(p->mb),
                                   (char**)&cbtext.string.utf16_char,
                                   &len);
             cbtext.length -= len;
             cbtext.length /= sizeof(unsigned short);
             (*cb->callback)((XIC)ic,
                           cb->client_data,
                           (XPointer)&cbtext);

         } else {
           /* return back to client KeyPressEvent keycode == 0 */
           ev->xkey.keycode = XIM_COMPOSE_KEYCODE;
           XPutBackEvent(d, ev);
         }
       }
       else { /* Change state */
         ic->local_icpart->imstate = (LocalIMState *)BCF_DEF_TARGET(d_addr, index);
         Ximp_Local_Status_Set(ic);
         Ximp_Local_Status_Start(ic);
         Ximp_Local_Status_Draw(ic);
       }
       /* initialize internal state for next key sequence */
       ic->local_icpart->context = (DefTree *)BCF_STATE_PARSER(s_addr, (CARD32)(ic->local_icpart->imstate));
      }
      return (True);
    }
    else{ /* Unmatched */
      if (ic->local_icpart->context == (DefTree *)BCF_STATE_PARSER(s_addr, (CARD32)(ic->local_icpart->imstate))){
       return (False);
      }
      /* Error (Sequence Unmatch occured) */
#ifdef BACKTRACK_WHEN_UNMATCHED
      XPutBackEvent(d, ev);
      while (ic->ximp_icpart.num_saved > 0) {
       ic->ximp_icpart.num_saved--;
       XPutBackEvent(d, &ic->ximp_icpart.saved_event[ic->ximp_icpart.num_saved]);
      }
      must_be_through = 1;
#endif
      /* initialize internal state for next key sequence */
      ic->local_icpart->context = (DefTree *)BCF_STATE_PARSER(s_addr, (CARD32)(ic->local_icpart->imstate));

      return (True);
    }
  }

  /* use text compose file */
  else{
    TRACE_MESSAGE('k', ("0x%08x 0x%08x\n", ic->local_icpart->imstate,
                     ((XimCommon)ic->core.im)->local_impart->top_state));
    if (USE_KEYCODEINFO(((XimCommon)ic->core.im)->local_impart->top_state)) {
      for (p = ic->local_icpart->context; p; p = p->next) {
       if (p->keycode != 0) {
         if (((mod_state & p->modifier_mask) == p->modifier) &&
             (ev->xkey.keycode == p->keycode) &&
             (keysym == p->keysym)) {
           break;
         }
       }
      }
    }
    if (p == NULL) { /* Unmatched */
      for (p = ic->local_icpart->context; p; p = p->next) {
       if (p->keycode == 0) {
         if (((mod_state & p->modifier_mask) == p->modifier) &&
             (keysym == p->keysym)) {
           break;
         }
       }
      }
    }
    if (p) { /* Matched */
      if (p->succession) { /* Intermediate */
       ic->local_icpart->context = p->succession;
#ifdef BACKTRACK_WHEN_UNMATCHED
       /* Seve Event */
       bcopy(ev, &ic->ximp_icpart.saved_event[ic->ximp_icpart.num_saved++], sizeof(XKeyEvent));
#endif
       returnflag = True;
      } else { /* Terminate (reached to leaf) */
       prev_state = ic->local_icpart->imstate;
       if (prev_state->type == RemoteIMState) {
         return False;
       }
       if (p->target_name == NULL){
         switch (p->action) {
         case TopPage:
         case LastPage:
         case NextPage:
         case PrevPage:
         case UpCand:
         case DownCand:
         case NextCand:
         case PrevCand:
         case SelectCand:
           /* only for lookup */
           Ximp_Local_Lookup_Action_Filter(ic, p->action, ev);
           return(True);
         case DoConv:
           if (prev_state->type == CodeInputState) {
             Ximp_Local_Preedit_Conv(ic, ev);
             return(True);
           }
         case DoLookup:
           if (prev_state->type == CodeInputState) {
             Ximp_Local_Preedit_Lookup(ic, ev);
             return(True);
           }
           break;
         case NoAction:
           /* create a copy of Compose key, BugID: 4157565 */
           ic->local_icpart->composed = (DefTree *)Xmalloc(sizeof(DefTree));
           if (ic->local_icpart->composed == (DefTree *)NULL)
             return(False);
           memset(ic->local_icpart->composed, 0, sizeof(DefTree));
           bcopy((DefTree *)p, ic->local_icpart->composed, sizeof(DefTree));
           if (((DefTree *)p)->mb != NULL) {
             int l;
             l = strlen(p->mb);
             if (l > 0) {
              ic->local_icpart->composed->mb = (char *)Xmalloc(l+1);
              bcopy(((DefTree *)p)->mb, ic->local_icpart->composed->mb, l);
              ic->local_icpart->composed->mb[l] = '\0';
             }
           }

           useUnicode = (XIM_USE_UNICODE(im) &&
                       NULL != ic->commit_string_callback.callback);
           /* private XIC extension */
           if (useUnicode) {
             XIMCallback *cb = &ic->commit_string_callback;
             XIMUnicodeText cbtext;
             size_t len = 256;     /* enough */
             char buffer[256];
             memset(&cbtext, 0, sizeof(XIMUnicodeText));
             cbtext.string.multi_byte = buffer;
             cbtext.length = len;
             IMConvertFromUTF8ToUTF16(p->mb, strlen(p->mb),
                                   (char**)&cbtext.string.utf16_char,
                                   &len);
             cbtext.length -= len;
             cbtext.length /= sizeof(unsigned short);
             (*cb->callback)((XIC)ic,
                           cb->client_data,
                           (XPointer)&cbtext);

           } else {
             /* return back to client KeyPressEvent keycode == 0 */
             ev->xkey.keycode = XIM_COMPOSE_KEYCODE;
             XPutBackEvent(d, ev);
           }
           break;
         default:
           break;
         }
       } else {
         TRACE_MESSAGE('k', ("local_Filter: %s\n", p->target_name));
         ic->local_icpart->imstate = p->target;
         ic->local_icpart->context = ic->local_icpart->imstate->parser;
         if (prev_state->type == CodeInputState) {
           Ximp_Local_Preedit_Done(ic);
         } else if (prev_state->type == LookupState) {
           Ximp_Local_Table_Done(ic);
         }
          switch (ic->local_icpart->imstate->type) {
         case RemoteIMState:
           if (!SwitchRemoteIMState(ic,
                                 ic->local_icpart->imstate->language)) {
             ic->local_icpart->imstate = prev_state;
             ic->local_icpart->context = ic->local_icpart->imstate->parser;
             return False;
           }
           ic->local_icpart->imstate = ((XimCommon)ic->core.im)->local_impart->top_state;
           ic->local_icpart->context = ic->local_icpart->imstate->parser;
           break;
         case CodeInputState:
         case LookupState:
         default:
           Ximp_Local_Status_Set(ic);
           Ximp_Local_Status_Start(ic);
           Ximp_Local_Status_Draw(ic);
           if (ic->local_icpart->imstate->type == CodeInputState) {
             Ximp_Local_Preedit_Start(ic);
           }
           if (ic->local_icpart->imstate->type == LookupState) {
             Ximp_Local_Table_Start(ic);
           }
           break;
         }
       }
       /* initialize internal state for next key sequence */
       ic->local_icpart->context = ic->local_icpart->imstate->parser;
#ifdef BACKTRACK_WHEN_UNMATCHED
       ic->ximp_icpart.num_saved = 0;
#endif
      }
      return (True);

    } else { /* Unmatched */
      if (ic->local_icpart->context == ic->local_icpart->imstate->parser) {
       returnflag = False;
      }
      /* Error (Sequence Unmatch occured) */
#ifdef BACKTRACK_WHEN_UNMATCHED
      XPutBackEvent(d, ev);
      while (ic->ximp_icpart.num_saved > 0) {
       ic->ximp_icpart.num_saved--;
       XPutBackEvent(d, &ic->ximp_icpart.saved_event[ic->ximp_icpart.num_saved]);
      }
      must_be_through = 1;
#endif
      /* initialize internal state for next key sequence */
      ic->local_icpart->context = ic->local_icpart->imstate->parser;
      returnflag = False;
    }
  }

  if(ic->local_icpart->imstate->type == CodeInputState) {
    LocalPreeditExt *hook = (LocalPreeditExt *)(ic->local_icpart->preedit_ext);
    LocalIMState *state = (LocalIMState *)(ic->local_icpart->imstate);
    LocalLookupExt *lookup = (LocalLookupExt *)(ic->local_icpart->lookup_ext);
    int max_len = state->attr->_attr_u.CIstruct.max_input_len;

    returnflag = True;
    if (lookup && lookup->mapped) {
      Ximp_Local_Lookup_Input_Filter(ic, buf, ev);
    } else {
      if (Ximp_Local_Preedit_Draw(ic, keysym)) {
       if (hook && hook->preedit_len >= max_len) {
         Ximp_Local_Preedit_Conv(ic, ev);
       }
      } else {
       returnflag = False;
      }
    }
  } else if (ic->local_icpart->imstate->type == LookupState) {
    LocalLookupExt *lookup = (LocalLookupExt *)(ic->local_icpart->lookup_ext);
    if (lookup && lookup->mapped) {
      returnflag = Ximp_Local_Lookup_Input_Filter(ic, buf, ev);
    }
    Ximp_Local_Table_Draw(ic);
  }
  return(returnflag);
}

Here is the call graph for this function:

Here is the caller graph for this function: