void update_in_win_pos() { check_CS(); // dbg("update_in_win_pos %x %d\n", current_CS, current_CS->input_style); if (current_CS->input_style == InputStyleRoot) { Window r_root, r_child; int winx, winy, rootx, rooty; u_int mask; XQueryPointer(dpy, root, &r_root, &r_child, &rootx, &rooty, &winx, &winy, &mask); winx++; winy++; Window inpwin = current_CS->client_win; #if 0 dbg("update_in_win_pos\n"); #endif if (inpwin) { int tx, ty; Window ow; XTranslateCoordinates(dpy, root, inpwin, winx, winy, &tx, &ty, &ow); current_CS->spot_location.x = tx; current_CS->spot_location.y = ty; } move_in_win(current_CS, winx, winy); } else { move_IC_in_win(current_CS); } }
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 } }
void move_in_win(ClientState *cs, int x, int y) { check_CS(); if (current_CS && current_CS->fixed_pos) { x = current_CS->fixed_x; y = current_CS->fixed_y; } else if (gcin_input_style == InputStyleRoot) { x = gcin_root_x; y = gcin_root_y; } #if 0 dbg("move_in_win %d %d\n",x, y); #endif #if 1 if (current_in_win_x == x && current_in_win_y == y) return; #endif current_in_win_x = x ; current_in_win_y = y; switch (current_method_type()) { case method_type_PHO: move_win_pho(x, y); break; #if USE_TSIN case method_type_TSIN: move_win0(x, y); break; #endif case method_type_INT_CODE: move_win_int(x, y); break; #if USE_ANTHY case method_type_ANTHY: move_win_anthy(x, y); break; #endif default: if (!cs->in_method) return; move_win_gtab(x, y); } }
void toggle_half_full_char() { #if WIN32 if (test_mode) return; #endif check_CS(); if (!hime_shift_space_eng_full) { current_CS->b_half_full_char = 0; tss.tsin_half_full=0; disp_im_half_full(); return; } // dbg("toggle_half_full_char\n"); if (current_method_type() == method_type_TSIN && current_CS->im_state == HIME_STATE_CHINESE) { tsin_toggle_half_full(); } else { if (current_CS->im_state == HIME_STATE_ENG_FULL) { current_CS->im_state = HIME_STATE_DISABLED; hide_in_win(current_CS); } else if (current_CS->im_state == HIME_STATE_DISABLED) { toggle_im_enabled(); current_CS->im_state = HIME_STATE_ENG_FULL; } else if (current_CS->im_state == HIME_STATE_CHINESE) { current_CS->b_half_full_char = !current_CS->b_half_full_char; } // dbg("current_CS->in_method %d\n", current_CS->in_method); disp_im_half_full(); } save_CS_current_to_temp(); // dbg("half full toggle\n"); }
void move_in_win(ClientState *cs, int x, int y) { check_CS(); if (current_CS && current_CS->fixed_pos) { x = current_CS->fixed_x; y = current_CS->fixed_y; } else if (hime_input_style == InputStyleRoot) { x = hime_root_x; y = hime_root_y; } #if 0 dbg("move_in_win %d %d\n",x, y); #endif #if 0 if (current_in_win_x == x && current_in_win_y == y) return; #endif current_in_win_x = x ; current_in_win_y = y; switch (current_method_type()) { case method_type_PHO: move_win_pho(x, y); break; #if USE_TSIN case method_type_TSIN: move_win0(x, y); break; #endif case method_type_MODULE: if (inmd[cs->in_method].mod_cb_funcs) module_cb1(cs)->module_move_win(x, y); break; default: if (!cs->in_method) return; move_win_gtab(x, y); } }
// <Shift><Space> is pressed void toggle_half_full_char() { check_CS(); if (!hime_shift_space_eng_full) { current_CS->b_half_full_char = 0; tss.tsin_half_full=0; disp_im_half_full(); return; } // dbg("toggle_half_full_char\n"); if (current_method_type() == method_type_TSIN && current_CS->im_state == HIME_STATE_CHINESE) { tsin_toggle_half_full(); } else { switch (current_CS->im_state) { case HIME_STATE_ENG_FULL: current_CS->im_state = HIME_STATE_DISABLED; hide_in_win(current_CS); break; case HIME_STATE_DISABLED: toggle_im_enabled(); current_CS->im_state = HIME_STATE_ENG_FULL; break; case HIME_STATE_CHINESE: current_CS->b_half_full_char = !current_CS->b_half_full_char; break; } // dbg("current_CS->in_method %d\n", current_CS->in_method); disp_im_half_full(); } save_CS_current_to_temp(); // dbg("half full toggle\n"); }
// return TRUE if the key press is processed gboolean ProcessKeyRelease(KeySym keysym, u_int kev_state) { disp_win_kbm_capslock(); check_CS(); #if 0 dbg_time("key release %x %x\n", keysym, kev_state); #endif if (current_CS->im_state == HIME_STATE_DISABLED) return FALSE; #if 1 if (current_CS->b_hime_protocol && (last_keysym == XK_Shift_L || last_keysym == XK_Shift_R || last_keysym == XK_Control_L || last_keysym == XK_Control_R)) { 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; } } #endif switch(current_method_type()) { case method_type_TSIN: return feedkey_pp_release(keysym, kev_state); case method_type_MODULE: if (!module_cb()) return FALSE; return module_cb()->module_feedkey_release(keysym, kev_state); default: return feedkey_gtab_release(keysym, kev_state); } return FALSE; }
// return TRUE if the key press is processed gboolean ProcessKeyRelease(KeySym keysym, u_int kev_state) { check_CS(); #if 0 dbg_time("key release %x %x\n", keysym, kev_state); #endif if (current_CS->im_state == GCIN_STATE_DISABLED) return FALSE; #if 1 if (current_CS->b_gcin_protocol && (last_keysym == XK_Shift_L || last_keysym == XK_Shift_R || last_keysym == XK_Control_L || last_keysym == XK_Control_R)) { 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; } } #endif #if USE_TSIN switch(current_method_type()) { case method_type_TSIN: return feedkey_pp_release(keysym, kev_state); #if USE_ANTHY case method_type_ANTHY: return feedkey_anthy_release(keysym, kev_state); #endif } #endif return FALSE; }
gboolean init_in_method(int in_no) { gboolean init_im = !(cur_inmd && (cur_inmd->flag & FLAG_GTAB_SYM_KBM)); if (in_no < 0) return FALSE; check_CS(); if (current_CS->in_method != in_no) { if (!(inmd[in_no].flag & FLAG_GTAB_SYM_KBM)) { if (current_method_type() == method_type_TSIN) { flush_tsin_buffer(); } else output_gbuf(); hide_in_win(current_CS); } if (cur_inmd && (cur_inmd->flag & FLAG_GTAB_SYM_KBM)) hide_win_kbm(); } reset_current_in_win_xy(); // dbg("switch init_in_method %x %d\n", current_CS, in_no); set_tsin_pho_mode0(current_CS); tsin_set_win1_cb(); switch (inmd[in_no].method_type) { case method_type_PHO: current_CS->in_method = in_no; init_tab_pho(); break; case method_type_TSIN: set_wselkey(pho_selkey); current_CS->in_method = in_no; init_tab_pp(init_im); break; case method_type_MODULE: { HIME_module_main_functions gmf; init_HIME_module_main_functions(&gmf); if (!inmd[in_no].mod_cb_funcs) { char ttt[256]; strcpy(ttt, inmd[in_no].filename); dbg("module %s\n", ttt); if (!(inmd[in_no].mod_cb_funcs = init_HIME_module_callback_functions(ttt))) { dbg("module not found\n"); return FALSE; } } if (inmd[in_no].mod_cb_funcs->module_init_win(&gmf)) { current_CS->in_method = in_no; module_cb()->module_show_win(); set_wselkey(pho_selkey); } else { return FALSE; } break; } default: init_gtab(in_no); if (!inmd[in_no].DefChars) return FALSE; current_CS->in_method = in_no; if (!(inmd[in_no].flag & FLAG_GTAB_SYM_KBM)) show_win_gtab(); else { win_kbm_inited = 1; show_win_kbm(); } set_gtab_input_method_name(inmd[in_no].cname); break; } #if WIN32 if (current_CS && current_CS->in_method != last_input_method) last_input_method = current_CS->in_method; #endif #if TRAY_ENABLED disp_tray_icon(); #endif if (inmd[current_CS->in_method].selkey) { set_wselkey(inmd[current_CS->in_method].selkey); gtab_set_win1_cb(); // dbg("aa selkey %s\n", inmd[current_CS->in_method].selkey); } update_in_win_pos(); update_win_kbm_inited(); return TRUE; }
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(); }
// 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; }
gboolean init_in_method(int in_no) { gboolean init_im = !(cur_inmd && (cur_inmd->flag & FLAG_GTAB_SYM_KBM)); if (in_no < 0 || in_no > MAX_GTAB_NUM_KEY) return FALSE; check_CS(); if (current_CS->in_method != in_no) { if (!(inmd[in_no].flag & FLAG_GTAB_SYM_KBM)) { if (current_method_type() == method_type_TSIN) { #if USE_TSIN flush_tsin_buffer(); #endif } else output_gbuf(); hide_in_win(current_CS); } if (cur_inmd && (cur_inmd->flag & FLAG_GTAB_SYM_KBM)) hide_win_kbm(); } reset_current_in_win_xy(); // dbg("switch init_in_method %x %d\n", current_CS, in_no); switch (inmd[in_no].method_type) { case method_type_PHO: current_CS->in_method = in_no; init_tab_pho(); break; #if USE_TSIN case method_type_TSIN: current_CS->in_method = in_no; set_tsin_pho_mode0(current_CS); init_tab_pp(init_im); break; #endif case method_type_INT_CODE: current_CS->in_method = in_no; init_inter_code(); break; #if USE_ANTHY case method_type_ANTHY: if (init_win_anthy()) { current_CS->in_method = in_no; show_win_anthy(); } else { return FALSE; } break; #endif default: init_gtab(in_no); if (!inmd[in_no].DefChars) return FALSE; current_CS->in_method = in_no; if (!(inmd[in_no].flag & FLAG_GTAB_SYM_KBM)) show_win_gtab(); else { win_kbm_inited = 1; show_win_kbm(); } set_gtab_input_method_name(inmd[in_no].cname); break; } #if WIN32 if (current_CS && current_CS->in_method != last_input_method) last_input_method = current_CS->in_method; #endif #if TRAY_ENABLED disp_tray_icon(); #endif update_in_win_pos(); update_win_kbm_inited(); return TRUE; }