--- ray/src/rt/x11.c 1992/06/25 13:32:47 2.7 +++ ray/src/rt/x11.c 1993/11/18 09:43:06 2.13 @@ -11,7 +11,7 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include - +#include #include #include @@ -26,7 +26,7 @@ static char SCCSid[] = "$SunId$ LBL"; #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; @@ -77,7 +78,11 @@ static struct driver x11_driver = { x11_comout, x11_comin, x11_flush, 1.0 }; +static int getpixels(), xnewcolr(), freepixels(), resizewindow(), + getevent(), getkey(), fixwindow(), x11_getc(); +static unsigned long true_pixel(); + struct driver * x11_init(name, id) /* initialize driver */ char *name, *id; @@ -160,6 +165,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; @@ -237,16 +243,14 @@ x11_paintr(col, xmin, ymin, xmax, ymax) /* fill a rec COLOR col; int xmin, ymin, xmax, ymax; { - extern int xnewcolr(); /* pixel assignment routine */ - 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); @@ -266,8 +270,6 @@ static x11_comin(inp, prompt) /* read in a command line */ char *inp, *prompt; { - extern int x11_getc(); - if (prompt != NULL) if (fromcombuf(inp, &x11_driver)) return; @@ -319,14 +321,12 @@ int *xp, *yp; if (c_last > c_first) /* key pressed */ return(x11_getc()); /* button pressed */ - if (levptr(XButtonPressedEvent)->button & Button1) + if (levptr(XButtonPressedEvent)->button == Button1) return(MB1); - if (levptr(XButtonPressedEvent)->button & Button2) + if (levptr(XButtonPressedEvent)->button == Button2) return(MB2); - if (levptr(XButtonPressedEvent)->button & Button3) + if (levptr(XButtonPressedEvent)->button == Button3) return(MB3); - if (levptr(XButtonPressedEvent)->button & (Button4|Button5)) - return(MB1); return(ABORT); } @@ -369,8 +369,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; @@ -452,6 +451,7 @@ getevent() /* get next event */ resizewindow(levptr(XConfigureEvent)); break; case UnmapNotify: + mapped = 0; freepixels(); break; case MapNotify: @@ -461,6 +461,7 @@ getevent() /* get next event */ stderr_v("Cannot allocate colors\n"); else new_ctab(ncolors); + mapped = 1; break; case Expose: fixwindow(levptr(XExposeEvent));