7.4 Allocating Shared Colors

Since free colorcells can quickly become a scarce resource when clients store private color values, simple clients that mainly use color for decoration are encouraged always to allocate read-only colors, so that these colorcells can be shared by other clients that allocate the same colors read-only.

The returned pixel value can be used to set the background_pixel or border_pixel attribute of a window or to set the foreground or background member of a GC, which are used by drawing requests. (See Chapter 4 and Chapter 5, The for more information.)

Read-only colorcells can be allocated with the following routines:

XAllocColor()

Returns the index of the colorcell (a pixel value) that contains the RGB values that are requested or that contains the closest RGB values physically possible on the screen. XcmsAllocColor() is the same except that colors are specified using Xcms syntax.

XAllocNamedColor()

Returns the index of the colorcell that contains the RGB values associated with a specified color name from the string color name database or the closest RGB values physically possible on the screen. In R5, XAllocNamedColor() accepts strings in Xcms syntax. XcmsAllocNamedColor() is almost the same except with a different style of arguments. XcmsAllocNamedColor() also is capable of returning a symbol describing the format found in the specified string.

By convention, clients allow the user to specify colors on the command line or in the resource database using a color ...

Get XLIB Programming Manual, Rel. 5, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.