|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Copyright 1989, 1998 The Open Group
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Permission to use, copy, modify, distribute, and sell this software and its
|
|
Packit Service |
2b1f13 |
documentation for any purpose is hereby granted without fee, provided that
|
|
Packit Service |
2b1f13 |
the above copyright notice appear in all copies and that both that
|
|
Packit Service |
2b1f13 |
copyright notice and this permission notice appear in supporting
|
|
Packit Service |
2b1f13 |
documentation.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
The above copyright notice and this permission notice shall be included in
|
|
Packit Service |
2b1f13 |
all copies or substantial portions of the Software.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
Packit Service |
2b1f13 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
Packit Service |
2b1f13 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
Packit Service |
2b1f13 |
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
Packit Service |
2b1f13 |
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
Packit Service |
2b1f13 |
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Except as contained in this notice, the name of The Open Group shall not be
|
|
Packit Service |
2b1f13 |
used in advertising or otherwise to promote the sale, use or other dealings
|
|
Packit Service |
2b1f13 |
in this Software without prior written authorization from The Open Group.
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#ifdef HAVE_CONFIG_H
|
|
Packit Service |
2b1f13 |
#include <config.h>
|
|
Packit Service |
2b1f13 |
#endif
|
|
Packit Service |
2b1f13 |
#include <X11/Xlib.h>
|
|
Packit Service |
2b1f13 |
#include <X11/Xatom.h>
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
#include <X11/Xmu/WinUtil.h>
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/*
|
|
Packit Service |
2b1f13 |
* Prototypes
|
|
Packit Service |
2b1f13 |
*/
|
|
Packit Service |
2b1f13 |
static Window TryChildren(Display*, Window, Atom);
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
/* Find a window with WM_STATE, else return win itself, as per ICCCM */
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
Window
|
|
Packit Service |
2b1f13 |
XmuClientWindow(Display *dpy, Window win)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
Atom WM_STATE;
|
|
Packit Service |
2b1f13 |
Atom type = None;
|
|
Packit Service |
2b1f13 |
int format;
|
|
Packit Service |
2b1f13 |
unsigned long nitems, after;
|
|
Packit Service |
2b1f13 |
unsigned char *data = NULL;
|
|
Packit Service |
2b1f13 |
Window inf;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
WM_STATE = XInternAtom(dpy, "WM_STATE", True);
|
|
Packit Service |
2b1f13 |
if (!WM_STATE)
|
|
Packit Service |
2b1f13 |
return win;
|
|
Packit Service |
2b1f13 |
XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType,
|
|
Packit Service |
2b1f13 |
&type, &format, &nitems, &after, &data);
|
|
Packit Service |
2b1f13 |
if (data)
|
|
Packit Service |
2b1f13 |
XFree(data);
|
|
Packit Service |
2b1f13 |
if (type)
|
|
Packit Service |
2b1f13 |
return win;
|
|
Packit Service |
2b1f13 |
inf = TryChildren(dpy, win, WM_STATE);
|
|
Packit Service |
2b1f13 |
if (!inf)
|
|
Packit Service |
2b1f13 |
inf = win;
|
|
Packit Service |
2b1f13 |
return inf;
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
static Window
|
|
Packit Service |
2b1f13 |
TryChildren(Display *dpy, Window win, Atom WM_STATE)
|
|
Packit Service |
2b1f13 |
{
|
|
Packit Service |
2b1f13 |
Window root, parent;
|
|
Packit Service |
2b1f13 |
Window *children;
|
|
Packit Service |
2b1f13 |
unsigned int nchildren;
|
|
Packit Service |
2b1f13 |
unsigned int i;
|
|
Packit Service |
2b1f13 |
Atom type = None;
|
|
Packit Service |
2b1f13 |
int format;
|
|
Packit Service |
2b1f13 |
unsigned long nitems, after;
|
|
Packit Service |
2b1f13 |
unsigned char *data;
|
|
Packit Service |
2b1f13 |
Window inf = 0;
|
|
Packit Service |
2b1f13 |
|
|
Packit Service |
2b1f13 |
if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren))
|
|
Packit Service |
2b1f13 |
return 0;
|
|
Packit Service |
2b1f13 |
for (i = 0; !inf && (i < nchildren); i++) {
|
|
Packit Service |
2b1f13 |
data = NULL;
|
|
Packit Service |
2b1f13 |
XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False,
|
|
Packit Service |
2b1f13 |
AnyPropertyType, &type, &format, &nitems,
|
|
Packit Service |
2b1f13 |
&after, &data);
|
|
Packit Service |
2b1f13 |
if (data)
|
|
Packit Service |
2b1f13 |
XFree(data);
|
|
Packit Service |
2b1f13 |
if (type)
|
|
Packit Service |
2b1f13 |
inf = children[i];
|
|
Packit Service |
2b1f13 |
}
|
|
Packit Service |
2b1f13 |
for (i = 0; !inf && (i < nchildren); i++)
|
|
Packit Service |
2b1f13 |
inf = TryChildren(dpy, children[i], WM_STATE);
|
|
Packit Service |
2b1f13 |
if (children)
|
|
Packit Service |
2b1f13 |
XFree(children);
|
|
Packit Service |
2b1f13 |
return inf;
|
|
Packit Service |
2b1f13 |
}
|