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 1.1 by greg, Mon Apr 22 13:40:49 1991 UTC vs.
Revision 2.5 by greg, Tue Feb 25 02:47:22 2003 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 <X11/Xlib.h>
12  
# Line 23 | Line 20 | int    depth;
20   {
21          char    *nr;
22          Window  rr, pr, *cl;
23 <        int     nc;
23 >        Window  wr;
24 >        unsigned int    nc;
25 >        register int    i;
26  
28        if (XFetchName(dpy, win, &nr)) {
29                register int    succ = !strcmp(nr, name);
30                free(nr);
31                if (succ) return(win);
32        }
27          if (depth == 0)         /* negative depths search all */
28                  return(None);
29          if (!XQueryTree(dpy, win, &rr, &pr, &cl, &nc) || nc == 0)
30                  return(None);
31 <        while (nc--)
32 <                if ((rr = xfindwind(dpy, cl[nc], name, depth-1)) != None)
33 <                        break;
31 >        wr = None;              /* breadth first search */
32 >        for (i = 0; wr == None && i < nc; i++)
33 >                if (XFetchName(dpy, cl[i], &nr)) {
34 >                        if (!strcmp(nr, name))
35 >                                wr = cl[i];
36 >                        free(nr);
37 >                }
38 >        for (i = 0; wr == None && i < nc; i++)
39 >                wr = xfindwind(dpy, cl[i], name, depth-1);
40          XFree((char *)cl);
41 <        return(rr);
41 >        return(wr);
42   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines