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

πŸ’– 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 case XCB_ALLOC_COLOR. This field is also present in the xcb_generic_reply_t and 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 colormap cmap does 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 πŸ’–