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

Comparing ray/src/rt/x10.c (file contents):
Revision 1.18 by greg, Mon Jan 8 13:38:41 1990 UTC vs.
Revision 1.24 by greg, Wed Feb 21 18:17:56 1990 UTC

# Line 44 | Line 44 | static char SCCSid[] = "$SunId$ LBL";
44  
45   #define  levptr(etype)  ((etype *)&thisevent)
46  
47 static char  *clientname;               /* calling client's name */
48
47   static XEvent  thisevent;               /* current event */
48  
49   static int  ncolors = 0;                /* color table size */
# Line 57 | Line 55 | static Window  gwind = 0;              /* our graphics window */
55  
56   static Cursor  pickcursor = 0;          /* cursor used for picking */
57  
58 < static int  gwidth = 0;                 /* graphics window width */
61 < static int  gheight = 0;                /* graphics window height */
58 > static int  gwidth, gheight;            /* graphics window size */
59  
60   static TEXTWIND  *comline = NULL;       /* our command line */
61  
# Line 68 | Line 65 | static int  c_last = 0;                        /* last character in queue *
65  
66   extern char  *malloc(), *getcombuf();
67  
68 + extern char  *progname;
69 +
70   int  x_close(), x_clear(), x_paintr(), x_errout(),
71                  x_getcur(), x_comout(), x_comin();
72  
# Line 81 | Line 80 | struct driver *
80   x_init(name, id)                /* initialize driver */
81   char  *name, *id;
82   {
83 +        char  defgeom[32];
84 +        OpaqueFrame  mainframe;
85 +
86          ourdisplay = XOpenDisplay(NULL);
87          if (ourdisplay == NULL) {
88                  stderr_v("cannot open X-windows; DISPLAY variable set?\n");
# Line 96 | Line 98 | char  *name, *id;
98                          bcross_bits, bcross_mask_bits,
99                          bcross_x_hot, bcross_y_hot,
100                          BlackPixel, WhitePixel, GXcopy);
101 <        clientname = id;
102 <        x_driver.xsiz = DisplayWidth()-(2*BORWIDTH);
103 <        x_driver.ysiz = DisplayHeight()-(COMHEIGHT+2*BORWIDTH);
101 >        mainframe.bdrwidth = BORWIDTH;
102 >        mainframe.border = BlackPixmap;
103 >        mainframe.background = BlackPixmap;
104 >        sprintf(defgeom, "=%dx%d+0+22", DisplayWidth()-(2*BORWIDTH),
105 >                        DisplayHeight()-(2*BORWIDTH+22));
106 >        gwind = XCreate("X10 display driver", progname, NULL, defgeom,
107 >                        &mainframe, MINWIDTH, MINHEIGHT+COMHEIGHT);
108 >        if (gwind == 0) {
109 >                stderr_v("can't create window\n");
110 >                return(NULL);
111 >        }
112 >        XStoreName(gwind, id);
113 >        XSelectInput(gwind, KeyPressed|ButtonPressed|
114 >                        ExposeWindow|ExposeRegion|UnmapWindow);
115 >        gwidth = mainframe.width;
116 >        gheight = mainframe.height-COMHEIGHT;
117 >        x_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth;
118 >        x_driver.ysiz = gheight < MINHEIGHT ? MINHEIGHT : gheight;
119          x_driver.inpready = 0;
120          cmdvec = x_comout;                      /* set error vectors */
121          if (wrnvec != NULL)
# Line 122 | Line 139 | x_close()                      /* close our display */
139          if (gwind != 0) {
140                  XDestroyWindow(gwind);
141                  gwind = 0;
125                gwidth = gheight = 0;
142          }
143          XFreeCursor(pickcursor);
144          freepixels();
# Line 135 | Line 151 | static
151   x_clear(xres, yres)                     /* clear our display */
152   int  xres, yres;
153   {
138        if (xres < MINWIDTH)
139                xres = MINWIDTH;
140        if (yres < MINHEIGHT)
141                yres = MINHEIGHT;
154          if (xres != gwidth || yres != gheight) {        /* new window */
155                  if (comline != NULL)
156                          xt_close(comline);
157 <                if (gwind == 0) {
146 <                        gwind = XCreateWindow(RootWindow, 0, 0,
147 <                                        xres, yres+COMHEIGHT, BORWIDTH,
148 <                                        BlackPixmap, BlackPixmap);
149 <                        if (gwind == 0)
150 <                                goto fail;
151 <                        XStoreName(gwind, clientname);
152 <                        XSelectInput(gwind, KeyPressed|ButtonPressed|
153 <                                        ExposeWindow|ExposeRegion|UnmapWindow);
154 <                        XMapWindow(gwind);
155 <                } else
156 <                        XChangeWindow(gwind, xres, yres+COMHEIGHT);
157 >                XChangeWindow(gwind, xres, yres+COMHEIGHT);
158                  comline = xt_open(gwind, 0, yres, xres, COMHEIGHT, 0, COMFN);
159 <                if (comline == NULL)
160 <                        goto fail;
159 >                if (comline == NULL) {
160 >                        stderr_v("Cannot open command line window\n");
161 >                        quit(1);
162 >                }
163                  gwidth = xres;
164                  gheight = yres;
165          } else                                          /* just clear */
166                  XClear(gwind);
167                                                  /* reinitialize color table */
168 <        if (ncolors == 0 && getpixels() == 0)
168 >        if (getpixels() == 0)
169                  stderr_v("cannot allocate colors\n");
170          else
171                  new_ctab(ncolors);
172 +
173 +        XMapWindow(gwind);                      /* make sure it's mapped */
174          XSync(1);                               /* discard input */
175          return;
171 fail:
172        stderr_v("Failure opening window in x_clear\n");
173        quit(1);
176   }
177  
178  
# Line 197 | Line 199 | int  xmin, ymin, xmax, ymax;
199  
200  
201   static
202 < x_comin(inp)                    /* read in a command line */
203 < char  *inp;
202 > x_comin(inp, prompt)            /* read in a command line */
203 > char  *inp, *prompt;
204   {
205          int  x_getc(), x_comout();
206  
207 <        if (fromcombuf(inp, &x_driver))
208 <                return;
207 >        if (prompt != NULL)
208 >                if (fromcombuf(inp, &x_driver))
209 >                        return;
210 >                else
211 >                        xt_puts(prompt, comline);
212          xt_cursor(comline, TBLKCURS);
213          editline(inp, x_getc, x_comout);
214          xt_cursor(comline, TNOCURS);
# Line 280 | Line 285 | getpixels()                            /* get the color map */
285   {
286          int  planes;
287  
288 <        freepixels();
288 >        if (ncolors > 0)
289 >                return(ncolors);
290          for (ncolors=(1<<DisplayPlanes())-3; ncolors>12; ncolors=ncolors*.937){
291                  pixval = (int *)malloc(ncolors*sizeof(int));
292                  if (pixval == NULL)
# Line 349 | Line 355 | register XExposeEvent  *eexp;
355                  return;
356          }
357                                          /* check for change in size */
358 <        if (eexp->width != gwidth || eexp->height != gheight+COMHEIGHT) {
359 <                x_driver.xsiz = eexp->width;
360 <                x_driver.ysiz = eexp->height;
358 >        if (eexp->width != gwidth || eexp->height-COMHEIGHT != gheight) {
359 >                gwidth = eexp->width;
360 >                gheight = eexp->height-COMHEIGHT;
361 >                x_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth;
362 >                x_driver.ysiz = gheight < MINHEIGHT ? MINHEIGHT : gheight;
363                  strcpy(getcombuf(&x_driver), "new\n");
364                  return;
365          }
366                                          /* remap colors */
367 <        if (ncolors == 0 && getpixels() == 0) {
367 >        if (getpixels() == 0) {
368                  stderr_v("cannot allocate colors\n");
369                  return;
370          }
# Line 374 | Line 382 | register XKeyPressedEvent  *ekey;
382          register char  *str;
383  
384          str = XLookupMapping(ekey, &n);
385 <        while (n-- > 0 && c_last < sizeof(c_queue))
385 >        while (n-- > 0 && c_last < sizeof(c_queue)) {
386                  c_queue[c_last++] = *str++;
387 <        x_driver.inpready = c_last - c_first;
387 >                x_driver.inpready++;
388 >        }
389   }
390  
391  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines