Re: canvas colormaps

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 15 Jan 97 13:36:04 PST

To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> Won't this destroy the colormap used by the rest of the window? Or
> does XForms allocate another colormap for the canvas?

Yes, the latter is correct -- XForms gives you your own colormap in a
Canvas.

> Well, because the colors are wrong. If I grab a section of the canvas with
> xmag, the xmag window will have the proper colormap. [...]
>
> It seems I'm setting the colormap properly, the window manager just isn't
> installing it for me. I've tried both fvwm and twm; I don't think it's a
> window manager bug.

Remember that a Colormap is only installed by the window manager
and/or server when you have focus in the Window to which it belongs.
This may seem elementary but have you tried moving the pointer into
the Canvas window to see what happens? (I'd be surprised if you
didn't but it's worth asking.)

It might be interesting to query the Colormap attribute of the Window
later on in the program and compare it with the Colormap you think
you've assigned, just to see if they're the same.

Another thing to watch out for: if you hide the form with
fl_hide_form(), the Canvas is destroyed by XForms and recreated when
you show the form again. This means that the Window is destroyed and
recreated and a *new* colormap is created. This will be the source of
numerous X errors and a lot of head scratching until you finally
realize what's going on. Always query the Colormap and other
properties of the Canvas using the appropriate XForms routines prior
to using them -- don't rely on values tucked away locally -- this
caused me to say many bad words before I got this worked out.

BTW, it's a Hard and Fast Rule: *do not ever* install your own
colormap with XInstallColormap(). The ICCCM says this is a big no-no!
(You don't want to get busted by the Protocol Police. :-) ) Use either
the Canvas function or call XChangeWindowAttributes(). Refer to
Chapter 12 of Volume I of the O'Reilly series for more detail.

spl