--- ray/src/rt/x11.c 1990/02/23 10:26:30 1.6 +++ ray/src/rt/x11.c 1990/03/02 15:05:26 1.10 @@ -84,8 +84,8 @@ char *name, *id; { int nplanes; XVisualInfo ourvinfo; + XSetWindowAttributes ourwinattr; XWMHints ourxwmhints; - Pixmap bmCursorSrc, bmCursorMsk; ourdisplay = XOpenDisplay(NULL); if (ourdisplay == NULL) { @@ -109,18 +109,21 @@ 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 = ourwhite; + 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; @@ -152,13 +155,11 @@ x11_close() /* close our display */ xt_close(comline); comline = NULL; } - if (gwind != 0) { - freepixels(); - XFreeGC(ourdisplay, ourgc); - XDestroyWindow(ourdisplay, gwind); - gwind = 0; - ourgc = 0; - } + freepixels(); + XFreeGC(ourdisplay, ourgc); + XDestroyWindow(ourdisplay, gwind); + gwind = 0; + ourgc = 0; XFreeCursor(ourdisplay, pickcursor); XCloseDisplay(ourdisplay); ourdisplay = NULL; @@ -184,8 +185,9 @@ int xres, yres; XSelectInput(ourdisplay, comline->w, ExposureMask); gwidth = xres; gheight = yres; - XSync(ourdisplay, 1); /* discard input */ + XFlush(ourdisplay); sleep(2); /* wait for window manager */ + XSync(ourdisplay, 1); /* discard input */ } XClearWindow(ourdisplay, gwind); if (ourvisual->class == PseudoColor) /* reinitialize color table */ @@ -223,8 +225,7 @@ int xmin, ymin, xmax, ymax; static x11_flush() /* flush output */ { - if (ncolors <= 0) /* output necessary for death */ - XFillRectangle(ourdisplay, gwind, ourgc, 0, 0, 1 ,1); + XNoOp(ourdisplay); while (XPending(ourdisplay) > 0) getevent(); } @@ -253,7 +254,6 @@ char *out; { if (comline != NULL) xt_puts(out, comline); - XFlush(ourdisplay); } @@ -261,8 +261,9 @@ static x11_errout(msg) /* output an error message */ char *msg; { - x11_comout(msg); stderr_v(msg); /* send to stderr also! */ + x11_comout(msg); + x11_flush(); } @@ -375,7 +376,7 @@ freepixels() /* free our pixels */ return; XFreeColors(ourdisplay,ourmap,pixval,ncolors,0L); ncolors = 0; - if (ourmap != 0 && ourmap != DefaultColormap(ourdisplay,ourscreen)) + if (ourmap != DefaultColormap(ourdisplay,ourscreen)) XFreeColormap(ourdisplay, ourmap); ourmap = 0; } @@ -442,9 +443,12 @@ static getkey(ekey) /* get input key */ register XKeyPressedEvent *ekey; { - c_last += XLookupString(ekey, c_queue+c_last, sizeof(c_queue)-c_last, + register int n; + + n = XLookupString(ekey, c_queue+c_last, sizeof(c_queue)-c_last, NULL, NULL); - x11_driver.inpready = c_last-c_first; + c_last += n; + x11_driver.inpready += n; }