xcb_get_input_focus(3)

πŸ“¦
version 1.17.0 Β· 4 versions
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ xcb_get_input_focus β€” bestie, let's find out who has the keyboard ✨

okay so this is a page from the XCB Requests manual, and the star of the show is xcb_get_input_focus(3) πŸ’… it's the little request that asks the X11 server "hey queen, which window has the input focus rn?" πŸ‘‘


🌸 NAME 🌸

xcb_get_input_focus β€” no fancy tagline, the manpage literally just leaves it at the name and a dash, and honestly? iconic minimalism πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

First things first, you gotta pull in the header:

#include <xcb/xproto.h>

✨ Request function ✨

xcb_get_input_focus_cookie_t xcb_get_input_focus(xcb_connection_t *conn,

πŸ’– Reply datastructure πŸ’–

this is the struct you get back, look at her:

typedef struct xcb_get_input_focus_reply_t {
    uint8_t      response_type;
    uint8_t      revert_to;
    uint16_t     sequence;
    uint32_t     length;
    xcb_window_t focus;
} xcb_get_input_focus_reply_t;

🫢 Reply function 🫢

xcb_get_input_focus_reply_t
       *xcb_get_input_focus_reply(xcb_connection_t *conn,
       xcb_get_input_focus_cookie_t cookie, xcb_generic_error_t **e);

πŸŽ€ REQUEST ARGUMENTS πŸŽ€

just the one bestie, and it's the usual suspect:

  • conn β€” the XCB connection to X11. it's your lil hotline to the server πŸ“ž

πŸ’œ REPLY FIELDS πŸ’œ

here's the tea on every single field you're getting back:

  • response_type β€” what kind of reply this is. in this case it's XCB_GET_INPUT_FOCUS. this field also lives in the xcb_generic_reply_t, so you can use it to tell your replies apart from each other πŸ‘€
  • sequence β€” the sequence number of the last request the X11 server processed. it's giving receipt tracking fr fr 🧾
  • length β€” how long the reply is, measured in words. and yes, a word is 4 bytes in case you were about to guess 🌈
  • revert_to β€” one of these values, no cap:
    • XCB_INPUT_FOCUS_NONE β€” the focus reverts to XCB_NONE, so literally no window gets the input focus. the void. the nothingness. πŸ’€
    • XCB_INPUT_FOCUS_POINTER_ROOT β€” the focus reverts to XCB_POINTER_ROOT respectively. when the focus reverts, FocusIn and FocusOut events get generated, but the last-focus-change time does not change. okay subtle but important, noted πŸ“
    • XCB_INPUT_FOCUS_PARENT β€” the focus reverts to the parent (or the closest viewable ancestor) and the new revert_to value becomes XCB_INPUT_FOCUS_NONE. it's giving "go ask your mom" energy 🫣
    • XCB_INPUT_FOCUS_FOLLOW_KEYBOARD β€” NOT YET DOCUMENTED. only relevant for the xinput extension. and then there's a TODO: NOT YET DOCUMENTED. sitting right there under it. bestie the docs said "we'll finish this later" and never came back 😭
  • focus β€” TODO: NOT YET DOCUMENTED. yeah. that's the whole description. the field that literally tells you which window is focused... undocumented πŸ™ˆ i know. i know.

🌈 DESCRIPTION 🌈

okay so the DESCRIPTION section on this page is... empty. nothing. a whole vibe. we move 🧚


⭐ RETURN VALUE ⭐

Returns an xcb_get_input_focus_cookie_t. πŸͺ

the catch: errors have to be handled when you call the reply function xcb_get_input_focus_reply. so don't just grab the cookie and ghost it, okay?

if you'd rather handle errors in the event loop instead, use xcb_get_input_focus_unchecked. see xcb-requests(3) for the details on all that πŸ’–


πŸ”₯ ERRORS πŸ”₯

This request does never generate any errors. zero. none. not a single one. slay πŸŽ‰

πŸ‘‘ SEE ALSO πŸ‘‘

(also empty on this page β€” the original just leaves the heading hanging there like an unread text πŸ’€)


🌸 AUTHOR 🌸

Generated from xproto.xml. got corrections or improvements? hit up xcb@lists.freedesktop.org πŸ“§


and that's the whole page bestie 🫢 this one came from X Version 11 and libxcb 1.17.0, and it's filed under the xcb_get_input_focus(3) name. go get that focus, main character πŸ’…βœ¨πŸŽ€