ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/x11.c
(Generate patch)

Comparing ray/src/rt/x11.c (file contents):
Revision 2.18 by greg, Tue Sep 20 15:46:34 1994 UTC vs.
Revision 2.22 by greg, Mon Dec 12 11:22:20 1994 UTC

# Line 13 | Line 13 | static char SCCSid[] = "$SunId$ LBL";
13   #include  <stdio.h>
14   #include  <math.h>
15   #include  <sys/ioctl.h>
16 + #include  <fcntl.h>
17  
18   #include  <X11/Xlib.h>
19   #include  <X11/cursorfont.h>
# Line 69 | Line 70 | static GC  ourgc = 0;                  /* our graphics context for dr
70  
71   static Colormap ourmap = 0;             /* our color map */
72  
73 < extern char  *malloc(), *getcombuf();
73 > #define IC_X11          0
74 > #define IC_IOCTL        1
75 > #define IC_READ         2
76  
77 + static int  inpcheck;                   /* whence to check input */
78 +
79 + extern char  *malloc();
80 +
81   static int  x11_close(), x11_clear(), x11_paintr(), x11_errout(),
82                  x11_getcur(), x11_comout(), x11_comin(), x11_flush();
83  
# Line 182 | Line 189 | char  *name, *id;
189                  cmdvec = x11_comout;
190                  if (wrnvec != NULL)
191                          wrnvec = x11_errout;
192 +                inpcheck = IC_X11;
193          } else {
194                  x11_driver.comin = std_comin;
195                  x11_driver.comout = std_comout;
196                  cmdvec = std_comout;
197 +                inpcheck = IC_IOCTL;
198          }
199          return(&x11_driver);
200   }
# Line 282 | Line 291 | int  xmin, ymin, xmax, ymax;
291   static
292   x11_flush()                     /* flush output */
293   {
294 +        char    buf[256];
295          int     n;
296                                                  /* check for input */
297          XNoOp(ourdisplay);
298          n = XPending(ourdisplay);                       /* from X server */
299          while (n-- > 0)
300                  getevent();
301 <        if (x11_driver.comin == std_comin) {            /* from stdin */
301 > #ifdef FNDELAY
302 >        if (inpcheck == IC_IOCTL) {                     /* from stdin */
303 > #ifdef FIONREAD
304                  if (ioctl(fileno(stdin), FIONREAD, &n) < 0) {
305 <                        stderr_v("ioctl error on stdin\n");
306 <                        quit(1);
305 > #else
306 >                if (1) {
307 > #endif
308 >                        if (fcntl(fileno(stdin), F_SETFL, FNDELAY) < 0) {
309 >                                stderr_v("Cannot change input mode\n");
310 >                                quit(1);
311 >                        }
312 >                        inpcheck = IC_READ;
313 >                } else
314 >                        x11_driver.inpready += n;
315 >        }
316 >        if (inpcheck == IC_READ) {
317 >                n = read(fileno(stdin), buf, sizeof(buf)-1);
318 >                if (n > 0) {
319 >                        buf[n] = '\0';
320 >                        tocombuf(buf, &x11_driver);
321                  }
296                x11_driver.inpready += n;
322          }
323 + #endif
324   }
325  
326  
# Line 362 | Line 388 | std_comout(outp)               /* write out string to stdout */
388   char    *outp;
389   {
390          fputs(outp, stdout);
391 +        fflush(stdout);
392   }
393  
394  
# Line 555 | Line 582 | static
582   fixwindow(eexp)                         /* repair damage to window */
583   register XExposeEvent  *eexp;
584   {
585 +        char  buf[80];
586 +
587          if (eexp->window == gwind) {
588 <                sprintf(getcombuf(&x11_driver), "repaint %d %d %d %d\n",
588 >                sprintf(buf, "repaint %d %d %d %d\n",
589                          eexp->x, gheight - eexp->y - eexp->height,
590                          eexp->x + eexp->width, gheight - eexp->y);
591 +                tocombuf(buf, &x11_driver);
592          } else if (eexp->window == comline->w) {
593                  if (eexp->count == 0)
594                          xt_redraw(comline);
# Line 578 | Line 608 | register XConfigureEvent  *ersz;
608          x11_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth;
609          x11_driver.ysiz = gheight < MINHEIGHT ? MINHEIGHT : gheight;
610  
611 <        strcpy(getcombuf(&x11_driver), "new\n");
611 >        tocombuf("new\n", &x11_driver);
612   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines