| 113 |
|
|
| 114 |
|
char errmsg[128]; |
| 115 |
|
|
| 116 |
< |
extern BYTE clrtab[256][3]; /* global color map */ |
| 116 |
> |
BYTE clrtab[256][3]; /* global color map */ |
| 117 |
|
|
| 118 |
|
extern long ftell(); |
| 119 |
|
|
| 147 |
|
greyscale = !greyscale; |
| 148 |
|
break; |
| 149 |
|
case 'm': |
| 150 |
+ |
greyscale = 1; |
| 151 |
|
maxcolors = 2; |
| 152 |
|
break; |
| 153 |
|
case 'd': |
| 215 |
|
|
| 216 |
|
init(argc, argv); /* get file and open window */ |
| 217 |
|
|
| 217 |
– |
if (parent < 0) { |
| 218 |
– |
kill(getppid(), SIGCONT); /* signal parent if child */ |
| 219 |
– |
sigrecv--; |
| 220 |
– |
} |
| 218 |
|
for ( ; ; ) |
| 219 |
|
getevent(); /* main loop */ |
| 220 |
|
userr: |
| 273 |
|
if (gamstr == NULL) /* get it from the X server */ |
| 274 |
|
gamstr = XGetDefault(thedisplay, "radiance", "gamma"); |
| 275 |
|
if (gamstr == NULL) /* get it from the environment */ |
| 276 |
< |
gamstr = getenv("GAMMA"); |
| 276 |
> |
gamstr = getenv("DISPLAY_GAMMA"); |
| 277 |
|
if (gamstr != NULL) |
| 278 |
|
gamcor = atof(gamstr); |
| 279 |
|
/* get best visual for default screen */ |
| 302 |
|
} |
| 303 |
|
} |
| 304 |
|
/* open window */ |
| 305 |
+ |
i = CWEventMask|CWCursor|CWBackPixel|CWBorderPixel; |
| 306 |
|
ourwinattr.border_pixel = ourwhite; |
| 307 |
|
ourwinattr.background_pixel = ourblack; |
| 308 |
< |
ourwinattr.colormap = XCreateColormap(thedisplay, ourroot, |
| 309 |
< |
ourvis.visual, AllocNone); |
| 308 |
> |
if (ourvis.visual != DefaultVisual(thedisplay,ourscreen)) { |
| 309 |
> |
ourwinattr.colormap = newcmap(thedisplay, ourscreen, ourvis.visual); |
| 310 |
> |
i |= CWColormap; |
| 311 |
> |
} |
| 312 |
|
ourwinattr.event_mask = ExposureMask|KeyPressMask|ButtonPressMask| |
| 313 |
|
ButtonReleaseMask|ButtonMotionMask|StructureNotifyMask; |
| 314 |
|
ourwinattr.cursor = XCreateFontCursor(thedisplay, XC_diamond_cross); |
| 315 |
|
wind = XCreateWindow(thedisplay, ourroot, xszhints.x, xszhints.y, |
| 316 |
|
xszhints.width, xszhints.height, BORWIDTH, |
| 317 |
< |
ourvis.depth, InputOutput, ourvis.visual, CWEventMask| |
| 318 |
< |
CWCursor|CWBackPixel|CWBorderPixel|CWColormap, &ourwinattr); |
| 317 |
> |
ourvis.depth, InputOutput, ourvis.visual, |
| 318 |
> |
i, &ourwinattr); |
| 319 |
|
if (wind == 0) |
| 320 |
|
quiterr("cannot create window"); |
| 321 |
|
width = xmax; |
| 353 |
|
XSetWMProtocols(thedisplay, wind, &closedownAtom, 1); |
| 354 |
|
|
| 355 |
|
XMapWindow(thedisplay, wind); |
| 356 |
– |
return; |
| 356 |
|
} /* end of init */ |
| 357 |
|
|
| 358 |
|
|
| 561 |
|
map_rcolors(ourras, wind); |
| 562 |
|
if (fast) |
| 563 |
|
make_rpixmap(ourras, wind); |
| 564 |
+ |
if (parent < 0 & sigrecv == 0) { /* notify parent */ |
| 565 |
+ |
kill(getppid(), SIGCONT); |
| 566 |
+ |
sigrecv--; |
| 567 |
+ |
} |
| 568 |
|
break; |
| 569 |
|
case UnmapNotify: |
| 570 |
|
if (!fast) |
| 1002 |
|
/* set gamma correction */ |
| 1003 |
|
setcolrgam(gamcor); |
| 1004 |
|
/* make histogram */ |
| 1005 |
< |
new_histo(); |
| 1005 |
> |
if (new_histo((long)xmax*ymax) == -1) |
| 1006 |
> |
quiterr("cannot initialize histogram"); |
| 1007 |
|
for (y = 0; y < ymax; y++) { |
| 1008 |
|
if (getscan(y) < 0) |
| 1009 |
|
break; |