| 86 |
|
XVisualInfo ourvinfo; |
| 87 |
|
XSetWindowAttributes ourwinattr; |
| 88 |
|
XWMHints ourxwmhints; |
| 89 |
+ |
XSizeHints oursizhints; |
| 90 |
|
|
| 91 |
|
ourdisplay = XOpenDisplay(NULL); |
| 92 |
|
if (ourdisplay == NULL) { |
| 111 |
|
ourvisual = ourvinfo.visual; |
| 112 |
|
make_gmap(GAMMA); |
| 113 |
|
/* open window */ |
| 114 |
< |
ourwinattr.background_pixel = ourwhite; |
| 114 |
> |
ourwinattr.background_pixel = ourblack; |
| 115 |
|
ourwinattr.border_pixel = ourblack; |
| 116 |
|
gwind = XCreateWindow(ourdisplay, ourroot, 0, 0, |
| 117 |
|
DisplayWidth(ourdisplay,ourscreen)-2*BORWIDTH, |
| 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)); |
| 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 |
> |
/* check limits */ |
| 179 |
> |
if (xres < MINWIDTH) |
| 180 |
> |
xres = MINWIDTH; |
| 181 |
> |
if (yres < MINHEIGHT) |
| 182 |
> |
yres = MINHEIGHT; |
| 183 |
> |
/* resize window */ |
| 184 |
> |
if (xres != gwidth || yres != gheight) { |
| 185 |
|
XSelectInput(ourdisplay, gwind, 0); |
| 186 |
|
XResizeWindow(ourdisplay, gwind, xres, yres+COMHEIGHT); |
| 178 |
– |
comline = xt_open(ourdisplay, |
| 179 |
– |
DefaultGC(ourdisplay,ourscreen), |
| 180 |
– |
gwind, 0, yres, xres, COMHEIGHT, 0, COMFN); |
| 181 |
– |
if (comline == NULL) { |
| 182 |
– |
stderr_v("Cannot open command line window\n"); |
| 183 |
– |
quit(1); |
| 184 |
– |
} |
| 185 |
– |
XSelectInput(ourdisplay, comline->w, ExposureMask); |
| 187 |
|
gwidth = xres; |
| 188 |
|
gheight = yres; |
| 189 |
|
XFlush(ourdisplay); |
| 191 |
|
XSync(ourdisplay, 1); /* discard input */ |
| 192 |
|
} |
| 193 |
|
XClearWindow(ourdisplay, gwind); |
| 194 |
< |
if (ourvisual->class == PseudoColor) /* reinitialize color table */ |
| 194 |
> |
/* reinitialize color table */ |
| 195 |
> |
if (ourvisual->class == PseudoColor) |
| 196 |
|
if (getpixels() == 0) |
| 197 |
|
stderr_v("cannot allocate colors\n"); |
| 198 |
|
else |
| 199 |
|
new_ctab(ncolors); |
| 200 |
< |
|
| 200 |
> |
/* get new command line */ |
| 201 |
> |
if (comline != NULL) |
| 202 |
> |
xt_close(comline); |
| 203 |
> |
comline = xt_open(ourdisplay, |
| 204 |
> |
DefaultGC(ourdisplay,ourscreen), |
| 205 |
> |
gwind, 0, gheight, gwidth, COMHEIGHT, 0, COMFN); |
| 206 |
> |
if (comline == NULL) { |
| 207 |
> |
stderr_v("Cannot open command line window\n"); |
| 208 |
> |
quit(1); |
| 209 |
> |
} |
| 210 |
> |
XSelectInput(ourdisplay, comline->w, ExposureMask); |
| 211 |
> |
/* remove earmuffs */ |
| 212 |
|
XSelectInput(ourdisplay, gwind, |
| 213 |
|
StructureNotifyMask|ExposureMask|KeyPressMask|ButtonPressMask); |
| 214 |
|
} |
| 265 |
|
x11_comout(out) /* output a string to command line */ |
| 266 |
|
char *out; |
| 267 |
|
{ |
| 268 |
< |
if (comline != NULL) |
| 269 |
< |
xt_puts(out, comline); |
| 268 |
> |
if (comline == NULL) |
| 269 |
> |
return; |
| 270 |
> |
xt_puts(out, comline); |
| 271 |
> |
if (out[strlen(out)-1] == '\n') |
| 272 |
> |
XFlush(ourdisplay); |
| 273 |
|
} |
| 274 |
|
|
| 275 |
|
|
| 279 |
|
{ |
| 280 |
|
stderr_v(msg); /* send to stderr also! */ |
| 281 |
|
x11_comout(msg); |
| 266 |
– |
x11_flush(); |
| 282 |
|
} |
| 283 |
|
|
| 284 |
|
|