--- ray/src/rt/x11.c 1990/03/01 08:22:44 1.8 +++ ray/src/rt/x11.c 1990/03/09 09:17:30 1.13 @@ -84,7 +84,9 @@ char *name, *id; { int nplanes; XVisualInfo ourvinfo; + XSetWindowAttributes ourwinattr; XWMHints ourxwmhints; + XSizeHints oursizhints; ourdisplay = XOpenDisplay(NULL); if (ourdisplay == NULL) { @@ -108,22 +110,29 @@ char *name, *id; } ourvisual = ourvinfo.visual; make_gmap(GAMMA); - /* create a cursor */ - pickcursor = XCreateFontCursor (ourdisplay, XC_diamond_cross); /* open window */ - gwind = XCreateSimpleWindow(ourdisplay, ourroot, 0, 0, + ourwinattr.background_pixel = ourblack; + ourwinattr.border_pixel = ourblack; + gwind = XCreateWindow(ourdisplay, ourroot, 0, 0, DisplayWidth(ourdisplay,ourscreen)-2*BORWIDTH, DisplayHeight(ourdisplay,ourscreen)-2*BORWIDTH, - BORWIDTH, ourblack, ourwhite); + BORWIDTH, nplanes, InputOutput, ourvisual, + CWBackPixel|CWBorderPixel, &ourwinattr); if (gwind == 0) { stderr_v("cannot create window\n"); return(NULL); } XStoreName(ourdisplay, gwind, id); + /* create a cursor */ + pickcursor = XCreateFontCursor(ourdisplay, XC_diamond_cross); ourgc = XCreateGC(ourdisplay, gwind, 0, NULL); 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)); @@ -166,19 +175,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); @@ -186,12 +191,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); } @@ -221,8 +238,7 @@ int xmin, ymin, xmax, ymax; static x11_flush() /* flush output */ { - if (ncolors <= 0 && ourvisual->class != TrueColor) /* dummy */ - XFillRectangle(ourdisplay, gwind, ourgc, 0, 0, 1 ,1); + XNoOp(ourdisplay); while (XPending(ourdisplay) > 0) getevent(); } @@ -249,8 +265,11 @@ static x11_comout(out) /* output a string to command line */ char *out; { - if (comline != NULL) - xt_puts(out, comline); + if (comline == NULL) + return; + xt_puts(out, comline); + if (out[strlen(out)-1] == '\n') + XFlush(ourdisplay); } @@ -258,8 +277,8 @@ static x11_errout(msg) /* output an error message */ char *msg; { - x11_comout(msg); stderr_v(msg); /* send to stderr also! */ + x11_comout(msg); }