dbestruct.h revision 4642e01f
1/******************************************************************************
2 *
3 * Copyright (c) 1994, 1995  Hewlett-Packard Company
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Except as contained in this notice, the name of the Hewlett-Packard
25 * Company shall not be used in advertising or otherwise to promote the
26 * sale, use or other dealings in this Software without prior written
27 * authorization from the Hewlett-Packard Company.
28 *
29 *     Header file for DIX-related DBE
30 *
31 *****************************************************************************/
32
33#ifndef DBE_STRUCT_H
34#define DBE_STRUCT_H
35
36
37/* INCLUDES */
38
39#define NEED_DBE_PROTOCOL
40#include <X11/extensions/Xdbeproto.h>
41#include "windowstr.h"
42#include "privates.h"
43
44
45/* DEFINES */
46
47#define DBE_SCREEN_PRIV(pScreen) ((DbeScreenPrivPtr) \
48    dixLookupPrivate(&(pScreen)->devPrivates, dbeScreenPrivKey))
49
50#define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \
51    DBE_SCREEN_PRIV((pDrawable)->pScreen)
52
53#define DBE_SCREEN_PRIV_FROM_WINDOW_PRIV(pDbeWindowPriv) \
54    DBE_SCREEN_PRIV((pDbeWindowPriv)->pWindow->drawable.pScreen)
55
56#define DBE_SCREEN_PRIV_FROM_WINDOW(pWindow) \
57    DBE_SCREEN_PRIV((pWindow)->drawable.pScreen)
58
59#define DBE_SCREEN_PRIV_FROM_PIXMAP(pPixmap) \
60    DBE_SCREEN_PRIV((pPixmap)->drawable.pScreen)
61
62#define DBE_SCREEN_PRIV_FROM_GC(pGC)\
63    DBE_SCREEN_PRIV((pGC)->pScreen)
64
65#define DBE_WINDOW_PRIV(pWin) ((DbeWindowPrivPtr) \
66    dixLookupPrivate(&(pWin)->devPrivates, dbeWindowPrivKey))
67
68/* Initial size of the buffer ID array in the window priv. */
69#define DBE_INIT_MAX_IDS	2
70
71/* Reallocation increment for the buffer ID array. */
72#define DBE_INCR_MAX_IDS	4
73
74/* Marker for free elements in the buffer ID array. */
75#define DBE_FREE_ID_ELEMENT	0
76
77extern void DbeExtensionInit (void);
78
79/* TYPEDEFS */
80
81/* Record used to pass swap information between DIX and DDX swapping
82 * procedures.
83 */
84typedef struct _DbeSwapInfoRec
85{
86    WindowPtr		pWindow;
87    unsigned char	swapAction;
88
89} DbeSwapInfoRec, *DbeSwapInfoPtr;
90
91/*
92 ******************************************************************************
93 ** Per-window data
94 ******************************************************************************
95 */
96
97typedef struct _DbeWindowPrivRec
98{
99    /* A pointer to the window with which the DBE window private (buffer) is
100     * associated.
101     */
102    WindowPtr		pWindow;
103
104    /* Last known swap action for this buffer.  Legal values for this field
105     * are XdbeUndefined, XdbeBackground, XdbeUntouched, and XdbeCopied.
106     */
107    unsigned char	swapAction;
108
109    /* Last known buffer size.
110     */
111    unsigned short	width, height;
112
113    /* Coordinates used for static gravity when the window is positioned.
114     */
115    short		x, y;
116
117    /* Number of XIDs associated with this buffer.
118     */
119    int			nBufferIDs;
120
121    /* Capacity of the current buffer ID array, IDs. */
122    int			maxAvailableIDs;
123
124    /* Pointer to the array of buffer IDs.  This initially points to initIDs.
125     * When the static limit of the initIDs array is reached, the array is
126     * reallocated and this pointer is set to the new array instead of initIDs.
127     */
128    XID			*IDs;
129
130    /* Initial array of buffer IDs.  We are defining the XID array within the
131     * window priv to optimize for data locality.  In most cases, only one
132     * buffer will be associated with a window.  Having the array declared
133     * here can prevent us from accessing the data in another memory page,
134     * possibly resulting in a page swap and loss of performance.  Initially we
135     * will use this array to store buffer IDs.  For situations where we have
136     * more IDs than can fit in this static array, we will allocate a larger
137     * array to use, possibly suffering a performance loss.
138     */
139    XID			initIDs[DBE_INIT_MAX_IDS];
140
141    /* Device-specific private information.
142     */
143    PrivateRec		*devPrivates;
144
145} DbeWindowPrivRec, *DbeWindowPrivPtr;
146
147
148/*
149 ******************************************************************************
150 ** Per-screen data
151 ******************************************************************************
152 */
153
154typedef struct _DbeScreenPrivRec
155{
156    /* Resources created by DIX to be used by DDX */
157    RESTYPE	dbeDrawableResType;
158    RESTYPE	dbeWindowPrivResType;
159
160    /* Private indices created by DIX to be used by DDX */
161    DevPrivateKey dbeScreenPrivKey;
162    DevPrivateKey dbeWindowPrivKey;
163
164    /* Wrapped functions
165     * It is the responsibilty of the DDX layer to wrap PositionWindow().
166     * DbeExtensionInit wraps DestroyWindow().
167     */
168    PositionWindowProcPtr PositionWindow;
169    DestroyWindowProcPtr  DestroyWindow;
170
171    /* Per-screen DIX routines */
172    Bool	(*SetupBackgroundPainter)(
173		WindowPtr /*pWin*/,
174		GCPtr /*pGC*/
175);
176
177    /* Per-screen DDX routines */
178    Bool	(*GetVisualInfo)(
179		ScreenPtr /*pScreen*/,
180		XdbeScreenVisualInfo * /*pVisInfo*/
181);
182    int		(*AllocBackBufferName)(
183		WindowPtr /*pWin*/,
184		XID /*bufId*/,
185		int /*swapAction*/
186);
187    int		(*SwapBuffers)(
188		ClientPtr /*client*/,
189		int * /*pNumWindows*/,
190		DbeSwapInfoPtr /*swapInfo*/
191);
192    void	(*BeginIdiom)(
193		ClientPtr /*client*/
194);
195    void	(*EndIdiom)(
196		ClientPtr /*client*/
197);
198    void	(*WinPrivDelete)(
199		DbeWindowPrivPtr /*pDbeWindowPriv*/,
200		XID /*bufId*/
201);
202    void	(*ResetProc)(
203		ScreenPtr /*pScreen*/
204);
205
206    /* Device-specific private information.
207     */
208    PrivateRec	*devPrivates;
209
210} DbeScreenPrivRec, *DbeScreenPrivPtr;
211
212#endif /* DBE_STRUCT_H */
213