uim_agent_context * switch_context_im(uim_agent_context *ua, const char *im) { const char *encoding; debug_printf(DEBUG_NOTE, "switch_context_im\n"); encoding = get_im_encoding(im); /* update IM name */ free(ua->im); if (im) ua->im = uim_strdup(im); else ua->im = NULL; if (strcmp(ua->encoding, encoding) == 0) { /* encodings are same */ debug_printf(DEBUG_NOTE, "same encoding %s %s\n", ua->im, im); update_context_im(ua); uim_prop_list_update(ua->context); } else { /* encodings are different */ debug_printf(DEBUG_NOTE, "different encoding %s %s\n", ua->encoding, encoding); free(ua->encoding); ua->encoding = uim_strdup(encoding); update_context_encoding(ua); update_context_im(ua); } uim_prop_list_update(ua->context); return ua; }
int set_current_uim_agent_context(uim_agent_context *ua) { debug_printf(DEBUG_NOTE, "set_current_context\n"); if (ua == NULL || ua->context == NULL) { debug_printf(DEBUG_ERROR, "set_current_context: invalid context\n"); return -1; } helper_send_message("focus_in\n"); current = ua; focused = 1; uim_prop_list_update(ua->context); return ua->context_id; }
void InputContext::focusIn() { setlocale(LC_CTYPE, mLocaleName); check_helper_connection(); uim_helper_client_focus_in(mUc); mFocusedContext = this; if (mConvdisp) { mConvdisp->unset_focus(); mConvdisp->move_candwin(); mConvdisp->update_caret_state(); } uim_prop_list_update(mUc); uim_prop_label_update(mUc); if (hasActiveCandwin()) candidate_update(); uim_focus_in_context(mUc); }
void QUimInputContext::setFocus() { #ifdef ENABLE_DEBUG qDebug( "QUimInputContext: %p->setFocus(), focusWidget()=%p", this, focusWidget() ); #endif focusedInputContext = this; disableFocusedContext = false; if ( candwinIsActive ) cwin->popup(); m_HelperManager->checkHelperConnection(); uim_helper_client_focus_in( m_uc ); uim_prop_list_update( m_uc ); uim_focus_in_context( m_uc ); }
uim_context QUimInputContext::createUimContext( const char *imname ) { m_imname = imname; uim_context uc = uim_create_context( this, "UTF-8", NULL, ( char * ) imname, NULL, QUimInputContext::commit_cb ); m_HelperManager->checkHelperConnection(); /**/ uim_set_preedit_cb( uc, QUimInputContext::clear_cb, QUimInputContext::pushback_cb, QUimInputContext::update_cb ); uim_set_candidate_selector_cb( uc, QUimInputContext::cand_activate_cb, QUimInputContext::cand_select_cb, QUimInputContext::cand_shift_page_cb, QUimInputContext::cand_deactivate_cb ); uim_set_prop_list_update_cb( uc, QUimHelperManager::update_prop_list_cb ); uim_set_prop_label_update_cb( uc, QUimHelperManager::update_prop_label_cb ); uim_set_im_switch_request_cb( uc, QUimInputContext::switch_app_global_im_cb, QUimInputContext::switch_system_global_im_cb); uim_set_text_acquisition_cb( uc, QUimTextUtil::acquire_text_cb, QUimTextUtil::delete_text_cb); uim_prop_list_update( uc ); return uc; }
void InputContext::createUimContext(const char *engine) { char *locale; const char *client_locale, *engine_locales; const char *encoding; const char *real_im; encoding = mXic->get_encoding(); client_locale = mXic->get_lang_region(); engine_locales = compose_localenames_from_im_lang(get_im_lang_from_engine(engine)); if (!strcmp(encoding, "UTF-8")) { real_im = engine; if (is_locale_included(engine_locales, client_locale)) locale = strdup(client_locale); else { locale = get_prefered_locale(engine_locales); } } else { // Use default engine for corresponding encoding of the client // unless encoding matches with selected engine. if (!is_locale_included(engine_locales, client_locale)) { const char *test_im = uim_get_default_im_name(client_locale); const char *test_im_lang = get_im_lang_from_engine(test_im); const char *test_im_locales = compose_localenames_from_im_lang(test_im_lang); if (is_locale_included(test_im_locales, client_locale)) real_im = test_im; else real_im = uim_get_im_name_for_locale(client_locale); } else real_im = engine; locale = strdup(client_locale); } locale = (char *)realloc(locale, strlen(locale) + strlen(encoding) + 2); strcat(locale, "."); strcat(locale, encoding); setlocale(LC_CTYPE, locale); free(mLocaleName); mLocaleName = locale; if (mEngineName != real_im) { free(mEngineName); mEngineName = strdup(real_im); } uim_context uc = uim_create_context((void *) this, "UTF-8", NULL, real_im, NULL, InputContext::commit_cb); if (uc) { uim_set_preedit_cb(uc, InputContext::clear_cb, InputContext::pushback_cb, InputContext::update_cb); uim_set_candidate_selector_cb(uc, InputContext::candidate_activate_cb, InputContext::candidate_select_cb, InputContext::candidate_shift_page_cb, InputContext::candidate_deactivate_cb); uim_set_prop_list_update_cb(uc, InputContext::update_prop_list_cb); #if 0 uim_set_prop_label_update_cb(uc, InputContext::update_prop_label_cb); #endif uim_set_configuration_changed_cb(uc, InputContext::configuration_changed_cb); uim_set_im_switch_request_cb(uc, InputContext::switch_app_global_im_cb, InputContext::switch_system_global_im_cb); #if UIM_XIM_USE_DELAY uim_set_delay_candidate_selector_cb(uc, InputContext::candidate_activate_with_delay_cb); #endif if (mFocusedContext == this) uim_prop_list_update(uc); } mUc = uc; }