--- ray/src/rt/x11.c 1992/06/18 14:55:24 2.5 +++ ray/src/rt/x11.c 1993/02/11 16:33:10 2.9 @@ -23,10 +23,10 @@ static char SCCSid[] = "$SunId$ LBL"; #include "x11twind.h" #include "x11icon.h" -#define GAMMA 2.2 /* exponent for color correction */ +#define GAMMA 2.2 /* default exponent correction */ #define MINWIDTH (32*COMCW) /* minimum graphics window width */ -#define MINHEIGHT MINWIDTH /* minimum graphics window height */ +#define MINHEIGHT (MINWIDTH/2) /* minimum graphics window height */ #define BORWIDTH 5 /* border width */ #define COMHEIGHT (COMLH*COMCH) /* command line height (pixels) */ @@ -44,6 +44,7 @@ static char SCCSid[] = "$SunId$ LBL"; static XEvent currentevent; /* current event */ static int ncolors = 0; /* color table size */ +static int mapped = 0; /* window is mapped? */ static unsigned long *pixval = NULL; /* allocated pixels */ static unsigned long ourblack=0, ourwhite=1; @@ -82,6 +83,8 @@ struct driver * x11_init(name, id) /* initialize driver */ char *name, *id; { + extern char *getenv(); + char *gv; int nplanes; XSetWindowAttributes ourwinattr; XWMHints ourxwmhints; @@ -117,8 +120,12 @@ char *name, *id; ourblack = BlackPixel(ourdisplay,ourscreen); ourwhite = WhitePixel(ourdisplay,ourscreen); } - make_gmap(GAMMA); - /* open window */ + /* set gamma */ + if ((gv = getenv("GAMMA")) != NULL) + make_gmap(atof(gv)); + else + make_gmap(GAMMA); + /* open window */ ourwinattr.background_pixel = ourblack; ourwinattr.border_pixel = ourblack; /* this is stupid */ @@ -154,6 +161,7 @@ char *name, *id; x11_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth; x11_driver.ysiz = gheight < MINHEIGHT ? MINHEIGHT : gheight; x11_driver.inpready = 0; + mapped = 1; cmdvec = x11_comout; /* set error vectors */ if (wrnvec != NULL) wrnvec = x11_errout; @@ -235,12 +243,12 @@ int xmin, ymin, xmax, ymax; extern unsigned long true_pixel(); unsigned long pixel; + if (!mapped) + return; if (ncolors > 0) pixel = pixval[get_pixel(col, xnewcolr)]; - else if (ourvinfo.class == TrueColor || ourvinfo.class == DirectColor) - pixel = true_pixel(col); else - return; + pixel = true_pixel(col); XSetForeground(ourdisplay, ourgc, pixel); XFillRectangle(ourdisplay, gwind, ourgc, xmin, gheight-ymax, xmax-xmin, ymax-ymin); @@ -363,8 +371,7 @@ loop: pixval = (unsigned long *)malloc(ncolors*sizeof(unsigned long)); if (pixval == NULL) return(ncolors = 0); - if (XAllocColorCells(ourdisplay,ourmap,0,NULL,0, - pixval,ncolors) != 0) + if (XAllocColorCells(ourdisplay,ourmap,0,NULL,0,pixval,ncolors)) break; free((char *)pixval); pixval = NULL; @@ -401,6 +408,8 @@ freepixels() /* free our pixels */ if (ncolors == 0) return; XFreeColors(ourdisplay,ourmap,pixval,ncolors,0L); + free((char *)pixval); + pixval = NULL; ncolors = 0; if (ourmap != DefaultColormap(ourdisplay,ourscreen)) XFreeColormap(ourdisplay, ourmap); @@ -444,6 +453,7 @@ getevent() /* get next event */ resizewindow(levptr(XConfigureEvent)); break; case UnmapNotify: + mapped = 0; freepixels(); break; case MapNotify: @@ -453,6 +463,7 @@ getevent() /* get next event */ stderr_v("Cannot allocate colors\n"); else new_ctab(ncolors); + mapped = 1; break; case Expose: fixwindow(levptr(XExposeEvent));