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 |
|
*/ |
23 |
|
#include "x11twind.h" |
24 |
|
#include "x11icon.h" |
25 |
|
|
26 |
< |
#define GAMMA 2.2 /* exponent for color correction */ |
26 |
> |
#define GAMMA 2.2 /* default exponent correction */ |
27 |
|
|
28 |
|
#define MINWIDTH (32*COMCW) /* minimum graphics window width */ |
29 |
|
#define MINHEIGHT MINWIDTH /* minimum graphics window height */ |
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 |
|
|
82 |
|
x11_init(name, id) /* initialize driver */ |
83 |
|
char *name, *id; |
84 |
|
{ |
85 |
+ |
extern char *getenv(); |
86 |
+ |
char *gv; |
87 |
|
int nplanes; |
88 |
|
XSetWindowAttributes ourwinattr; |
89 |
|
XWMHints ourxwmhints; |
96 |
|
} |
97 |
|
/* find a usable visual */ |
98 |
|
nplanes = DisplayPlanes(ourdisplay, ourscreen); |
99 |
< |
if ( !XMatchVisualInfo(ourdisplay,ourscreen, |
100 |
< |
24,TrueColor,&ourvinfo) && |
101 |
< |
!XMatchVisualInfo(ourdisplay,ourscreen, |
102 |
< |
24,DirectColor,&ourvinfo) ) |
99 |
> |
if (XMatchVisualInfo(ourdisplay,ourscreen, |
100 |
> |
24,TrueColor,&ourvinfo) || |
101 |
> |
XMatchVisualInfo(ourdisplay,ourscreen, |
102 |
> |
24,DirectColor,&ourvinfo)) { |
103 |
> |
ourblack = 0; |
104 |
> |
ourwhite = ourvinfo.red_mask | |
105 |
> |
ourvinfo.green_mask | |
106 |
> |
ourvinfo.blue_mask ; |
107 |
> |
} else { |
108 |
|
if (nplanes < 4) { |
109 |
|
stderr_v("not enough colors\n"); |
110 |
|
return(NULL); |
111 |
< |
} else if (!XMatchVisualInfo(ourdisplay,ourscreen, |
111 |
> |
} |
112 |
> |
if (!XMatchVisualInfo(ourdisplay,ourscreen, |
113 |
|
nplanes,PseudoColor,&ourvinfo) && |
114 |
|
!XMatchVisualInfo(ourdisplay,ourscreen, |
115 |
|
nplanes,GrayScale,&ourvinfo)) { |
116 |
|
stderr_v("unsupported visual type\n"); |
117 |
|
return(NULL); |
118 |
|
} |
119 |
< |
make_gmap(GAMMA); |
120 |
< |
/* open window */ |
119 |
> |
ourblack = BlackPixel(ourdisplay,ourscreen); |
120 |
> |
ourwhite = WhitePixel(ourdisplay,ourscreen); |
121 |
> |
} |
122 |
> |
/* set gamma */ |
123 |
> |
if ((gv = getenv("GAMMA")) != NULL) |
124 |
> |
make_gmap(atof(gv)); |
125 |
> |
else |
126 |
> |
make_gmap(GAMMA); |
127 |
> |
/* open window */ |
128 |
|
ourwinattr.background_pixel = ourblack; |
129 |
|
ourwinattr.border_pixel = ourblack; |
130 |
< |
/* this is a waste! */ |
130 |
> |
/* this is stupid */ |
131 |
|
ourwinattr.colormap = XCreateColormap(ourdisplay, ourroot, |
132 |
|
ourvinfo.visual, AllocNone); |
133 |
|
gwind = XCreateWindow(ourdisplay, ourroot, 0, 0, |
139 |
|
stderr_v("cannot create window\n"); |
140 |
|
return(NULL); |
141 |
|
} |
142 |
< |
XStoreName(ourdisplay, gwind, id); |
142 |
> |
XStoreName(ourdisplay, gwind, id); |
143 |
|
/* create a cursor */ |
144 |
|
pickcursor = XCreateFontCursor(ourdisplay, XC_diamond_cross); |
145 |
|
ourgc = XCreateGC(ourdisplay, gwind, 0, NULL); |
219 |
|
/* get new command line */ |
220 |
|
if (comline != NULL) |
221 |
|
xt_close(comline); |
222 |
< |
comline = xt_open(ourdisplay, |
223 |
< |
DefaultGC(ourdisplay,ourscreen), |
210 |
< |
gwind, 0, gheight, gwidth, COMHEIGHT, 0, COMFN); |
222 |
> |
comline = xt_open(ourdisplay, gwind, 0, gheight, |
223 |
> |
gwidth, COMHEIGHT, 0, ourblack, ourwhite, COMFN); |
224 |
|
if (comline == NULL) { |
225 |
|
stderr_v("Cannot open command line window\n"); |
226 |
|
quit(1); |