XSetInputFocus()XSetInputFocus()NameXSetInputFocus – set the keyboard focus window.
Synopsis
XSetInputFocus(display, focus, revert_to, time)
Display *display;
Window focus;
int revert_to;
Time time;
Arguments
display Specifies a connection to an X server; returned from XOpenDis‐
play().
focus Specifies 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 con‐
stants: RevertToParent, RevertToPointerRoot, or RevertToNone.
Must not be a window ID.
time Specifies 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.
DescriptionXSetInputFocus() 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. Other‐
wise, 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 dif‐
ferent 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 win‐
dow. 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 key‐
board event. In this case, revert_to is ignored. This is the
default keyboard focus setting.
If the focus window later becomes not viewable, XSetInputFocus() evalu‐
ates 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
argument of RevertToName.
· If you assign RevertToPointerRoot or RevertToNone, the focus reverts
to that value automatically. FocusIn and FocusOut events are gener‐
ated when the focus reverts, but the last focus change time is not
affected.
Errors
BadMatch focus window not viewable when XSetInputFocus() called.
BadValue
BadWindow
See AlsoXQLength(), XAllowEvents(), XCheckIfEvent(), XCheckMaskEvent(), XCheck‐
TypedEvent(), XCheckTypedWindowEvent(), XCheckWindowEvent(),
XEventsQueued(), XGetInputFocus(), XGetMotionEvents(), XIfEvent(),
XMaskEvent(), XNextEvent(), XPeekEvent(), XPeekIfEvent(), XPending(),
XPutBackEvent(), XSelectInput(), XSendEvent(), XSynchronize(), XWindow‐
Event().
Xlib - Input Handling XSetInputFocus()