void XIM_focus_event (struct frame *f, int in_p) { if (in_p) XmImVaSetFocusValues (FRAME_X_TEXT_WIDGET (f), NULL); else XmImUnsetFocus (FRAME_X_TEXT_WIDGET (f)); }
void _DtTermPrimCursorChangeFocus(Widget w) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; struct termData *tpd = tw->term.tpd; XPoint point; if (tw->term.hasFocus) { /* if the input method already didn't have focus or the cursor * position has changed, then set the input method focus and * spot location... */ if ((!tpd->IMHasFocus) || (tpd->IMCursorColumn != tpd->cursorColumn) || (tpd->IMCursorRow != tpd->cursorRow)) { tpd->IMHasFocus = True; tpd->IMCursorColumn = tpd->cursorColumn; tpd->IMCursorRow = tpd->cursorRow; point.x = tpd->IMCursorColumn * tpd->cellWidth + tpd->offsetX; point.y = tpd->IMCursorRow * tpd->cellHeight + tpd->offsetY + tpd->ascent; DebugF('F', 1, fprintf(stderr, "%s() %s calling %s\n", "_DtTermPrimCursorChangeFocus", "hasFocus", "XmImVaSetFocusValues()")); (void) XmImVaSetFocusValues(w, XmNspotLocation, &point, NULL); } /* we want to blink now... */ if (tpd->cursorVisible && (!tpd->cursorTimeoutId) && (tw->term.blinkRate > 0) && (tpd->cursorState != CURSORoff)) { Debug('F', fprintf(stderr, ">>we got focus, turning off cursor...\n")); (void) cursorToggle(w); /* add a timeout... */ Debug('F', fprintf(stderr, ">>adding a timeout...\n")); tpd->cursorTimeoutId = XtAppAddTimeOut( XtWidgetToApplicationContext(w), tw->term.blinkRate, timeoutCallback, (XtPointer) w); } } else { if (tpd->IMHasFocus) { tpd->IMHasFocus = False; DebugF('F', 1, fprintf(stderr, "%s() %s calling %s\n", "_DtTermPrimCursorChangeFocus", "!hasFocus", "XmImUnsetFocus()")); /* remove input method focus... */ (void) XmImUnsetFocus(w); } /* we want to stop blinking now... */ if (tpd->cursorTimeoutId && (tpd->cursorState != CURSORoff)) { Debug('F', fprintf(stderr, ">>we lost focus...\n")); if (CURSORon == tpd->cursorState) { /* we need to make the cursor visible... */ Debug('F', fprintf(stderr, ">>turning on the cursor...\n")); (void) cursorToggle(w); } /* we need to kill the timeout... */ Debug('F', fprintf(stderr, ">>removing the timeout...\n")); (void) XtRemoveTimeOut(tpd->cursorTimeoutId); tpd->cursorTimeoutId = (XtIntervalId) 0; } else { if (tw->term.blinkRate > 0) { Debug('F', fprintf(stderr, ">>we lost focus, but cursor is not on and blinking...\n")); } } } }