1/***********************************************************
2
3Copyright 1987, 1998  The Open Group
4
5Permission to use, copy, modify, distribute, and sell this software and its
6documentation for any purpose is hereby granted without fee, provided that
7the above copyright notice appear in all copies and that both that
8copyright notice and this permission notice appear in supporting
9documentation.
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21Except as contained in this notice, the name of The Open Group shall not be
22used in advertising or otherwise to promote the sale, use or other dealings
23in this Software without prior written authorization from The Open Group.
24
25Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
26
27                        All Rights Reserved
28
29Permission to use, copy, modify, and distribute this software and its
30documentation for any purpose and without fee is hereby granted,
31provided that the above copyright notice appear in all copies and that
32both that copyright notice and this permission notice appear in
33supporting documentation, and that the name of Digital not be
34used in advertising or publicity pertaining to distribution of the
35software without specific, written prior permission.
36
37DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
38ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
39DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
40ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
41WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
42ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
43SOFTWARE.
44
45******************************************************************/
46
47#ifndef WINDOWSTRUCT_H
48#define WINDOWSTRUCT_H
49
50#include "window.h"
51#include "pixmapstr.h"
52#include "regionstr.h"
53#include "cursor.h"
54#include "property.h"
55#include "resource.h"           /* for ROOT_WINDOW_ID_BASE */
56#include "dix.h"
57#include "privates.h"
58#include "miscstruct.h"
59#include <X11/Xprotostr.h>
60#include "opaque.h"
61
62#define GuaranteeNothing	0
63#define GuaranteeVisBack	1
64
65#define SameBackground(as, a, bs, b)				\
66    ((as) == (bs) && ((as) == None ||				\
67		      (as) == ParentRelative ||			\
68 		      SamePixUnion(a,b,as == BackgroundPixel)))
69
70#define SameBorder(as, a, bs, b)				\
71    EqualPixUnion(as, a, bs, b)
72
73/* used as NULL-terminated list */
74typedef struct _DevCursorNode {
75    CursorPtr cursor;
76    DeviceIntPtr dev;
77    struct _DevCursorNode *next;
78} DevCursNodeRec, *DevCursNodePtr, *DevCursorList;
79
80typedef struct _WindowOpt {
81    CursorPtr cursor;           /* default: window.cursorNone */
82    VisualID visual;            /* default: same as parent */
83    Colormap colormap;          /* default: same as parent */
84    Mask dontPropagateMask;     /* default: window.dontPropagate */
85    Mask otherEventMasks;       /* default: 0 */
86    struct _OtherClients *otherClients; /* default: NULL */
87    struct _GrabRec *passiveGrabs;      /* default: NULL */
88    PropertyPtr userProps;      /* default: NULL */
89    CARD32 backingBitPlanes;    /* default: ~0L */
90    CARD32 backingPixel;        /* default: 0 */
91    RegionPtr boundingShape;    /* default: NULL */
92    RegionPtr clipShape;        /* default: NULL */
93    RegionPtr inputShape;       /* default: NULL */
94    struct _OtherInputMasks *inputMasks;        /* default: NULL */
95    DevCursorList deviceCursors;        /* default: NULL */
96} WindowOptRec, *WindowOptPtr;
97
98#define BackgroundPixel	    2L
99#define BackgroundPixmap    3L
100
101/*
102 * The redirectDraw field can have one of three values:
103 *
104 *  RedirectDrawNone
105 *	A normal window; painted into the same pixmap as the parent
106 *	and clipping parent and siblings to its geometry. These
107 *	windows get a clip list equal to the intersection of their
108 *	geometry with the parent geometry, minus the geometry
109 *	of overlapping None and Clipped siblings.
110 *  RedirectDrawAutomatic
111 *	A redirected window which clips parent and sibling drawing.
112 *	Contents for these windows are manage inside the server.
113 *	These windows get an internal clip list equal to their
114 *	geometry.
115 *  RedirectDrawManual
116 *	A redirected window which does not clip parent and sibling
117 *	drawing; the window must be represented within the parent
118 *	geometry by the client performing the redirection management.
119 *	Contents for these windows are managed outside the server.
120 *	These windows get an internal clip list equal to their
121 *	geometry.
122 */
123
124#define RedirectDrawNone	0
125#define RedirectDrawAutomatic	1
126#define RedirectDrawManual	2
127
128typedef struct _Window {
129    DrawableRec drawable;
130    PrivateRec *devPrivates;
131    WindowPtr parent;           /* ancestor chain */
132    WindowPtr nextSib;          /* next lower sibling */
133    WindowPtr prevSib;          /* next higher sibling */
134    WindowPtr firstChild;       /* top-most child */
135    WindowPtr lastChild;        /* bottom-most child */
136    RegionRec clipList;         /* clipping rectangle for output */
137    RegionRec borderClip;       /* NotClippedByChildren + border */
138    union _Validate *valdata;
139    RegionRec winSize;
140    RegionRec borderSize;
141    DDXPointRec origin;         /* position relative to parent */
142    unsigned short borderWidth;
143    unsigned short deliverableEvents;   /* all masks from all clients */
144    Mask eventMask;             /* mask from the creating client */
145    PixUnion background;
146    PixUnion border;
147    WindowOptPtr optional;
148    unsigned backgroundState:2; /* None, Relative, Pixel, Pixmap */
149    unsigned borderIsPixel:1;
150    unsigned cursorIsNone:1;    /* else real cursor (might inherit) */
151    unsigned backingStore:2;
152    unsigned saveUnder:1;
153    unsigned bitGravity:4;
154    unsigned winGravity:4;
155    unsigned overrideRedirect:1;
156    unsigned visibility:2;
157    unsigned mapped:1;
158    unsigned realized:1;        /* ancestors are all mapped */
159    unsigned viewable:1;        /* realized && InputOutput */
160    unsigned dontPropagate:3;   /* index into DontPropagateMasks */
161    unsigned redirectDraw:2;    /* COMPOSITE rendering redirect */
162    unsigned forcedBG:1;        /* must have an opaque background */
163    unsigned unhittable:1;      /* doesn't hit-test, for rootless */
164#ifdef COMPOSITE
165    unsigned damagedDescendants:1;      /* some descendants are damaged */
166    unsigned inhibitBGPaint:1;  /* paint the background? */
167#endif
168} WindowRec;
169
170/*
171 * Ok, a bunch of macros for accessing the optional record
172 * fields (or filling the appropriate default value)
173 */
174
175extern _X_EXPORT Mask DontPropagateMasks[];
176
177#define wTrackParent(w,field)	((w)->optional ? \
178				    (w)->optional->field \
179 				 : FindWindowWithOptional(w)->optional->field)
180#define wUseDefault(w,field,def)	((w)->optional ? \
181				    (w)->optional->field \
182				 : def)
183
184#define wVisual(w)		wTrackParent(w, visual)
185#define wCursor(w)		((w)->cursorIsNone ? None : wTrackParent(w, cursor))
186#define wColormap(w)		((w)->drawable.class == InputOnly ? None : wTrackParent(w, colormap))
187#define wDontPropagateMask(w)	wUseDefault(w, dontPropagateMask, DontPropagateMasks[(w)->dontPropagate])
188#define wOtherEventMasks(w)	wUseDefault(w, otherEventMasks, 0)
189#define wOtherClients(w)	wUseDefault(w, otherClients, NULL)
190#define wOtherInputMasks(w)	wUseDefault(w, inputMasks, NULL)
191#define wPassiveGrabs(w)	wUseDefault(w, passiveGrabs, NULL)
192#define wUserProps(w)		wUseDefault(w, userProps, NULL)
193#define wBackingBitPlanes(w)	wUseDefault(w, backingBitPlanes, ~0L)
194#define wBackingPixel(w)	wUseDefault(w, backingPixel, 0)
195#define wBoundingShape(w)	wUseDefault(w, boundingShape, NULL)
196#define wClipShape(w)		wUseDefault(w, clipShape, NULL)
197#define wInputShape(w)          wUseDefault(w, inputShape, NULL)
198#define wClient(w)		(clients[CLIENT_ID((w)->drawable.id)])
199#define wBorderWidth(w)		((int) (w)->borderWidth)
200
201/* true when w needs a border drawn. */
202
203#define HasBorder(w)	((w)->borderWidth || wClipShape(w))
204
205typedef struct _ScreenSaverStuff *ScreenSaverStuffPtr;
206
207#define SCREEN_IS_BLANKED   0
208#define SCREEN_ISNT_SAVED   1
209#define SCREEN_IS_TILED     2
210#define SCREEN_IS_BLACK	    3
211
212#define HasSaverWindow(pScreen)   (pScreen->screensaver.pWindow != NullWindow)
213
214extern _X_EXPORT int screenIsSaved;
215
216#endif                          /* WINDOWSTRUCT_H */
217