| 45 |
|
static XEvent currentevent; /* current event */ |
| 46 |
|
|
| 47 |
|
static int ncolors = 0; /* color table size */ |
| 48 |
< |
static int *pixval = NULL; /* allocated pixels */ |
| 48 |
> |
static unsigned long *pixval = NULL; /* allocated pixels */ |
| 49 |
|
|
| 50 |
|
static Display *ourdisplay = NULL; /* our display */ |
| 51 |
|
|
| 100 |
|
} else if (nplanes <= 12) { |
| 101 |
|
if (!XMatchVisualInfo(ourdisplay,ourscreen, |
| 102 |
|
nplanes,PseudoColor,&ourvinfo)) { |
| 103 |
< |
stderr_v("PseudoColor not supported\n"); |
| 103 |
> |
stderr_v("PseudoColor server required\n"); |
| 104 |
|
return(NULL); |
| 105 |
|
} |
| 106 |
|
} else if (!XMatchVisualInfo(ourdisplay,ourscreen, |
| 107 |
< |
nplanes,TrueColor,&ourvinfo)) { |
| 108 |
< |
stderr_v("TrueColor not supported\n"); |
| 107 |
> |
nplanes,TrueColor,&ourvinfo) && |
| 108 |
> |
/* kludge for DirectColor */ |
| 109 |
> |
!XMatchVisualInfo(ourdisplay,ourscreen, |
| 110 |
> |
nplanes,DirectColor,&ourvinfo)) { |
| 111 |
> |
stderr_v("TrueColor server required\n"); |
| 112 |
|
return(NULL); |
| 113 |
|
} |
| 114 |
|
ourvisual = ourvinfo.visual; |
| 138 |
|
XSetNormalHints(ourdisplay, gwind, &oursizhints); |
| 139 |
|
XSelectInput(ourdisplay, gwind, ExposureMask); |
| 140 |
|
XMapWindow(ourdisplay, gwind); |
| 141 |
< |
XWindowEvent(ourdisplay, gwind, ExposureMask, levptr(XExposeEvent)); |
| 141 |
> |
XWindowEvent(ourdisplay, gwind, ExposureMask, levptr(XEvent)); |
| 142 |
|
gwidth = levptr(XExposeEvent)->width; |
| 143 |
|
gheight = levptr(XExposeEvent)->height - COMHEIGHT; |
| 144 |
|
x11_driver.xsiz = gwidth < MINWIDTH ? MINWIDTH : gwidth; |
| 228 |
|
|
| 229 |
|
if (ncolors > 0) |
| 230 |
|
pixel = pixval[get_pixel(col, xnewcolr)]; |
| 231 |
< |
else if (ourvisual->class == TrueColor) |
| 231 |
> |
else if (ourvisual->class != PseudoColor) |
| 232 |
|
pixel = true_pixel(col); |
| 233 |
|
else |
| 234 |
|
return; |
| 336 |
|
static int |
| 337 |
|
getpixels() /* get the color map */ |
| 338 |
|
{ |
| 339 |
+ |
XColor thiscolor; |
| 340 |
+ |
register int i, j; |
| 341 |
+ |
|
| 342 |
|
if (ncolors > 0) |
| 343 |
< |
return(ncolors); |
| 343 |
> |
goto donecolors; |
| 344 |
|
if (ourvisual == DefaultVisual(ourdisplay,ourscreen)) { |
| 345 |
|
ourmap = DefaultColormap(ourdisplay,ourscreen); |
| 346 |
|
goto loop; |
| 351 |
|
for (ncolors = ourvisual->map_entries; |
| 352 |
|
ncolors > ourvisual->map_entries/3; |
| 353 |
|
ncolors = ncolors*.937) { |
| 354 |
< |
pixval = (int *)malloc(ncolors*sizeof(int)); |
| 354 |
> |
pixval = (unsigned long *)malloc(ncolors*sizeof(unsigned long)); |
| 355 |
|
if (pixval == NULL) |
| 356 |
|
return(ncolors = 0); |
| 357 |
|
if (XAllocColorCells(ourdisplay,ourmap,0,NULL,0, |
| 366 |
|
else |
| 367 |
|
return(ncolors = 0); /* failed */ |
| 368 |
|
} |
| 369 |
< |
if (ourmap != DefaultColormap(ourdisplay,ourscreen)) { |
| 370 |
< |
XColor thiscolor; |
| 365 |
< |
register int i, j; |
| 366 |
< |
/* reset black and white */ |
| 367 |
< |
for (i = 0; i < ncolors; i++) { |
| 369 |
> |
if (ourmap != DefaultColormap(ourdisplay,ourscreen)) |
| 370 |
> |
for (i = 0; i < ncolors; i++) { /* reset black and white */ |
| 371 |
|
if (pixval[i] != ourblack && pixval[i] != ourwhite) |
| 372 |
|
continue; |
| 373 |
|
thiscolor.pixel = pixval[i]; |
| 381 |
|
ncolors--; |
| 382 |
|
i--; |
| 383 |
|
} |
| 381 |
– |
} |
| 384 |
|
XSetWindowColormap(ourdisplay, gwind, ourmap); |
| 385 |
+ |
donecolors: |
| 386 |
+ |
#ifdef DEBUG |
| 387 |
+ |
thiscolor.flags = DoRed|DoGreen|DoBlue; |
| 388 |
+ |
thiscolor.red = thiscolor.green = thiscolor.blue = 0; |
| 389 |
+ |
for (i = 0; i < ncolors; i++) { |
| 390 |
+ |
thiscolor.pixel = pixval[i]; |
| 391 |
+ |
XStoreColor(ourdisplay, ourmap, &thiscolor); |
| 392 |
+ |
} |
| 393 |
+ |
#endif |
| 394 |
|
return(ncolors); |
| 395 |
|
} |
| 396 |
|
|