xcb_alloc_color(3)
π xcb_alloc_color β the "make it a color bestie" request π
okay so real talk: this is page xcb_alloc_color(3) from the XCB Requests girlies, and it's literally all about asking the X server to hand you a color. let's get into it π
β¨ NAME β¨
xcb_alloc_color β Allocate a color π¨
πΈ SYNOPSIS πΈ
#include <xcb/xproto.h>
π Request function
xcb_alloc_color_cookie_t xcb_alloc_color(xcb_connection_t *conn,
xcb_colormap_t cmap, uint16_t red, uint16_t green,
uint16_t blue);
π¦ Reply datastructure
typedef struct xcb_alloc_color_reply_t {
uint8_t response_type;
uint8_t pad0;
uint16_t sequence;
uint32_t length;
uint16_t red;
uint16_t green;
uint16_t blue;
uint8_t pad1[2];
uint32_t pixel;
} xcb_alloc_color_reply_t;
π§ Reply function
xcb_alloc_color_reply_t *xcb_alloc_color_reply(xcb_connection_t *conn,
xcb_alloc_color_cookie_t cookie, xcb_generic_error_t **e);
π«Ά REQUEST ARGUMENTS π«Ά
connβ The XCB connection to X11. your lil hotline to the server, basically πcmapβ TODO π (the manpage literally just says TODO, no cap, so we're not gonna invent lore for it)redβ The red value of your color. π΄greenβ The green value of your color. π’blueβ The blue value of your color. π΅
π REPLY FIELDS π
response_typeβ The type of this reply, in this caseXCB_ALLOC_COLOR. This field is also present in thexcb_generic_reply_tand can be used 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.lengthβ The length of the reply, in words (a word is 4 bytes). yes bestie, a word, not a letter, we're in C land now πredβ TODO: NOT YET DOCUMENTED. πgreenβ TODO: NOT YET DOCUMENTED. πblueβ TODO: NOT YET DOCUMENTED. πpixelβ TODO: NOT YET DOCUMENTED. π
π DESCRIPTION π
Allocates a read-only colormap entry corresponding to the closest RGB value supported by the hardware. β¨
If you are using TrueColor, you can take a shortcut and directly calculate the color pixel value to avoid the round trip β lowkey iconic, skip the whole conversation with the server, just do the math yourself π
But, for example, on 16-bit color setups (VNC), you can easily get the closest supported RGB value to the RGB value you are specifying. so like, when the hardware can't give you exactly the shade you want, this is the friend that finds you the closest match π
β RETURN VALUE β
Returns an xcb_alloc_color_cookie_t. Errors have to be handled when calling the reply function xcb_alloc_color_reply.
not me handing you a cookie and then making you come back for the actual answer π that's just how async works bestie
If you want to handle errors in the event loop instead, use xcb_alloc_color_unchecked. See xcb-requests(3) for details.
π ERRORS π
xcb_colormap_error_tβ The specified colormapcmapdoes not exist. she's not here, she never was π«
π₯ SEE ALSO π₯
π AUTHOR π
Generated from xproto.xml. Contact xcb@lists.freedesktop.org for corrections and improvements.
and that's the whole vibe, bestie β¨ go forth and allocate your colors, you absolute main character π¦
this was brought to you by X Version 11, libxcb 1.17.0, and the page xcb_alloc_color(3) β slay, drink water, and remember to call your reply function π
π¦ 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