| Revision: | 2.6 |
| Committed: | Sun Jul 4 12:08:47 2004 UTC (21 years, 4 months ago) by schorsch |
| Content type: | text/plain |
| Branch: | MAIN |
| CVS Tags: | rad5R4, rad5R2, rad5R3, rad5R0, rad5R1, rad4R2, rad3R7P2, rad3R7P1, rad6R0, rad4R1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9, rad4R2P1, rad4R2P2, HEAD |
| Changes since 2.5: | +9 -6 lines |
| Log Message: | Updated SCons build environment to work with a fresh download and on OS X, as suggested by Randolph Fritz. |
| # | User | Rev | Content |
|---|---|---|---|
| 1 | greg | 1.1 | #ifndef lint |
| 2 | schorsch | 2.6 | static const char RCSid[] = "$Id: x11findwind.c,v 2.5 2003/02/25 02:47:22 greg Exp $"; |
| 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 | schorsch | 2.6 | #include <string.h> |
| 12 | #include <stdlib.h> | ||
| 13 | greg | 1.1 | #include <X11/Xlib.h> |
| 14 | |||
| 15 | |||
| 16 | Window | ||
| 17 | schorsch | 2.6 | xfindwind( |
| 18 | Display *dpy, | ||
| 19 | Window win, | ||
| 20 | char *name, | ||
| 21 | int depth | ||
| 22 | ) | ||
| 23 | greg | 1.1 | { |
| 24 | char *nr; | ||
| 25 | Window rr, pr, *cl; | ||
| 26 | greg | 2.3 | Window wr; |
| 27 | greg | 2.2 | unsigned int nc; |
| 28 | greg | 2.3 | register int i; |
| 29 | greg | 1.1 | |
| 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 | greg | 2.3 | 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 | greg | 1.1 | XFree((char *)cl); |
| 44 | greg | 2.3 | return(wr); |
| 45 | greg | 1.1 | } |