/* release context from context list */ int release_uim_agent_context(int context_id) { uim_agent_context_list *ptr; for (ptr = agent_context_list_head; ptr != NULL; ptr = ptr->next) { if (ptr->agent_context->context_id == context_id) { uim_agent_context *ua = ptr->agent_context; /* clear current */ if (current == ua) clear_current_uim_agent_context(); /* release */ uim_release_context(ua->context); /* clear candidate */ clear_candidate(ua->cand); free(ua->cand); /* clear preedit */ clear_preedit(ua->pe); free(ua->pe); /* free others */ free(ua->encoding); free(ua->im); free(ua->prop->list); free(ua->prop); free(ua->comstr); /* rebuild list */ if (ptr->next != NULL) ptr->next->prev = ptr->prev; else agent_context_list_tail = ptr->prev; if (ptr->prev != NULL) ptr->prev->next = ptr->next; else agent_context_list_head = ptr->next; free(ua); free(ptr); return context_id; } } return -1; }
/* * remove Emacs local focus from current context */ static int cmd_unfocused(int context_id) { uim_agent_context *ua = get_uim_agent_context(context_id); if (ua) { /* keep preedit if exists */ show_preedit_uim_agent_context(ua); show_candidate_uim_agent_context(ua); check_default_engine(); return clear_current_uim_agent_context(); } else { /* error */ return -1; } }