XSetInputFocus(3)
π NAME π
okay so bestie, this is XSetInputFocus(3) β¨ β the Xlib page for XSetInputFocus and XGetInputFocus, aka the functions that control input focus π. Yes, itβs the βwho gets the keyboard rnβ manual, and itβs lowkey main character energy.
π¦ SYNTAX π¦
int XSetInputFocus(Display *display, Window focus, int revert_to, Time
time);
int XGetInputFocus(Display *display, Window *focus_return, int
*revert_to_return);
π ARGUMENTS π
displayβ Specifies the connection to the X server. the whole βhi, X serverβ situation πfocusβ Specifies the window,PointerRoot, orNone. pick your focus fave β¨focus_returnβ Returns the focus window,PointerRoot, orNone.revert_toβ Specifies where the input focus reverts to if the window becomes not viewable. You can passRevertToParent,RevertToPointerRoot, orRevertToNone.revert_to_returnβ Returns the current focus state (RevertToParent,RevertToPointerRoot, orRevertToNone).timeβ Specifies the time. You can pass either a timestamp orCurrentTime.
πΈ DESCRIPTION πΈ
The XSetInputFocus function changes the input focus and the last-focus-change time. It has no effect if the specified time is earlier than the current last-focus-change time or is later than the current X server time. Otherwise, the last-focus-change time is set to the specified time (CurrentTime is replaced by the current X server time). XSetInputFocus causes the X server to generate FocusIn and FocusOut events. π
Depending on the focus argument, the following occurs:
- If
focusisNone, all keyboard events are discarded until a new focus window is set, and therevert_toargument is ignored. bye-bye keyboard input, fr fr π - If
focusis a window, it becomes the 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 as usual. Otherwise, the event is reported relative to the focus window. - If
focusisPointerRoot, 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, therevert_toargument is ignored. pointer-following realness π±οΈβ¨
The specified focus window must be viewable at the time XSetInputFocus is called, or a BadMatch error results. If the focus window later becomes not viewable, the X server evaluates the revert_to argument to determine the new focus window as follows:
- If
revert_toisRevertToParent, the focus reverts to the parent (or the closest viewable ancestor), and the newrevert_tovalue is taken to beRevertToNone. - If
revert_toisRevertToPointerRootorRevertToNone, the focus reverts toPointerRootorNone, respectively. When the focus reverts, the X server generatesFocusInandFocusOutevents, but the last-focus-change time is not affected.
XSetInputFocus can generate BadMatch, BadValue, and BadWindow errors. β οΈ
The XGetInputFocus function returns the focus window and the current focus state. slay, thatβs the whole vibe check π«Ά
π DIAGNOSTICS π
BadValueβ Some numeric value falls outside the range of values accepted by the request. Unless a specific range is specified for an argument, the full range defined by the argumentβs type is accepted. Any argument defined as a set of alternatives can generate this error.BadWindowβ A value for aWindowargument does not name a definedWindow.
π SEE ALSO π
XWarpPointer(3)Xlib - C Language X Interface
cute little sign-off to the footer, bestie: X Version 11, libX11 1.8.14, and XSetInputFocus(3) πβ¨ date? the original footer doesnβt list one, and weβre not out here inventing facts π
π¦ where this page comes from
- alpine 3.24: libx11-doc 1.8.14-r0 Β· X11
- arch rolling: libx11 1.8.14-1 Β· MIT AND X11
- nixos 26.05: libx11 1.8.14
- nixpkgs unstable: libx11 1.8.14
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms