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.17 by greg, Mon Sep 12 15:57:55 1994 UTC vs.
Revision 2.23 by greg, Mon Dec 12 16:47:29 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 + #ifdef sparc
18 + #include  <sys/conf.h>
19 + #include  <sys/file.h>
20 + #include  <sys/filio.h>
21 + #endif
22  
23   #include  <X11/Xlib.h>
24   #include  <X11/cursorfont.h>
# Line 69 | Line 75 | static GC  ourgc = 0;                  /* our graphics context for dr
75  
76   static Colormap ourmap = 0;             /* our color map */
77  
78 < extern char  *malloc(), *getcombuf();
78 > #define IC_X11          0
79 > #define IC_IOCTL        1
80 > #define IC_READ         2
81  
82 + static int  inpcheck;                   /* whence to check input */
83 +
84 + extern char  *malloc();
85 +
86   static int  x11_close(), x11_clear(), x11_paintr(), x11_errout(),
87                  x11_getcur(), x11_comout(), x11_comin(), x11_flush();
88  
# Line 129 | Line 141 | char  *name, *id;
141          }
142                                          /* set gamma */
143          if ((gv = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL
144 <                        || (gv = getenv("GAMMA")) != NULL)
144 >                        || (gv = getenv("DISPLAY_GAMMA")) != NULL)
145                  make_gmap(atof(gv));
146          else
147                  make_gmap(GAMMA);
# Line 182 | Line 194 | char  *name, *id;
194                  cmdvec = x11_comout;
195                  if (wrnvec != NULL)
196                          wrnvec = x11_errout;
197 +                inpcheck = IC_X11;
198          } else {
199                  x11_driver.comin = std_comin;
200                  x11_driver.comout = std_comout;
201                  cmdvec = std_comout;
202 +                inpcheck = IC_IOCTL;
203          }
204          return(&x11_driver);
205   }
# Line 282 | Line 296 | int  xmin, ymin, xmax, ymax;
296   static
297   x11_flush()                     /* flush output */
298   {
299 +        char    buf[256];
300          int     n;
301                                                  /* check for input */
302          XNoOp(ourdisplay);
303          n = XPending(ourdisplay);                       /* from X server */
304          while (n-- > 0)
305                  getevent();
306 <        if (x11_driver.comin == std_comin) {            /* from stdin */
306 > #ifdef FNDELAY
307 >        if (inpcheck == IC_IOCTL) {                     /* from stdin */
308 > #ifdef FIONREAD
309                  if (ioctl(fileno(stdin), FIONREAD, &n) < 0) {
310 <                        stderr_v("ioctl error on stdin\n");
311 <                        quit(1);
310 > #else
311 >                if (1) {
312 > #endif
313 >                        if (fcntl(fileno(stdin), F_SETFL, FNDELAY) < 0) {
314 >                                stderr_v("Cannot change input mode\n");
315 >                                quit(1);
316 >                        }
317 >                        inpcheck = IC_READ;
318 >                } else
319 >                        x11_driver.inpready += n;
320 >        }
321 >        if (inpcheck == IC_READ) {
322 >                n = read(fileno(stdin), buf, sizeof(buf)-1);
323 >                if (n > 0) {
324 >                        buf[n] = '\0';
325 >                        tocombuf(buf, &x11_driver);
326                  }
296                x11_driver.inpready += n;
327          }
328 + #endif
329   }
330  
331  
# Line 362 | Line 393 | std_comout(outp)               /* write out string to stdout */
393   char    *outp;
394   {
395          fputs(outp, stdout);
396 +        fflush(stdout);
397   }
398  
399  
# Line 555 | Line 587 | static
587   fixwindow(eexp)                         /* repair damage to window */
588   register XExposeEvent  *eexp;
589   {
590 +        char  buf[80];
591 +
592          if (eexp->window == gwind) {
593 <                sprintf(getcombuf(&x11_driver), "repaint %d %d %d %d\n",
593 >                sprintf(buf, "repaint %d %d %d %d\n",
594                          eexp->x, gheight - eexp->y - eexp->height,
595                          eexp->x + eexp->width, gheight - eexp->y);
596 +                tocombuf(buf, &x11_driver);
597          } else if (eexp->window == comline->w) {
598                  if (eexp->count == 0)
599                          xt_redraw(comline);
# Line 578 | Line 613 | register XConfigureEvent  *ersz;
613          x11_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth;
614          x11_driver.ysiz = gheight < MINHEIGHT ? MINHEIGHT : gheight;
615  
616 <        strcpy(getcombuf(&x11_driver), "new\n");
616 >        tocombuf("new\n", &x11_driver);
617   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines