예제 #1
0
파일: eve.cpp 프로젝트: gogonkt/gcin
void toggle_im_enabled()
{
//    dbg("toggle_im_enabled\n");
    check_CS();

    if (current_CS->in_method < 0 || current_CS->in_method > MAX_GTAB_NUM_KEY)
      p_err("err found");


    if (current_CS->im_state != GCIN_STATE_DISABLED) {
      if (current_CS->im_state == GCIN_STATE_ENG_FULL) {
        current_CS->im_state = GCIN_STATE_CHINESE;
        disp_im_half_full();
        return;
      }

      if (current_method_type() == method_type_TSIN) {
#if USE_TSIN
        flush_tsin_buffer();
#endif
      }
      else {
        output_gbuf();
        reset_gtab_all();
      }

      hide_in_win(current_CS);
#if 0
      hide_win_status();
#endif
      current_CS->im_state = GCIN_STATE_DISABLED;

      update_win_kbm();

#if TRAY_ENABLED
      disp_tray_icon();
#endif
    } else {
      if (!current_method_type())
        init_gtab(current_CS->in_method);


      init_state_chinese(current_CS);
      reset_current_in_win_xy();
#if 1
      show_in_win(current_CS);
      update_in_win_pos();
#else
      update_in_win_pos();
      show_in_win(current_CS);
#endif

      update_win_kbm();

#if TRAY_ENABLED
      disp_tray_icon();
#endif
    }
}
예제 #2
0
파일: eve.c 프로젝트: CarterTsai/hime
gboolean timeout_raise_window(gpointer data)
{
//  dbg("timeout_raise_window\n");
  timeout_handle = 0;
  show_in_win(current_CS);
  return FALSE;
}
예제 #3
0
파일: IC.c 프로젝트: CarterTsai/hime
void load_IC(IC *rec)
{
   ClientState *cs = &rec->cs;
   Window win = cs->client_win;

   if (win == focus_win && !current_CS) {
     current_CS = cs;
     save_CS_temp_to_current();
   }

   if (win == focus_win) {
     if (cs->im_state == HIME_STATE_DISABLED)
       hide_in_win(cs);
     else
     if (cs->im_state != HIME_STATE_DISABLED)
       show_in_win(cs);
   }

   if (cs->input_style & InputStyleOnSpot) {
     if (cs->im_state != HIME_STATE_DISABLED)
       move_IC_in_win(cs);
   } else
   if (cs->input_style & InputStyleOverSpot) {
     if (cs->im_state != HIME_STATE_DISABLED)
       move_IC_in_win(cs);
   } else
   if (cs->input_style & InputStyleRoot) {
     move_IC_in_win(cs);
   }
}
예제 #4
0
파일: eve.c 프로젝트: CarterTsai/hime
int hime_FocusIn(ClientState *cs)
{
//  dbg("hime_FocusIn\n");
  Window win = cs->client_win;

#if UNIX && 0
  if (skip_window(win))
    return FALSE;
#endif

  reset_current_in_win_xy();

  if (cs) {
    Window win = cs->client_win;

    if (focus_win != win) {
#if 1
      hime_reset();
#endif
      hide_in_win(current_CS);
      focus_win = win;
    }
  }

  current_CS = cs;
  save_CS_temp_to_current();

//  dbg("current_CS %x %d %d\n", cs, cs->im_state, current_CS->im_state);

  if (win == focus_win) {
    if (cs->im_state != HIME_STATE_DISABLED) {
      show_in_win(cs);
      move_IC_in_win(cs);
    } else
      hide_in_win(cs);
  }

  if (inmd[cs->in_method].selkey)
    set_wselkey(inmd[cs->in_method].selkey);
  else {
    set_wselkey(pho_selkey);
    gtab_set_win1_cb();
    tsin_set_win1_cb();
  }

  update_win_kbm();
#if TRAY_ENABLED
  disp_tray_icon();
#endif
#if 0
  dbg_time("hime_FocusIn %x %x\n",cs, current_CS);
#endif
  return True;
}
예제 #5
0
파일: eve.cpp 프로젝트: gogonkt/gcin
int gcin_FocusIn(ClientState *cs)
{
  Window win = cs->client_win;

  gcin_reset();
#if UNIX
  if (skip_window(win))
    return FALSE;
#endif

  reset_current_in_win_xy();

  if (cs) {
    Window win = cs->client_win;

    if (focus_win != win) {
      hide_in_win(current_CS);
      focus_win = win;
    }
  }

  current_CS = cs;

//  dbg("current_CS %x %d %d\n", cs, cs->im_state, current_CS->im_state);

  if (win == focus_win) {
    if (cs->im_state != GCIN_STATE_DISABLED) {
      show_in_win(cs);
      move_IC_in_win(cs);
#if 0
      set_win_status_inmd(inmd[cs->in_method].cname);
#endif
    } else
      hide_in_win(cs);
  }

  update_win_kbm();
#if TRAY_ENABLED
  disp_tray_icon();
#endif
#if 0
  dbg_time("gcin_FocusIn %x %x\n",cs, current_CS);
#endif
  return True;
}
예제 #6
0
파일: eve.c 프로젝트: Tetralet/hime
void toggle_symbol_table()
{
  if (current_CS->im_state == HIME_STATE_CHINESE) {
    if (!win_is_visible())
      win_sym_enabled=1;
    else
      win_sym_enabled^=1;
  } else
    win_sym_enabled=0;

  create_win_sym();
  if (win_sym_enabled) {
    force_show = TRUE;
    if (current_CS->im_state == HIME_STATE_CHINESE)
      show_in_win(current_CS);
    force_show = FALSE;
  }
}
예제 #7
0
파일: eve.c 프로젝트: CarterTsai/hime
void toggle_im_enabled()
{
//    dbg("toggle_im_enabled\n");
    check_CS();

    if (current_CS->in_method < 0)
      p_err("err found");


    if (current_CS->im_state != HIME_STATE_DISABLED) {
      if (current_CS->im_state == HIME_STATE_ENG_FULL) {
        current_CS->im_state = HIME_STATE_CHINESE;
        disp_im_half_full();
        save_CS_current_to_temp();
        return;
      }

      if (current_method_type() == method_type_TSIN) {
#if USE_TSIN
        flush_tsin_buffer();
#endif
      }
      else if (current_method_type () == method_type_MODULE)
      {
          module_cb ()->module_flush_input ();
      }
      else {
        output_gbuf();
        reset_gtab_all();
      }

      hide_in_win(current_CS);
#if 0
      hide_win_status();
#endif
      current_CS->im_state = HIME_STATE_DISABLED;

      update_win_kbm();

#if TRAY_ENABLED
      disp_tray_icon();
#endif
    } else {
      if (!current_method_type())
        init_gtab(current_CS->in_method);


      init_state_chinese(current_CS);
      reset_current_in_win_xy();
#if 1
      show_in_win(current_CS);
      update_in_win_pos();
#else
      update_in_win_pos();
      show_in_win(current_CS);
#endif

      update_win_kbm();

#if TRAY_ENABLED
      disp_tray_icon();
#endif
    }

    save_CS_current_to_temp();
}
예제 #8
0
파일: eve.c 프로젝트: CarterTsai/hime
// return TRUE if the key press is processed
gboolean ProcessKeyPress(KeySym keysym, u_int kev_state)
{
#if 0
  dbg("key press %x %x\n", keysym, kev_state);
#endif
  destroy_phrase_save_menu();

  disp_win_kbm_capslock();
  check_CS();

  if (current_CS->client_win)
    focus_win = current_CS->client_win;

  if (
#if WIN32
  !test_mode &&
#endif
  callback_str_buffer && strlen(callback_str_buffer)) {
    send_text(callback_str_buffer);
    callback_str_buffer[0]=0;
    return TRUE;
  }

  if (force_preedit) {
    force_preedit=0;
    return 1;
  }

  if (keysym == XK_space) {
#if 0
    dbg("state %x\n", kev->state);
    dbg("%x\n", Mod4Mask);
#endif
    if (
      ((kev_state & (ControlMask|Mod1Mask|ShiftMask))==ControlMask && hime_im_toggle_keys==Control_Space) ||
      ((kev_state & Mod1Mask) && hime_im_toggle_keys==Alt_Space) ||
      ((kev_state & ShiftMask) && hime_im_toggle_keys==Shift_Space) ||
      ((kev_state & Mod4Mask) && hime_im_toggle_keys==Windows_Space)
    ) {
      if (current_method_type() == method_type_TSIN) {
        tsin_set_eng_ch(1);
      }

      toggle_im_enabled();
#if UNIX
      return TRUE;
#else
      return FALSE;
#endif
    }
  }

  if (keysym == XK_space && (kev_state & ShiftMask)) {
    if (last_keysym != XK_Shift_L && last_keysym != XK_Shift_R)
      return FALSE;

    toggle_half_full_char();

    return TRUE;
  }


  if ((kev_state & (Mod1Mask|ShiftMask)) == (Mod1Mask|ShiftMask)) {
    if (current_CS->im_state != HIME_STATE_DISABLED || hime_eng_phrase_enabled)
      return feed_phrase(keysym, kev_state);
    else
      return 0;
  }

//  dbg("state %x\n", kev_state);
  if ((current_CS->im_state & (HIME_STATE_ENG_FULL)) ) {
    return full_char_proc(keysym);
  }


  if ((kev_state & ControlMask) && (kev_state&(Mod1Mask|Mod5Mask))) {
    if (keysym == 'g' || keysym == 'r') {
      send_output_buffer_bak();
      return TRUE;
    }

    if (!hime_enable_ctrl_alt_switch)
      return FALSE;

    int kidx = hime_switch_keys_lookup(keysym);
    if (kidx < 0)
      return FALSE;

    if (inmd[kidx].method_type == method_type_SYMBOL_TABLE) {
#if 1
      if (current_CS->im_state == HIME_STATE_CHINESE) {
        if (!win_is_visible())
          win_sym_enabled=1;
        else
          win_sym_enabled^=1;
      } else
        win_sym_enabled=0;
#else
      win_sym_enabled^=1;
#endif

      create_win_sym();
      if (win_sym_enabled) {
        force_show = TRUE;
        if (current_CS->im_state == HIME_STATE_CHINESE)
          show_in_win(current_CS);
        force_show = FALSE;
      }
      return TRUE;
    }

    if (!inmd[kidx].cname)
      return FALSE;

    current_CS->im_state = HIME_STATE_CHINESE;
#if WIN32
    if (!test_mode)
#endif
      init_in_method(kidx);

    return TRUE;
  }

  last_keysym = keysym;

  if (current_CS->im_state == HIME_STATE_DISABLED) {
    return FALSE;
  }

  if (!current_CS->b_hime_protocol) {
  if (((keysym == XK_Control_L || keysym == XK_Control_R)
                   && (kev_state & ShiftMask)) ||
      ((keysym == XK_Shift_L || keysym == XK_Shift_R)
                   && (kev_state & ControlMask))) {
     cycle_next_in_method();
     return TRUE;
  }
  }

  if (current_CS->b_raise_window && keysym>=' ' && keysym < 127) {
    if (timeout_handle)
      g_source_remove(timeout_handle);
    timeout_handle = g_timeout_add(200, timeout_raise_window, NULL);
  }

  if (kev_state & ControlMask) {
    if (feed_phrase(keysym, kev_state))
      return TRUE;
  }

  switch(current_method_type()) {
    case method_type_PHO:
      return feedkey_pho(keysym, kev_state);
#if USE_TSIN
    case method_type_TSIN:
      return feedkey_pp(keysym, kev_state);
#endif
    case method_type_MODULE:
      return module_cb()->module_feedkey(keysym, kev_state);
    default:
      return feedkey_gtab(keysym, kev_state);
  }

  return FALSE;
}