Re: XForms: colormaps and canvases

Stephen Langer (
Fri, 31 Oct 1997 10:37:56 -0500

To subscribers of the xforms list from "Stephen Langer" <> :

Hi --

Last week I posted a question about whether it's possible to have
two canvases share the same colormap, when that colormap is different
from the one used by the rest of the forms. I got a few helpful suggestions
about workarounds, but no real answer to the question.

Since I really need to know if this is a bug that could be fixed or
if it's just something that I'll have to live with, I'm going to ask
again: Is it legal to use fl_set_canvas_colormap() to install the same
colormap in two different canvases?

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,


-- EMail: Phone: (301) 975-5423 --
-- WWW: Fax: (301) 990-4127 --
-- Mail: Building 820 Room 365; NIST; Gaithersburg, Md 20899-0001 --

----------- cut here -------------------

/* Test program that creates a form with two canvases and a Quit
* button. The canvases share a colormap. When the Quit button is
* pressed, the form is hidden and freed, generating an X error. If
* the colormap is installed in only one of the canvases, no error is
* generated.

#include <stdio.h>
#include <stdlib.h>
#include "forms.h"

typedef struct {
FL_FORM *testform;
void *vdata;
long ldata;
FL_OBJECT *quitbutton;
FL_OBJECT *canvas1;
FL_OBJECT *canvas2;
} FD_testform;

extern void quit(FL_OBJECT *, long);

FD_testform *create_form_testform(void)
FD_testform *fdui = (FD_testform *) fl_calloc(1, sizeof(*fdui));

fdui->testform = fl_bgn_form(FL_NO_BOX, 320, 250);
obj = fl_add_box(FL_UP_BOX,0,0,320,250,"");
fdui->quitbutton = obj =
fdui->canvas1 = obj = fl_add_canvas(FL_NORMAL_CANVAS,30,50,110,110,"");
fdui->canvas2 = obj = fl_add_canvas(FL_NORMAL_CANVAS,170,50,110,110,"");

fdui->testform->fdui = fdui;

return fdui;


FD_testform *testform;

int main(int argc, char *argv[]) {
Colormap colormap;

fl_initialize(&argc, argv, "TestCanvas", 0, 0);

/* make sure errors are reported right away */
XSynchronize(fl_get_display(), True);

testform = create_form_testform();

/* create a colormap and tell the canvases to use it. */
colormap = fl_create_colormap(fl_state[fl_get_vclass()].xvinfo, 16);
fl_set_canvas_colormap(testform->canvas1, colormap);
* If the next line is deleted no error is generated!
fl_set_canvas_colormap(testform->canvas2, colormap);

fl_show_form(testform->testform, FL_PLACE_MOUSE, FL_FULLBORDER, "test");
return 0;

void quit(FL_OBJECT *obj, long arg) {
fputs("Success!\n", stderr);
To unsubscribe, send the message "unsubscribe" to or see
Xforms Home Page:
List Archive: