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
31
/* $XFree86: xc/programs/Xserver/hw/xwin/winallpriv.c,v 1.12 2002/10/31 23:04:39 alanh Exp $ */
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
ErrorF ("winAllocateScreenPrivates - g_ulServerGeneration: %d "
52
"serverGeneration: %d\n",
53
g_ulServerGeneration, serverGeneration);
56
/* We need a new slot for our privates if the screen gen has changed */
57
if (g_ulServerGeneration != serverGeneration)
59
/* Get an index that we can store our privates at */
60
g_iScreenPrivateIndex = AllocateScreenPrivateIndex ();
61
g_iGCPrivateIndex = AllocateGCPrivateIndex ();
62
g_iPixmapPrivateIndex = AllocatePixmapPrivateIndex ();
63
g_iWindowPrivateIndex = AllocateWindowPrivateIndex ();
65
g_ulServerGeneration = serverGeneration;
68
/* Allocate memory for the screen private structure */
69
pScreenPriv = (winPrivScreenPtr) malloc (sizeof (winPrivScreenRec));
72
ErrorF ("winAllocateScreenPrivates - malloc () failed\n");
76
/* Initialize the memory of the private structure */
77
ZeroMemory (pScreenPriv, sizeof (winPrivScreenRec));
79
/* Intialize private structure members */
80
pScreenPriv->fActive = TRUE;
82
/* Save the screen private pointer */
83
winSetScreenPriv (pScreen, pScreenPriv);
85
/* Reserve GC memory for our privates */
86
if (!AllocateGCPrivate (pScreen, g_iGCPrivateIndex,
87
sizeof (winPrivGCRec)))
89
ErrorF ("winAllocatePrivates - AllocateGCPrivate () failed\n");
93
/* Reserve Pixmap memory for our privates */
94
if (!AllocatePixmapPrivate (pScreen, g_iPixmapPrivateIndex,
95
sizeof (winPrivPixmapRec)))
97
ErrorF ("winAllocatePrivates - AllocatePixmapPrivates () failed\n");
101
/* Reserve Window memory for our privates */
102
if (!AllocateWindowPrivate (pScreen, g_iWindowPrivateIndex,
103
sizeof (winPrivWinRec)))
105
ErrorF ("winAllocatePrivates () - AllocateWindowPrivates () failed\n");
114
* Colormap privates may be allocated after the default colormap has
115
* already been created for some screens. This initialization procedure
116
* is called for each default colormap that is found.
120
winInitCmapPrivates (ColormapPtr pcmap)
123
ErrorF ("winInitCmapPrivates\n");
127
* I see no way that this function can do anything useful
128
* with only a ColormapPtr. We don't have the index for
129
* our dev privates yet, so we can't really initialize
130
* anything. Perhaps I am misunderstanding the purpose
139
* Allocate memory for our colormap privates
143
winAllocateCmapPrivates (ColormapPtr pCmap)
145
winPrivCmapPtr pCmapPriv;
146
static unsigned long s_ulPrivateGeneration = 0;
149
ErrorF ("winAllocateCmapPrivates\n");
152
/* Get a new privates index when the server generation changes */
153
if (s_ulPrivateGeneration != serverGeneration)
155
/* Get an index that we can store our privates at */
156
g_iCmapPrivateIndex = AllocateColormapPrivateIndex (winInitCmapPrivates);
158
/* Save the new server generation */
159
s_ulPrivateGeneration = serverGeneration;
162
/* Allocate memory for our private structure */
163
pCmapPriv = (winPrivCmapPtr) malloc (sizeof (winPrivCmapRec));
166
ErrorF ("winAllocateCmapPrivates - malloc () failed\n");
170
/* Initialize the memory of the private structure */
171
ZeroMemory (pCmapPriv, sizeof (winPrivCmapRec));
173
/* Save the cmap private pointer */
174
winSetCmapPriv (pCmap, pCmapPriv);
177
ErrorF ("winAllocateCmapPrivates - Returning\n");