xcb_set_input_focus(3)
๐ xcb_set_input_focus โ bestie, we're setting the input focus ๐
okay so this is a page from the XCB Requests corner of the manual, and today's main character is xcb_set_input_focus(3). yes we're doing X11 protocol stuff. yes it's giving โจkeyboard authorityโจ. let's go.
๐ธ NAME ๐ธ
xcb_set_input_focus โ sets input focus ๐ฏ
๐ฆ SYNOPSIS ๐ฆ
#include <xcb/xproto.h>
โจ Request function โจ
xcb_void_cookie_t xcb_set_input_focus(xcb_connection_t *conn,
uint8_t revert_to, xcb_window_t focus, xcb_timestamp_t time);
like. look at her. four little args and she controls who gets the keyboard. iconic behavior honestly ๐
๐ REQUEST ARGUMENTS ๐
connโ the XCB connection to X11. your lil hotline to the server, bestie ๐ซถrevert_toโ one of the following values. this is the "what happens when things go sideways" setting, so pay attention:XCB_INPUT_FOCUS_NONEโ the focus reverts toXCB_NONE, so literally no window will have the input focus. nobody. zero. empty. ๐XCB_INPUT_FOCUS_POINTER_ROOTโ the focus reverts toXCB_POINTER_ROOTrespectively. when the focus reverts,FocusInandFocusOutevents are generated, but the last-focus-change time is not changed. (not me remembering that one specific exception, but yes, noted ๐)XCB_INPUT_FOCUS_PARENTโ the focus reverts to the parent (or closest viewable ancestor), and the newrevert_tovalue isXCB_INPUT_FOCUS_NONE.XCB_INPUT_FOCUS_FOLLOW_KEYBOARDโ NOT YET DOCUMENTED. only relevant for the xinput extension. (mystery queen. we don't know her. ๐ฎ)
so basically revert_to specifies what happens when the focus window becomes unviewable (that's if focus is neither XCB_NONE nor XCB_POINTER_ROOT).
focusโ the window to focus. all keyboard events will be reported to this window. the window must be viewable (TODO), or axcb_match_error_toccurs (TODO).- if
focusisXCB_NONE(TODO), all keyboard events are discarded until a new focus window is set. keyboard goes quiet. ghost town energy ๐ป - if
focusisXCB_POINTER_ROOT(TODO), focus is on the root window of the screen on which the pointer is on currently.
- if
timeโ timestamp to avoid race conditions when running X over the network. bestie, networking is chaos and this is your little shield ๐ก๏ธ- the special value
XCB_CURRENT_TIMEwill be replaced with the current server time. slay, let the server decide โฐ
- the special value
๐ DESCRIPTION ๐
changes the input focus and the last-focus-change time. two for one, we love efficiency.
if the specified time is earlier than the current last-focus-change time, the request is ignored (to avoid race conditions when running X over the network). so if you're late with your timestamp, you get nothing. the request said "too slow" and moved on ๐โ๏ธ๐จ
a FocusIn and FocusOut event is generated when focus is changed. events! drama! the group chat is notified ๐ฃ
โญ RETURN VALUE โญ
returns an xcb_void_cookie_t. errors (if any) have to be handled in the event loop. no sneaky return-value checks here, you gotta go to the loop for that.
if you want to handle errors directly with xcb_request_check instead, use xcb_set_input_focus_checked. see xcb-requests(3) for details. ๐
๐ฅ ERRORS ๐ฅ
xcb_match_error_tโ the specified focus window is not viewable.xcb_value_error_tโ TODO: Reasons? (the manpage itself is like "idk bestie" ๐ญ)xcb_window_error_tโ the specified focus window does not exist.
๐ SEE ALSO ๐
xcb-requests(3)xcb_focus_in_event_t(3)xcb_focus_out_event_t(3)
๐ AUTHOR ๐
generated from xproto.xml. contact xcb@lists.freedesktop.org for corrections and improvements. they're literally asking for feedback, so if you spot something, tell them ๐ซถ
heads up bestie:timematters,focushas to be viewable or you eat an error, and the two TODOs plus the NOT YET DOCUMENTED are exactly how the original page reads. i'm not making anything up, i'm just being cute about it ๐
and that's the whole page, fr fr. this was X Version 11, from libxcb 1.17.0, and you just read xcb_set_input_focus(3). mwah, go focus a window responsibly ๐โจ
๐ฆ where this page comes from
- alpine 3.22: libxcb-doc 1.17.0-r0 ยท MIT
- alpine 3.23: libxcb-doc 1.17.0-r1 ยท MIT
- alpine 3.24: libxcb-doc 1.17.0-r2 ยท MIT
- arch rolling: libxcb 1.17.0-1 ยท X11
- centos-stream 10: libxcb-devel 1.17.0-3.el10 ยท X11
- debian trixie: libxcb-doc 1.17.0-2
- fedora 43: libxcb-devel 1.17.0-6.fc43 ยท X11
- fedora 43: libxcb-devel 1.17.0-6.fc43 ยท X11
- fedora 44: libxcb-devel 1.17.0-7.fc44 ยท X11
- fedora 44: libxcb-devel 1.17.0-7.fc44 ยท X11
- nixpkgs unstable: libxcb 1.17.0
- opensuse-leap 16.0: libxcb-devel-doc 1.17.0-160000.2.2 ยท MIT
- ubuntu questing: libxcb-doc 1.17.0-2build1
- ubuntu resolute: libxcb-doc 1.17.0-2ubuntu1
- ubuntu stonking: libxcb-doc 1.17.0-2ubuntu1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms