--- ray/src/rt/x11.c 1993/02/11 16:33:10 2.9 +++ ray/src/rt/x11.c 1994/09/12 14:41:54 2.16 @@ -11,7 +11,7 @@ static char SCCSid[] = "$SunId$ LBL"; */ #include - +#include #include #include @@ -78,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; @@ -121,7 +125,8 @@ char *name, *id; ourwhite = WhitePixel(ourdisplay,ourscreen); } /* set gamma */ - if ((gv = getenv("GAMMA")) != NULL) + if ((gv = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL + || (gv = getenv("GAMMA")) != NULL) make_gmap(atof(gv)); else make_gmap(GAMMA); @@ -239,8 +244,6 @@ 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) @@ -258,9 +261,19 @@ int xmin, ymin, xmax, ymax; static x11_flush() /* flush output */ { + int n; + char *buf; + /* check for input */ XNoOp(ourdisplay); - while (XPending(ourdisplay) > 0) + n = XPending(ourdisplay); /* from X server */ + while (n-- > 0) getevent(); + if (ioctl(0, FIONREAD, &n) == 0 && n > 0) { /* from stdin */ + buf = getcombuf(&x11_driver); + n = read(0, buf, n); + if (n > 0) + buf[n] = '\0'; + } } @@ -268,13 +281,12 @@ static x11_comin(inp, prompt) /* read in a command line */ char *inp, *prompt; { - extern int x11_getc(); - - if (prompt != NULL) + if (prompt != NULL) { + x11_flush(); /* make sure we get everything */ if (fromcombuf(inp, &x11_driver)) return; - else - xt_puts(prompt, comline); + xt_puts(prompt, comline); + } xt_cursor(comline, TBLKCURS); editline(inp, x11_getc, x11_comout); xt_cursor(comline, TNOCURS); @@ -321,14 +333,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); }