NAME
XSetInputFocus − set the keyboard focus window.
Synopsis
XSetInputFocus(display, focus, revert_to, time)
Display *display;
Window focus;
int revert_to;
Time time;
Arguments
displaySpecifies a connection to an X server; returned from XOpenDisplay().
focusSpecifies the ID of the window you want to be the keyboard focus. Pass the window ID, PointerRoot, or None.
revert_to
Specifies which window the keyboard focus reverts to if the focus window becomes not viewable. Pass one of these constants: RevertToParent, RevertToPointerRoot, or RevertToNone. Must not be a window ID.
timeSpecifies the time when the focus change should take place. Pass either a timestamp, expressed in milliseconds, or the constant CurrentTime. Also returns the time of the focus change when CurrentTime is specified.
Description
XSetInputFocus() changes the keyboard focus and the last-focus-change time. The function has no effect if time is earlier than the current last-focus-change time or later than the current X server time. Otherwise, the last-focus-change time is set to the specified time, with CurrentTime replaced by the current X server time. XSetInputFocus() generates FocusIn and FocusOut events if focus is different from the current focus. XSetInputFocus() executes as follows, depending on what value you assign to the focus argument:
•If you assign None, all keyboard events are discarded until you set a new focus window. In this case, revert_to is ignored.
•If you assign a window ID, it becomes the main keyboard’s focus window. If a generated keyboard event would normally be reported to this window or one of its inferiors, the event is reported normally; otherwise, the event is reported to the focus window. The specified focus window must be viewable at the time of the request (else a BadMatch error). If the focus window later becomes not viewable, the focus window will change to the revert_to argument.
•If you assign PointerRoot, the focus window is dynamically taken to be the root window of whatever screen the pointer is on at each keyboard event. In this case, revert_to is ignored. This is the default keyboard focus setting. If the focus window later becomes not viewable, XSetInputFocus() evaluates the revert_to argument to determine the new focus window:
•If you assign RevertToParent, the focus reverts to the parent (or the closest viewable ancestor) automatically with a new revert_to
•If you assign RevertToPointerRoot or RevertToNone, the focus reverts to that value automatically. FocusIn and FocusOut events are generated when the focus reverts, but the last focus change time is not affected.
Errors
BadMatchfocus window not viewable when XSetInputFocus() called.
BadValue
BadWindow
See Also
QLength(), XAllowEvents(), XCheckIfEvent(), XCheckMaskEvent(), XCheckTypedEvent(), XCheckTypedWindowEvent(), XCheckWindowEvent(), XEventsQueued(), XGetInputFocus(), XGetMotionEvents(), XIfEvent(), XMaskEvent(), XNextEvent(), XPeekEvent(), XPeekIfEvent(), XPending(), XPutBackEvent(), XSelectInput(), XSendEvent(), XSynchronize(), XWindowEvent.
Copyright O’Reilly & Assoc. —