ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/x11findwind.c
(Generate patch)

Comparing ray/src/common/x11findwind.c (file contents):
Revision 2.2 by greg, Thu May 21 10:45:09 1992 UTC vs.
Revision 2.6 by schorsch, Sun Jul 4 12:08:47 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1991 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * find a window by its name under X
9 *
10 *      4/22/91         Greg Ward
6   */
7  
8 + #include "copyright.h"
9 +
10   #include <stdio.h>
11 + #include <string.h>
12 + #include <stdlib.h>
13   #include <X11/Xlib.h>
14  
15  
16   Window
17 < xfindwind(dpy, win, name, depth)
18 < Display *dpy;
19 < Window  win;
20 < char    *name;
21 < int     depth;
17 > xfindwind(
18 >        Display *dpy,
19 >        Window  win,
20 >        char    *name,
21 >        int     depth
22 > )
23   {
24          char    *nr;
25          Window  rr, pr, *cl;
26 +        Window  wr;
27          unsigned int    nc;
28 +        register int    i;
29  
28        if (XFetchName(dpy, win, &nr)) {
29                register int    succ = !strcmp(nr, name);
30                free(nr);
31                if (succ) return(win);
32        }
30          if (depth == 0)         /* negative depths search all */
31                  return(None);
32          if (!XQueryTree(dpy, win, &rr, &pr, &cl, &nc) || nc == 0)
33                  return(None);
34 <        while (nc--)
35 <                if ((rr = xfindwind(dpy, cl[nc], name, depth-1)) != None)
36 <                        break;
34 >        wr = None;              /* breadth first search */
35 >        for (i = 0; wr == None && i < nc; i++)
36 >                if (XFetchName(dpy, cl[i], &nr)) {
37 >                        if (!strcmp(nr, name))
38 >                                wr = cl[i];
39 >                        free(nr);
40 >                }
41 >        for (i = 0; wr == None && i < nc; i++)
42 >                wr = xfindwind(dpy, cl[i], name, depth-1);
43          XFree((char *)cl);
44 <        return(rr);
44 >        return(wr);
45   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines