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 1.7 by greg, Fri Feb 23 14:50:38 1990 UTC vs.
Revision 1.12 by greg, Thu Mar 8 10:09:58 1990 UTC

# Line 84 | Line 84 | char  *name, *id;
84   {
85          int  nplanes;
86          XVisualInfo  ourvinfo;
87 +        XSetWindowAttributes    ourwinattr;
88          XWMHints  ourxwmhints;
89 <        Pixmap  bmCursorSrc, bmCursorMsk;
89 >        XSizeHints      oursizhints;
90  
91          ourdisplay = XOpenDisplay(NULL);
92          if (ourdisplay == NULL) {
# Line 109 | Line 110 | char  *name, *id;
110          }
111          ourvisual = ourvinfo.visual;
112          make_gmap(GAMMA);
112        /* create a cursor */
113        pickcursor = XCreateFontCursor (ourdisplay, XC_diamond_cross);
113          /* open window */
114 <        gwind = XCreateSimpleWindow(ourdisplay, ourroot, 0, 0,
114 >        ourwinattr.background_pixel = ourblack;
115 >        ourwinattr.border_pixel = ourblack;
116 >        gwind = XCreateWindow(ourdisplay, ourroot, 0, 0,
117                  DisplayWidth(ourdisplay,ourscreen)-2*BORWIDTH,
118                  DisplayHeight(ourdisplay,ourscreen)-2*BORWIDTH,
119 <                BORWIDTH, ourblack, ourwhite);
119 >                BORWIDTH, nplanes, InputOutput, ourvisual,
120 >                CWBackPixel|CWBorderPixel, &ourwinattr);
121          if (gwind == 0) {
122                  stderr_v("cannot create window\n");
123                  return(NULL);
124          }
125          XStoreName(ourdisplay, gwind, id);
126 +        /* create a cursor */
127 +        pickcursor = XCreateFontCursor(ourdisplay, XC_diamond_cross);
128          ourgc = XCreateGC(ourdisplay, gwind, 0, NULL);
129          ourxwmhints.flags = InputHint;
130          ourxwmhints.input = True;
131          XSetWMHints(ourdisplay, gwind, &ourxwmhints);
132 +        oursizhints.min_width = MINWIDTH;
133 +        oursizhints.min_height = MINHEIGHT+COMHEIGHT;
134 +        oursizhints.flags = PMinSize;
135 +        XSetNormalHints(ourdisplay, gwind, &oursizhints);
136          XSelectInput(ourdisplay, gwind, ExposureMask);
137          XMapWindow(ourdisplay, gwind);
138          XWindowEvent(ourdisplay, gwind, ExposureMask, levptr(XExposeEvent));
# Line 152 | Line 160 | x11_close()                    /* close our display */
160                  xt_close(comline);
161                  comline = NULL;
162          }
163 <        if (gwind != 0) {
164 <                freepixels();
165 <                XFreeGC(ourdisplay, ourgc);
166 <                XDestroyWindow(ourdisplay, gwind);
167 <                gwind = 0;
160 <                ourgc = 0;
161 <        }
163 >        freepixels();
164 >        XFreeGC(ourdisplay, ourgc);
165 >        XDestroyWindow(ourdisplay, gwind);
166 >        gwind = 0;
167 >        ourgc = 0;
168          XFreeCursor(ourdisplay, pickcursor);
169          XCloseDisplay(ourdisplay);
170          ourdisplay = NULL;
# Line 169 | Line 175 | static
175   x11_clear(xres, yres)                   /* clear our display */
176   int  xres, yres;
177   {
178 <        if (xres != gwidth || yres != gheight) {        /* change window */
179 <                if (comline != NULL)
180 <                        xt_close(comline);
178 >                                                /* destroy command line */
179 >        if (comline != NULL)
180 >                xt_close(comline);
181 >                                                /* check limits */
182 >        if (xres < MINWIDTH)
183 >                xres = MINWIDTH;
184 >        if (yres < MINHEIGHT)
185 >                yres = MINHEIGHT;
186 >                                                /* resize window */
187 >        if (xres != gwidth || yres != gheight) {
188                  XSelectInput(ourdisplay, gwind, 0);
189                  XResizeWindow(ourdisplay, gwind, xres, yres+COMHEIGHT);
177                comline = xt_open(ourdisplay,
178                                DefaultGC(ourdisplay,ourscreen),
179                                gwind, 0, yres, xres, COMHEIGHT, 0, COMFN);
180                if (comline == NULL) {
181                        stderr_v("Cannot open command line window\n");
182                        quit(1);
183                }
184                XSelectInput(ourdisplay, comline->w, ExposureMask);
190                  gwidth = xres;
191                  gheight = yres;
192 <                XSync(ourdisplay, 1);           /* discard input */
192 >                XFlush(ourdisplay);
193                  sleep(2);                       /* wait for window manager */
194 +                XSync(ourdisplay, 1);           /* discard input */
195          }
196 +                                                /* get new command line */
197 +        comline = xt_open(ourdisplay,
198 +                        DefaultGC(ourdisplay,ourscreen),
199 +                        gwind, 0, gheight, gwidth, COMHEIGHT, 0, COMFN);
200 +        if (comline == NULL) {
201 +                stderr_v("Cannot open command line window\n");
202 +                quit(1);
203 +        }
204 +        XSelectInput(ourdisplay, comline->w, ExposureMask);
205 +                                                /* clear graphics window */
206          XClearWindow(ourdisplay, gwind);
207 <        if (ourvisual->class == PseudoColor)    /* reinitialize color table */
207 >                                                /* reinitialize color table */
208 >        if (ourvisual->class == PseudoColor)
209                  if (getpixels() == 0)
210                          stderr_v("cannot allocate colors\n");
211                  else
212                          new_ctab(ncolors);
213 <
213 >                                                /* remove earmuffs */
214          XSelectInput(ourdisplay, gwind,
215                  StructureNotifyMask|ExposureMask|KeyPressMask|ButtonPressMask);
216   }
# Line 223 | Line 240 | int  xmin, ymin, xmax, ymax;
240   static
241   x11_flush()                     /* flush output */
242   {
243 <        if (ncolors <= 0)       /* output necessary for death */
227 <                XFillRectangle(ourdisplay, gwind, ourgc, 0, 0, 1 ,1);
243 >        XNoOp(ourdisplay);
244          while (XPending(ourdisplay) > 0)
245                  getevent();
246   }
# Line 251 | Line 267 | static
267   x11_comout(out)                 /* output a string to command line */
268   char  *out;
269   {
270 <        if (comline != NULL)
271 <                xt_puts(out, comline);
272 <        XFlush(ourdisplay);
270 >        if (comline == NULL)
271 >                return;
272 >        xt_puts(out, comline);
273 >        if (out[strlen(out)-1] == '\n')
274 >                XFlush(ourdisplay);
275   }
276  
277  
# Line 261 | Line 279 | static
279   x11_errout(msg)                 /* output an error message */
280   char  *msg;
281   {
264        x11_comout(msg);
282          stderr_v(msg);          /* send to stderr also! */
283 +        x11_comout(msg);
284   }
285  
286  
# Line 375 | Line 393 | freepixels()                           /* free our pixels */
393                  return;
394          XFreeColors(ourdisplay,ourmap,pixval,ncolors,0L);
395          ncolors = 0;
396 <        if (ourmap != 0 && ourmap != DefaultColormap(ourdisplay,ourscreen))
396 >        if (ourmap != DefaultColormap(ourdisplay,ourscreen))
397                  XFreeColormap(ourdisplay, ourmap);
398          ourmap = 0;
399   }
# Line 442 | Line 460 | static
460   getkey(ekey)                            /* get input key */
461   register XKeyPressedEvent  *ekey;
462   {
463 <        int  n;
463 >        register int  n;
464  
465          n = XLookupString(ekey, c_queue+c_last, sizeof(c_queue)-c_last,
466                                  NULL, NULL);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines