Window.c revision 1ab64890
1/* $Xorg: Window.c,v 1.5 2001/02/09 02:03:37 xorgcvs Exp $ */
2/*
3
4Copyright 1986, 1998  The Open Group
5
6Permission to use, copy, modify, distribute, and sell this software and its
7documentation for any purpose is hereby granted without fee, provided that
8the above copyright notice appear in all copies and that both that
9copyright notice and this permission notice appear in supporting
10documentation.
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
18OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of The Open Group shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from The Open Group.
25
26*/
27/* $XFree86: xc/lib/X11/Window.c,v 1.4 2001/12/14 19:54:08 dawes Exp $ */
28
29#ifdef HAVE_CONFIG_H
30#include <config.h>
31#endif
32#include "Xlibint.h"
33
34void _XProcessWindowAttributes (
35    register Display *dpy,
36    xChangeWindowAttributesReq *req,
37    register unsigned long valuemask,
38    register XSetWindowAttributes *attributes)
39{
40    unsigned long values[32];
41    register unsigned long *value = values;
42    unsigned int nvalues;
43
44    if (valuemask & CWBackPixmap)
45	*value++ = attributes->background_pixmap;
46
47    if (valuemask & CWBackPixel)
48    	*value++ = attributes->background_pixel;
49
50    if (valuemask & CWBorderPixmap)
51    	*value++ = attributes->border_pixmap;
52
53    if (valuemask & CWBorderPixel)
54    	*value++ = attributes->border_pixel;
55
56    if (valuemask & CWBitGravity)
57    	*value++ = attributes->bit_gravity;
58
59    if (valuemask & CWWinGravity)
60	*value++ = attributes->win_gravity;
61
62    if (valuemask & CWBackingStore)
63        *value++ = attributes->backing_store;
64
65    if (valuemask & CWBackingPlanes)
66	*value++ = attributes->backing_planes;
67
68    if (valuemask & CWBackingPixel)
69    	*value++ = attributes->backing_pixel;
70
71    if (valuemask & CWOverrideRedirect)
72    	*value++ = attributes->override_redirect;
73
74    if (valuemask & CWSaveUnder)
75    	*value++ = attributes->save_under;
76
77    if (valuemask & CWEventMask)
78	*value++ = attributes->event_mask;
79
80    if (valuemask & CWDontPropagate)
81	*value++ = attributes->do_not_propagate_mask;
82
83    if (valuemask & CWColormap)
84	*value++ = attributes->colormap;
85
86    if (valuemask & CWCursor)
87	*value++ = attributes->cursor;
88
89    req->length += (nvalues = value - values);
90
91    nvalues <<= 2;			    /* watch out for macros... */
92    Data32 (dpy, (long *) values, (long)nvalues);
93
94}
95
96#define AllMaskBits (CWBackPixmap|CWBackPixel|CWBorderPixmap|\
97		     CWBorderPixel|CWBitGravity|CWWinGravity|\
98		     CWBackingStore|CWBackingPlanes|CWBackingPixel|\
99		     CWOverrideRedirect|CWSaveUnder|CWEventMask|\
100		     CWDontPropagate|CWColormap|CWCursor)
101
102Window XCreateWindow(
103    register Display *dpy,
104    Window parent,
105    int x,
106    int y,
107    unsigned int width,
108    unsigned int height,
109    unsigned int borderWidth,
110    int depth,
111    unsigned int class,
112    Visual *visual,
113    unsigned long valuemask,
114    XSetWindowAttributes *attributes)
115{
116    Window wid;
117    register xCreateWindowReq *req;
118
119    LockDisplay(dpy);
120    GetReq(CreateWindow, req);
121    req->parent = parent;
122    req->x = x;
123    req->y = y;
124    req->width = width;
125    req->height = height;
126    req->borderWidth = borderWidth;
127    req->depth = depth;
128    req->class = class;
129    if (visual == CopyFromParent)
130	req->visual = CopyFromParent;
131    else
132	req->visual = visual->visualid;
133    wid = req->wid = XAllocID(dpy);
134    valuemask &= AllMaskBits;
135    if ((req->mask = valuemask))
136        _XProcessWindowAttributes (dpy, (xChangeWindowAttributesReq *)req,
137			valuemask, attributes);
138    UnlockDisplay(dpy);
139    SyncHandle();
140    return (wid);
141    }
142
143