--- ray/src/rt/x11.c 1990/03/08 09:47:23 1.11 +++ ray/src/rt/x11.c 1990/07/10 08:47:07 1.15 @@ -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 = { @@ -86,6 +86,7 @@ char *name, *id; XVisualInfo ourvinfo; XSetWindowAttributes ourwinattr; XWMHints ourxwmhints; + XSizeHints oursizhints; ourdisplay = XOpenDisplay(NULL); if (ourdisplay == NULL) { @@ -99,18 +100,21 @@ 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; make_gmap(GAMMA); /* open window */ - ourwinattr.background_pixel = ourwhite; + ourwinattr.background_pixel = ourblack; ourwinattr.border_pixel = ourblack; gwind = XCreateWindow(ourdisplay, ourroot, 0, 0, DisplayWidth(ourdisplay,ourscreen)-2*BORWIDTH, @@ -128,6 +132,10 @@ char *name, *id; ourxwmhints.flags = InputHint; ourxwmhints.input = True; XSetWMHints(ourdisplay, gwind, &ourxwmhints); + oursizhints.min_width = MINWIDTH; + oursizhints.min_height = MINHEIGHT+COMHEIGHT; + oursizhints.flags = PMinSize; + XSetNormalHints(ourdisplay, gwind, &oursizhints); XSelectInput(ourdisplay, gwind, ExposureMask); XMapWindow(ourdisplay, gwind); XWindowEvent(ourdisplay, gwind, ExposureMask, levptr(XExposeEvent)); @@ -170,19 +178,15 @@ static x11_clear(xres, yres) /* clear our display */ int xres, yres; { - if (xres != gwidth || yres != gheight) { /* change window */ - if (comline != NULL) - xt_close(comline); + /* check limits */ + if (xres < MINWIDTH) + xres = MINWIDTH; + if (yres < MINHEIGHT) + yres = MINHEIGHT; + /* resize window */ + if (xres != gwidth || yres != gheight) { XSelectInput(ourdisplay, gwind, 0); XResizeWindow(ourdisplay, gwind, xres, yres+COMHEIGHT); - comline = xt_open(ourdisplay, - DefaultGC(ourdisplay,ourscreen), - gwind, 0, yres, xres, COMHEIGHT, 0, COMFN); - if (comline == NULL) { - stderr_v("Cannot open command line window\n"); - quit(1); - } - XSelectInput(ourdisplay, comline->w, ExposureMask); gwidth = xres; gheight = yres; XFlush(ourdisplay); @@ -190,12 +194,24 @@ int xres, yres; XSync(ourdisplay, 1); /* discard input */ } XClearWindow(ourdisplay, gwind); - if (ourvisual->class == PseudoColor) /* reinitialize color table */ + /* reinitialize color table */ + if (ourvisual->class == PseudoColor) if (getpixels() == 0) stderr_v("cannot allocate colors\n"); else new_ctab(ncolors); - + /* get new command line */ + if (comline != NULL) + xt_close(comline); + comline = xt_open(ourdisplay, + DefaultGC(ourdisplay,ourscreen), + gwind, 0, gheight, gwidth, COMHEIGHT, 0, COMFN); + if (comline == NULL) { + stderr_v("Cannot open command line window\n"); + quit(1); + } + XSelectInput(ourdisplay, comline->w, ExposureMask); + /* remove earmuffs */ XSelectInput(ourdisplay, gwind, StructureNotifyMask|ExposureMask|KeyPressMask|ButtonPressMask); } @@ -212,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; @@ -235,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))