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.28 by gregl, Tue Dec 2 15:57:45 1997 UTC vs.
Revision 2.35 by greg, Fri May 20 02:06:39 2011 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1995 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  x11.c - driver for X-windows version 11
9 *
10 *     Jan 1990
6   */
7  
8 + #include "copyright.h"
9 +
10   #include  "standard.h"
11   #include  <sys/ioctl.h>
15 #ifdef sparc
16 #include  <sys/conf.h>
17 #include  <sys/file.h>
18 #include  <sys/filio.h>
19 #endif
12   #if  !defined(FNDELAY) && defined(O_NONBLOCK)
13   #define  FNDELAY  O_NONBLOCK
14   #endif
# Line 25 | Line 17 | static char SCCSid[] = "$SunId$ LBL";
17   #include  <X11/cursorfont.h>
18   #include  <X11/Xutil.h>
19  
20 + #include  "platform.h"
21   #include  "color.h"
22   #include  "driver.h"
23   #include  "x11twind.h"
# Line 82 | Line 75 | static Colormap ourmap = 0;            /* our color map */
75  
76   static int  inpcheck;                   /* whence to check input */
77  
78 < extern char  *malloc();
78 > static void x11_errout(char  *msg);
79  
80 < static int  x11_close(), x11_clear(), x11_paintr(), x11_errout(),
81 <                x11_getcur(), x11_comout(), x11_comin(), x11_flush();
80 > static dr_closef_t x11_close;
81 > static dr_clearf_t x11_clear;
82 > static dr_paintrf_t x11_paintr;
83 > static dr_getcurf_t x11_getcur;
84 > static dr_comoutf_t x11_comout;
85 > static dr_cominf_t x11_comin;
86 > static dr_flushf_t x11_flush;
87  
88 < static int  std_comin(), std_comout();
88 > static dr_cominf_t std_comin;
89 > static dr_comoutf_t std_comout;
90  
91   static struct driver  x11_driver = {
92          x11_close, x11_clear, x11_paintr, x11_getcur,
93          NULL, NULL, x11_flush, 1.0
94   };
95  
96 < static int  getpixels(), xnewcolr(), freepixels(), resizewindow(),
98 <                getevent(), getkey(), fixwindow(), x11_getc();
99 < static unsigned long  true_pixel();
96 > static dr_getchf_t x11_getc;
97  
98 + static void freepixels(void);
99 + static int getpixels(void);
100 + static dr_newcolrf_t xnewcolr;
101 + static unsigned long true_pixel(COLOR  col);
102 + static void getevent(void);
103 + static void getkey(XKeyPressedEvent  *ekey);
104 + static void fixwindow(XExposeEvent  *eexp);
105 + static void resizewindow(XConfigureEvent  *ersz);
106  
107 < struct driver *
108 < x11_init(name, id)              /* initialize driver */
109 < char  *name, *id;
107 > extern dr_initf_t x11_init; /* XXX this should be in a seperate header file */
108 >
109 >
110 > extern struct driver *
111 > x11_init(               /* initialize driver */
112 >        char  *name,
113 >        char  *id
114 > )
115   {
106        extern char  *getenv();
116          char  *gv;
117          int  nplanes;
118          XSetWindowAttributes    ourwinattr;
# Line 197 | Line 206 | char  *name, *id;
206                  x11_driver.comin = x11_comin;
207                  x11_driver.comout = x11_comout;
208                  erract[COMMAND].pf = x11_comout;
209 +                /*                      doesn't work with raypcalls.c
210                  if (erract[WARNING].pf != NULL)
211                          erract[WARNING].pf = x11_errout;
212 +                */
213                  inpcheck = IC_X11;
214          } else {
215                  x11_driver.comin = std_comin;
# Line 210 | Line 221 | char  *name, *id;
221   }
222  
223  
224 < static
225 < x11_close()                     /* close our display */
224 > static void
225 > x11_close(void)                 /* close our display */
226   {
227          erract[COMMAND].pf = NULL;              /* reset error vectors */
228          if (erract[WARNING].pf != NULL)
# Line 233 | Line 244 | x11_close()                    /* close our display */
244   }
245  
246  
247 < static
248 < x11_clear(xres, yres)                   /* clear our display */
249 < int  xres, yres;
247 > static void
248 > x11_clear(                      /* clear our display */
249 >        int  xres,
250 >        int  yres
251 > )
252   {
253                                                  /* check limits */
254          if (xres < MINWIDTH)
# Line 254 | Line 267 | int  xres, yres;
267          }
268          XClearWindow(ourdisplay, gwind);
269                                                  /* reinitialize color table */
270 <        if (ourvinfo.class == PseudoColor || ourvinfo.class == GrayScale)
270 >        if (ourvinfo.class == PseudoColor || ourvinfo.class == GrayScale) {
271                  if (getpixels() == 0)
272                          eputs("cannot allocate colors\n");
273                  else
274                          new_ctab(ncolors);
275 +        }
276                                                  /* get new command line */
277          if (comline != NULL)
278                  xt_close(comline);
# Line 279 | Line 293 | int  xres, yres;
293   }
294  
295  
296 < static
297 < x11_paintr(col, xmin, ymin, xmax, ymax)         /* fill a rectangle */
298 < COLOR  col;
299 < int  xmin, ymin, xmax, ymax;
296 > static void
297 > x11_paintr(             /* fill a rectangle */
298 >        COLOR  col,
299 >        int  xmin,
300 >        int  ymin,
301 >        int  xmax,
302 >        int  ymax
303 > )
304   {
305          unsigned long  pixel;
306  
# Line 298 | Line 316 | int  xmin, ymin, xmax, ymax;
316   }
317  
318  
319 < static
320 < x11_flush()                     /* flush output */
319 > static void
320 > x11_flush(void)                 /* flush output */
321   {
322          char    buf[256];
323          int     n;
# Line 334 | Line 352 | x11_flush()                    /* flush output */
352   }
353  
354  
355 < static
356 < x11_comin(inp, prompt)          /* read in a command line */
357 < char  *inp, *prompt;
355 > static void
356 > x11_comin(              /* read in a command line */
357 >        char  *inp,
358 >        char  *prompt
359 > )
360   {
361          if (prompt != NULL) {
362                  x11_flush();            /* make sure we get everything */
# Line 350 | Line 370 | char  *inp, *prompt;
370   }
371  
372  
373 < static
374 < x11_comout(outp)                /* output a string to command line */
375 < char  *outp;
373 > static void
374 > x11_comout(             /* output a string to command line */
375 >        char  *outp
376 > )
377   {
378          if (comline == NULL || outp == NULL || !outp[0])
379                  return;
# Line 362 | Line 383 | char  *outp;
383   }
384  
385  
386 < static
387 < x11_errout(msg)                 /* output an error message */
388 < char  *msg;
386 > static void
387 > x11_errout(                     /* output an error message */
388 >        char  *msg
389 > )
390   {
391          eputs(msg);             /* send to stderr also! */
392          x11_comout(msg);
393   }
394  
395  
396 < static
397 < std_comin(inp, prompt)          /* read in command line from stdin */
398 < char  *inp, *prompt;
396 > static void
397 > std_comin(              /* read in command line from stdin */
398 >        char  *inp,
399 >        char  *prompt
400 > )
401   {
378        extern char     *gets();
379
402          if (prompt != NULL) {
403                  if (fromcombuf(inp, &x11_driver))
404                          return;
# Line 402 | Line 424 | char  *inp, *prompt;
424   }
425  
426  
427 < static
428 < std_comout(outp)                /* write out string to stdout */
429 < char    *outp;
427 > static void
428 > std_comout(             /* write out string to stdout */
429 >        char    *outp
430 > )
431   {
432          fputs(outp, stdout);
433          fflush(stdout);
# Line 412 | Line 435 | char   *outp;
435  
436  
437   static int
438 < x11_getcur(xp, yp)              /* get cursor position */
439 < int  *xp, *yp;
438 > x11_getcur(             /* get cursor position */
439 >        int  *xp,
440 >        int  *yp
441 > )
442   {
443          while (XGrabPointer(ourdisplay, gwind, True, ButtonPressMask,
444                          GrabModeAsync, GrabModeAsync, None, pickcursor,
# Line 440 | Line 465 | int  *xp, *yp;
465   }
466  
467  
468 < static
469 < xnewcolr(ndx, r, g, b)          /* enter a color into hardware table */
470 < int  ndx;
471 < int  r, g, b;
468 > static void
469 > xnewcolr(               /* enter a color into hardware table */
470 >        int  ndx,
471 >        int  r,
472 >        int  g,
473 >        int  b
474 > )
475   {
476          XColor  xcolor;
477  
# Line 458 | Line 486 | int  r, g, b;
486  
487  
488   static int
489 < getpixels()                             /* get the color map */
489 > getpixels(void)                         /* get the color map */
490   {
491          XColor  thiscolor;
492          register int  i, j;
# Line 480 | Line 508 | loop:
508                          return(ncolors = 0);
509                  if (XAllocColorCells(ourdisplay,ourmap,0,NULL,0,pixval,ncolors))
510                          break;
511 <                free((char *)pixval);
511 >                free((void *)pixval);
512                  pixval = NULL;
513          }
514          if (pixval == NULL) {
# Line 509 | Line 537 | loop:
537   }
538  
539  
540 < static
541 < freepixels()                            /* free our pixels */
540 > static void
541 > freepixels(void)                                /* free our pixels */
542   {
543          if (ncolors == 0)
544                  return;
545          XFreeColors(ourdisplay,ourmap,pixval,ncolors,0L);
546 <        free((char *)pixval);
546 >        free((void *)pixval);
547          pixval = NULL;
548          ncolors = 0;
549          if (ourmap != DefaultColormap(ourdisplay,ourscreen))
# Line 525 | Line 553 | freepixels()                           /* free our pixels */
553  
554  
555   static unsigned long
556 < true_pixel(col)                 /* return true pixel value for color */
557 < COLOR  col;
556 > true_pixel(                     /* return true pixel value for color */
557 >        COLOR  col
558 > )
559   {
560          unsigned long  rval;
561 <        BYTE  rgb[3];
561 >        uby8  rgb[3];
562  
563          map_color(rgb, col);
564          rval = ourvinfo.red_mask*rgb[RED]/255 & ourvinfo.red_mask;
# Line 540 | Line 569 | COLOR  col;
569  
570  
571   static int
572 < x11_getc()                      /* get a command character */
572 > x11_getc(void)                  /* get a command character */
573   {
574          while (c_last <= c_first) {
575                  c_first = c_last = 0;           /* reset */
# Line 551 | Line 580 | x11_getc()                     /* get a command character */
580   }
581  
582  
583 < static
584 < getevent()                      /* get next event */
583 > static void
584 > getevent(void)                  /* get next event */
585   {
586          XNextEvent(ourdisplay, levptr(XEvent));
587          switch (levptr(XEvent)->type) {
# Line 565 | Line 594 | getevent()                     /* get next event */
594                  break;
595          case MapNotify:
596                  if (ourvinfo.class == PseudoColor ||
597 <                                ourvinfo.class == GrayScale)
597 >                                ourvinfo.class == GrayScale) {
598                          if (getpixels() == 0)
599                                  eputs("cannot allocate colors\n");
600                          else
601                                  new_ctab(ncolors);
602 +                }
603                  mapped = 1;
604                  break;
605          case Expose:
# Line 584 | Line 614 | getevent()                     /* get next event */
614   }
615  
616  
617 < static
618 < getkey(ekey)                            /* get input key */
619 < register XKeyPressedEvent  *ekey;
617 > static void
618 > getkey(                         /* get input key */
619 >        register XKeyPressedEvent  *ekey
620 > )
621   {
622          register int  n;
623  
# Line 597 | Line 628 | register XKeyPressedEvent  *ekey;
628   }
629  
630  
631 < static
632 < fixwindow(eexp)                         /* repair damage to window */
633 < register XExposeEvent  *eexp;
631 > static void
632 > fixwindow(                              /* repair damage to window */
633 >        register XExposeEvent  *eexp
634 > )
635   {
636          char  buf[80];
637  
# Line 615 | Line 647 | register XExposeEvent  *eexp;
647   }
648  
649  
650 < static
651 < resizewindow(ersz)                      /* resize window */
652 < register XConfigureEvent  *ersz;
650 > static void
651 > resizewindow(                   /* resize window */
652 >        register XConfigureEvent  *ersz
653 > )
654   {
655          if (ersz->width == gwidth && ersz->height-comheight == gheight)
656                  return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines