119 |
|
Display *thedisplay; |
120 |
|
Atom closedownAtom, wmProtocolsAtom; |
121 |
|
|
122 |
< |
int noop() {} |
122 |
> |
int sigrecv; |
123 |
|
|
124 |
+ |
int onsig() { sigrecv++; } |
125 |
|
|
126 |
+ |
|
127 |
|
main(argc, argv) |
128 |
|
int argc; |
129 |
|
char *argv[]; |
181 |
|
if (i > argc) |
182 |
|
goto userr; |
183 |
|
while (i < argc-1) { |
184 |
+ |
sigrecv = 0; |
185 |
+ |
signal(SIGCONT, onsig); |
186 |
|
if ((pid=fork()) == 0) { /* a child for each picture */ |
187 |
|
parent = -1; |
188 |
|
break; |
190 |
|
if (pid < 0) |
191 |
|
quiterr("fork failed"); |
192 |
|
parent++; |
193 |
< |
signal(SIGCONT, noop); |
194 |
< |
pause(); /* wait for wake-up call */ |
193 |
> |
while (!sigrecv) |
194 |
> |
pause(); /* wait for wake-up call */ |
195 |
|
i++; |
196 |
|
} |
197 |
|
if (i < argc) { /* open picture file */ |
217 |
|
|
218 |
|
init(argc, argv); /* get file and open window */ |
219 |
|
|
220 |
< |
if (parent < 0) |
220 |
> |
if (parent < 0) { |
221 |
|
kill(getppid(), SIGCONT); /* signal parent if child */ |
222 |
< |
|
222 |
> |
sigrecv--; |
223 |
> |
} |
224 |
|
for ( ; ; ) |
225 |
|
getevent(); /* main loop */ |
226 |
|
userr: |
316 |
|
quiterr("cannot create window"); |
317 |
|
width = xmax; |
318 |
|
height = ymax; |
319 |
< |
xgcv.foreground = ourblack; |
315 |
< |
xgcv.background = ourwhite; |
319 |
> |
/* prepare graphics drawing context */ |
320 |
|
if ((xgcv.font = XLoadFont(thedisplay, FONTNAME)) == 0) |
321 |
|
quiterr("cannot get font"); |
322 |
+ |
xgcv.foreground = ourblack; |
323 |
+ |
xgcv.background = ourwhite; |
324 |
|
ourgc = XCreateGC(thedisplay, wind, GCForeground|GCBackground| |
325 |
|
GCFont, &xgcv); |
326 |
|
xgcv.function = GXinvert; |
365 |
|
if (parent > 0 & wind != 0) { |
366 |
|
XDestroyWindow(thedisplay, wind); |
367 |
|
XFlush(thedisplay); |
368 |
< |
} |
368 |
> |
} else if (parent < 0 & sigrecv == 0) |
369 |
> |
kill(getppid(), SIGCONT); |
370 |
|
while (parent > 0 && wait(&cs) != -1) { /* wait for any children */ |
371 |
|
if (es == 0) |
372 |
|
es = cs>>8 & 0xff; |