1 |
+ |
/* Copyright (c) 1992 Regents of the University of California */ |
2 |
+ |
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
5 |
|
#endif |
6 |
|
|
5 |
– |
/* Copyright (c) 1989 Regents of the University of California */ |
6 |
– |
|
7 |
|
/* |
8 |
< |
* x11.c - driver for X-windows version 11.3 |
8 |
> |
* x11.c - driver for X-windows version 11 |
9 |
|
* |
10 |
|
* Jan 1990 |
11 |
|
*/ |
38 |
|
|
39 |
|
#define ourscreen DefaultScreen(ourdisplay) |
40 |
|
#define ourroot RootWindow(ourdisplay,ourscreen) |
41 |
– |
#define ourwhite WhitePixel(ourdisplay,ourscreen) |
42 |
– |
#define ourblack BlackPixel(ourdisplay,ourscreen) |
41 |
|
|
42 |
|
#define levptr(etype) ((etype *)¤tevent) |
43 |
|
|
45 |
|
|
46 |
|
static int ncolors = 0; /* color table size */ |
47 |
|
static unsigned long *pixval = NULL; /* allocated pixels */ |
48 |
+ |
static unsigned long ourblack=0, ourwhite=1; |
49 |
|
|
50 |
|
static Display *ourdisplay = NULL; /* our display */ |
51 |
|
|
94 |
|
} |
95 |
|
/* find a usable visual */ |
96 |
|
nplanes = DisplayPlanes(ourdisplay, ourscreen); |
97 |
< |
if ( !XMatchVisualInfo(ourdisplay,ourscreen, |
98 |
< |
24,TrueColor,&ourvinfo) && |
99 |
< |
!XMatchVisualInfo(ourdisplay,ourscreen, |
100 |
< |
24,DirectColor,&ourvinfo) ) |
97 |
> |
if (XMatchVisualInfo(ourdisplay,ourscreen, |
98 |
> |
24,TrueColor,&ourvinfo) || |
99 |
> |
XMatchVisualInfo(ourdisplay,ourscreen, |
100 |
> |
24,DirectColor,&ourvinfo)) { |
101 |
> |
ourblack = 0; |
102 |
> |
ourwhite = ourvinfo.red_mask | |
103 |
> |
ourvinfo.green_mask | |
104 |
> |
ourvinfo.blue_mask ; |
105 |
> |
} else { |
106 |
|
if (nplanes < 4) { |
107 |
|
stderr_v("not enough colors\n"); |
108 |
|
return(NULL); |
109 |
< |
} else if (!XMatchVisualInfo(ourdisplay,ourscreen, |
109 |
> |
} |
110 |
> |
if (!XMatchVisualInfo(ourdisplay,ourscreen, |
111 |
|
nplanes,PseudoColor,&ourvinfo) && |
112 |
|
!XMatchVisualInfo(ourdisplay,ourscreen, |
113 |
|
nplanes,GrayScale,&ourvinfo)) { |
114 |
|
stderr_v("unsupported visual type\n"); |
115 |
|
return(NULL); |
116 |
|
} |
117 |
+ |
ourblack = BlackPixel(ourdisplay,ourscreen); |
118 |
+ |
ourwhite = WhitePixel(ourdisplay,ourscreen); |
119 |
+ |
} |
120 |
|
make_gmap(GAMMA); |
121 |
|
/* open window */ |
122 |
|
ourwinattr.background_pixel = ourblack; |
123 |
|
ourwinattr.border_pixel = ourblack; |
124 |
< |
/* this is a waste! */ |
124 |
> |
/* this is stupid */ |
125 |
|
ourwinattr.colormap = XCreateColormap(ourdisplay, ourroot, |
126 |
|
ourvinfo.visual, AllocNone); |
127 |
|
gwind = XCreateWindow(ourdisplay, ourroot, 0, 0, |
133 |
|
stderr_v("cannot create window\n"); |
134 |
|
return(NULL); |
135 |
|
} |
136 |
< |
XStoreName(ourdisplay, gwind, id); |
136 |
> |
XFreeColormap(ourdisplay, ourwinattr.colormap); |
137 |
> |
XStoreName(ourdisplay, gwind, id); |
138 |
|
/* create a cursor */ |
139 |
|
pickcursor = XCreateFontCursor(ourdisplay, XC_diamond_cross); |
140 |
|
ourgc = XCreateGC(ourdisplay, gwind, 0, NULL); |
214 |
|
/* get new command line */ |
215 |
|
if (comline != NULL) |
216 |
|
xt_close(comline); |
217 |
< |
comline = xt_open(ourdisplay, |
218 |
< |
DefaultGC(ourdisplay,ourscreen), |
210 |
< |
gwind, 0, gheight, gwidth, COMHEIGHT, 0, COMFN); |
217 |
> |
comline = xt_open(ourdisplay, gwind, 0, gheight, |
218 |
> |
gwidth, COMHEIGHT, 0, ourblack, ourwhite, COMFN); |
219 |
|
if (comline == NULL) { |
220 |
|
stderr_v("Cannot open command line window\n"); |
221 |
|
quit(1); |