Ejemplo n.º 1
0
void disp_win_screen_status(char *in_method, char *half_status)
{
  dbg("disp_win_screen_status\n");
  if (
//  tss.c_len || ggg.gbufN ||
  cur_file_hf && !strcmp(cur_file_hf, half_status) &&
  cur_file_inmd && !strcmp(cur_file_inmd, in_method) 
#if 0  
  && old_x==current_in_win_x && old_y==current_in_win_y
#endif  
  )
    return;
    
  old_x = current_in_win_x;
  old_y = current_in_win_y;

  clear_timeout();
  free(cur_file_hf); cur_file_hf = strdup(half_status);
  free(cur_file_inmd); cur_file_inmd = strdup(in_method);

  if (!win_screen_status) {
    win_screen_status = create_no_focus_win();
    GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
    gtk_container_add(GTK_CONTAINER(win_screen_status), hbox);
    icon_inmd = gtk_image_new_from_file(in_method);
    gtk_box_pack_start (GTK_BOX (hbox), icon_inmd, FALSE, FALSE, 0);
#if 1
    icon_hf = gtk_image_new_from_file(half_status);
    gtk_box_pack_start (GTK_BOX (hbox), icon_hf, FALSE, FALSE, 0);
#endif    
  } else {
#if 1
    gtk_image_set_from_file(GTK_IMAGE(icon_hf), half_status);
#endif
    gtk_image_set_from_file(GTK_IMAGE(icon_inmd), in_method);
  }

  gtk_widget_show_all(win_screen_status);
  gtk_window_present(GTK_WINDOW(win_screen_status));

  timeout_handle = g_timeout_add(1000, timeout_hide, NULL);
  int w,h;
  get_win_size(win_screen_status, &w, &h);

  int x = current_in_win_x;
  int y = current_in_win_y + (win_is_visible()?win_yl:0);


  if (x + w > dpy_xl)
    x = dpy_xl - w;

  if (y + h > dpy_yl)
    y = win_y - h;

  gtk_window_move(GTK_WINDOW(win_screen_status), x, y);
}
Ejemplo n.º 2
0
Archivo: eve.c Proyecto: 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;
  }
}
Ejemplo n.º 3
0
// 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;
}