[comp.windows.x] Colormap strangeness

paul@cacilj.UUCP (Paul Close) (09/09/89)

I have noticed some strange behavior when trying to modify color programs to
use color "responsibly".  By that I mean to search the visuals list for a
visual class of PseudoColor if I intend to change the colormap entries.  The
program I'm working with is xgif.

The client runs on a sun-4 using MIT's X11R3; the server is a DECstation 3100
running "Ultrix Worksystem V2.0 (Rev. 7)".

Once I create a new colormap, and try to use it, the entire screen goes black,
except for the picture I'm drawing and the mouse pointer.  Unfortunately, I
cannot restore the colors to the way they were, not do they revert once the
program exits.

I also tried running "puzzle -cm -pic mandrill.cm".  That changed all the
colors on my screen!  (At least they weren't all black!)  No amount of window
selection or anything would change the colors back.  What is the problem here?

Basically, the program works like this:

	Determine which visual class to use, and select that visual.

	Create a colormap:
	    Colormap = XCreateColormap( dpy, RootWindow(dpy,screen),
					visual, AllocNone );

	Use XallocColor to allocate the colors:
	     ... = XAllocColor(dpy,Colormap,&colorMap[i]);

	Create a window using the selected visual.

	Map the window.

I also tried using XSetWindowColormap, but that seemed to have no effect (the
screen still went completely black except for the mouse pointer).  I also
tried creating a window and then creating a colormap for that window only,
but that didn't help either.

I hope someone can help--I'm getting tired of rebooting just to get a screen I
can see!  I'm trying to use the visuals correctly, but it sure is difficult!!!
-- 
Paul Close	paul@cacilj.CTS.COM 	...!{uunet, ucsd, crash}!cacilj!paul

    The Obi-wan Kenobi method:  "Use the Source, Luke"	-Jim Fulton

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (09/11/89)

    Once I create a new colormap, and try to use it, the entire screen goes
    black, except for the picture I'm drawing and the mouse pointer.

    I also tried running "puzzle -cm -pic mandrill.cm".  That changed all the
    colors on my screen!

Going "technicolor" is an expected fallout of running on hardware that only
supports a single physical colormap.

    Unfortunately, I cannot restore the colors to the way they were,

If you are running an ICCCM-compliant window manager, it should support a
way of installing the "right" colormap for a given window.

    not do they revert once the program exits.

This sounds like a server bug, unless you are doing something strange.

klee@gilroy.pa.dec.com (Ken Lee) (09/12/89)

In article <1215@cacilj.UUCP>, paul@cacilj.UUCP (Paul Close) writes:
> I have noticed some strange behavior when trying to modify color programs to
> use color "responsibly". 
>
> Once I create a new colormap, and try to use it, the entire screen goes black,
> except for the picture I'm drawing and the mouse pointer.  Unfortunately, I
> cannot restore the colors to the way they were, not do they revert once the
> program exits.

Unfortunately, negotiating colormaps between clients has only recently
been standardized and many older programs go not yet use the standard
methods.  Look in the Inter-Client Communications Conventions Manual
(ICCCM) for details.  Both your clients and window managers must follow
the ICCCM for good results.  Most clients and window managers follow
the (now out of date) X11R2 draft ICCCM.  If your window manager uses
these, you should write your client to use them, too, until your window
manager is updated.

Ken Lee
DEC Western Software Laboratory, Palo Alto, Calif.
Internet: klee@decwrl.dec.com
uucp: uunet!decwrl!klee