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.32 by schorsch, Tue Mar 30 16:13:01 2004 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>
12   #ifdef sparc
# Line 25 | Line 22 | static char SCCSid[] = "$SunId$ LBL";
22   #include  <X11/cursorfont.h>
23   #include  <X11/Xutil.h>
24  
25 + #include  "platform.h"
26   #include  "color.h"
27   #include  "driver.h"
28   #include  "x11twind.h"
# Line 82 | Line 80 | static Colormap ourmap = 0;            /* our color map */
80  
81   static int  inpcheck;                   /* whence to check input */
82  
83 < extern char  *malloc();
83 > static void x11_errout(char  *msg);
84  
85 < static int  x11_close(), x11_clear(), x11_paintr(), x11_errout(),
86 <                x11_getcur(), x11_comout(), x11_comin(), x11_flush();
85 > static dr_closef_t x11_close;
86 > static dr_clearf_t x11_clear;
87 > static dr_paintrf_t x11_paintr;
88 > static dr_getcurf_t x11_getcur;
89 > static dr_comoutf_t x11_comout;
90 > static dr_cominf_t x11_comin;
91 > static dr_flushf_t x11_flush;
92  
93 < static int  std_comin(), std_comout();
93 > static dr_cominf_t std_comin;
94 > static dr_comoutf_t std_comout;
95  
96   static struct driver  x11_driver = {
97          x11_close, x11_clear, x11_paintr, x11_getcur,
98          NULL, NULL, x11_flush, 1.0
99   };
100  
101 < static int  getpixels(), xnewcolr(), freepixels(), resizewindow(),
98 <                getevent(), getkey(), fixwindow(), x11_getc();
99 < static unsigned long  true_pixel();
101 > static dr_getchf_t x11_getc;
102  
103 + static void freepixels(void);
104 + static int getpixels(void);
105 + static dr_newcolrf_t xnewcolr;
106 + static unsigned long true_pixel(COLOR  col);
107 + static void getevent(void);
108 + static void getkey(XKeyPressedEvent  *ekey);
109 + static void fixwindow(XExposeEvent  *eexp);
110 + static void resizewindow(XConfigureEvent  *ersz);
111  
112 < struct driver *
113 < x11_init(name, id)              /* initialize driver */
114 < char  *name, *id;
112 > extern dr_initf_t x11_init; /* XXX this should be in a seperate header file */
113 >
114 >
115 > extern struct driver *
116 > x11_init(               /* initialize driver */
117 >        char  *name,
118 >        char  *id
119 > )
120   {
106        extern char  *getenv();
121          char  *gv;
122          int  nplanes;
123          XSetWindowAttributes    ourwinattr;
# Line 210 | Line 224 | char  *name, *id;
224   }
225  
226  
227 < static
228 < x11_close()                     /* close our display */
227 > static void
228 > x11_close(void)                 /* close our display */
229   {
230          erract[COMMAND].pf = NULL;              /* reset error vectors */
231          if (erract[WARNING].pf != NULL)
# Line 233 | Line 247 | x11_close()                    /* close our display */
247   }
248  
249  
250 < static
251 < x11_clear(xres, yres)                   /* clear our display */
252 < int  xres, yres;
250 > static void
251 > x11_clear(                      /* clear our display */
252 >        int  xres,
253 >        int  yres
254 > )
255   {
256                                                  /* check limits */
257          if (xres < MINWIDTH)
# Line 254 | Line 270 | int  xres, yres;
270          }
271          XClearWindow(ourdisplay, gwind);
272                                                  /* reinitialize color table */
273 <        if (ourvinfo.class == PseudoColor || ourvinfo.class == GrayScale)
273 >        if (ourvinfo.class == PseudoColor || ourvinfo.class == GrayScale) {
274                  if (getpixels() == 0)
275                          eputs("cannot allocate colors\n");
276                  else
277                          new_ctab(ncolors);
278 +        }
279                                                  /* get new command line */
280          if (comline != NULL)
281                  xt_close(comline);
# Line 279 | Line 296 | int  xres, yres;
296   }
297  
298  
299 < static
300 < x11_paintr(col, xmin, ymin, xmax, ymax)         /* fill a rectangle */
301 < COLOR  col;
302 < int  xmin, ymin, xmax, ymax;
299 > static void
300 > x11_paintr(             /* fill a rectangle */
301 >        COLOR  col,
302 >        int  xmin,
303 >        int  ymin,
304 >        int  xmax,
305 >        int  ymax
306 > )
307   {
308          unsigned long  pixel;
309  
# Line 298 | Line 319 | int  xmin, ymin, xmax, ymax;
319   }
320  
321  
322 < static
323 < x11_flush()                     /* flush output */
322 > static void
323 > x11_flush(void)                 /* flush output */
324   {
325          char    buf[256];
326          int     n;
# Line 334 | Line 355 | x11_flush()                    /* flush output */
355   }
356  
357  
358 < static
359 < x11_comin(inp, prompt)          /* read in a command line */
360 < char  *inp, *prompt;
358 > static void
359 > x11_comin(              /* read in a command line */
360 >        char  *inp,
361 >        char  *prompt
362 > )
363   {
364          if (prompt != NULL) {
365                  x11_flush();            /* make sure we get everything */
# Line 350 | Line 373 | char  *inp, *prompt;
373   }
374  
375  
376 < static
377 < x11_comout(outp)                /* output a string to command line */
378 < char  *outp;
376 > static void
377 > x11_comout(             /* output a string to command line */
378 >        char  *outp
379 > )
380   {
381          if (comline == NULL || outp == NULL || !outp[0])
382                  return;
# Line 362 | Line 386 | char  *outp;
386   }
387  
388  
389 < static
390 < x11_errout(msg)                 /* output an error message */
391 < char  *msg;
389 > static void
390 > x11_errout(                     /* output an error message */
391 >        char  *msg
392 > )
393   {
394          eputs(msg);             /* send to stderr also! */
395          x11_comout(msg);
396   }
397  
398  
399 < static
400 < std_comin(inp, prompt)          /* read in command line from stdin */
401 < char  *inp, *prompt;
399 > static void
400 > std_comin(              /* read in command line from stdin */
401 >        char  *inp,
402 >        char  *prompt
403 > )
404   {
378        extern char     *gets();
379
405          if (prompt != NULL) {
406                  if (fromcombuf(inp, &x11_driver))
407                          return;
# Line 402 | Line 427 | char  *inp, *prompt;
427   }
428  
429  
430 < static
431 < std_comout(outp)                /* write out string to stdout */
432 < char    *outp;
430 > static void
431 > std_comout(             /* write out string to stdout */
432 >        char    *outp
433 > )
434   {
435          fputs(outp, stdout);
436          fflush(stdout);
# Line 412 | Line 438 | char   *outp;
438  
439  
440   static int
441 < x11_getcur(xp, yp)              /* get cursor position */
442 < int  *xp, *yp;
441 > x11_getcur(             /* get cursor position */
442 >        int  *xp,
443 >        int  *yp
444 > )
445   {
446          while (XGrabPointer(ourdisplay, gwind, True, ButtonPressMask,
447                          GrabModeAsync, GrabModeAsync, None, pickcursor,
# Line 440 | Line 468 | int  *xp, *yp;
468   }
469  
470  
471 < static
472 < xnewcolr(ndx, r, g, b)          /* enter a color into hardware table */
473 < int  ndx;
474 < int  r, g, b;
471 > static void
472 > xnewcolr(               /* enter a color into hardware table */
473 >        int  ndx,
474 >        int  r,
475 >        int  g,
476 >        int  b
477 > )
478   {
479          XColor  xcolor;
480  
# Line 458 | Line 489 | int  r, g, b;
489  
490  
491   static int
492 < getpixels()                             /* get the color map */
492 > getpixels(void)                         /* get the color map */
493   {
494          XColor  thiscolor;
495          register int  i, j;
# Line 480 | Line 511 | loop:
511                          return(ncolors = 0);
512                  if (XAllocColorCells(ourdisplay,ourmap,0,NULL,0,pixval,ncolors))
513                          break;
514 <                free((char *)pixval);
514 >                free((void *)pixval);
515                  pixval = NULL;
516          }
517          if (pixval == NULL) {
# Line 509 | Line 540 | loop:
540   }
541  
542  
543 < static
544 < freepixels()                            /* free our pixels */
543 > static void
544 > freepixels(void)                                /* free our pixels */
545   {
546          if (ncolors == 0)
547                  return;
548          XFreeColors(ourdisplay,ourmap,pixval,ncolors,0L);
549 <        free((char *)pixval);
549 >        free((void *)pixval);
550          pixval = NULL;
551          ncolors = 0;
552          if (ourmap != DefaultColormap(ourdisplay,ourscreen))
# Line 525 | Line 556 | freepixels()                           /* free our pixels */
556  
557  
558   static unsigned long
559 < true_pixel(col)                 /* return true pixel value for color */
560 < COLOR  col;
559 > true_pixel(                     /* return true pixel value for color */
560 >        COLOR  col
561 > )
562   {
563          unsigned long  rval;
564          BYTE  rgb[3];
# Line 540 | Line 572 | COLOR  col;
572  
573  
574   static int
575 < x11_getc()                      /* get a command character */
575 > x11_getc(void)                  /* get a command character */
576   {
577          while (c_last <= c_first) {
578                  c_first = c_last = 0;           /* reset */
# Line 551 | Line 583 | x11_getc()                     /* get a command character */
583   }
584  
585  
586 < static
587 < getevent()                      /* get next event */
586 > static void
587 > getevent(void)                  /* get next event */
588   {
589          XNextEvent(ourdisplay, levptr(XEvent));
590          switch (levptr(XEvent)->type) {
# Line 565 | Line 597 | getevent()                     /* get next event */
597                  break;
598          case MapNotify:
599                  if (ourvinfo.class == PseudoColor ||
600 <                                ourvinfo.class == GrayScale)
600 >                                ourvinfo.class == GrayScale) {
601                          if (getpixels() == 0)
602                                  eputs("cannot allocate colors\n");
603                          else
604                                  new_ctab(ncolors);
605 +                }
606                  mapped = 1;
607                  break;
608          case Expose:
# Line 584 | Line 617 | getevent()                     /* get next event */
617   }
618  
619  
620 < static
621 < getkey(ekey)                            /* get input key */
622 < register XKeyPressedEvent  *ekey;
620 > static void
621 > getkey(                         /* get input key */
622 >        register XKeyPressedEvent  *ekey
623 > )
624   {
625          register int  n;
626  
# Line 597 | Line 631 | register XKeyPressedEvent  *ekey;
631   }
632  
633  
634 < static
635 < fixwindow(eexp)                         /* repair damage to window */
636 < register XExposeEvent  *eexp;
634 > static void
635 > fixwindow(                              /* repair damage to window */
636 >        register XExposeEvent  *eexp
637 > )
638   {
639          char  buf[80];
640  
# Line 615 | Line 650 | register XExposeEvent  *eexp;
650   }
651  
652  
653 < static
654 < resizewindow(ersz)                      /* resize window */
655 < register XConfigureEvent  *ersz;
653 > static void
654 > resizewindow(                   /* resize window */
655 >        register XConfigureEvent  *ersz
656 > )
657   {
658          if (ersz->width == gwidth && ersz->height-comheight == gheight)
659                  return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines