--- ray/src/rt/x11.c 1994/10/03 12:58:58 2.20 +++ ray/src/rt/x11.c 1995/09/29 20:20:37 2.25 @@ -1,4 +1,4 @@ -/* Copyright (c) 1992 Regents of the University of California */ +/* Copyright (c) 1995 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -14,6 +14,14 @@ static char SCCSid[] = "$SunId$ LBL"; #include #include #include +#ifdef sparc +#include +#include +#include +#endif +#if !defined(FNDELAY) && defined(O_NONBLOCK) +#define FNDELAY O_NONBLOCK +#endif #include #include @@ -76,7 +84,7 @@ static Colormap ourmap = 0; /* our color map */ static int inpcheck; /* whence to check input */ -extern char *malloc(), *getcombuf(); +extern char *malloc(); static int x11_close(), x11_clear(), x11_paintr(), x11_errout(), x11_getcur(), x11_comout(), x11_comin(), x11_flush(); @@ -143,8 +151,12 @@ char *name, *id; /* X11 command line or no? */ if (!strcmp(name, "x11")) comheight = COMHEIGHT; - else /* "x11d" */ + else /* "x11d" */ { comheight = 0; +#ifndef FNDELAY + stderr_v("warning: x11d driver not fully functional on this machine\n"); +#endif + } /* open window */ ourwinattr.background_pixel = ourblack; ourwinattr.border_pixel = ourblack; @@ -256,7 +268,7 @@ int xres, yres; comline = xt_open(ourdisplay, gwind, 0, gheight, gwidth, comheight, 0, ourblack, ourwhite, COMFN); if (comline == NULL) { - stderr_v("Cannot open command line window\n"); + stderr_v("cannot open command line window\n"); quit(1); } XSelectInput(ourdisplay, comline->w, ExposureMask); @@ -298,10 +310,15 @@ x11_flush() /* flush output */ n = XPending(ourdisplay); /* from X server */ while (n-- > 0) getevent(); +#ifdef FNDELAY if (inpcheck == IC_IOCTL) { /* from stdin */ +#ifdef FIONREAD if (ioctl(fileno(stdin), FIONREAD, &n) < 0) { +#else + if (1) { +#endif if (fcntl(fileno(stdin), F_SETFL, FNDELAY) < 0) { - stderr_v("Cannot change input mode\n"); + stderr_v("cannot change input mode\n"); quit(1); } inpcheck = IC_READ; @@ -312,9 +329,10 @@ x11_flush() /* flush output */ n = read(fileno(stdin), buf, sizeof(buf)-1); if (n > 0) { buf[n] = '\0'; - strcpy(getcombuf(&x11_driver), buf); + tocombuf(buf, &x11_driver); } } +#endif } @@ -365,8 +383,17 @@ char *inp, *prompt; if (fromcombuf(inp, &x11_driver)) return; if (!x11_driver.inpready) - fputs(prompt, stdout); + std_comout(prompt); } +#ifdef FNDELAY + if (inpcheck == IC_READ) { /* turn off FNDELAY */ + if (fcntl(fileno(stdin), F_SETFL, 0) < 0) { + stderr_v("cannot change input mode\n"); + quit(1); + } + inpcheck = IC_IOCTL; + } +#endif if (gets(inp) == NULL) { strcpy(inp, "quit"); return; @@ -542,7 +569,7 @@ getevent() /* get next event */ if (ourvinfo.class == PseudoColor || ourvinfo.class == GrayScale) if (getpixels() == 0) - stderr_v("Cannot allocate colors\n"); + stderr_v("cannot allocate colors\n"); else new_ctab(ncolors); mapped = 1; @@ -576,10 +603,13 @@ static fixwindow(eexp) /* repair damage to window */ register XExposeEvent *eexp; { + char buf[80]; + if (eexp->window == gwind) { - sprintf(getcombuf(&x11_driver), "repaint %d %d %d %d\n", + sprintf(buf, "repaint %d %d %d %d\n", eexp->x, gheight - eexp->y - eexp->height, eexp->x + eexp->width, gheight - eexp->y); + tocombuf(buf, &x11_driver); } else if (eexp->window == comline->w) { if (eexp->count == 0) xt_redraw(comline); @@ -599,5 +629,5 @@ register XConfigureEvent *ersz; x11_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth; x11_driver.ysiz = gheight < MINHEIGHT ? MINHEIGHT : gheight; - strcpy(getcombuf(&x11_driver), "new\n"); + tocombuf("new\n", &x11_driver); }