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 */ |
79 |
|
x_init(name, id) /* initialize driver */ |
80 |
|
char *name, *id; |
81 |
|
{ |
82 |
+ |
char defgeom[32]; |
83 |
+ |
OpaqueFrame mainframe; |
84 |
+ |
|
85 |
|
ourdisplay = XOpenDisplay(NULL); |
86 |
|
if (ourdisplay == NULL) { |
87 |
|
stderr_v("cannot open X-windows; DISPLAY variable set?\n"); |
97 |
|
bcross_bits, bcross_mask_bits, |
98 |
|
bcross_x_hot, bcross_y_hot, |
99 |
|
BlackPixel, WhitePixel, GXcopy); |
100 |
< |
clientname = id; |
101 |
< |
x_driver.xsiz = DisplayWidth()-(2*BORWIDTH); |
102 |
< |
x_driver.ysiz = DisplayHeight()-(COMHEIGHT+2*BORWIDTH); |
100 |
> |
mainframe.bdrwidth = BORWIDTH; |
101 |
> |
mainframe.border = BlackPixmap; |
102 |
> |
mainframe.background = BlackPixmap; |
103 |
> |
sprintf(defgeom, "=%dx%d+0+22", DisplayWidth()-(2*BORWIDTH), |
104 |
> |
DisplayHeight()-(2*BORWIDTH+22)); |
105 |
> |
gwind = XCreate("X10 driver", name, NULL, defgeom, |
106 |
> |
&mainframe, MINWIDTH, MINHEIGHT+COMHEIGHT); |
107 |
> |
if (gwind == 0) { |
108 |
> |
stderr_v("can't create window\n"); |
109 |
> |
return(NULL); |
110 |
> |
} |
111 |
> |
XStoreName(gwind, id); |
112 |
> |
XMapWindow(gwind); |
113 |
> |
XSelectInput(gwind, KeyPressed|ButtonPressed| |
114 |
> |
ExposeWindow|ExposeRegion|UnmapWindow); |
115 |
> |
x_driver.xsiz = mainframe.width; |
116 |
> |
x_driver.ysiz = mainframe.height-COMHEIGHT; |
117 |
|
x_driver.inpready = 0; |
118 |
|
cmdvec = x_comout; /* set error vectors */ |
119 |
|
if (wrnvec != NULL) |
157 |
|
if (xres != gwidth || yres != gheight) { /* new window */ |
158 |
|
if (comline != NULL) |
159 |
|
xt_close(comline); |
160 |
< |
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); |
160 |
> |
XChangeWindow(gwind, xres, yres+COMHEIGHT); |
161 |
|
comline = xt_open(gwind, 0, yres, xres, COMHEIGHT, 0, COMFN); |
162 |
< |
if (comline == NULL) |
163 |
< |
goto fail; |
162 |
> |
if (comline == NULL) { |
163 |
> |
stderr_v("Cannot open command line window\n"); |
164 |
> |
quit(1); |
165 |
> |
} |
166 |
|
gwidth = xres; |
167 |
|
gheight = yres; |
168 |
|
} else /* just clear */ |
174 |
|
new_ctab(ncolors); |
175 |
|
XSync(1); /* discard input */ |
176 |
|
return; |
171 |
– |
fail: |
172 |
– |
stderr_v("Failure opening window in x_clear\n"); |
173 |
– |
quit(1); |
177 |
|
} |
178 |
|
|
179 |
|
|
352 |
|
return; |
353 |
|
} |
354 |
|
/* check for change in size */ |
355 |
< |
if (eexp->width != gwidth || eexp->height != gheight+COMHEIGHT) { |
355 |
> |
if (eexp->width != gwidth || eexp->height-COMHEIGHT != gheight) { |
356 |
|
x_driver.xsiz = eexp->width; |
357 |
< |
x_driver.ysiz = eexp->height; |
357 |
> |
x_driver.ysiz = eexp->height-COMHEIGHT; |
358 |
|
strcpy(getcombuf(&x_driver), "new\n"); |
359 |
|
return; |
360 |
|
} |
377 |
|
register char *str; |
378 |
|
|
379 |
|
str = XLookupMapping(ekey, &n); |
380 |
< |
while (n-- > 0 && c_last < sizeof(c_queue)) |
380 |
> |
while (n-- > 0 && c_last < sizeof(c_queue)) { |
381 |
|
c_queue[c_last++] = *str++; |
382 |
< |
x_driver.inpready = c_last - c_first; |
382 |
> |
x_driver.inpready++; |
383 |
> |
} |
384 |
|
} |
385 |
|
|
386 |
|
|