27 |
|
#define GAMMA 2.2 /* exponent for color correction */ |
28 |
|
|
29 |
|
#define BORWIDTH 5 /* border width */ |
30 |
– |
#define BARHEIGHT 25 /* menu bar size */ |
30 |
|
#define COMHEIGHT (COMLH*COMCH) /* command line height (pixels) */ |
31 |
+ |
#define MINWIDTH (32*COMCW) /* minimum graphics window width */ |
32 |
+ |
#define MINHEIGHT 64 /* minimum graphics window height */ |
33 |
|
|
34 |
|
#define COMFN "8x13" /* command line font name */ |
35 |
|
#define COMLH 3 /* number of command lines */ |
66 |
|
static int c_first = 0; /* first character in queue */ |
67 |
|
static int c_last = 0; /* last character in queue */ |
68 |
|
|
69 |
< |
extern char *malloc(); |
69 |
> |
extern char *malloc(), *getcombuf(); |
70 |
|
|
71 |
|
int x_close(), x_clear(), x_paintr(), x_errout(), |
72 |
|
x_getcur(), x_comout(), x_comin(); |
73 |
|
|
74 |
|
static struct driver x_driver = { |
75 |
|
x_close, x_clear, x_paintr, x_getcur, |
76 |
< |
x_comout, x_comin, |
76 |
< |
MAXRES, MAXRES |
76 |
> |
x_comout, x_comin, 1.0 |
77 |
|
}; |
78 |
|
|
79 |
|
|
97 |
|
bcross_x_hot, bcross_y_hot, |
98 |
|
BlackPixel, WhitePixel, GXcopy); |
99 |
|
clientname = id; |
100 |
+ |
x_driver.xsiz = DisplayWidth()-(2*BORWIDTH); |
101 |
+ |
x_driver.ysiz = DisplayHeight()-(COMHEIGHT+2*BORWIDTH); |
102 |
|
x_driver.inpready = 0; |
103 |
|
cmdvec = x_comout; /* set error vectors */ |
104 |
|
if (wrnvec != NULL) |
135 |
|
x_clear(xres, yres) /* clear our display */ |
136 |
|
int xres, yres; |
137 |
|
{ |
138 |
+ |
if (xres < MINWIDTH) |
139 |
+ |
xres = MINWIDTH; |
140 |
+ |
if (yres < MINHEIGHT) |
141 |
+ |
yres = MINHEIGHT; |
142 |
|
if (xres != gwidth || yres != gheight) { /* new window */ |
143 |
|
if (comline != NULL) |
144 |
|
xt_close(comline); |
145 |
|
if (gwind == 0) { |
146 |
< |
gwind = XCreateWindow(RootWindow, 0, BARHEIGHT, |
146 |
> |
gwind = XCreateWindow(RootWindow, 0, 0, |
147 |
|
xres, yres+COMHEIGHT, BORWIDTH, |
148 |
|
BlackPixmap, BlackPixmap); |
149 |
|
if (gwind == 0) |
202 |
|
{ |
203 |
|
int x_getc(), x_comout(); |
204 |
|
|
205 |
+ |
if (fromcombuf(inp, &x_driver)) |
206 |
+ |
return; |
207 |
|
xt_cursor(comline, TBLKCURS); |
208 |
|
editline(inp, x_getc, x_comout); |
209 |
|
xt_cursor(comline, TNOCURS); |
325 |
|
getkey(levptr(XKeyPressedEvent)); |
326 |
|
break; |
327 |
|
case ExposeWindow: |
328 |
< |
if (levptr(XExposeEvent)->subwindow == 0) { |
329 |
< |
if (ncolors == 0 && getpixels() == 0) { |
322 |
< |
stderr_v("cannot allocate colors\n"); |
323 |
< |
break; |
324 |
< |
} |
325 |
< |
new_ctab(ncolors); |
326 |
< |
} |
327 |
< |
/* fall through */ |
328 |
> |
windowchange(levptr(XExposeEvent)); |
329 |
> |
break; |
330 |
|
case ExposeRegion: |
331 |
|
fixwindow(levptr(XExposeEvent)); |
332 |
|
break; |
341 |
|
|
342 |
|
|
343 |
|
static |
344 |
+ |
windowchange(eexp) /* process window change event */ |
345 |
+ |
register XExposeEvent *eexp; |
346 |
+ |
{ |
347 |
+ |
if (eexp->subwindow != 0) { |
348 |
+ |
fixwindow(eexp); |
349 |
+ |
return; |
350 |
+ |
} |
351 |
+ |
/* check for change in size */ |
352 |
+ |
if (eexp->width != gwidth || eexp->height != gheight+COMHEIGHT) { |
353 |
+ |
x_driver.xsiz = eexp->width; |
354 |
+ |
x_driver.ysiz = eexp->height; |
355 |
+ |
strcpy(getcombuf(&x_driver), "new\n"); |
356 |
+ |
return; |
357 |
+ |
} |
358 |
+ |
/* remap colors */ |
359 |
+ |
if (ncolors == 0 && getpixels() == 0) { |
360 |
+ |
stderr_v("cannot allocate colors\n"); |
361 |
+ |
return; |
362 |
+ |
} |
363 |
+ |
new_ctab(ncolors); |
364 |
+ |
/* redraw */ |
365 |
+ |
fixwindow(eexp); |
366 |
+ |
} |
367 |
+ |
|
368 |
+ |
|
369 |
+ |
static |
370 |
|
getkey(ekey) /* get input key */ |
371 |
|
register XKeyPressedEvent *ekey; |
372 |
|
{ |
385 |
|
register XExposeEvent *eexp; |
386 |
|
{ |
387 |
|
if (eexp->subwindow == 0) |
388 |
< |
repaint(eexp->x, gheight - eexp->y - eexp->height, |
388 |
> |
sprintf(getcombuf(&x_driver), "repaint %d %d %d %d\n", |
389 |
> |
eexp->x, gheight - eexp->y - eexp->height, |
390 |
|
eexp->x + eexp->width, gheight - eexp->y); |
391 |
|
else if (eexp->subwindow == comline->w) |
392 |
|
xt_redraw(comline); |