Re: XForms: colormaps and canvases

Steve Lamont (spl@szechuan.ucsd.edu)
Fri, 31 Oct 97 08:46:52 PST

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

> Here's an example code (somewhat simplified from the one I posted
> earlier). Running on an SGI, but displaying on either an 8-bit Sun
> or a 24-bit SGI, I get the error
> X Error of failed request: BadColor (invalid Colormap parameter)
> Major opcode of failed request: 79 (X_FreeColormap)
> when the "Quit" button is pressed and the form is freed.
>
> I've tried this with XForms versions 0.81 (IRIX 5.3) and 0.86 (IRIX 6.2,
> n32).

The problem persists in 0.87.5.

My workaround, as I mentioned, is to allocate my own Colormap for each
canvas or use the DefaultColormap() macro.

screen_number = DefaultScreen( fl_get_display() );
default_visual = DefaultVisual( fl_get_display(), screen_number );
if ( default_visual->class != vi->visual->class )
fl_set_canvas_colormap(ob, fl_create_colormap(vi, 1));
else
fl_set_canvas_colormap( ob,
DefaultColormap( fl_get_display(),
screen_number ) );

Here `vi' is the Visual handed to me by glXChooseVisual() since I'm
working with an OpenGL application. This code is in my glx_init()
function which is set in the standard manner with
fl_modify_canvas_prop(). This works for me even when displaying
stereo pairs.

Of course, this means that the two Canvases have different colormaps.

Since Canvas has to clean up after itself when it goes away, I'm not
sure that there is a good way to handle this problem other than to use
the screen's default Colormap (which doesn't get blown away by
XFreeColormap()).

About the only other thing I can think of is to fake out XForms by
assigning the DefaultColormap or some other bogus Colormap to the
canvas just before you delete it, but this is a really disgusting,
ugly hack.

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
Xforms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/