Function x11rb::protocol::xproto::query_tree

source ·
pub fn query_tree<Conn>(
    conn: &Conn,
    window: Window
) -> Result<Cookie<'_, Conn, QueryTreeReply>, ConnectionError>
where Conn: RequestConnection + ?Sized,
Expand description

query the window tree.

Gets the root window ID, parent window ID and list of children windows for the specified window. The children are listed in bottom-to-top stacking order.

Fields

  • window - The window to query.

See

  • xwininfo: program

Example

/*
 * 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);
    }
}