xcb_create_gc(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

πŸ’… NAME πŸ’…

xcb_create_gc β€” bestie, it creates a graphics context. that's the whole vibe. ✨


πŸŽ€ SYNOPSIS πŸŽ€

first things first, you gotta pull in the header:

#include <xcb/xproto.h>

✨ Request function ✨

xcb_void_cookie_t xcb_create_gc(xcb_connection_t *conn,
       xcb_gcontext_t cid, xcb_drawable_t drawable, uint32_t value_mask,
       const void *value_list);

πŸ¦‹ REQUEST ARGUMENTS πŸ¦‹

  • conn β€” your XCB connection to X11. the group chat with the X server, basically.
  • cid β€” the ID you'll use to refer to this graphics context later. you make it with xcb_generate_id. so iconic of you.
  • drawable β€” the drawable it's gonna grab the root/depth from.
  • value_mask β€” TODO: NOT YET DOCUMENTED. 😭 yeah bestie, the docs left us on read.
  • value_list β€” TODO: NOT YET DOCUMENTED. πŸ™ˆ same energy, no cap.

🌸 DESCRIPTION 🌸

so it creates a graphics context. that's it, that's the whole thing. 🫢

and here's the lil rule you cannot skip: the graphics context can be used with any drawable that has the same root and depth as the specified drawable. same root, same depth, or it's not gonna work. periodt. πŸ’…


🌈 RETURN VALUE 🌈

it hands you back an xcb_void_cookie_t. so like, if errors pop off (and they might πŸ‘€), you have to deal with them in the event loop. that's just how void cookies work, iykyk.

but if you'd rather handle errors directly with xcb_request_check instead β€” totally valid β€” then use xcb_create_gc_checked. see xcb-requests(3) for the details, bestie. ✨


πŸ’€ ERRORS πŸ’€

these are the ones that can show up, and yes some of them are literally undocumented, we don't make the rules:

  • xcb_alloc_error_t β€” the X server could not allocate the requested resources (no memory? 😭).
  • xcb_drawable_error_t β€” the specified drawable (Window or Pixmap) does not exist. it's giving ghosted.
  • xcb_font_error_t β€” TODO: reasons? 🀷
  • xcb_match_error_t β€” TODO: reasons? 🀷
  • xcb_pixmap_error_t β€” TODO: reasons? 🀷
  • xcb_value_error_t β€” TODO: reasons? 🀷

πŸ‘‘ SEE ALSO πŸ‘‘


πŸ’œ AUTHOR πŸ’œ

generated from xproto.xml. for corrections and improvements, contact xcb@lists.freedesktop.org. they're the ones to dm, not me. 🫢


okay and the lil sign-off so you have the receipts: this is X Version 11, libxcb 1.17.0, and this whole page is xcb_create_gc(3). slay, go make some graphics contexts, bestie. πŸŽ€βœ¨πŸ¦‹