static void _ecore_imf_context_xim_focus_in(Ecore_IMF_Context *ctx) { EINA_LOG_DBG("in"); #ifdef ENABLE_XIM XIC ic; Ecore_IMF_Context_Data *imf_context_data; imf_context_data = ecore_imf_context_data_get(ctx); EINA_SAFETY_ON_NULL_RETURN(imf_context_data); ic = imf_context_data->ic; imf_context_data->has_focus = EINA_TRUE; if (ecore_imf_context_input_panel_enabled_get(ctx)) ecore_imf_context_input_panel_show(ctx); if (ic) { char *str; #ifdef X_HAVE_UTF8_STRING if ((str = Xutf8ResetIC(ic))) #else if ((str = XmbResetIC(ic))) #endif XFree(str); XSetICFocus(ic); } #else (void)ctx; #endif }
TInputContext::~TInputContext() { char* result = XmbResetIC(fXIC); if (result) XFree(result); XDestroyIC(fXIC); }
void CXWindowsPrimaryScreen::onPreLeave() { assert(m_window != None); if (m_ic != NULL) { XmbResetIC(m_ic); XSetICFocus(m_ic); } }
void X11DRV_ForceXIMReset(HWND hwnd) { XIC ic = X11DRV_get_ic(hwnd); if (ic) { char* leftover; TRACE("Forcing Reset %p\n",ic); leftover = XmbResetIC(ic); XFree(leftover); } }
void WindowContextBase::enableOrResetIME() { Display *display = gdk_x11_display_get_xdisplay(glass_gdk_window_get_display(gdk_window)); if (xim.im == NULL || xim.ic == NULL) { xim.im = XOpenIM(display, NULL, NULL, NULL); if (xim.im == NULL) { return; } XIMStyle styles = get_best_supported_style(xim.im); if (styles == 0) { return; } XIMCallback startCallback = {(XPointer) jview, (XIMProc) im_preedit_start}; XIMCallback doneCallback = {(XPointer) jview, im_preedit_done}; XIMCallback drawCallback = {(XPointer) jview, im_preedit_draw}; XIMCallback caretCallback = {(XPointer) jview, im_preedit_caret}; XVaNestedList list = XVaCreateNestedList(0, XNPreeditStartCallback, &startCallback, XNPreeditDoneCallback, &doneCallback, XNPreeditDrawCallback, &drawCallback, XNPreeditCaretCallback, &caretCallback, NULL); xim.ic = XCreateIC(xim.im, XNInputStyle, styles, XNClientWindow, GDK_WINDOW_XID(gdk_window), XNPreeditAttributes, list, NULL); XFree(list); if (xim.ic == NULL) { return; } } if (xim.enabled) { //called when changed focus to different input XmbResetIC(xim.ic); } XSetICFocus(xim.ic); xim.enabled = TRUE; }
static void _ecore_imf_context_xim_reset(Ecore_IMF_Context *ctx) { EINA_LOG_DBG("%s in", __FUNCTION__); #ifdef ENABLE_XIM XIC ic; Ecore_IMF_Context_Data *imf_context_data; char *result; /* restore conversion state after resetting ic later */ XIMPreeditState preedit_state = XIMPreeditUnKnown; XVaNestedList preedit_attr; Eina_Bool have_preedit_state = EINA_FALSE; imf_context_data = ecore_imf_context_data_get(ctx); EINA_SAFETY_ON_NULL_RETURN(imf_context_data); ic = imf_context_data->ic; if (!ic) return; if (imf_context_data->preedit_length == 0) return; preedit_attr = XVaCreateNestedList(0, XNPreeditState, &preedit_state, NULL); if (!XGetICValues(ic, XNPreeditAttributes, preedit_attr, NULL)) have_preedit_state = EINA_TRUE; XFree(preedit_attr); result = XmbResetIC(ic); preedit_attr = XVaCreateNestedList(0, XNPreeditState, preedit_state, NULL); if (have_preedit_state) XSetICValues(ic, XNPreeditAttributes, preedit_attr, NULL); XFree(preedit_attr); if (imf_context_data->feedbacks) { free(imf_context_data->feedbacks); imf_context_data->feedbacks = NULL; } if (imf_context_data->preedit_length) { imf_context_data->preedit_length = 0; free(imf_context_data->preedit_chars); imf_context_data->preedit_chars = NULL; ecore_imf_context_preedit_changed_event_add(ctx); ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, NULL); } if (result) { char *result_utf8 = strdup(result); if (result_utf8) { ecore_imf_context_commit_event_add(ctx, result_utf8); ecore_imf_context_event_callback_call(ctx, ECORE_IMF_CALLBACK_COMMIT, result_utf8); free(result_utf8); } } XFree(result); #else (void)ctx; #endif }