ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/x11findwind.c
Revision: 2.5
Committed: Tue Feb 25 02:47:22 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.4: +1 -56 lines
Log Message:
Replaced inline copyright notice with #include "copyright.h"

File Contents

# User Rev Content
1 greg 1.1 #ifndef lint
2 greg 2.4 static const char RCSid[] = "$Id$";
3 greg 1.1 #endif
4     /*
5     * find a window by its name under X
6 greg 2.4 */
7    
8 greg 2.5 #include "copyright.h"
9 greg 1.1
10     #include <stdio.h>
11     #include <X11/Xlib.h>
12    
13    
14     Window
15     xfindwind(dpy, win, name, depth)
16     Display *dpy;
17     Window win;
18     char *name;
19     int depth;
20     {
21     char *nr;
22     Window rr, pr, *cl;
23 greg 2.3 Window wr;
24 greg 2.2 unsigned int nc;
25 greg 2.3 register int i;
26 greg 1.1
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 greg 2.3 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 greg 1.1 XFree((char *)cl);
41 greg 2.3 return(wr);
42 greg 1.1 }