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.20 by greg, Mon Oct 3 12:58:58 1994 UTC vs.
Revision 2.25 by greg, Fri Sep 29 20:20:37 1995 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1992 Regents of the University of California */
1 > /* Copyright (c) 1995 Regents of the University of California */
2  
3   #ifndef lint
4   static char SCCSid[] = "$SunId$ LBL";
# Line 14 | Line 14 | static char SCCSid[] = "$SunId$ LBL";
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 + #if  !defined(FNDELAY) && defined(O_NONBLOCK)
23 + #define  FNDELAY  O_NONBLOCK
24 + #endif
25  
26   #include  <X11/Xlib.h>
27   #include  <X11/cursorfont.h>
# Line 76 | Line 84 | static Colormap ourmap = 0;            /* our color map */
84  
85   static int  inpcheck;                   /* whence to check input */
86  
87 < extern char  *malloc(), *getcombuf();
87 > extern char  *malloc();
88  
89   static int  x11_close(), x11_clear(), x11_paintr(), x11_errout(),
90                  x11_getcur(), x11_comout(), x11_comin(), x11_flush();
# Line 143 | Line 151 | char  *name, *id;
151                                          /* X11 command line or no? */
152          if (!strcmp(name, "x11"))
153                  comheight = COMHEIGHT;
154 <        else /* "x11d" */
154 >        else /* "x11d" */ {
155                  comheight = 0;
156 + #ifndef  FNDELAY
157 +                stderr_v("warning: x11d driver not fully functional on this machine\n");
158 + #endif
159 +        }
160                                          /* open window */
161          ourwinattr.background_pixel = ourblack;
162          ourwinattr.border_pixel = ourblack;
# Line 256 | Line 268 | int  xres, yres;
268                  comline = xt_open(ourdisplay, gwind, 0, gheight, gwidth,
269                                  comheight, 0, ourblack, ourwhite, COMFN);
270                  if (comline == NULL) {
271 <                        stderr_v("Cannot open command line window\n");
271 >                        stderr_v("cannot open command line window\n");
272                          quit(1);
273                  }
274                  XSelectInput(ourdisplay, comline->w, ExposureMask);
# Line 298 | Line 310 | x11_flush()                    /* flush output */
310          n = XPending(ourdisplay);                       /* from X server */
311          while (n-- > 0)
312                  getevent();
313 + #ifdef FNDELAY
314          if (inpcheck == IC_IOCTL) {                     /* from stdin */
315 + #ifdef FIONREAD
316                  if (ioctl(fileno(stdin), FIONREAD, &n) < 0) {
317 + #else
318 +                if (1) {
319 + #endif
320                          if (fcntl(fileno(stdin), F_SETFL, FNDELAY) < 0) {
321 <                                stderr_v("Cannot change input mode\n");
321 >                                stderr_v("cannot change input mode\n");
322                                  quit(1);
323                          }
324                          inpcheck = IC_READ;
# Line 312 | Line 329 | x11_flush()                    /* flush output */
329                  n = read(fileno(stdin), buf, sizeof(buf)-1);
330                  if (n > 0) {
331                          buf[n] = '\0';
332 <                        strcpy(getcombuf(&x11_driver), buf);
332 >                        tocombuf(buf, &x11_driver);
333                  }
334          }
335 + #endif
336   }
337  
338  
# Line 365 | Line 383 | char  *inp, *prompt;
383                  if (fromcombuf(inp, &x11_driver))
384                          return;
385                  if (!x11_driver.inpready)
386 <                        fputs(prompt, stdout);
386 >                        std_comout(prompt);
387          }
388 + #ifdef FNDELAY
389 +        if (inpcheck == IC_READ) {      /* turn off FNDELAY */
390 +                if (fcntl(fileno(stdin), F_SETFL, 0) < 0) {
391 +                        stderr_v("cannot change input mode\n");
392 +                        quit(1);
393 +                }
394 +                inpcheck = IC_IOCTL;
395 +        }
396 + #endif
397          if (gets(inp) == NULL) {
398                  strcpy(inp, "quit");
399                  return;
# Line 542 | Line 569 | getevent()                     /* get next event */
569                  if (ourvinfo.class == PseudoColor ||
570                                  ourvinfo.class == GrayScale)
571                          if (getpixels() == 0)
572 <                                stderr_v("Cannot allocate colors\n");
572 >                                stderr_v("cannot allocate colors\n");
573                          else
574                                  new_ctab(ncolors);
575                  mapped = 1;
# Line 576 | Line 603 | static
603   fixwindow(eexp)                         /* repair damage to window */
604   register XExposeEvent  *eexp;
605   {
606 +        char  buf[80];
607 +
608          if (eexp->window == gwind) {
609 <                sprintf(getcombuf(&x11_driver), "repaint %d %d %d %d\n",
609 >                sprintf(buf, "repaint %d %d %d %d\n",
610                          eexp->x, gheight - eexp->y - eexp->height,
611                          eexp->x + eexp->width, gheight - eexp->y);
612 +                tocombuf(buf, &x11_driver);
613          } else if (eexp->window == comline->w) {
614                  if (eexp->count == 0)
615                          xt_redraw(comline);
# Line 599 | Line 629 | register XConfigureEvent  *ersz;
629          x11_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth;
630          x11_driver.ysiz = gheight < MINHEIGHT ? MINHEIGHT : gheight;
631  
632 <        strcpy(getcombuf(&x11_driver), "new\n");
632 >        tocombuf("new\n", &x11_driver);
633   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines