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

File Contents

# User Rev Content
1 greg 3.1 #ifndef lint
2     static const char RCSid[] = "$Id$";
3     #endif
4     /*
5     * find a window by its name under X
6     */
7    
8 greg 3.2 #include "copyright.h"
9 greg 3.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     Window wr;
24     unsigned int nc;
25     register int i;
26    
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     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(wr);
42     }