--- ray/src/rt/x11.c 1992/05/29 10:57:15 2.2 +++ ray/src/rt/x11.c 1992/06/18 14:55:24 2.5 @@ -1,11 +1,11 @@ +/* Copyright (c) 1992 Regents of the University of California */ + #ifndef lint static char SCCSid[] = "$SunId$ LBL"; #endif -/* Copyright (c) 1989 Regents of the University of California */ - /* - * x11.c - driver for X-windows version 11.3 + * x11.c - driver for X-windows version 11 * * Jan 1990 */ @@ -38,8 +38,6 @@ static char SCCSid[] = "$SunId$ LBL"; #define ourscreen DefaultScreen(ourdisplay) #define ourroot RootWindow(ourdisplay,ourscreen) -#define ourwhite WhitePixel(ourdisplay,ourscreen) -#define ourblack BlackPixel(ourdisplay,ourscreen) #define levptr(etype) ((etype *)¤tevent) @@ -47,6 +45,7 @@ static XEvent currentevent; /* current event */ static int ncolors = 0; /* color table size */ static unsigned long *pixval = NULL; /* allocated pixels */ +static unsigned long ourblack=0, ourwhite=1; static Display *ourdisplay = NULL; /* our display */ @@ -95,25 +94,34 @@ char *name, *id; } /* find a usable visual */ nplanes = DisplayPlanes(ourdisplay, ourscreen); - if ( !XMatchVisualInfo(ourdisplay,ourscreen, - 24,TrueColor,&ourvinfo) && - !XMatchVisualInfo(ourdisplay,ourscreen, - 24,DirectColor,&ourvinfo) ) + if (XMatchVisualInfo(ourdisplay,ourscreen, + 24,TrueColor,&ourvinfo) || + XMatchVisualInfo(ourdisplay,ourscreen, + 24,DirectColor,&ourvinfo)) { + ourblack = 0; + ourwhite = ourvinfo.red_mask | + ourvinfo.green_mask | + ourvinfo.blue_mask ; + } else { if (nplanes < 4) { stderr_v("not enough colors\n"); return(NULL); - } else if (!XMatchVisualInfo(ourdisplay,ourscreen, + } + if (!XMatchVisualInfo(ourdisplay,ourscreen, nplanes,PseudoColor,&ourvinfo) && !XMatchVisualInfo(ourdisplay,ourscreen, nplanes,GrayScale,&ourvinfo)) { stderr_v("unsupported visual type\n"); return(NULL); } + ourblack = BlackPixel(ourdisplay,ourscreen); + ourwhite = WhitePixel(ourdisplay,ourscreen); + } make_gmap(GAMMA); /* open window */ ourwinattr.background_pixel = ourblack; ourwinattr.border_pixel = ourblack; - /* this is a waste! */ + /* this is stupid */ ourwinattr.colormap = XCreateColormap(ourdisplay, ourroot, ourvinfo.visual, AllocNone); gwind = XCreateWindow(ourdisplay, ourroot, 0, 0, @@ -125,7 +133,7 @@ char *name, *id; stderr_v("cannot create window\n"); return(NULL); } - XStoreName(ourdisplay, gwind, id); + XStoreName(ourdisplay, gwind, id); /* create a cursor */ pickcursor = XCreateFontCursor(ourdisplay, XC_diamond_cross); ourgc = XCreateGC(ourdisplay, gwind, 0, NULL); @@ -205,9 +213,8 @@ int xres, yres; /* get new command line */ if (comline != NULL) xt_close(comline); - comline = xt_open(ourdisplay, - DefaultGC(ourdisplay,ourscreen), - gwind, 0, gheight, gwidth, COMHEIGHT, 0, COMFN); + comline = xt_open(ourdisplay, gwind, 0, gheight, + gwidth, COMHEIGHT, 0, ourblack, ourwhite, COMFN); if (comline == NULL) { stderr_v("Cannot open command line window\n"); quit(1);