[comp.windows.x] Can't get color... Why?

jjm@otter.hpl.hp.com (Jean-Jacques Moreau) (03/30/89)

  I can have more than 3 different colors in two different windows, but
i can't have more than 3 different colors in a particular window (with
X10 or with X11). Does anyone know why?
  Moreover, when I run xchess (with X10 or with X11), it says that "it
can't get color..." and diplays a black and white window. That's
not the only graphic program that can't get color, and they sometime
alter the color of my other windows. Why?

converse@EXPO.LCS.MIT.EDU (Donna Converse) (03/30/89)

> I can have more than 3 different colors in two different windows, but
> i can't have more than 3 different colors in a particular window (with
> X10 or with X11). Does anyone know why?

The ability to see colors in a window depends on 2 things:
    + The size of your colormap, and whether the colormap is 
      writeable by client programs such as xchess.  Use xdpyinfo
      to find out the size of your display's colormap and the visual
      types of the screen; then read about visuals in the Xlib doc.
      Know the characteristics of your display's visual types.

    + The client program's treatment of color.  The program has two
      ways to allocate colors in the colormap: as writable cells or
      as read-only cells.  If a client allocates a writable cell,
      no other client program can share that cell during the lifetime
      of the originally allocating client.  If you have a colormap of
      size 16, client programs may quickly find that no more colors
      can be allocated.  

Other than issues of sharing colormap entries, there is no reason
why a single window cannot display every color of the colormap 
simultaneously.

>  Moreover, when I run xchess (with X10 or with X11), it says that "it
>can't get color..." and diplays a black and white window. That's
>not the only graphic program that can't get color, and they sometime
>alter the color of my other windows. Why?

If it can't get color, it is doing the next best thing, which is 
black and white.  No client can assume availability of color.
As for altering the color of other windows, this can be caused by
a client creating a colormap of it's own, and causing it to be 
installed, or, perhaps a client program is referencing an element
of the colormap without having allocated it in any way; then another
client program allocates that element of the colormap and changes
the color definition of the cell.

aad@stpstn.UUCP (Anthony A. Datri) (04/03/89)

>The ability to see colors in a window depends on 2 things:
>    + The size of your colormap, and whether the colormap is 
>      writeable by client programs such as xchess.  Use xdpyinfo
>      to find out the size of your display's colormap

I'd be happy if I could find something to tell me just what a colormap *IS*.
eg, I'm on a Sun 4/110 with a cgfour -- xdpyinfo tells me that there
are 256 colormap cells.  I can run

ico -faces -colors  aquamarine MediumAquamarine CadetBlue CornflowerBlue \
DarkSlateBlue LightBlue LightSteelBlue MediumBlue MediumSlateBlue \
MidnightBlue violetred pink violet brown yellow thistle goldenrod

just fine at the moment, when I have maybe 10 colors in use, including two
I specified with #rgb values.  I also just ran about 20 xterm's, with
unique -fg args.  Everything worked fine.  But when I tried an xterm -fg
mediumslategray, I got

X Toolkit Warning: Cannot allocate colormap entry for "mediumslategray"

I looked in /usr/lib/X11/rgb.txt, and lo and behold, there isn't a
mediumslategray defined (I was confusing it with the mediumslateblue entry).
Now, I've been troubled by what I thought was a problem with these colormaps,
whatever they are, but now I think my problems are due to confusion between
"no colormap cells available" and "unknown color", which seem to generate the
same message.  I just tried out an HP machine, which reports 16 colormap
entries, and it seemed to verify the above:  I tried from a similar setup to
the one on the Sun an "xterm -goldenrod", and got the above message.  I
killed off my uwm, freeing some colors, and I was able to fire up the xterm.
-- 
@disclaimer(Any concepts or opinions above are entirely mine, not those of my
	    employer, my GIGI, my VT05, or my 11/34)
beak is@>beak is not
Anthony A. Datri @SysAdmin(Stepstone Corporation) aad@stepstone.com stpstn!aad