ScrOfWin.c revision 6c321187
1/* $Xorg: ScrOfWin.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */
2
3/*
4
5Copyright 1989, 1998  The Open Group
6
7Permission to use, copy, modify, distribute, and sell this software and its
8documentation for any purpose is hereby granted without fee, provided that
9the above copyright notice appear in all copies and that both that
10copyright notice and this permission notice appear in supporting
11documentation.
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
19OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of The Open Group shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from The Open Group.
26
27*/
28/* $XFree86: xc/lib/Xmu/ScrOfWin.c,v 1.6 2001/01/17 19:42:56 dawes Exp $ */
29
30/*
31 * Author:  Jim Fulton, MIT X Consortium
32 */
33
34#ifdef HAVE_CONFIG_H
35#include <config.h>
36#endif
37#include <stdio.h>
38#include <X11/Xlib.h>
39#include <X11/Xmu/WinUtil.h>
40
41Screen *
42XmuScreenOfWindow(Display *dpy, Window w)
43{
44    register int i;
45    Window root;
46    int x, y;					/* dummy variables */
47    unsigned int width, height, bw, depth;	/* dummy variables */
48
49    if (!XGetGeometry (dpy, w, &root, &x, &y, &width, &height,
50		       &bw, &depth)) {
51	return NULL;
52    }
53    for (i = 0; i < ScreenCount (dpy); i++) {	/* find root from list */
54	if (root == RootWindow (dpy, i)) {
55	    return ScreenOfDisplay (dpy, i);
56	}
57    }
58    return NULL;
59}
60
61