xcb_query_tree(3)
โจ xcb_query_tree(3) โจ
okay bestie, welcome to xcb_query_tree from section 3 of the manual โ yes the library-functions girly section ๐
this one lives in libxcb and it's literally the request that lets you peek at a window's family tree. iconic behavior honestly ๐
๐ธ NAME ๐ธ
xcb_query_tree โ query the window tree ๐ณ
๐ SYNOPSIS ๐
#include <xcb/xproto.h>
๐ Request function
xcb_query_tree_cookie_t xcb_query_tree(xcb_connection_t *conn,
xcb_window_t window);
๐ Reply datastructure
typedef struct xcb_query_tree_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
xcb_window_t root;
xcb_window_t parent;
uint16_t children_len;
uint8_t pad1[14];
} xcb_query_tree_reply_t;
๐ Reply function
xcb_query_tree_reply_t *xcb_query_tree_reply(xcb_connection_t *conn,
xcb_query_tree_cookie_t cookie, xcb_generic_error_t **e);
๐ Reply accessors
xcb_window_t *xcb_query_tree_children(const xcb_query_tree_request_t
*reply);
int xcb_query_tree_children_length(const xcb_query_tree_reply_t *reply);
xcb_generic_iterator_t xcb_query_tree_children_end(const
xcb_query_tree_reply_t *reply);
๐ REQUEST ARGUMENTS ๐
connโ the XCB connection to X11, your little lifeline to the server fr fr ๐ซถwindowโ the window you're interrogating. the one you wanna know everything about ๐
๐ REPLY FIELDS ๐
response_typeโ the type of this reply, which in this case isXCB_QUERY_TREE. this field is also chillin' inside thexcb_generic_reply_t, so you can use it to tell your replies apart from each other. vibe check for replies basically โจsequenceโ the sequence number of the last request the X11 server actually processed.lengthโ the length of the reply, measured in words. and a word is 4 bytes, no cap ๐rootโ the root window ofwindow. the ancestor of all ancestors ๐ณparentโ the parent window ofwindow. yes she has a mom ๐children_lenโ how many child windows there are. count 'em ๐งฎ
๐ฆ DESCRIPTION ๐ฆ
so this request gets you three things for the window you specify: the root window ID, the parent window ID, and the list of children windows. and the children come back listed in bottom-to-top stacking order โ so the bottom-most one is first, going up from there. stacking order, not alphabetical, bestie, don't get it twisted ๐
โญ RETURN VALUE โญ
it hands you back an xcb_query_tree_cookie_t ๐ช (yes, cookie, we love a snack). any errors have to be dealt with when you call the reply function, xcb_query_tree_reply.
if you'd rather handle your errors inside the event loop instead, then use xcb_query_tree_unchecked. see xcb-requests(3) for the deets ๐
๐ ERRORS ๐
this request does never generate any errors. not one. zero. she's unproblematic and we love that for her ๐โจ
๐ EXAMPLE ๐
here's the whole thing, verbatim, so you can copy it straight into your little project:
/*
* Displays the root, parent and children of the specified window.
*
*/
void my_example(xcb_connection_t *conn, xcb_window_t window) {
xcb_query_tree_cookie_t cookie;
xcb_query_tree_reply_t *reply;
cookie = xcb_query_tree(conn, window);
if ((reply = xcb_query_tree_reply(conn, cookie, NULL))) {
printf("root = 0x%08x\n", reply->root);
printf("parent = 0x%08x\n", reply->parent);
xcb_window_t *children = xcb_query_tree_children(reply);
for (int i = 0; i < xcb_query_tree_children_length(reply); i++)
printf("child window = 0x%08x\n", children[i]);
free(reply);
}
}
bestie, don't forget the free(reply) at the end. the way that memory is not gonna free itself ๐ญ
๐ฅ SEE ALSO ๐ฅ
xcb-requests(3), xcb-examples(3), xwininfo(1)
๐ AUTHOR ๐
Generated from xproto.xml. Contact xcb@lists.freedesktop.org for corrections and improvements.
kisses, that's the whole page ๐ซถ this was brought to you by X Version 11 and libxcb 1.17.0 โ she's serving xcb_query_tree(3) realness and honestly? obsessed. go query that tree bestie ๐ณ๐โจ
๐ฆ 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