XcmsAllocColor(3)
π NAME π
okay so this is XcmsAllocColor(3) β yes, the XLIB FUNCTIONS manual page, bestie. The two functions here are XcmsAllocColor and XcmsAllocNamedColor, and their whole thing is allocating colors. iconic behavior, honestly. β¨
π SYNTAX π
Status XcmsAllocColor(Display *display, Colormap colormap, XcmsColor
*color_in_out, XcmsColorFormat result_format);
Status XcmsAllocNamedColor(Display *display, Colormap colormap, _Xconst
char *color_string, XcmsColor *color_screen_return, XcmsColor
*color_exact_return, XcmsColorFormat result_format);
π ARGUMENTS π
displayβ tells it which X server connection we're talking to. πcolormapβ the colormap in question, periodt.color_stringβ this one shows up in theXcmsAllocNamedColorsyntax, but the original ARGUMENTS list doesn't give it a standalone description. The color-string sentence is chillin' undercolor_screen_returnbelow, and I'm leaving it right there. π«Άcolor_exact_returnβ returns the color specification parsed from the color string, or parsed from the matching string found in a color-name database. πcolor_in_outβ you put in the color to allocate; it comes back with the pixel and color that actually got used in the colormap. β¨color_screen_returnβ returns the pixel value of the color cell and the color specification that's actually stored for that cell. Also, the original page has βSpecifies the color string whose color definition structure is to be returned.β sitting right here under this argument β yes, really, I'm not moving it. πresult_formatβ specifies the color format you want for the returned color specification. πΈ
π¦ DESCRIPTION π¦
So XcmsAllocColor is basically XAllocColor's more flexible bestie: same allocation vibe, except the color can be specified in any format. It ultimately calls XAllocColor to allocate a read-only color cell (colormap entry) with the specified color. The way it does that: XcmsAllocColor first converts the color you specified to an RGB value, then passes that to XAllocColor. It returns the pixel value of the color cell and the color specification actually allocated. That returned color specification is the result of converting the RGB value returned by XAllocColor into the format specified with the result_format argument. If you don't care about a returned color specification, unnecessary computation can be bypassed if result_format is set to XcmsRGBFormat. The corresponding colormap cell is read-only. And if this routine returns XcmsFailure, the color_in_out color specification is left unchanged. π
XcmsAllocColor can generate BadColor errors.
XcmsAllocNamedColor is similar to XAllocNamedColor, except that the color returned can be in any format specified. This function ultimately calls XAllocColor to allocate a read-only color cell with the color specified by a color string. The color string is parsed into an XcmsColor structure (see XcmsLookupColor), converted to an RGB value, and finally passed to XAllocColor. If the color name is not in the Host Portable Character Encoding, the result is implementation-dependent. Use of uppercase or lowercase does not matter. π₯
This function returns both the color specification as a result of parsing (the exact specification) and the actual color specification stored (the screen specification). This screen specification is the result of converting the RGB value returned by XAllocColor into the format specified in result_format. If there is no interest in a returned color specification, unnecessary computation can be bypassed if result_format is set to XcmsRGBFormat. If color_screen_return and color_exact_return point to the same structure, the pixel field will be set correctly, but the color values are undefined. π
XcmsAllocNamedColor can generate BadColor errors.
π©Ί DIAGNOSTICS π©Ί
BadColorβ A value for aColormapargument does not name a definedColormap. no cap, that's the whole diagnosis. π«Ά
π SEE ALSO π
XcmsQueryColor(3)XcmsStoreColor(3)Xlib - C Language X Interface
mwah π that's the page, bestie. Footer check: this is from X Version 11, libX11 1.8.14, and it's the XcmsAllocColor(3) manual page. The original footer doesn't list a date, so I'm not inventing one β we don't do made-up facts here. πβ¨
π¦ where this page comes from
- alpine 3.24: libx11-doc 1.8.14-r0 Β· X11
- arch rolling: libx11 1.8.14-1 Β· MIT AND X11
- nixos 26.05: libx11 1.8.14
- nixpkgs unstable: libx11 1.8.14
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms