|  | 
You may find these two routines helpful.
/* Returns time from an event data structure. */
Time
TimeOfEvent ( event )
XEvent          * event;
{
Time            local_time;
/*............................................................................*/
/* Treat null pointer specially. Return CurrentTime. */
if (event == NULL)
    {
    return(CurrentTime);
    }
/* See if this type of event has a time field associated with it. */
switch (event -> type)
    {
    case KeyPress:
        local_time = ((XKeyPressedEvent *) event) -> time;
        break;
    case KeyRelease:
        local_time = ((XKeyReleasedEvent *) event) -> time;
        break;
    case ButtonPress:
        local_time = ((XButtonPressedEvent *) event) -> time;
        break;
    case ButtonRelease:
        local_time = ((XButtonReleasedEvent *) event) -> time;
        break;
    case MotionNotify:
        local_time = ((XPointerMovedEvent *) event) -> time;
        break;
    case EnterNotify:
        local_time = ((XEnterWindowEvent *) event) -> time;
        break;
    case LeaveNotify:
        local_time = ((XLeaveWindowEvent *) event) -> time;
        break;
    case PropertyNotify:
        local_time = ((XPropertyEvent *) event) -> time;
        break;
    case SelectionClear:
        local_time = ((XSelectionClearEvent *) event) -> time;
    case SelectionClear:
        local_time = ((XSelectionClearEvent *) event) -> time;
        break;
    case SelectionRequest:
        local_time = ((XSelectionRequestEvent *) event) -> time;
        break;
    case SelectionNotify:
        local_time = ((XSelectionEvent *) event) -> time;
        break;
    case FocusIn:
    case FocusOut:
    case KeymapNotify:
    case Expose:
    case GraphicsExpose:
    case NoExpose:
    case VisibilityNotify:
    case CreateNotify:
    case DestroyNotify:
    case UnmapNotify:
    case MapNotify:
    case MapRequest:
    case ReparentNotify:
    case ConfigureNotify:
    case ConfigureRequest:
    case GravityNotify:
    case ResizeRequest:
    case CirculateNotify:
    case CirculateRequest:
    case ColormapNotify:
    case ClientMessage:
    case MappingNotify:
        local_time = CurrentTime;
        break;
    }
/* Return the time */
return(local_time);
}
/* Sets input focus to a widget */
void
SetInputFocus(widget, time )
Widget          widget;
Time            time;
{
/*............................................................................*/
/* If the widget has an accept focus routine, then call it. Otherwise,
   try setting the input focus directly. */
if (! XtCallAcceptFocus(widget, & time) )
    {
    /* Above procedure returns FALSE when there is no accept focus routine */
    /* See if this widget has an associated window before setting focus. */
    if (XtWindow (widget) != 0)
        {
        XSetInputFocus (
            XtDisplay (widget),
            XtWindow (widget),
            RevertToNone,                   /* Revert to no one if covered */
            time);
        }
    }
}
 |