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")); } } } }
void _DtTermPrimCursorOn(Widget w) { DtTermPrimitiveWidget tw = (DtTermPrimitiveWidget) w; struct termData *tpd = tw->term.tpd; XPoint point; static Boolean alreadyActive = False; short chunkWidth; enhValues enhancements; unsigned long valueMask = 0L; XGCValues values; TermEnhInfoRec enhInfo; int cursorRow; /* if we are being called cyclically (by _DtTermPrimScrollWait -> * _DtTermPrimExposeText -> _DtTermPrimCursorOn), just return... */ _DtTermProcessLock(); if (alreadyActive) { /*DKS!!! vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ fprintf(stderr, "tell Dave _DtTermPrimCursorOn has alreadyActive == True\n"); /*DKS!!! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */ _DtTermProcessUnlock(); return; } /* this is where we will actually perform a pending scroll and * text refresh... */ if (tw->term.jumpScroll && tpd->scroll.jump.scrolled) { /* make sure we don't end up in an infinite loop... */ alreadyActive = True; Debug('t', fprintf(stderr, ">>_DtTermPrimCursorOn() calling _DtTermPrimScrollWait()\n")); (void) _DtTermPrimScrollWait(w); alreadyActive = False; } _DtTermProcessUnlock(); #ifdef DISOWN_SELECTION_ON_CURSOR_ON_OR_OFF if ( _DtTermPrimSelectIsAboveSelection(w,tpd->cursorRow, tpd->cursorColumn)) { _DtTermPrimSelectDisown(w) ; } #endif /* DISOWN_SELECTION_ON_CURSOR_ON_OR_OFF */ /* update the input method spot location... */ if ((tpd->IMCursorColumn != tpd->cursorColumn) || (tpd->IMCursorRow != tpd->cursorRow)) { tpd->IMCursorColumn = tpd->cursorColumn; tpd->IMCursorRow = tpd->cursorRow; point.x = tpd->cursorColumn * tpd->cellWidth + tpd->offsetX; point.y = tpd->cursorRow * tpd->cellHeight + tpd->offsetY + tpd->ascent; DebugF('F', 1, fprintf(stderr, "%s() %s calling %s\n", "_DtTermPrimCursorOn", "dont care", "XmImVaSetValues()")); (void) XmImVaSetValues(w, XmNspotLocation, &point, NULL); } #ifdef NOT_NEEDED if (!tw->term.hasFocus) { (void) fprintf(stderr, "%s() %s calling %s\n", "_DtTermPrimCursorOn", "!hasFocus", "XmImUnsetFocus()"); (void) XmImUnsetFocus(w); } #endif /* NOT_NEEDED */ /* update the scrollbar and position indicator... */ (void) _DtTermPrimCursorUpdate(w); /* if the cursor is not visible, we are done now... */ if (!tpd->cursorVisible) { return; } /* set up the GC... */ if (!tpd->cursorGC.gc) { tpd->cursorGC.foreground = tw->primitive.foreground ^ tw->core.background_pixel; values.foreground = tpd->cursorGC.foreground; values.function = GXxor; tpd->cursorGC.gc = XCreateGC(XtDisplay(w), XtWindow(w), GCForeground | GCFunction, &values); } /* update the cursor's foreground and background... */ /* if we are past the lastUsedRow, or the column > width, use color * pair 0... */ /* reasonable defaults... */ enhInfo.fg = tw->primitive.foreground; enhInfo.bg = tw->core.background_pixel; if (!((tpd->lastUsedRow <= tpd->topRow + tpd->cursorRow) || (_DtTermPrimBufferGetLineWidth(tpd->termBuffer, tpd->topRow + tpd->cursorRow) <= MIN(tpd->cursorColumn, tw->term.columns - 1)))) { /* get the current enhancement to determine the color pair to use... */ (void) _DtTermPrimBufferGetEnhancement(tpd->termBuffer, /* TermBuffer */ tpd->topRow + tpd->cursorRow, /* row */ MIN(tpd->cursorColumn, tw->term.columns - 1), /* col */ &enhancements, /* enhancements */ &chunkWidth, /* width */ countNew); /* countWhich */ /* set our font and color from the enhancements... */ if (ENH_PROC(tpd->termBuffer)) { (void) (*(ENH_PROC(tpd->termBuffer)))(w, enhancements, &enhInfo); } } /* set the GC... */ if (tpd->cursorGC.foreground != enhInfo.fg ^ enhInfo.bg) { tpd->cursorGC.foreground = enhInfo.fg ^ enhInfo.bg; values.foreground = enhInfo.fg ^ enhInfo.bg; valueMask |= GCForeground; } if (valueMask) { (void) XChangeGC(XtDisplay(w), tpd->cursorGC.gc, valueMask, &values); } if (tpd->cursorState != CURSORoff) { return; } tpd->cursorState = CURSORon; (void) cursorToggle(w); if (tw->term.hasFocus) { /* add a timeout... */ if (tw->term.blinkRate > 0) { tpd->cursorTimeoutId = XtAppAddTimeOut(XtWidgetToApplicationContext(w), tw->term.blinkRate, (XtTimerCallbackProc) timeoutCallback, (XtPointer) w); } } }