int _xim_forward_event(XIMHandle* handle, IMForwardEventStruct* proto) { LOG("%d", proto->icid); XKeyEvent* evt = (XKeyEvent*) &(proto->event); IC* ic = icmgr_get_current(); if (ic == NULL) { icmgr_set_current(proto->icid); ic = icmgr_get_current(); if (ic == NULL) return 1; } /* some of swing applications like netbeans won't set focus, * we have to set focus ourself */ if (ic->icid != proto->icid || preedit_status() == false) { icmgr_set_current(proto->icid); ic = icmgr_get_current(); icmgr_refresh(); } if (!__filter_forward_triger_key(handle, ic, evt)) { int masked_state = evt->state & STATE_MASK; if (masked_state != ShiftMask && masked_state != 0) { __do_forward_event(handle, proto); } else if (!ic->is_enabled || ic->is_english) { __do_forward_event(handle, proto); } else { KeySym sym; XLookupString(evt, NULL, 0, &sym, NULL); if ((sym <= 0x20 || sym > 0x7E) && preedit_status() == false) { __do_forward_event(handle, proto); } else if (sym >= 0x30 && sym <= 0x39 && preedit_status() == false) { // digit key pressed if (settings_get_int(SMART_PUNCT) && evt->type == KeyPress) { preedit_omit_next_punct(); } __do_forward_event(handle, proto); } else { if (evt->type == KeyPress) { __move_preedit(ic); preedit_on_key(handle, sym, evt->state); } else { LOG("ignore"); } } } } return 1; }
static int _xim_set_ic_focus(XIMHandle* handle, IMChangeFocusStruct* proto) { DEBUG("%d", proto->icid); LOG("set focus on ic %d %d", proto->icid, preedit_status()); /* if use didn't finish typing, we won't focus to new context */ if (preedit_status() == false) { icmgr_set_current(proto->icid); } icmgr_refresh(); return 1; }
static int _xim_unset_ic_focus(XIMHandle* handle, IMChangeFocusStruct* proto) { LOG("unset focus on ic %d", proto->icid); IC* ic = icmgr_get_current(); if (ic != NULL && ic->icid == proto->icid && preedit_status() == false) { icmgr_clear_current(); icmgr_refresh(); } return 1; }