--- ray/src/px/xshowtrace.c 1992/10/30 09:54:19 2.3 +++ ray/src/px/xshowtrace.c 2003/11/10 12:28:56 2.9 @@ -1,19 +1,17 @@ -/* Copyright (c) 1991 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: xshowtrace.c,v 2.9 2003/11/10 12:28:56 schorsch Exp $"; #endif - /* * Display an image and watch the rays get traced. * * 9/21/90 Greg Ward */ +#include + #include "standard.h" +#include "paths.h" #include "view.h" -#include "resolu.h" -#include #define MAXDEPTH 32 /* ridiculous ray tree depth */ @@ -24,7 +22,7 @@ static char SCCSid[] = "$SunId$ LBL"; #endif char rtcom[] = "rtrace -h- -otp -fa -x 1"; -char xicom[] = "ximage"; +char xicom[] = "ximage -c 256"; VIEW ourview = STDVIEW; /* view for picture */ RESOLU ourres; /* picture resolution */ @@ -53,7 +51,7 @@ int argc; char *argv[]; { int i; - char combuf[256]; + char combuf[PATH_MAX]; progname = argv[0]; for (i = 1; i < argc-2; i++) @@ -82,7 +80,7 @@ char *argv[]; exit(1); } /* build input command */ - sprintf(combuf, "%s %s | %s", xicom, picture, rtcom); + sprintf(combuf, "%s \"%s\" | %s", xicom, picture, rtcom); for ( ; i < argc-1; i++) { strcat(combuf, " "); strcat(combuf, argv[i]); @@ -140,11 +138,13 @@ mainloop() /* get and process input */ freetree(tp) /* free a trace tree */ struct node *tp; { - register struct node *kid; + register struct node *kid, *k2; - for (kid = tp->daughter; kid != NULL; kid = kid->sister) + for (kid = tp->daughter; kid != NULL; kid = k2) { + k2 = kid->sister; freetree(kid); - free((char *)tp); + } + free((void *)tp); } @@ -189,6 +189,7 @@ int xoff, yoff; setvec(ipt) /* set up vector drawing for pick */ int ipt[2]; { + extern Window xfindwind(); XWindowAttributes wa; XColor xc; XGCValues gcv; @@ -196,10 +197,15 @@ int ipt[2]; Window rw, cw; unsigned int pm; /* compute pointer location */ - if (gwind == 0 && - (gwind = xfindwind(theDisplay, rwind, picture, 2)) == 0) { - fprintf(stderr, "%s: cannot find display window!\n", progname); - exit(1); + if (gwind == 0) { + register char *wn; + for (wn = picture; *wn; wn++); + while (wn > picture && wn[-1] != '/') wn--; + if ((gwind = xfindwind(theDisplay, rwind, wn, 4)) == 0) { + fprintf(stderr, "%s: cannot find display window!\n", + progname); + exit(1); + } } XQueryPointer(theDisplay, gwind, &rw, &cw, &rx, &ry, &wx, &wy, &pm); xoff = wx - ipt[0];