--- ray/src/rt/x11.c 1990/03/09 09:17:30 1.13 +++ ray/src/rt/x11.c 1990/12/21 17:27:31 1.17 @@ -45,7 +45,7 @@ static char SCCSid[] = "$SunId$ LBL"; static XEvent currentevent; /* current event */ static int ncolors = 0; /* color table size */ -static int *pixval = NULL; /* allocated pixels */ +static unsigned long *pixval = NULL; /* allocated pixels */ static Display *ourdisplay = NULL; /* our display */ @@ -67,9 +67,9 @@ static GC ourgc = 0; /* our graphics context for dr static Colormap ourmap = 0; /* our color map */ -extern char *malloc(); +extern char *malloc(), *getcombuf(); -int x11_close(), x11_clear(), x11_paintr(), x11_errout(), +static int x11_close(), x11_clear(), x11_paintr(), x11_errout(), x11_getcur(), x11_comout(), x11_comin(), x11_flush(); static struct driver x11_driver = { @@ -100,12 +100,15 @@ char *name, *id; } else if (nplanes <= 12) { if (!XMatchVisualInfo(ourdisplay,ourscreen, nplanes,PseudoColor,&ourvinfo)) { - stderr_v("PseudoColor not supported\n"); + stderr_v("PseudoColor server required\n"); return(NULL); } } else if (!XMatchVisualInfo(ourdisplay,ourscreen, - nplanes,TrueColor,&ourvinfo)) { - stderr_v("TrueColor not supported\n"); + nplanes,TrueColor,&ourvinfo) && + /* kludge for DirectColor */ + !XMatchVisualInfo(ourdisplay,ourscreen, + nplanes,DirectColor,&ourvinfo)) { + stderr_v("TrueColor server required\n"); return(NULL); } ourvisual = ourvinfo.visual; @@ -135,7 +138,7 @@ char *name, *id; XSetNormalHints(ourdisplay, gwind, &oursizhints); XSelectInput(ourdisplay, gwind, ExposureMask); XMapWindow(ourdisplay, gwind); - XWindowEvent(ourdisplay, gwind, ExposureMask, levptr(XExposeEvent)); + XWindowEvent(ourdisplay, gwind, ExposureMask, levptr(XEvent)); gwidth = levptr(XExposeEvent)->width; gheight = levptr(XExposeEvent)->height - COMHEIGHT; x11_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth; @@ -225,7 +228,7 @@ int xmin, ymin, xmax, ymax; if (ncolors > 0) pixel = pixval[get_pixel(col, xnewcolr)]; - else if (ourvisual->class == TrueColor) + else if (ourvisual->class != PseudoColor) pixel = true_pixel(col); else return; @@ -248,7 +251,7 @@ static x11_comin(inp, prompt) /* read in a command line */ char *inp, *prompt; { - int x11_getc(), x11_comout(); + extern int x11_getc(); if (prompt != NULL) if (fromcombuf(inp, &x11_driver)) @@ -333,8 +336,11 @@ int r, g, b; static int getpixels() /* get the color map */ { + XColor thiscolor; + register int i, j; + if (ncolors > 0) - return(ncolors); + goto donecolors; if (ourvisual == DefaultVisual(ourdisplay,ourscreen)) { ourmap = DefaultColormap(ourdisplay,ourscreen); goto loop; @@ -345,7 +351,7 @@ loop: for (ncolors = ourvisual->map_entries; ncolors > ourvisual->map_entries/3; ncolors = ncolors*.937) { - pixval = (int *)malloc(ncolors*sizeof(int)); + pixval = (unsigned long *)malloc(ncolors*sizeof(unsigned long)); if (pixval == NULL) return(ncolors = 0); if (XAllocColorCells(ourdisplay,ourmap,0,NULL,0, @@ -360,11 +366,8 @@ loop: else return(ncolors = 0); /* failed */ } - if (ourmap != DefaultColormap(ourdisplay,ourscreen)) { - XColor thiscolor; - register int i, j; - /* reset black and white */ - for (i = 0; i < ncolors; i++) { + if (ourmap != DefaultColormap(ourdisplay,ourscreen)) + for (i = 0; i < ncolors; i++) { /* reset black and white */ if (pixval[i] != ourblack && pixval[i] != ourwhite) continue; thiscolor.pixel = pixval[i]; @@ -378,8 +381,16 @@ loop: ncolors--; i--; } - } XSetWindowColormap(ourdisplay, gwind, ourmap); +donecolors: +#ifdef DEBUG + thiscolor.flags = DoRed|DoGreen|DoBlue; + thiscolor.red = thiscolor.green = thiscolor.blue = 0; + for (i = 0; i < ncolors; i++) { + thiscolor.pixel = pixval[i]; + XStoreColor(ourdisplay, ourmap, &thiscolor); + } +#endif return(ncolors); }