Back to index

im-sdk  12.3.91
Functions
KeyMap.h File Reference
#include <X11/Xmd.h>
#include <X11/Xlib.h>
#include <iiimcf.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void IIIMCF_keyevent_To_XKeyEvent (IIIMCF_keyevent *pkev, Display *dpy, Window w, XKeyEvent *kev)
Bool XKeyEvent_To_IIIMCF_keyevent (XKeyEvent *ev, IIIMCF_keyevent *pkev)
Bool XKeysym_To_IIIMCF_keyevent (int keysym, int state, IIIMCF_keyevent *pkev)

Function Documentation

void IIIMCF_keyevent_To_XKeyEvent ( IIIMCF_keyevent pkev,
Display *  dpy,
Window  w,
XKeyEvent *  kev 
)

Definition at line 1097 of file KeyMap.c.

{
    if (first_call && dpy != (Display*)0) {
       setup_modifier_map(dpy);
       first_call = False;
    }

    memset(kev, 0, sizeof(*kev));
    
    kev->type = KeyPress;
    kev->display = dpy;
    kev->window = w;
    kev->root = None;
    kev->subwindow = None;
    kev->same_screen = True;
    kev->time = pkev->time_stamp;

    modify_Event((XEvent*)kev, pkev->keycode,
               pkev->keychar, pkev->modifier);

    return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool XKeyEvent_To_IIIMCF_keyevent ( XKeyEvent *  ev,
IIIMCF_keyevent pkev 
)

Definition at line 1130 of file KeyMap.c.

{
    KeySym keysym;
    char buf[64];
    int len = sizeof(buf);
    int state;
    int i;

    pkev->keychar = 0;
    pkev->keycode = 0;
    pkev->time_stamp = ev->time;

    if (first_call && ev->display != (Display*)0) {
       setup_modifier_map(ev->display);
       first_call = False;
    }

    state = ev->state;

    if (getenv("HTT_IGNORES_LOCK_MASK")) {
      /* LockMask, NumLockMask, KanaLockMask should be ignored for
         Java Client compatibility */
      if(state & LockMask){
         state -= LockMask;
      }
      if(state & awt_NumLockMask){
         state -= awt_NumLockMask;
      }
      if(state & awt_KanaLockMask){
         state -= awt_KanaLockMask;
      }
    }

    /* IIIMP's control_mask(1<<1) and X's control_mask(1<<2)is
       different, so it should be changed */
    if (state & ControlMask) {
       state -= (1<<2);
       state |= (1<<1);
    }

    pkev->modifier = state;
    /* Set mask with 0x80000000 to indicate the event is key release event */
    if (ev->type == KeyRelease)
       pkev->modifier |= 0x80000000;

    len = XLookupString(ev, buf, len - 1, &keysym, NULL);

#ifdef  linux
    /* Linux generates XK_Mode_switch at Shift + Henkan_Mode */
    if (state & ShiftMask && keysym == XK_Mode_switch)
      keysym = XK_Henkan_Mode;
#endif /* linux */

#ifdef linux
    if (KanaMode != -1){
       GetKanaFlag(ev->display);
    }   

    if (KanaMode != -1){
       if (keysym == XK_Hiragana_Katakana){
          int    (*oldhandler)(Display *, XErrorEvent *) = NULL;
          Window   kana_w;
#ifdef DEBUG
           printf("Kanakey is pressed\n");
#endif
           if (KanaMode == 1){
              KanaMode = 0;
#ifdef DEBUG
              printf("      off\n");
#endif
           } else {
              KanaMode = 1;
#ifdef DEBUG
              printf("      on\n");
#endif
           }

           XSync(ev->display, False);
           oldhandler = XSetErrorHandler(IgnoreError);

           kana_w = XGetSelectionOwner(ev->display, kanawin_atom);
           if (kana_w) {
              XChangeProperty(ev->display, kana_w, kanaflag_atom,
                            XA_WINDOW, 32,
                            PropModeReplace,
                            (unsigned char*) &KanaMode,
                            sizeof(KanaMode));
           }

           XSync(ev->display, False);
           XSetErrorHandler(oldhandler);

           return False;
       }
    }

    if (KanaMode == 1) {
       if (ev->state & ShiftMask) {
           /* check kana_shift_keymapTable first is ShiftMask */
           for (i = 0; kana_shift_keymapTable[i].awtKey != 0; i++) {
              if (kana_shift_keymapTable[i].keycode == ev->keycode) {
                  getAWTKeyCode2(kana_shift_keymapTable[i].x11Key,
                               &pkev->keycode, &pkev->keychar);
                  if (pkev->keycode) {
                     return True;
                  }
                  break;
              }
           }
       }

       for (i = 0; kana_normal_keymapTable[i].awtKey != 0; i++) {
           if (kana_normal_keymapTable[i].keycode == ev->keycode) {
              getAWTKeyCode2(kana_normal_keymapTable[i].x11Key,
                            &pkev->keycode, &pkev->keychar);
              if (pkev->keycode) {
                  return True;
              }
              break;
           }
       }

       for (i = 0; kana_shift_keymapTable[i].awtKey != 0; i++) {
           if (kana_shift_keymapTable[i].keycode == ev->keycode) {
              getAWTKeyCode2(kana_shift_keymapTable[i].x11Key,
                            &pkev->keycode, &pkev->keychar);
              if (pkev->keycode) {
                  return True;
              }
              break;
           }
       }
    }
#endif /* linux */

    /* store keycode for XK_Delete */
    if(keysym == XK_Delete && keyCode_XK_Delete == 0){
       keyCode_XK_Delete = ev->keycode;
    }

    if (keysym < 256) {
       if ((ev->state & ControlMask)) {
           if (isalpha(keysym)) {
              keysym = toupper(keysym);
           }
       }
       pkev->keycode = getAWTKeyCode(keysym);
       if (pkev->keycode == 0 && (ev->state & ShiftMask)) {
           /* when Shift key is pressed, need to get the normal keysym,
              then get the AWT keycode */
           if (ev->display != (Display*)0) {
              pkev->keycode = getAWTKeyCode(XKeycodeToKeysym(ev->display,
                                                        ev->keycode, 0));
           }
       }
       if (pkev->keycode == 0) {
           pkev->keycode = keysym;
       }
       pkev->keychar = keysym;
       return True;
    } else {
       pkev->keycode = getAWTKeyCode(keysym);
       switch (keysym) {
         case XK_KP_Decimal:
          pkev->keychar = '.';
          break;
         case XK_KP_Add:
          pkev->keychar = '+';
          break;
         case XK_KP_Subtract:
          pkev->keychar = '-';
          break;
         case XK_KP_Divide:
          pkev->keychar = '/';
          break;
         case XK_KP_Multiply:
          pkev->keychar = '*';
          break;
         case XK_KP_0:
          pkev->keychar = '0';
          break;
         case XK_KP_1:
          pkev->keychar = '1';
          break;
         case XK_KP_2:
          pkev->keychar = '2';
          break;
         case XK_KP_3:
          pkev->keychar = '3';
          break;
         case XK_KP_4:
          pkev->keychar = '4';
          break;
         case XK_KP_5:
          pkev->keychar = '5';
          break;
         case XK_KP_6:
          pkev->keychar = '6';
          break;
         case XK_KP_7:
          pkev->keychar = '7';
          break;
         case XK_KP_8:
          pkev->keychar = '8';
          break;
         case XK_KP_9:
          pkev->keychar = '9';
          break;
       }
       if (pkev->keycode) {
           return True;
       }

       /* get Kana code */
       getAWTKeyCode2(keysym, &pkev->keycode, &pkev->keychar);

       if (pkev->keycode) {
           return True;
       }

       if (pkev->keycode == 0 && (ev->state & ShiftMask)) {
           /* when Shift key is pressed, need to get the normal keysym,
              then get the AWT keycode */
           pkev->keycode = getAWTKeyCode(XKeycodeToKeysym(ev->display,
                                                    ev->keycode, 0));
       }

       if (pkev->keycode) {
           return True;
       }
    }
    return False;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Bool XKeysym_To_IIIMCF_keyevent ( int  keysym,
int  state,
IIIMCF_keyevent pkev 
)

Definition at line 1368 of file KeyMap.c.

{
    pkev->keychar = 0;
    pkev->keycode = 0;
    pkev->time_stamp = 0;

    /* LockMask, NumLockMask, KanaLockMask should be ignored for
       Java Client compatibility */
    if (state & LockMask) {
       state -= LockMask;
    }
    if (state & awt_NumLockMask) {
       state -= awt_NumLockMask;
    }
    if (state & awt_KanaLockMask) {
       state -= awt_KanaLockMask;
    }

    /* IIIMP's control_mask(1<<1) and X's control_mask(1<<2)is
       different, so it should be changed */
    if (state & ControlMask) {
       state -= (1<<2);
       state |= (1<<1);
    }

    pkev->modifier = state;

#ifdef  linux
    /* Linux generates XK_Mode_switch at Shift + Henkan_Mode */
    if (state & ShiftMask && keysym == XK_Mode_switch)
      keysym = XK_Henkan_Mode;
#endif /* linux */

    if (keysym < 256) {
       if ((state & ControlMask)) {
           if (isalpha(keysym)) {
              keysym = toupper(keysym);
           }
       }
       pkev->keycode = getAWTKeyCode(keysym);
       if (pkev->keycode == 0) {
           pkev->keycode = keysym;
       }
       pkev->keychar = keysym;
       return True;
    } else {
       pkev->keycode = getAWTKeyCode(keysym);
       switch (keysym) {
         case XK_KP_Decimal:
          pkev->keychar = '.';
          break;
         case XK_KP_Add:
          pkev->keychar = '+';
          break;
         case XK_KP_Subtract:
          pkev->keychar = '-';
          break;
         case XK_KP_Divide:
          pkev->keychar = '/';
          break;
         case XK_KP_Multiply:
          pkev->keychar = '*';
          break;
         case XK_KP_0:
          pkev->keychar = '0';
          break;
         case XK_KP_1:
          pkev->keychar = '1';
          break;
         case XK_KP_2:
          pkev->keychar = '2';
          break;
         case XK_KP_3:
          pkev->keychar = '3';
          break;
         case XK_KP_4:
          pkev->keychar = '4';
          break;
         case XK_KP_5:
          pkev->keychar = '5';
          break;
         case XK_KP_6:
          pkev->keychar = '6';
          break;
         case XK_KP_7:
          pkev->keychar = '7';
          break;
         case XK_KP_8:
          pkev->keychar = '8';
          break;
         case XK_KP_9:
          pkev->keychar = '9';
          break;
       }
       if (pkev->keycode) {
           return True;
       }

       /* get Kana code */
       getAWTKeyCode2(keysym, &pkev->keycode, &pkev->keychar);
       if (pkev->keycode) {
           return True;
       }
    }

    return False;
}

Here is the call graph for this function:

Here is the caller graph for this function: