2 *Copyright (C) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
4 *Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 *"Software"), to deal in the Software without restriction, including
7 *without limitation the rights to use, copy, modify, merge, publish,
8 *distribute, sublicense, and/or sell copies of the Software, and to
9 *permit persons to whom the Software is furnished to do so, subject to
10 *the following conditions:
12 *The above copyright notice and this permission notice shall be
13 *included in all copies or substantial portions of the Software.
15 *THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 *EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 *MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 *NONINFRINGEMENT. IN NO EVENT SHALL THE XFREE86 PROJECT BE LIABLE FOR
19 *ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
20 *CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 *WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *Except as contained in this notice, the name of the XFree86 Project
24 *shall not be used in advertising or otherwise to promote the sale, use
25 *or other dealings in this Software without prior written authorization
26 *from the XFree86 Project.
28 * Authors: Keith Packard, MIT X Consortium
32 #ifdef HAVE_XWIN_CONFIG_H
33 #include <xwin-config.h>
37 /* See Porting Layer Definition - p. 58 */
39 * Allocate indexes for the privates that we use.
40 * Allocate memory directly for the screen privates.
41 * Reserve space in GCs and Pixmaps for our privates.
42 * Colormap privates are handled in winAllocateCmapPrivates ()
46 winAllocatePrivates(ScreenPtr pScreen
)
48 winPrivScreenPtr pScreenPriv
;
51 winDebug("winAllocateScreenPrivates - g_ulServerGeneration: %d "
52 "serverGeneration: %d\n", g_ulServerGeneration
, serverGeneration
);
55 /* We need a new slot for our privates if the screen gen has changed */
56 if (g_ulServerGeneration
!= serverGeneration
) {
57 g_ulServerGeneration
= serverGeneration
;
60 /* Allocate memory for the screen private structure */
61 pScreenPriv
= (winPrivScreenPtr
) malloc(sizeof(winPrivScreenRec
));
63 ErrorF("winAllocateScreenPrivates - malloc () failed\n");
67 /* Initialize the memory of the private structure */
68 ZeroMemory(pScreenPriv
, sizeof(winPrivScreenRec
));
70 /* Intialize private structure members */
71 pScreenPriv
->fActive
= TRUE
;
73 /* Register our screen private */
74 if (!dixRegisterPrivateKey(g_iScreenPrivateKey
, PRIVATE_SCREEN
, 0)) {
75 ErrorF("winAllocatePrivates - AllocateScreenPrivate () failed\n");
79 /* Save the screen private pointer */
80 winSetScreenPriv(pScreen
, pScreenPriv
);
82 /* Reserve GC memory for our privates */
83 if (!dixRegisterPrivateKey
84 (g_iGCPrivateKey
, PRIVATE_GC
, sizeof(winPrivGCRec
))) {
85 ErrorF("winAllocatePrivates - AllocateGCPrivate () failed\n");
89 /* Reserve Pixmap memory for our privates */
90 if (!dixRegisterPrivateKey
91 (g_iPixmapPrivateKey
, PRIVATE_PIXMAP
, sizeof(winPrivPixmapRec
))) {
92 ErrorF("winAllocatePrivates - AllocatePixmapPrivates () failed\n");
96 /* Reserve Window memory for our privates */
97 if (!dixRegisterPrivateKey
98 (g_iWindowPrivateKey
, PRIVATE_WINDOW
, sizeof(winPrivWinRec
))) {
99 ErrorF("winAllocatePrivates () - AllocateWindowPrivates () failed\n");
107 * Colormap privates may be allocated after the default colormap has
108 * already been created for some screens. This initialization procedure
109 * is called for each default colormap that is found.
113 winInitCmapPrivates(ColormapPtr pcmap
, int i
)
116 winDebug("winInitCmapPrivates\n");
120 * I see no way that this function can do anything useful
121 * with only a ColormapPtr. We don't have the index for
122 * our dev privates yet, so we can't really initialize
123 * anything. Perhaps I am misunderstanding the purpose
126 /* That's definitely true.
127 * I therefore changed the API and added the index as argument.
133 * Allocate memory for our colormap privates
137 winAllocateCmapPrivates(ColormapPtr pCmap
)
139 winPrivCmapPtr pCmapPriv
;
140 static unsigned long s_ulPrivateGeneration
= 0;
143 winDebug("winAllocateCmapPrivates\n");
146 /* Get a new privates index when the server generation changes */
147 if (s_ulPrivateGeneration
!= serverGeneration
) {
148 /* Save the new server generation */
149 s_ulPrivateGeneration
= serverGeneration
;
152 /* Allocate memory for our private structure */
153 pCmapPriv
= (winPrivCmapPtr
) malloc(sizeof(winPrivCmapRec
));
155 ErrorF("winAllocateCmapPrivates - malloc () failed\n");
159 /* Initialize the memory of the private structure */
160 ZeroMemory(pCmapPriv
, sizeof(winPrivCmapRec
));
162 /* Register our colourmap private */
163 if (!dixRegisterPrivateKey(g_iCmapPrivateKey
, PRIVATE_COLORMAP
, 0)) {
164 ErrorF("winAllocateCmapPrivates - AllocateCmapPrivate () failed\n");
168 /* Save the cmap private pointer */
169 winSetCmapPriv(pCmap
, pCmapPriv
);
172 winDebug("winAllocateCmapPrivates - Returning\n");