~ubuntu-branches/ubuntu/precise/libx11/precise-security

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