| 12 |
|
|
| 13 |
|
#include "standard.h" |
| 14 |
|
#include "view.h" |
| 15 |
+ |
#include <signal.h> |
| 16 |
|
#include <X11/Xlib.h> |
| 17 |
|
#include <X11/Xutil.h> |
| 18 |
|
|
| 19 |
+ |
#ifndef BSD |
| 20 |
+ |
#define vfork fork |
| 21 |
+ |
#endif |
| 22 |
+ |
|
| 23 |
+ |
#define XIM "ximage" |
| 24 |
+ |
|
| 25 |
|
#define NSEG 30 /* number of segments per circle */ |
| 26 |
|
|
| 27 |
|
VIEW ourview = STDVIEW; /* view for picture */ |
| 43 |
|
int argc; |
| 44 |
|
char *argv[]; |
| 45 |
|
{ |
| 46 |
+ |
char *windowname; |
| 47 |
|
FILE *fp; |
| 48 |
|
|
| 49 |
|
progname = argv[0]; |
| 50 |
+ |
if (argc > 2 && !strcmp(argv[1], "-n")) { |
| 51 |
+ |
windowname = argv[2]; |
| 52 |
+ |
argv += 2; |
| 53 |
+ |
argc -= 2; |
| 54 |
+ |
} else |
| 55 |
+ |
windowname = argv[1]; |
| 56 |
|
if (argc < 2 || argc > 3) { |
| 57 |
< |
fprintf(stderr, "Usage: %s picture [glaresrc]\n", |
| 57 |
> |
fprintf(stderr, |
| 58 |
> |
"Usage: %s [-n windowname] picture [glaresrc]\n", |
| 59 |
|
progname); |
| 60 |
|
exit(1); |
| 61 |
|
} |
| 62 |
< |
init(argv[1]); |
| 62 |
> |
init(argv[1], windowname); |
| 63 |
|
if (argc < 3) |
| 64 |
|
fp = stdin; |
| 65 |
|
else if ((fp = fopen(argv[2], "r")) == NULL) { |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
|
| 75 |
< |
init(name) /* set up vector drawing from pick */ |
| 76 |
< |
char *name; |
| 75 |
> |
init(pname, wname) /* get view and find window */ |
| 76 |
> |
char *pname, *wname; |
| 77 |
|
{ |
| 78 |
|
extern Window xfindwind(); |
| 79 |
|
XWindowAttributes wa; |
| 80 |
|
XColor xc; |
| 81 |
|
XGCValues gcv; |
| 82 |
|
/* get the viewing parameters */ |
| 83 |
< |
if (viewfile(name, &ourview, &xres, &yres) <= 0 || |
| 83 |
> |
if (viewfile(pname, &ourview, &xres, &yres) <= 0 || |
| 84 |
|
setview(&ourview) != NULL) { |
| 85 |
|
fprintf(stderr, "%s: cannot get view from \"%s\"\n", |
| 86 |
< |
progname, name); |
| 86 |
> |
progname, pname); |
| 87 |
|
exit(1); |
| 88 |
|
} |
| 89 |
|
/* open the display */ |
| 94 |
|
exit(1); |
| 95 |
|
} |
| 96 |
|
/* find our window */ |
| 97 |
< |
gwind = xfindwind(theDisplay, rwind, name, 2); |
| 97 |
> |
gwind = xfindwind(theDisplay, rwind, wname, 2); |
| 98 |
|
if (gwind == None) { |
| 99 |
< |
fprintf(stderr, "%s: cannot find \"%s\" window\n", |
| 100 |
< |
progname, name); |
| 101 |
< |
exit(2); |
| 99 |
> |
if (wname != pname) { |
| 100 |
> |
fprintf(stderr, "%s: cannot find \"%s\" window\n", |
| 101 |
> |
progname, wname); |
| 102 |
> |
exit(2); |
| 103 |
> |
} |
| 104 |
> |
/* start ximage */ |
| 105 |
> |
if (vfork() == 0) { |
| 106 |
> |
execlp(XIM, XIM, pname, 0); |
| 107 |
> |
perror(XIM); |
| 108 |
> |
fprintf(stderr, "%s: cannot start %s\n", |
| 109 |
> |
progname, XIM); |
| 110 |
> |
kill(getppid(), SIGPIPE); |
| 111 |
> |
_exit(1); |
| 112 |
> |
} |
| 113 |
> |
do |
| 114 |
> |
sleep(8); |
| 115 |
> |
while ((gwind=xfindwind(theDisplay,rwind,pname,2)) == None); |
| 116 |
> |
} else { |
| 117 |
> |
XMapRaised(theDisplay, gwind); |
| 118 |
> |
XFlush(theDisplay); |
| 119 |
> |
sleep(4); |
| 120 |
|
} |
| 88 |
– |
XMapRaised(theDisplay, gwind); |
| 121 |
|
XGetWindowAttributes(theDisplay, gwind, &wa); |
| 90 |
– |
sleep(4); |
| 122 |
|
if (wa.width != xres || wa.height != yres) { |
| 123 |
|
fprintf(stderr, |
| 124 |
|
"%s: warning -- window seems to be the wrong size!\n", |