xcb_get_geometry(3)
β¨ xcb_get_geometry β¨
okay so bestie, we're in the XCB Requests chapter of the libxcb manual, and today's main character is xcb_get_geometry β aka the glow-up that tells you where a thing actually is on screen. π«Ά
πΈ NAME πΈ
xcb_get_geometry β Get current window geometry π
π SYNOPSIS π
#include <xcb/xproto.h>
π¦ Request function
xcb_get_geometry_cookie_t xcb_get_geometry(xcb_connection_t *conn,
xcb_drawable_t drawable);
π¦ Reply datastructure
typedef struct xcb_get_geometry_reply_t {
uint8_t response_type;
uint8_t depth;
uint16_t sequence;
uint32_t length;
xcb_window_t root;
int16_t x;
int16_t y;
uint16_t width;
uint16_t height;
uint16_t border_width;
uint8_t pad0[2];
} xcb_get_geometry_reply_t;
π¦ Reply function
xcb_get_geometry_reply_t *xcb_get_geometry_reply(xcb_connection_t *conn,
xcb_get_geometry_cookie_t cookie, xcb_generic_error_t **e);
π REQUEST ARGUMENTS π
connβ your XCB connection to X11, the lil telephone line to the server πdrawableβ the drawable (Window or Pixmap) whose geometry we're about to go get. no cap, both count β¨
π REPLY FIELDS π
response_typeβ the type of this reply, which in this case isXCB_GET_GEOMETRY. this field is also chillin' in thexcb_generic_reply_t, and you can use it to tell replies apart from each other. it's giving name tag at a party πsequenceβ the sequence number of the last request processed by the X11 server. the receipts, basically π§Ύlengthβ the length of the reply, in words (and a word here is 4 bytes, periodt)depthβ the depth of the drawable (bits per pixel for the object)rootβ root window of the screen containingdrawable. the ultimate ancestor, the mother of all windows πxβ the X coordinate ofdrawable. ifdrawableis a window, this coordinate specifies the upper-left outer corner relative to its parent's origin. ifdrawableis a pixmap, the X coordinate is always0. literally always. zero. πyβ the Y coordinate ofdrawable. same deal: ifdrawableis a window, this coordinate specifies the upper-left outer corner relative to its parent's origin. ifdrawableis a pixmap, the Y coordinate is always0. fr frwidthβ the width ofdrawableheightβ the height ofdrawableborder_widthβ the border width (in pixels). the little fit around the edges π
π DESCRIPTION π
Gets the current geometry of the specified drawable (either Window or Pixmap). that's it, that's the vibe check. obsessed. β¨
π RETURN VALUE π
Returns an xcb_get_geometry_cookie_t. Errors have to be handled when calling the reply function xcb_get_geometry_reply.
If you want to handle errors in the event loop instead, use xcb_get_geometry_unchecked. See xcb-requests(3) for details.
ok so real talk: the cookie is not the answer, it's the promise of an answer. go get your reply, bestie π
π ERRORS π
xcb_drawable_error_tβ TODO: reasons?xcb_window_error_tβ TODO: reasons?
not me leaving the reasons as a mystery π the original page literally says TODO: reasons? so we're keeping that energy exactly as-is. no inventing, no guessing, iykyk.
β EXAMPLE β
/*
* Displays the x and y position of the given window.
*
*/
void my_example(xcb_connection_t *c, xcb_window_t window) {
xcb_get_geometry_cookie_t cookie;
xcb_get_geometry_reply_t *reply;
cookie = xcb_get_geometry(c, window);
/* ... do other work here if possible ... */
if ((reply = xcb_get_geometry_reply(c, cookie, NULL))) {
printf("This window is at %d, %d\n", reply->x, reply->y);
}
free(reply);
}
look at that. send the request, go do your little side quests while the server thinks, then grab the reply and print the coordinates. main character energy, truly π₯
π§ SEE ALSO π§
π AUTHOR π
Generated from xproto.xml. Contact xcb@lists.freedesktop.org for corrections and improvements.
and that's the whole page bestie!! this one's part of X Version 11, shipped with libxcb 1.17.0, and it goes by xcb_get_geometry(3) ππ¦β¨
π¦ 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