ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/x11.c
Revision: 2.23
Committed: Mon Dec 12 16:47:29 1994 UTC (29 years, 4 months ago) by greg
Content type: text/plain
Branch: MAIN
Changes since 2.22: +5 -0 lines
Log Message:
added appropriate headers for Solaris (I hope)

File Contents

# User Rev Content
1 greg 2.4 /* Copyright (c) 1992 Regents of the University of California */
2    
3 greg 1.1 #ifndef lint
4     static char SCCSid[] = "$SunId$ LBL";
5     #endif
6    
7     /*
8 greg 2.4 * x11.c - driver for X-windows version 11
9 greg 1.1 *
10 greg 1.4 * Jan 1990
11 greg 1.1 */
12    
13     #include <stdio.h>
14 greg 2.12 #include <math.h>
15 greg 1.1 #include <sys/ioctl.h>
16 greg 2.19 #include <fcntl.h>
17 greg 2.23 #ifdef sparc
18     #include <sys/conf.h>
19     #include <sys/file.h>
20     #include <sys/filio.h>
21     #endif
22 greg 1.1
23     #include <X11/Xlib.h>
24 greg 1.4 #include <X11/cursorfont.h>
25     #include <X11/Xutil.h>
26 greg 1.1
27     #include "color.h"
28     #include "driver.h"
29     #include "x11twind.h"
30 greg 1.18 #include "x11icon.h"
31 greg 1.1
32 greg 2.6 #define GAMMA 2.2 /* default exponent correction */
33 greg 1.1
34 greg 1.6 #define MINWIDTH (32*COMCW) /* minimum graphics window width */
35 greg 2.9 #define MINHEIGHT (MINWIDTH/2) /* minimum graphics window height */
36 greg 1.4
37 greg 1.1 #define BORWIDTH 5 /* border width */
38     #define COMHEIGHT (COMLH*COMCH) /* command line height (pixels) */
39    
40     #define COMFN "8x13" /* command line font name */
41     #define COMLH 3 /* number of command lines */
42     #define COMCW 8 /* approx. character width (pixels) */
43     #define COMCH 14 /* approx. character height (pixels) */
44    
45 greg 1.4 #define ourscreen DefaultScreen(ourdisplay)
46     #define ourroot RootWindow(ourdisplay,ourscreen)
47    
48     #define levptr(etype) ((etype *)&currentevent)
49 greg 1.1
50 greg 1.4 static XEvent currentevent; /* current event */
51 greg 1.1
52     static int ncolors = 0; /* color table size */
53 greg 2.8 static int mapped = 0; /* window is mapped? */
54 greg 1.17 static unsigned long *pixval = NULL; /* allocated pixels */
55 greg 2.3 static unsigned long ourblack=0, ourwhite=1;
56 greg 1.1
57     static Display *ourdisplay = NULL; /* our display */
58    
59 greg 2.2 static XVisualInfo ourvinfo; /* our visual information */
60 greg 1.6
61 greg 1.1 static Window gwind = 0; /* our graphics window */
62    
63     static Cursor pickcursor = 0; /* cursor used for picking */
64    
65 greg 1.4 static int gwidth, gheight; /* graphics window size */
66 greg 1.1
67 greg 2.17 static int comheight; /* desired comline height */
68 greg 1.1 static TEXTWIND *comline = NULL; /* our command line */
69    
70     static char c_queue[64]; /* input queue */
71     static int c_first = 0; /* first character in queue */
72     static int c_last = 0; /* last character in queue */
73    
74     static GC ourgc = 0; /* our graphics context for drawing */
75    
76 greg 1.6 static Colormap ourmap = 0; /* our color map */
77 greg 1.1
78 greg 2.19 #define IC_X11 0
79     #define IC_IOCTL 1
80     #define IC_READ 2
81    
82     static int inpcheck; /* whence to check input */
83    
84 greg 2.21 extern char *malloc();
85 greg 1.1
86 greg 1.14 static int x11_close(), x11_clear(), x11_paintr(), x11_errout(),
87 greg 1.5 x11_getcur(), x11_comout(), x11_comin(), x11_flush();
88 greg 1.1
89 greg 2.17 static int std_comin(), std_comout();
90    
91 greg 1.1 static struct driver x11_driver = {
92     x11_close, x11_clear, x11_paintr, x11_getcur,
93 greg 2.17 NULL, NULL, x11_flush, 1.0
94 greg 1.1 };
95    
96 greg 2.13 static int getpixels(), xnewcolr(), freepixels(), resizewindow(),
97     getevent(), getkey(), fixwindow(), x11_getc();
98 greg 2.11 static unsigned long true_pixel();
99 greg 1.1
100 greg 2.11
101 greg 1.1 struct driver *
102     x11_init(name, id) /* initialize driver */
103     char *name, *id;
104     {
105 greg 2.6 extern char *getenv();
106     char *gv;
107 greg 1.6 int nplanes;
108 greg 1.10 XSetWindowAttributes ourwinattr;
109 greg 1.4 XWMHints ourxwmhints;
110 greg 1.12 XSizeHints oursizhints;
111 greg 2.17 /* open display server */
112 greg 1.1 ourdisplay = XOpenDisplay(NULL);
113     if (ourdisplay == NULL) {
114     stderr_v("cannot open X-windows; DISPLAY variable set?\n");
115     return(NULL);
116     }
117 greg 2.2 /* find a usable visual */
118 greg 1.6 nplanes = DisplayPlanes(ourdisplay, ourscreen);
119 greg 2.4 if (XMatchVisualInfo(ourdisplay,ourscreen,
120     24,TrueColor,&ourvinfo) ||
121     XMatchVisualInfo(ourdisplay,ourscreen,
122     24,DirectColor,&ourvinfo)) {
123     ourblack = 0;
124     ourwhite = ourvinfo.red_mask |
125     ourvinfo.green_mask |
126     ourvinfo.blue_mask ;
127     } else {
128 greg 2.2 if (nplanes < 4) {
129     stderr_v("not enough colors\n");
130 greg 1.6 return(NULL);
131 greg 2.4 }
132     if (!XMatchVisualInfo(ourdisplay,ourscreen,
133 greg 2.2 nplanes,PseudoColor,&ourvinfo) &&
134     !XMatchVisualInfo(ourdisplay,ourscreen,
135     nplanes,GrayScale,&ourvinfo)) {
136     stderr_v("unsupported visual type\n");
137     return(NULL);
138 greg 1.6 }
139 greg 2.3 ourblack = BlackPixel(ourdisplay,ourscreen);
140     ourwhite = WhitePixel(ourdisplay,ourscreen);
141     }
142 greg 2.6 /* set gamma */
143 greg 2.14 if ((gv = XGetDefault(ourdisplay, "radiance", "gamma")) != NULL
144 greg 2.18 || (gv = getenv("DISPLAY_GAMMA")) != NULL)
145 greg 2.6 make_gmap(atof(gv));
146     else
147     make_gmap(GAMMA);
148 greg 2.17 /* X11 command line or no? */
149     if (!strcmp(name, "x11"))
150     comheight = COMHEIGHT;
151     else /* "x11d" */
152     comheight = 0;
153 greg 2.6 /* open window */
154 greg 1.12 ourwinattr.background_pixel = ourblack;
155 greg 1.10 ourwinattr.border_pixel = ourblack;
156 greg 2.4 /* this is stupid */
157 greg 2.2 ourwinattr.colormap = XCreateColormap(ourdisplay, ourroot,
158     ourvinfo.visual, AllocNone);
159 greg 1.10 gwind = XCreateWindow(ourdisplay, ourroot, 0, 0,
160 greg 1.4 DisplayWidth(ourdisplay,ourscreen)-2*BORWIDTH,
161     DisplayHeight(ourdisplay,ourscreen)-2*BORWIDTH,
162 greg 2.2 BORWIDTH, ourvinfo.depth, InputOutput, ourvinfo.visual,
163     CWBackPixel|CWBorderPixel|CWColormap, &ourwinattr);
164 greg 1.4 if (gwind == 0) {
165     stderr_v("cannot create window\n");
166     return(NULL);
167     }
168 greg 2.4 XStoreName(ourdisplay, gwind, id);
169 greg 1.10 /* create a cursor */
170     pickcursor = XCreateFontCursor(ourdisplay, XC_diamond_cross);
171 greg 1.4 ourgc = XCreateGC(ourdisplay, gwind, 0, NULL);
172 greg 1.18 ourxwmhints.flags = InputHint|IconPixmapHint;
173 greg 1.4 ourxwmhints.input = True;
174 greg 1.18 ourxwmhints.icon_pixmap = XCreateBitmapFromData(ourdisplay,
175     gwind, x11icon_bits, x11icon_width, x11icon_height);
176 greg 1.4 XSetWMHints(ourdisplay, gwind, &ourxwmhints);
177 greg 1.12 oursizhints.min_width = MINWIDTH;
178 greg 2.17 oursizhints.min_height = MINHEIGHT+comheight;
179 greg 1.12 oursizhints.flags = PMinSize;
180     XSetNormalHints(ourdisplay, gwind, &oursizhints);
181 greg 1.4 XSelectInput(ourdisplay, gwind, ExposureMask);
182     XMapWindow(ourdisplay, gwind);
183 greg 1.17 XWindowEvent(ourdisplay, gwind, ExposureMask, levptr(XEvent));
184 greg 1.4 gwidth = levptr(XExposeEvent)->width;
185 greg 2.17 gheight = levptr(XExposeEvent)->height - comheight;
186 greg 1.4 x11_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth;
187     x11_driver.ysiz = gheight < MINHEIGHT ? MINHEIGHT : gheight;
188 greg 1.1 x11_driver.inpready = 0;
189 greg 2.8 mapped = 1;
190 greg 2.17 /* set i/o vectors */
191     if (comheight) {
192     x11_driver.comin = x11_comin;
193     x11_driver.comout = x11_comout;
194     cmdvec = x11_comout;
195     if (wrnvec != NULL)
196     wrnvec = x11_errout;
197 greg 2.19 inpcheck = IC_X11;
198 greg 2.17 } else {
199     x11_driver.comin = std_comin;
200     x11_driver.comout = std_comout;
201     cmdvec = std_comout;
202 greg 2.19 inpcheck = IC_IOCTL;
203 greg 2.17 }
204 greg 1.1 return(&x11_driver);
205     }
206    
207    
208     static
209     x11_close() /* close our display */
210     {
211     cmdvec = NULL; /* reset error vectors */
212     if (wrnvec != NULL)
213     wrnvec = stderr_v;
214     if (ourdisplay == NULL)
215     return;
216     if (comline != NULL) {
217     xt_close(comline);
218     comline = NULL;
219     }
220 greg 1.8 freepixels();
221     XFreeGC(ourdisplay, ourgc);
222     XDestroyWindow(ourdisplay, gwind);
223     gwind = 0;
224     ourgc = 0;
225 greg 1.1 XFreeCursor(ourdisplay, pickcursor);
226     XCloseDisplay(ourdisplay);
227     ourdisplay = NULL;
228     }
229    
230    
231     static
232     x11_clear(xres, yres) /* clear our display */
233     int xres, yres;
234     {
235 greg 1.12 /* check limits */
236     if (xres < MINWIDTH)
237     xres = MINWIDTH;
238     if (yres < MINHEIGHT)
239     yres = MINHEIGHT;
240     /* resize window */
241     if (xres != gwidth || yres != gheight) {
242 greg 1.4 XSelectInput(ourdisplay, gwind, 0);
243 greg 2.17 XResizeWindow(ourdisplay, gwind, xres, yres+comheight);
244 greg 1.1 gwidth = xres;
245     gheight = yres;
246 greg 1.8 XFlush(ourdisplay);
247     sleep(2); /* wait for window manager */
248 greg 1.4 XSync(ourdisplay, 1); /* discard input */
249     }
250 greg 1.13 XClearWindow(ourdisplay, gwind);
251     /* reinitialize color table */
252 greg 2.2 if (ourvinfo.class == PseudoColor || ourvinfo.class == GrayScale)
253 greg 1.13 if (getpixels() == 0)
254     stderr_v("cannot allocate colors\n");
255     else
256     new_ctab(ncolors);
257 greg 1.12 /* get new command line */
258 greg 1.13 if (comline != NULL)
259     xt_close(comline);
260 greg 2.17 if (comheight) {
261     comline = xt_open(ourdisplay, gwind, 0, gheight, gwidth,
262     comheight, 0, ourblack, ourwhite, COMFN);
263     if (comline == NULL) {
264     stderr_v("Cannot open command line window\n");
265     quit(1);
266     }
267     XSelectInput(ourdisplay, comline->w, ExposureMask);
268 greg 1.12 /* remove earmuffs */
269 greg 2.17 XSelectInput(ourdisplay, gwind,
270 greg 1.4 StructureNotifyMask|ExposureMask|KeyPressMask|ButtonPressMask);
271 greg 2.17 } else /* remove earmuffs */
272     XSelectInput(ourdisplay, gwind,
273     StructureNotifyMask|ExposureMask|ButtonPressMask);
274 greg 1.1 }
275    
276    
277     static
278     x11_paintr(col, xmin, ymin, xmax, ymax) /* fill a rectangle */
279     COLOR col;
280     int xmin, ymin, xmax, ymax;
281     {
282 greg 1.6 unsigned long pixel;
283 greg 1.1
284 greg 2.8 if (!mapped)
285     return;
286 greg 1.6 if (ncolors > 0)
287     pixel = pixval[get_pixel(col, xnewcolr)];
288 greg 2.8 else
289 greg 1.6 pixel = true_pixel(col);
290     XSetForeground(ourdisplay, ourgc, pixel);
291     XFillRectangle(ourdisplay, gwind,
292     ourgc, xmin, gheight-ymax, xmax-xmin, ymax-ymin);
293 greg 1.5 }
294    
295    
296     static
297     x11_flush() /* flush output */
298     {
299 greg 2.19 char buf[256];
300 greg 2.15 int n;
301 greg 2.16 /* check for input */
302 greg 1.10 XNoOp(ourdisplay);
303 greg 2.16 n = XPending(ourdisplay); /* from X server */
304     while (n-- > 0)
305 greg 1.5 getevent();
306 greg 2.22 #ifdef FNDELAY
307 greg 2.19 if (inpcheck == IC_IOCTL) { /* from stdin */
308 greg 2.22 #ifdef FIONREAD
309 greg 2.17 if (ioctl(fileno(stdin), FIONREAD, &n) < 0) {
310 greg 2.22 #else
311     if (1) {
312     #endif
313 greg 2.19 if (fcntl(fileno(stdin), F_SETFL, FNDELAY) < 0) {
314     stderr_v("Cannot change input mode\n");
315     quit(1);
316     }
317     inpcheck = IC_READ;
318     } else
319     x11_driver.inpready += n;
320     }
321     if (inpcheck == IC_READ) {
322     n = read(fileno(stdin), buf, sizeof(buf)-1);
323     if (n > 0) {
324     buf[n] = '\0';
325 greg 2.21 tocombuf(buf, &x11_driver);
326 greg 2.17 }
327 greg 2.15 }
328 greg 2.22 #endif
329 greg 1.1 }
330    
331    
332     static
333 greg 1.3 x11_comin(inp, prompt) /* read in a command line */
334     char *inp, *prompt;
335 greg 1.1 {
336 greg 2.15 if (prompt != NULL) {
337     x11_flush(); /* make sure we get everything */
338 greg 1.4 if (fromcombuf(inp, &x11_driver))
339     return;
340 greg 2.15 xt_puts(prompt, comline);
341     }
342 greg 1.1 xt_cursor(comline, TBLKCURS);
343     editline(inp, x11_getc, x11_comout);
344     xt_cursor(comline, TNOCURS);
345     }
346    
347    
348     static
349 greg 2.17 x11_comout(outp) /* output a string to command line */
350     char *outp;
351 greg 1.1 {
352 greg 1.11 if (comline == NULL)
353     return;
354 greg 2.17 xt_puts(outp, comline);
355     if (outp[strlen(outp)-1] == '\n')
356 greg 1.11 XFlush(ourdisplay);
357 greg 1.1 }
358    
359    
360     static
361     x11_errout(msg) /* output an error message */
362     char *msg;
363     {
364 greg 1.9 stderr_v(msg); /* send to stderr also! */
365 greg 1.1 x11_comout(msg);
366     }
367    
368    
369 greg 2.17 static
370     std_comin(inp, prompt) /* read in command line from stdin */
371     char *inp, *prompt;
372     {
373     extern char *gets();
374    
375     if (prompt != NULL) {
376     if (fromcombuf(inp, &x11_driver))
377     return;
378     if (!x11_driver.inpready)
379     fputs(prompt, stdout);
380     }
381     if (gets(inp) == NULL) {
382     strcpy(inp, "quit");
383     return;
384     }
385     x11_driver.inpready -= strlen(inp) + 1;
386     if (x11_driver.inpready < 0)
387     x11_driver.inpready = 0;
388     }
389    
390    
391     static
392     std_comout(outp) /* write out string to stdout */
393     char *outp;
394     {
395     fputs(outp, stdout);
396 greg 2.20 fflush(stdout);
397 greg 2.17 }
398    
399    
400 greg 1.1 static int
401     x11_getcur(xp, yp) /* get cursor position */
402     int *xp, *yp;
403     {
404     while (XGrabPointer(ourdisplay, gwind, True, ButtonPressMask,
405     GrabModeAsync, GrabModeAsync, None, pickcursor,
406     CurrentTime) != GrabSuccess)
407     sleep(2);
408    
409     do
410     getevent();
411     while (c_last <= c_first && levptr(XEvent)->type != ButtonPress);
412     *xp = levptr(XButtonPressedEvent)->x;
413     *yp = gheight-1 - levptr(XButtonPressedEvent)->y;
414     XUngrabPointer(ourdisplay, CurrentTime);
415     XFlush(ourdisplay); /* insure release */
416     if (c_last > c_first) /* key pressed */
417     return(x11_getc());
418     /* button pressed */
419 greg 2.10 if (levptr(XButtonPressedEvent)->button == Button1)
420 greg 1.1 return(MB1);
421 greg 2.10 if (levptr(XButtonPressedEvent)->button == Button2)
422 greg 1.1 return(MB2);
423 greg 2.10 if (levptr(XButtonPressedEvent)->button == Button3)
424 greg 1.1 return(MB3);
425     return(ABORT);
426     }
427    
428    
429     static
430     xnewcolr(ndx, r, g, b) /* enter a color into hardware table */
431     int ndx;
432     int r, g, b;
433     {
434     XColor xcolor;
435    
436     xcolor.pixel = pixval[ndx];
437     xcolor.red = r << 8;
438     xcolor.green = g << 8;
439     xcolor.blue = b << 8;
440     xcolor.flags = DoRed|DoGreen|DoBlue;
441    
442     XStoreColor(ourdisplay, ourmap, &xcolor);
443     }
444    
445    
446     static int
447     getpixels() /* get the color map */
448     {
449 greg 1.16 XColor thiscolor;
450     register int i, j;
451    
452 greg 1.4 if (ncolors > 0)
453 greg 2.2 return(ncolors);
454     if (ourvinfo.visual == DefaultVisual(ourdisplay,ourscreen)) {
455 greg 1.6 ourmap = DefaultColormap(ourdisplay,ourscreen);
456     goto loop;
457     }
458     newmap:
459 greg 2.2 ourmap = XCreateColormap(ourdisplay,gwind,ourvinfo.visual,AllocNone);
460 greg 1.6 loop:
461 greg 2.2 for (ncolors = ourvinfo.colormap_size;
462     ncolors > ourvinfo.colormap_size/3;
463 greg 1.6 ncolors = ncolors*.937) {
464 greg 1.17 pixval = (unsigned long *)malloc(ncolors*sizeof(unsigned long));
465 greg 1.1 if (pixval == NULL)
466 greg 1.6 return(ncolors = 0);
467 greg 2.8 if (XAllocColorCells(ourdisplay,ourmap,0,NULL,0,pixval,ncolors))
468 greg 1.6 break;
469 greg 1.1 free((char *)pixval);
470 greg 1.6 pixval = NULL;
471 greg 1.1 }
472 greg 1.6 if (pixval == NULL) {
473     if (ourmap == DefaultColormap(ourdisplay,ourscreen))
474     goto newmap; /* try it with our map */
475     else
476     return(ncolors = 0); /* failed */
477     }
478 greg 1.16 if (ourmap != DefaultColormap(ourdisplay,ourscreen))
479     for (i = 0; i < ncolors; i++) { /* reset black and white */
480 greg 1.6 if (pixval[i] != ourblack && pixval[i] != ourwhite)
481     continue;
482     thiscolor.pixel = pixval[i];
483     thiscolor.flags = DoRed|DoGreen|DoBlue;
484     XQueryColor(ourdisplay,
485     DefaultColormap(ourdisplay,ourscreen),
486     &thiscolor);
487     XStoreColor(ourdisplay, ourmap, &thiscolor);
488     for (j = i; j+1 < ncolors; j++)
489     pixval[j] = pixval[j+1];
490     ncolors--;
491     i--;
492     }
493 greg 1.16 XSetWindowColormap(ourdisplay, gwind, ourmap);
494 greg 1.6 return(ncolors);
495 greg 1.1 }
496    
497    
498     static
499     freepixels() /* free our pixels */
500     {
501     if (ncolors == 0)
502     return;
503     XFreeColors(ourdisplay,ourmap,pixval,ncolors,0L);
504 greg 2.7 free((char *)pixval);
505     pixval = NULL;
506 greg 1.1 ncolors = 0;
507 greg 1.8 if (ourmap != DefaultColormap(ourdisplay,ourscreen))
508 greg 1.6 XFreeColormap(ourdisplay, ourmap);
509     ourmap = 0;
510 greg 1.1 }
511    
512    
513 greg 1.6 static unsigned long
514     true_pixel(col) /* return true pixel value for color */
515     COLOR col;
516     {
517     unsigned long rval;
518     BYTE rgb[3];
519    
520     map_color(rgb, col);
521 greg 2.2 rval = ourvinfo.red_mask*rgb[RED]/255 & ourvinfo.red_mask;
522     rval |= ourvinfo.green_mask*rgb[GRN]/255 & ourvinfo.green_mask;
523     rval |= ourvinfo.blue_mask*rgb[BLU]/255 & ourvinfo.blue_mask;
524 greg 1.6 return(rval);
525     }
526    
527    
528 greg 1.1 static int
529     x11_getc() /* get a command character */
530     {
531     while (c_last <= c_first) {
532     c_first = c_last = 0; /* reset */
533     getevent(); /* wait for key */
534     }
535     x11_driver.inpready--;
536     return(c_queue[c_first++]);
537     }
538    
539    
540     static
541     getevent() /* get next event */
542     {
543     XNextEvent(ourdisplay, levptr(XEvent));
544     switch (levptr(XEvent)->type) {
545 greg 1.4 case ConfigureNotify:
546     resizewindow(levptr(XConfigureEvent));
547     break;
548     case UnmapNotify:
549 greg 2.8 mapped = 0;
550 greg 1.4 freepixels();
551     break;
552     case MapNotify:
553 greg 2.2 if (ourvinfo.class == PseudoColor ||
554     ourvinfo.class == GrayScale)
555 greg 1.6 if (getpixels() == 0)
556     stderr_v("Cannot allocate colors\n");
557     else
558     new_ctab(ncolors);
559 greg 2.8 mapped = 1;
560 greg 1.4 break;
561     case Expose:
562     fixwindow(levptr(XExposeEvent));
563     break;
564 greg 1.1 case KeyPress:
565     getkey(levptr(XKeyPressedEvent));
566     break;
567     case ButtonPress:
568     break;
569     }
570     }
571    
572    
573     static
574     getkey(ekey) /* get input key */
575     register XKeyPressedEvent *ekey;
576     {
577 greg 1.8 register int n;
578 greg 1.7
579     n = XLookupString(ekey, c_queue+c_last, sizeof(c_queue)-c_last,
580 greg 1.1 NULL, NULL);
581 greg 1.7 c_last += n;
582     x11_driver.inpready += n;
583 greg 1.1 }
584    
585    
586     static
587     fixwindow(eexp) /* repair damage to window */
588     register XExposeEvent *eexp;
589     {
590 greg 2.21 char buf[80];
591    
592 greg 1.4 if (eexp->window == gwind) {
593 greg 2.21 sprintf(buf, "repaint %d %d %d %d\n",
594 greg 1.4 eexp->x, gheight - eexp->y - eexp->height,
595 greg 1.1 eexp->x + eexp->width, gheight - eexp->y);
596 greg 2.21 tocombuf(buf, &x11_driver);
597 greg 1.4 } else if (eexp->window == comline->w) {
598     if (eexp->count == 0)
599     xt_redraw(comline);
600     }
601 greg 1.1 }
602 greg 1.4
603    
604     static
605     resizewindow(ersz) /* resize window */
606     register XConfigureEvent *ersz;
607     {
608 greg 2.17 if (ersz->width == gwidth && ersz->height-comheight == gheight)
609 greg 1.4 return;
610    
611     gwidth = ersz->width;
612 greg 2.17 gheight = ersz->height-comheight;
613 greg 1.4 x11_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth;
614     x11_driver.ysiz = gheight < MINHEIGHT ? MINHEIGHT : gheight;
615    
616 greg 2.21 tocombuf("new\n", &x11_driver);
617 greg 1.4 }