| 13 |
|
#include "standard.h" |
| 14 |
|
#include "view.h" |
| 15 |
|
#include "resolu.h" |
| 16 |
+ |
#include "vfork.h" |
| 17 |
|
#include <signal.h> |
| 18 |
|
#include <X11/Xlib.h> |
| 19 |
|
#include <X11/Xutil.h> |
| 20 |
|
|
| 20 |
– |
#ifndef BSD |
| 21 |
– |
#define vfork fork |
| 22 |
– |
#endif |
| 23 |
– |
|
| 21 |
|
#define XIM "ximage" |
| 22 |
|
|
| 23 |
|
#define NSEG 30 /* number of segments per circle */ |
| 44 |
|
int argc; |
| 45 |
|
char *argv[]; |
| 46 |
|
{ |
| 50 |
– |
extern double atof(); |
| 47 |
|
char *windowname = NULL; |
| 48 |
|
FILE *fp; |
| 49 |
|
|
| 88 |
|
XWindowAttributes wa; |
| 89 |
|
XColor xc; |
| 90 |
|
XGCValues gcv; |
| 91 |
+ |
register int i; |
| 92 |
|
/* get the viewing parameters */ |
| 93 |
|
if (viewfile(pname, &ourview, &pres) <= 0 || |
| 94 |
|
setview(&ourview) != NULL) { |
| 104 |
|
exit(1); |
| 105 |
|
} |
| 106 |
|
/* find our window */ |
| 107 |
< |
if (wname == NULL) |
| 108 |
< |
wname = pname; |
| 109 |
< |
gwind = xfindwind(theDisplay, rwind, wname, 2); |
| 107 |
> |
if (wname == NULL) { |
| 108 |
> |
/* remove directory prefix from name */ |
| 109 |
> |
for (i = strlen(pname); i-- > 0; ) |
| 110 |
> |
if (pname[i] == '/') |
| 111 |
> |
break; |
| 112 |
> |
wname = pname+i+1; |
| 113 |
> |
i = 0; |
| 114 |
> |
} else |
| 115 |
> |
i = 1; |
| 116 |
> |
gwind = xfindwind(theDisplay, rwind, wname, 4); |
| 117 |
|
if (gwind == None) { |
| 118 |
< |
if (wname != pname) { |
| 118 |
> |
if (i) { |
| 119 |
|
fprintf(stderr, "%s: cannot find \"%s\" window\n", |
| 120 |
|
progname, wname); |
| 121 |
|
exit(2); |
| 122 |
|
} |
| 123 |
|
/* start ximage */ |
| 124 |
|
if (vfork() == 0) { |
| 125 |
< |
execlp(XIM, XIM, pname, 0); |
| 125 |
> |
execlp(XIM, XIM, "-c", "256", pname, 0); |
| 126 |
|
perror(XIM); |
| 127 |
|
fprintf(stderr, "%s: cannot start %s\n", |
| 128 |
|
progname, XIM); |
| 131 |
|
} |
| 132 |
|
do |
| 133 |
|
sleep(8); |
| 134 |
< |
while ((gwind=xfindwind(theDisplay,rwind,pname,2)) == None); |
| 134 |
> |
while ((gwind=xfindwind(theDisplay,rwind,wname,4)) == None); |
| 135 |
|
} else |
| 136 |
|
XMapRaised(theDisplay, gwind); |
| 137 |
|
do { |