summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEamon Walsh <ewalsh@tycho.nsa.gov>2007-08-28 09:28:25 -0400
committerEamon Walsh <ewalsh@moss-charon.epoch.ncsc.mil>2007-08-28 09:28:25 -0400
commit4017d3190234e189a0bbd33193a148d4d3c7556b (patch)
tree2ab228113d410386afde50c893f137d95974b8f3
parent85547073265ae9bc4ae3af920a6d3214fd1ca0c5 (diff)
devPrivates rework: since API is already broken, switch everything
over to new system. Need to update documentation and address some remaining vestiges of old system such as CursorRec structure, fb "offman" structure, and FontRec privates.
-rw-r--r--Xext/dpmsstubs.c2
-rw-r--r--Xext/panoramiX.c41
-rw-r--r--Xext/saver.c11
-rw-r--r--Xext/shm.c18
-rw-r--r--Xext/xevie.c19
-rw-r--r--Xext/xprint.c173
-rw-r--r--Xext/xvdisp.c11
-rw-r--r--Xext/xvdix.h9
-rw-r--r--Xext/xvmain.c32
-rw-r--r--Xext/xvmc.c23
-rw-r--r--afb/afb.h18
-rw-r--r--afb/afbfillarc.c3
-rw-r--r--afb/afbfillrct.c3
-rw-r--r--afb/afbfillsp.c15
-rw-r--r--afb/afbgc.c7
-rw-r--r--afb/afbimggblt.c4
-rw-r--r--afb/afbline.c6
-rw-r--r--afb/afbpixmap.c2
-rw-r--r--afb/afbply1rct.c4
-rw-r--r--afb/afbplygblt.c4
-rw-r--r--afb/afbpntwin.c4
-rw-r--r--afb/afbpolypnt.c4
-rw-r--r--afb/afbscrinit.c52
-rw-r--r--afb/afbtegblt.c4
-rw-r--r--afb/afbwindow.c19
-rw-r--r--afb/afbzerarc.c4
-rw-r--r--cfb/cfb.h14
-rw-r--r--cfb/cfballpriv.c41
-rw-r--r--cfb/cfbpixmap.c2
-rw-r--r--cfb/cfbrrop.h3
-rw-r--r--cfb/cfbscrinit.c20
-rw-r--r--cfb/cfbwindow.c6
-rw-r--r--composite/compalloc.c10
-rw-r--r--composite/compext.c10
-rw-r--r--composite/compinit.c30
-rw-r--r--composite/compint.h16
-rw-r--r--configure.ac1
-rwxr-xr-xdamageext/damageext.c6
-rw-r--r--damageext/damageextint.h2
-rw-r--r--dbe/dbe.c226
-rw-r--r--dbe/dbestruct.h37
-rw-r--r--dbe/midbe.c37
-rw-r--r--dbe/midbestr.h12
-rw-r--r--dix/colormap.c34
-rw-r--r--dix/devices.c32
-rw-r--r--dix/dispatch.c58
-rw-r--r--dix/extension.c40
-rw-r--r--dix/gc.c42
-rw-r--r--dix/getevents.c12
-rw-r--r--dix/main.c54
-rw-r--r--dix/pixmap.c27
-rw-r--r--dix/privates.c448
-rw-r--r--dix/window.c43
-rw-r--r--exa/exa.c20
-rw-r--r--exa/exa_priv.h10
-rw-r--r--fb/fb.h20
-rw-r--r--fb/fballpriv.c48
-rw-r--r--fb/fboverlay.c19
-rw-r--r--fb/fboverlay.h9
-rw-r--r--fb/fbpixmap.c2
-rw-r--r--fb/fbpseudocolor.c50
-rw-r--r--fb/fbscreen.c6
-rw-r--r--fb/fbwindow.c4
-rw-r--r--fb/wfbrename.h22
-rw-r--r--hw/darwin/darwin.h6
-rw-r--r--hw/darwin/iokit/xfIOKit.h6
-rw-r--r--hw/darwin/iokit/xfIOKitCursor.c18
-rw-r--r--hw/darwin/quartz/fullscreen/fullscreen.c28
-rw-r--r--hw/darwin/quartz/fullscreen/quartzCursor.c16
-rw-r--r--hw/darwin/quartz/quartz.c10
-rw-r--r--hw/darwin/quartz/quartzCommon.h4
-rw-r--r--hw/darwin/quartz/quartzCursor.c16
-rw-r--r--hw/darwin/quartz/xpr/dri.c47
-rw-r--r--hw/darwin/quartz/xpr/dristruct.h21
-rw-r--r--hw/darwin/quartz/xpr/xprCursor.c19
-rw-r--r--hw/dmx/dmxcmap.c14
-rw-r--r--hw/dmx/dmxcmap.h9
-rw-r--r--hw/dmx/dmxdpms.c7
-rw-r--r--hw/dmx/dmxgc.c6
-rw-r--r--hw/dmx/dmxgc.h4
-rw-r--r--hw/dmx/dmxpict.c3
-rw-r--r--hw/dmx/dmxpict.h10
-rw-r--r--hw/dmx/dmxpixmap.c5
-rw-r--r--hw/dmx/dmxpixmap.h4
-rw-r--r--hw/dmx/dmxscrinit.c46
-rw-r--r--hw/dmx/dmxscrinit.h2
-rw-r--r--hw/dmx/dmxwindow.c3
-rw-r--r--hw/dmx/dmxwindow.h6
-rw-r--r--hw/dmx/input/dmxconsole.c13
-rw-r--r--hw/kdrive/savage/s3draw.c17
-rw-r--r--hw/kdrive/savage/s3draw.h18
-rw-r--r--hw/kdrive/src/kaa.c22
-rw-r--r--hw/kdrive/src/kaa.h13
-rw-r--r--hw/kdrive/src/kdrive.h8
-rw-r--r--hw/kdrive/src/kxv.c44
-rw-r--r--hw/xfree86/common/xf86.h10
-rw-r--r--hw/xfree86/common/xf86DGA.c44
-rw-r--r--hw/xfree86/common/xf86DPMS.c32
-rw-r--r--hw/xfree86/common/xf86Globals.c8
-rw-r--r--hw/xfree86/common/xf86Init.c24
-rw-r--r--hw/xfree86/common/xf86RandR.c20
-rw-r--r--hw/xfree86/common/xf86VidMode.c27
-rw-r--r--hw/xfree86/common/xf86cmap.c122
-rw-r--r--hw/xfree86/common/xf86fbman.c148
-rw-r--r--hw/xfree86/common/xf86sbusBus.c13
-rw-r--r--hw/xfree86/common/xf86xv.c42
-rw-r--r--hw/xfree86/common/xf86xvmc.c20
-rw-r--r--hw/xfree86/common/xf86xvpriv.h3
-rw-r--r--hw/xfree86/dixmods/extmod/xf86dga2.c30
-rw-r--r--hw/xfree86/dixmods/extmod/xf86misc.c40
-rw-r--r--hw/xfree86/dixmods/extmod/xf86vmode.c43
-rw-r--r--hw/xfree86/dixmods/extmod/xvmod.c2
-rw-r--r--hw/xfree86/dixmods/extmod/xvmodproc.h2
-rw-r--r--hw/xfree86/dri/dri.c52
-rw-r--r--hw/xfree86/dri/dristruct.h22
-rw-r--r--hw/xfree86/exa/examodule.c18
-rw-r--r--hw/xfree86/loader/dixsym.c18
-rw-r--r--hw/xfree86/loader/misym.c4
-rw-r--r--hw/xfree86/loader/xf86sym.c4
-rw-r--r--hw/xfree86/modes/xf86RandR12.c13
-rw-r--r--hw/xfree86/os-support/solaris/sun_mouse.c14
-rw-r--r--hw/xfree86/rac/xf86RAC.c68
-rw-r--r--hw/xfree86/ramdac/xf86Cursor.c69
-rw-r--r--hw/xfree86/ramdac/xf86CursorPriv.h2
-rw-r--r--hw/xfree86/ramdac/xf86HWCurs.c16
-rw-r--r--hw/xfree86/shadowfb/shadow.c20
-rw-r--r--hw/xfree86/xaa/xaaDashLine.c3
-rw-r--r--hw/xfree86/xaa/xaaGC.c3
-rw-r--r--hw/xfree86/xaa/xaaGCmisc.c3
-rw-r--r--hw/xfree86/xaa/xaaInit.c45
-rw-r--r--hw/xfree86/xaa/xaaLineMisc.c3
-rw-r--r--hw/xfree86/xaa/xaaOverlayDF.c15
-rw-r--r--hw/xfree86/xaa/xaaStateChange.c15
-rw-r--r--hw/xfree86/xaa/xaaWrapper.c31
-rw-r--r--hw/xfree86/xaa/xaalocal.h22
-rw-r--r--hw/xfree86/xaa/xaawrap.h14
-rw-r--r--hw/xfree86/xf4bpp/mfbfillarc.c3
-rw-r--r--hw/xfree86/xf4bpp/mfbimggblt.c3
-rw-r--r--hw/xfree86/xf4bpp/mfbzerarc.c3
-rw-r--r--hw/xfree86/xf4bpp/ppcArea.c2
-rw-r--r--hw/xfree86/xf4bpp/ppcGC.c10
-rw-r--r--hw/xfree86/xf4bpp/ppcIO.c2
-rw-r--r--hw/xfree86/xf4bpp/ppcPixFS.c24
-rw-r--r--hw/xfree86/xf4bpp/ppcPixmap.c1
-rw-r--r--hw/xfree86/xf4bpp/ppcPntWin.c2
-rw-r--r--hw/xfree86/xf4bpp/ppcPolyPnt.c2
-rw-r--r--hw/xfree86/xf4bpp/ppcWinFS.c24
-rw-r--r--hw/xfree86/xf4bpp/ppcWindow.c2
-rw-r--r--hw/xfree86/xf4bpp/vgaGC.c2
-rw-r--r--hw/xfree86/xf8_32bpp/cfb8_32.h14
-rw-r--r--hw/xfree86/xf8_32bpp/cfbscrinit.c35
-rw-r--r--hw/xfree86/xf8_32bpp/xf86overlay.c35
-rw-r--r--hw/xgl/egl/xegl.c20
-rw-r--r--hw/xgl/egl/xegl.h6
-rw-r--r--hw/xgl/glx/xglx.c20
-rw-r--r--hw/xgl/xgl.h33
-rw-r--r--hw/xgl/xglpixmap.c2
-rw-r--r--hw/xgl/xglxv.c8
-rw-r--r--hw/xnest/GC.c2
-rw-r--r--hw/xnest/Init.c2
-rw-r--r--hw/xnest/Pixmap.c8
-rw-r--r--hw/xnest/Screen.c20
-rw-r--r--hw/xnest/Window.c2
-rw-r--r--hw/xnest/XNGC.h6
-rw-r--r--hw/xnest/XNPixmap.h6
-rw-r--r--hw/xnest/XNWindow.h6
-rw-r--r--hw/xprint/attributes.c27
-rw-r--r--hw/xprint/pcl/Pcl.h8
-rw-r--r--hw/xprint/pcl/PclArc.c2
-rw-r--r--hw/xprint/pcl/PclColor.c28
-rw-r--r--hw/xprint/pcl/PclGC.c15
-rw-r--r--hw/xprint/pcl/PclInit.c62
-rw-r--r--hw/xprint/pcl/PclLine.c4
-rw-r--r--hw/xprint/pcl/PclPixel.c8
-rw-r--r--hw/xprint/pcl/PclPolygon.c6
-rw-r--r--hw/xprint/pcl/PclPrint.c20
-rw-r--r--hw/xprint/pcl/PclText.c4
-rw-r--r--hw/xprint/pcl/PclWindow.c7
-rw-r--r--hw/xprint/pcl/Pclmap.h10
-rw-r--r--hw/xprint/ps/Ps.h8
-rw-r--r--hw/xprint/ps/PsGC.c14
-rw-r--r--hw/xprint/ps/PsInit.c48
-rw-r--r--hw/xprint/ps/PsPixmap.c9
-rw-r--r--hw/xprint/ps/PsPrint.c33
-rw-r--r--hw/xprint/ps/PsWindow.c7
-rw-r--r--hw/xprint/raster/Raster.c44
-rw-r--r--hw/xwin/win.h40
-rw-r--r--hw/xwin/winallpriv.c18
-rw-r--r--hw/xwin/wincursor.c3
-rw-r--r--hw/xwin/winfillsp.c9
-rw-r--r--hw/xwin/winglobals.c10
-rw-r--r--hw/xwin/winmultiwindowwndproc.c2
-rw-r--r--hw/xwin/winpixmap.c7
-rw-r--r--hw/xwin/winscrinit.c3
-rw-r--r--hw/xwin/winsetsp.c9
-rw-r--r--include/colormapst.h3
-rw-r--r--include/dix-config.h.in3
-rw-r--r--include/dix.h6
-rw-r--r--include/dixstruct.h3
-rw-r--r--include/extension.h6
-rw-r--r--include/extnsionst.h3
-rw-r--r--include/gcstruct.h3
-rw-r--r--include/input.h3
-rw-r--r--include/inputstr.h5
-rw-r--r--include/pixmapstr.h14
-rw-r--r--include/privates.h10
-rw-r--r--include/screenint.h28
-rw-r--r--include/scrnintstr.h11
-rw-r--r--include/window.h3
-rw-r--r--include/windowstr.h3
-rw-r--r--include/xkbsrv.h2
-rw-r--r--include/xorg-config.h.in3
-rw-r--r--include/xorg-server.h.in3
-rw-r--r--mfb/mfb.h14
-rw-r--r--mfb/mfbbitblt.c18
-rw-r--r--mfb/mfbfillarc.c3
-rw-r--r--mfb/mfbfillrct.c3
-rw-r--r--mfb/mfbfillsp.c9
-rw-r--r--mfb/mfbgc.c10
-rw-r--r--mfb/mfbimggblt.c3
-rw-r--r--mfb/mfbline.c6
-rw-r--r--mfb/mfbpixmap.c2
-rw-r--r--mfb/mfbpntwin.c5
-rw-r--r--mfb/mfbpolypnt.c3
-rw-r--r--mfb/mfbscrinit.c38
-rw-r--r--mfb/mfbwindow.c14
-rw-r--r--mfb/mfbzerarc.c3
-rw-r--r--mi/mi.h3
-rw-r--r--mi/mibank.c18
-rw-r--r--mi/midispcur.c30
-rw-r--r--mi/miline.h7
-rw-r--r--mi/mioverlay.c27
-rw-r--r--mi/mipointer.c15
-rw-r--r--mi/mipointer.h3
-rw-r--r--mi/miscrinit.c25
-rw-r--r--mi/misprite.c78
-rw-r--r--miext/cw/cw.c51
-rw-r--r--miext/cw/cw.h29
-rwxr-xr-xmiext/damage/damage.c41
-rwxr-xr-xmiext/damage/damagestr.h15
-rw-r--r--miext/rootless/accel/rlAccel.c13
-rw-r--r--miext/rootless/rootlessCommon.h19
-rw-r--r--miext/rootless/rootlessGC.c10
-rw-r--r--miext/rootless/rootlessScreen.c30
-rw-r--r--miext/rootless/rootlessWindow.c12
-rw-r--r--miext/shadow/shadow.c15
-rw-r--r--miext/shadow/shadow.h5
-rw-r--r--randr/randr.c16
-rw-r--r--randr/randrstr.h10
-rw-r--r--record/record.c15
-rw-r--r--render/animcur.c13
-rw-r--r--render/glyph.c321
-rw-r--r--render/glyphstr.h43
-rw-r--r--render/picture.c115
-rw-r--r--render/picturestr.h42
-rw-r--r--render/render.c10
-rwxr-xr-xxfixes/cursor.c18
-rwxr-xr-xxfixes/xfixes.c6
-rwxr-xr-xxfixes/xfixesint.h2
-rw-r--r--xkb/ddxFakeMtn.c2
-rw-r--r--xkb/xkbActions.c13
261 files changed, 1642 insertions, 3957 deletions
diff --git a/Xext/dpmsstubs.c b/Xext/dpmsstubs.c
index 8d58935da..fad07bde6 100644
--- a/Xext/dpmsstubs.c
+++ b/Xext/dpmsstubs.c
@@ -48,5 +48,5 @@ int DPMSGet(int *plevel)
int DPMSSet(ClientPtr client, int level)
{
-
+ return Success;
}
diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index 95df04320..26c280990 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -110,8 +110,8 @@ static void PanoramiXResetProc(ExtensionEntry*);
int (* SavedProcVector[256]) (ClientPtr client) = { NULL, };
-static int PanoramiXGCIndex = -1;
-static int PanoramiXScreenIndex = -1;
+static DevPrivateKey PanoramiXGCKey = &PanoramiXGCKey;
+static DevPrivateKey PanoramiXScreenKey = &PanoramiXScreenKey;
typedef struct {
DDXPointRec clipOrg;
@@ -140,8 +140,8 @@ static GCFuncs XineramaGCFuncs = {
};
#define Xinerama_GC_FUNC_PROLOGUE(pGC)\
- PanoramiXGCPtr pGCPriv = \
- (PanoramiXGCPtr) (pGC)->devPrivates[PanoramiXGCIndex].ptr;\
+ PanoramiXGCPtr pGCPriv = (PanoramiXGCPtr) \
+ dixLookupPrivate(&(pGC)->devPrivates, PanoramiXGCKey); \
(pGC)->funcs = pGCPriv->wrapFuncs;
#define Xinerama_GC_FUNC_EPILOGUE(pGC)\
@@ -152,8 +152,8 @@ static GCFuncs XineramaGCFuncs = {
static Bool
XineramaCloseScreen (int i, ScreenPtr pScreen)
{
- PanoramiXScreenPtr pScreenPriv =
- (PanoramiXScreenPtr) pScreen->devPrivates[PanoramiXScreenIndex].ptr;
+ PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr)
+ dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
pScreen->CreateGC = pScreenPriv->CreateGC;
@@ -171,14 +171,14 @@ static Bool
XineramaCreateGC(GCPtr pGC)
{
ScreenPtr pScreen = pGC->pScreen;
- PanoramiXScreenPtr pScreenPriv =
- (PanoramiXScreenPtr) pScreen->devPrivates[PanoramiXScreenIndex].ptr;
+ PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr)
+ dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey);
Bool ret;
pScreen->CreateGC = pScreenPriv->CreateGC;
if((ret = (*pScreen->CreateGC)(pGC))) {
- PanoramiXGCPtr pGCPriv =
- (PanoramiXGCPtr) pGC->devPrivates[PanoramiXGCIndex].ptr;
+ PanoramiXGCPtr pGCPriv = (PanoramiXGCPtr)
+ dixLookupPrivate(&pGC->devPrivates, PanoramiXGCKey);
pGCPriv->wrapFuncs = pGC->funcs;
pGC->funcs = &XineramaGCFuncs;
@@ -284,8 +284,8 @@ XineramaCopyGC (
unsigned long mask,
GCPtr pGCDst
){
- PanoramiXGCPtr pSrcPriv =
- (PanoramiXGCPtr) pGCSrc->devPrivates[PanoramiXGCIndex].ptr;
+ PanoramiXGCPtr pSrcPriv = (PanoramiXGCPtr)
+ dixLookupPrivate(&pGCSrc->devPrivates, PanoramiXGCKey);
Xinerama_GC_FUNC_PROLOGUE (pGCDst);
if(mask & GCTileStipXOrigin)
@@ -484,20 +484,17 @@ void PanoramiXExtensionInit(int argc, char *argv[])
xcalloc(PanoramiXNumScreens, sizeof(PanoramiXData));
BREAK_IF(!panoramiXdataPtr);
- BREAK_IF((PanoramiXGCIndex = AllocateGCPrivateIndex()) < 0);
- BREAK_IF((PanoramiXScreenIndex = AllocateScreenPrivateIndex()) < 0);
+
+ if (!dixRequestPrivate(PanoramiXGCKey, sizeof(PanoramiXGCRec))) {
+ noPanoramiXExtension = TRUE;
+ return;
+ }
for (i = 0; i < PanoramiXNumScreens; i++) {
pScreen = screenInfo.screens[i];
- if(!AllocateGCPrivate(pScreen, PanoramiXGCIndex,
- sizeof(PanoramiXGCRec))) {
- noPanoramiXExtension = TRUE;
- return;
- }
-
pScreenPriv = xalloc(sizeof(PanoramiXScreenRec));
- pScreen->devPrivates[PanoramiXScreenIndex].ptr =
- (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey,
+ pScreenPriv);
if(!pScreenPriv) {
noPanoramiXExtension = TRUE;
return;
diff --git a/Xext/saver.c b/Xext/saver.c
index dabfbea1b..004258382 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -234,10 +234,12 @@ MakeScreenPrivate (
ScreenPtr /* pScreen */
);
-static int ScreenPrivateIndex;
+static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKey;
-#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr)(s)->devPrivates[ScreenPrivateIndex].ptr)
-#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (pointer) v);
+#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
+ dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
+#define SetScreenPrivate(s,v) \
+ dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v);
#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL)
#define New(t) ((t *) xalloc (sizeof (t)))
@@ -260,14 +262,13 @@ ScreenSaverExtensionInit(INITARGS)
AttrType = CreateNewResourceType(ScreenSaverFreeAttr);
EventType = CreateNewResourceType(ScreenSaverFreeEvents);
SuspendType = CreateNewResourceType(ScreenSaverFreeSuspend);
- ScreenPrivateIndex = AllocateScreenPrivateIndex ();
for (i = 0; i < screenInfo.numScreens; i++)
{
pScreen = screenInfo.screens[i];
SetScreenPrivate (pScreen, NULL);
}
- if (AttrType && EventType && SuspendType && ScreenPrivateIndex != -1 &&
+ if (AttrType && EventType && SuspendType &&
(extEntry = AddExtension(ScreenSaverName, ScreenSaverNumberEvents, 0,
ProcScreenSaverDispatch, SProcScreenSaverDispatch,
ScreenSaverResetProc, StandardMinorOpcode)))
diff --git a/Xext/shm.c b/Xext/shm.c
index 7fa834952..8fa584275 100644
--- a/Xext/shm.c
+++ b/Xext/shm.c
@@ -119,7 +119,7 @@ static int pixmapFormat;
static int shmPixFormat[MAXSCREENS];
static ShmFuncsPtr shmFuncs[MAXSCREENS];
static DestroyPixmapProcPtr destroyPixmap[MAXSCREENS];
-static int shmPixmapPrivate;
+static DevPrivateKey shmPixmapPrivate = &shmPixmapPrivate;
static ShmFuncs miFuncs = {NULL, miShmPutImage};
static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage};
@@ -229,20 +229,11 @@ ShmExtensionInit(INITARGS)
if (!pixmapFormat)
pixmapFormat = ZPixmap;
if (sharedPixmaps)
- {
for (i = 0; i < screenInfo.numScreens; i++)
{
destroyPixmap[i] = screenInfo.screens[i]->DestroyPixmap;
screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap;
}
- shmPixmapPrivate = AllocatePixmapPrivateIndex();
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- if (!AllocatePixmapPrivate(screenInfo.screens[i],
- shmPixmapPrivate, 0))
- return;
- }
- }
}
ShmSegType = CreateNewResourceType(ShmDetachSegment);
if (ShmSegType &&
@@ -295,7 +286,8 @@ ShmDestroyPixmap (PixmapPtr pPixmap)
if (pPixmap->refcnt == 1)
{
ShmDescPtr shmdesc;
- shmdesc = (ShmDescPtr) pPixmap->devPrivates[shmPixmapPrivate].ptr;
+ shmdesc = (ShmDescPtr)dixLookupPrivate(&pPixmap->devPrivates,
+ shmPixmapPrivate);
if (shmdesc)
ShmDetachSegment ((pointer) shmdesc, pPixmap->drawable.id);
}
@@ -762,7 +754,7 @@ CreatePmap:
shmdesc->addr + stuff->offset);
if (pMap) {
- pMap->devPrivates[shmPixmapPrivate].ptr = (pointer) shmdesc;
+ dixSetPrivate(&pMap->devPrivates, shmPixmapPrivate, shmdesc);
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = newPix->info[j].id;
@@ -1076,7 +1068,7 @@ CreatePmap:
shmdesc->addr + stuff->offset);
if (pMap)
{
- pMap->devPrivates[shmPixmapPrivate].ptr = (pointer) shmdesc;
+ dixSetPrivate(&pMap->devPrivates, shmPixmapPrivate, shmdesc);
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid;
diff --git a/Xext/xevie.c b/Xext/xevie.c
index 7922913ba..7dd67bbf6 100644
--- a/Xext/xevie.c
+++ b/Xext/xevie.c
@@ -76,11 +76,11 @@ DeviceIntPtr xeviemouse = NULL;
Mask xevieMask = 0;
int xevieEventSent = 0;
int xevieKBEventSent = 0;
-static unsigned int xevieServerGeneration;
-static int xevieDevicePrivateIndex;
+static DevPrivateKey xevieDevicePrivateKey = &xevieDevicePrivateKey;
static Bool xevieModifiersOn = FALSE;
-#define XEVIEINFO(dev) ((xevieDeviceInfoPtr)dev->devPrivates[xevieDevicePrivateIndex].ptr)
+#define XEVIEINFO(dev) ((xevieDeviceInfoPtr) \
+ dixLookupPrivate(&(dev)->devPrivates, xevieDevicePrivateKey))
Mask xevieFilters[128] =
{
@@ -134,12 +134,6 @@ XevieExtensionInit (void)
{
ExtensionEntry* extEntry;
- if (serverGeneration != xevieServerGeneration) {
- if ((xevieDevicePrivateIndex = AllocateDevicePrivateIndex()) == -1)
- return;
- xevieServerGeneration = serverGeneration;
- }
-
if (!AddCallback(&ServerGrabCallback,XevieServerGrabStateCallback,NULL))
return;
@@ -618,14 +612,11 @@ XevieAdd(DeviceIntPtr device, void* data)
{
xevieDeviceInfoPtr xeviep;
- if (!AllocateDevicePrivate(device, xevieDevicePrivateIndex))
- return FALSE;
-
xeviep = xalloc (sizeof (xevieDeviceInfoRec));
if (!xeviep)
return FALSE;
- device->devPrivates[xevieDevicePrivateIndex].ptr = xeviep;
+ dixSetPrivate(&device->devPrivates, xevieDevicePrivateKey, xeviep);
XevieUnwrapAdd(device, data);
return TRUE;
@@ -642,7 +633,7 @@ XevieRemove(DeviceIntPtr device,pointer data)
UNWRAP_UNWRAPPROC(device,xeviep->unwrapProc);
xfree(xeviep);
- device->devPrivates[xevieDevicePrivateIndex].ptr = NULL;
+ dixSetPrivate(&device->devPrivates, xevieDevicePrivateKey, NULL);
return TRUE;
}
diff --git a/Xext/xprint.c b/Xext/xprint.c
index ff739c0e7..ef5111837 100644
--- a/Xext/xprint.c
+++ b/Xext/xprint.c
@@ -153,8 +153,6 @@ static int XpFreePage(pointer, XID);
static Bool XpCloseScreen(int, ScreenPtr);
static CARD32 GetAllEventMasks(XpContextPtr);
static struct _XpClient *CreateXpClient(ClientPtr);
-static void InitContextPrivates(XpContextPtr);
-static void ResetContextPrivates(void);
static struct _XpClient *FindClient(XpContextPtr, ClientPtr);
static struct _XpClient *AcquireClient(XpContextPtr, ClientPtr);
@@ -233,21 +231,12 @@ static XpScreenPtr XpScreens[MAXSCREENS];
static unsigned char XpReqCode;
static int XpEventBase;
static int XpErrorBase;
-static unsigned long XpGeneration = 0;
-static int XpClientPrivateIndex;
-
-/* Variables for the context private machinery.
- * These must be initialized at compile time because
- * main() calls InitOutput before InitExtensions, and the
- * output drivers are likely to call AllocateContextPrivate.
- * These variables are reset at CloseScreen time. CloseScreen
- * is used because it occurs after FreeAllResources, and before
- * the next InitOutput cycle.
- */
-static int contextPrivateCount = 0;
-static int contextPrivateLen = 0;
-static unsigned *contextPrivateSizes = (unsigned *)NULL;
-static unsigned totalContextSize = sizeof(XpContextRec);
+static DevPrivateKey XpClientPrivateKey = &XpClientPrivateKey;
+
+#define XP_GETPRIV(pClient) ((XpContextPtr) \
+ dixLookupPrivate(&(pClient)->devPrivates, XpClientPrivateKey))
+#define XP_SETPRIV(pClient, p) \
+ dixSetPrivate(&(pClient)->devPrivates, XpClientPrivateKey, p)
/*
* There are three types of resources involved. One is the resource associated
@@ -305,20 +294,6 @@ XpExtensionInit(INITARGS)
EventSwapVector[XpEventBase+1] = (EventSwapPtr) SwapXpAttributeEvent;
}
- if(XpGeneration != serverGeneration)
- {
- XpClientPrivateIndex = AllocateClientPrivateIndex();
- /*
- * We allocate 0 length & simply stuff a pointer to the
- * ContextRec in the DevUnion.
- */
- if(AllocateClientPrivate(XpClientPrivateIndex, 0) != TRUE)
- {
- /* we can't alloc a client private, should we bail??? XXX */
- }
- XpGeneration = serverGeneration;
- }
-
for(i = 0; i < MAXSCREENS; i++)
{
/*
@@ -377,14 +352,6 @@ XpCloseScreen(int index, ScreenPtr pScreen)
}
XpScreens[index] = (XpScreenPtr)NULL;
- /*
- * It's wasteful to call ResetContextPrivates() at every CloseScreen,
- * but it's the best we know how to do for now. We do this because we
- * have to wait until after all resources have been freed (so we know
- * how to free the ContextRecs), and before the next InitOutput cycle.
- * See dix/main.c for the order of initialization and reset.
- */
- ResetContextPrivates();
return (*CloseScreen)(index, pScreen);
}
@@ -956,12 +923,10 @@ ProcXpCreateContext(ClientPtr client)
/*
* Allocate and add the context resource.
*/
- if((pContext = (XpContextPtr) xalloc(totalContextSize)) ==
+ if((pContext = (XpContextPtr) xalloc(sizeof(XpContextRec))) ==
(XpContextPtr) NULL)
return BadAlloc;
- InitContextPrivates(pContext);
-
if(AddResource(stuff->contextID, RTcontext, (pointer) pContext)
!= TRUE)
{
@@ -975,6 +940,7 @@ ProcXpCreateContext(ClientPtr client)
pContext->state = 0;
pContext->clientSlept = (ClientPtr)NULL;
pContext->imageRes = 0;
+ pContext->devPrivates = NULL;
pContext->funcs.DestroyContext = 0;
pContext->funcs.StartJob = 0;
@@ -1041,8 +1007,7 @@ ProcXpSetContext(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xPrintSetContextReq);
- if((pContext = client->devPrivates[XpClientPrivateIndex].ptr) !=
- (pointer)NULL)
+ if((pContext = XP_GETPRIV(client)) != (pointer)NULL)
{
/*
* Erase this client's knowledge of its old context, if any.
@@ -1055,7 +1020,7 @@ ProcXpSetContext(ClientPtr client)
FreeXpClient(pPrintClient, TRUE);
}
- client->devPrivates[XpClientPrivateIndex].ptr = (pointer)NULL;
+ XP_SETPRIV(client, NULL);
}
if(stuff->printContext == None)
return Success;
@@ -1077,7 +1042,7 @@ ProcXpSetContext(ClientPtr client)
if((pPrintClient = AcquireClient(pContext, client)) == (XpClientPtr)NULL)
return BadAlloc;
- client->devPrivates[XpClientPrivateIndex].ptr = pContext;
+ XP_SETPRIV(client, pContext);
XpSetFontResFunc(client);
@@ -1090,7 +1055,7 @@ ProcXpSetContext(ClientPtr client)
XpContextPtr
XpGetPrintContext(ClientPtr client)
{
- return (client->devPrivates[XpClientPrivateIndex].ptr);
+ return XP_GETPRIV(client);
}
static int
@@ -1105,8 +1070,7 @@ ProcXpGetContext(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintGetContextReq);
- if((pContext = client->devPrivates[XpClientPrivateIndex].ptr) ==
- (pointer)NULL)
+ if((pContext = XP_GETPRIV(client)) == (pointer)NULL)
rep.printContext = None;
else
rep.printContext = pContext->contextID;
@@ -1249,6 +1213,7 @@ XpFreeContext(pointer data, XID id)
}
xfree(pContext->printerName);
+ dixFreePrivates(pContext->devPrivates);
xfree(pContext);
return Success; /* ??? */
}
@@ -1284,11 +1249,9 @@ FreeXpClient(XpClientPtr pXpClient, Bool freeResource)
* If we're freeing the clientRec associated with the context tied
* to the client's devPrivates, then we need to clear the devPrivates.
*/
- if(pXpClient->client->devPrivates[XpClientPrivateIndex].ptr ==
- pXpClient->context)
+ if(XP_GETPRIV(pXpClient->client) == pXpClient->context)
{
- pXpClient->client->devPrivates[XpClientPrivateIndex].ptr =
- (pointer)NULL;
+ XP_SETPRIV(pXpClient->client, NULL);
}
for(pPrev = (XpClientPtr)NULL, pCurrent = pContext->clientHead;
@@ -1372,87 +1335,6 @@ XpFreePage(pointer data, XID id)
return result;
}
-/*
- * ContextPrivate machinery.
- * Context privates are intended for use by the drivers, allowing the
- * drivers to maintain context-specific data. The driver should free
- * the associated data at DestroyContext time.
- */
-
-static void
-InitContextPrivates(XpContextPtr context)
-{
- register char *ptr;
- DevUnion *ppriv;
- register unsigned *sizes;
- register unsigned size;
- register int i;
-
- if (totalContextSize == sizeof(XpContextRec))
- ppriv = (DevUnion *)NULL;
- else
- ppriv = (DevUnion *)(context + 1);
-
- context->devPrivates = ppriv;
- sizes = contextPrivateSizes;
- ptr = (char *)(ppriv + contextPrivateLen);
- for (i = contextPrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
-}
-
-static void
-ResetContextPrivates(void)
-{
- contextPrivateCount = 0;
- contextPrivateLen = 0;
- xfree(contextPrivateSizes);
- contextPrivateSizes = (unsigned *)NULL;
- totalContextSize = sizeof(XpContextRec);
-
-}
-
-int
-XpAllocateContextPrivateIndex(void)
-{
- return contextPrivateCount++;
-}
-
-Bool
-XpAllocateContextPrivate(int index, unsigned amount)
-{
- unsigned oldamount;
-
- if (index >= contextPrivateLen)
- {
- unsigned *nsizes;
- nsizes = (unsigned *)xrealloc(contextPrivateSizes,
- (index + 1) * sizeof(unsigned));
- if (!nsizes)
- return FALSE;
- while (contextPrivateLen <= index)
- {
- nsizes[contextPrivateLen++] = 0;
- totalContextSize += sizeof(DevUnion);
- }
- contextPrivateSizes = nsizes;
- }
- oldamount = contextPrivateSizes[index];
- if (amount > oldamount)
- {
- contextPrivateSizes[index] = amount;
- totalContextSize += (amount - oldamount);
- }
- return TRUE;
-}
-
static XpClientPtr
AcquireClient(XpContextPtr pContext, ClientPtr client)
{
@@ -1501,8 +1383,7 @@ ProcXpStartJob(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintStartJobReq);
/* Check to see that a context has been established by this client. */
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadContext;
if(pContext->state != 0)
@@ -1542,8 +1423,7 @@ ProcXpEndJob(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintEndJobReq);
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadSequence;
if(!(pContext->state & JOB_STARTED))
@@ -1648,8 +1528,7 @@ ProcXpStartDoc(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintStartDocReq);
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadSequence;
if(!(pContext->state & JOB_STARTED) ||
@@ -1684,8 +1563,7 @@ ProcXpEndDoc(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintEndDocReq);
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadSequence;
if(!(pContext->state & DOC_RAW_STARTED) &&
@@ -1837,8 +1715,7 @@ ProcXpStartPage(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintStartPageReq);
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadSequence;
if(!(pContext->state & JOB_STARTED))
@@ -1882,8 +1759,7 @@ ProcXpEndPage(ClientPtr client)
REQUEST_SIZE_MATCH(xPrintEndPageReq);
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadSequence;
if(!(pContext->state & PAGE_STARTED))
@@ -1932,8 +1808,7 @@ ProcXpPutDocumentData(ClientPtr client)
REQUEST_AT_LEAST_SIZE(xPrintPutDocumentDataReq);
- if((pContext = (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr)
- == (XpContextPtr)NULL)
+ if((pContext = XP_GETPRIV(client)) == (XpContextPtr)NULL)
return XpErrorBase+XPBadSequence;
if(!(pContext->state & DOC_RAW_STARTED) &&
@@ -2443,7 +2318,7 @@ GetAllEventMasks(XpContextPtr pContext)
XpContextPtr
XpContextOfClient(ClientPtr client)
{
- return (XpContextPtr)client->devPrivates[XpClientPrivateIndex].ptr;
+ return XP_GETPRIV(client);
}
diff --git a/Xext/xvdisp.c b/Xext/xvdisp.c
index 21d00aa7f..af2e09b82 100644
--- a/Xext/xvdisp.c
+++ b/Xext/xvdisp.c
@@ -388,8 +388,8 @@ ProcXvQueryAdaptors(ClientPtr client)
return rc;
pScreen = pWin->drawable.pScreen;
- pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
-
+ pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ XvGetScreenKey());
if (!pxvs)
{
rep.type = X_Reply;
@@ -2099,7 +2099,8 @@ XineramaXvPutStill(ClientPtr client)
void XineramifyXv(void)
{
ScreenPtr pScreen, screen0 = screenInfo.screens[0];
- XvScreenPtr xvsp0 = (XvScreenPtr)screen0->devPrivates[XvScreenIndex].ptr;
+ XvScreenPtr xvsp0 = (XvScreenPtr)dixLookupPrivate(&screen0->devPrivates,
+ XvGetScreenKey());
XvAdaptorPtr refAdapt, pAdapt;
XvAttributePtr pAttr;
XvScreenPtr xvsp;
@@ -2132,8 +2133,8 @@ void XineramifyXv(void)
for(j = 1; j < PanoramiXNumScreens; j++) {
pScreen = screenInfo.screens[j];
- xvsp = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
-
+ xvsp = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ XvGetScreenKey());
/* Do not try to go on if xv is not supported on this screen */
if (xvsp==NULL) continue ;
diff --git a/Xext/xvdix.h b/Xext/xvdix.h
index 9e94e05d5..a516cf113 100644
--- a/Xext/xvdix.h
+++ b/Xext/xvdix.h
@@ -55,7 +55,6 @@ SOFTWARE.
#include "scrnintstr.h"
#include <X11/extensions/Xvproto.h>
-extern int XvScreenIndex;
extern unsigned long XvExtensionGeneration;
extern unsigned long XvScreenGeneration;
extern unsigned long XvResourceGeneration;
@@ -224,10 +223,8 @@ typedef struct {
DevUnion devPriv;
} XvScreenRec, *XvScreenPtr;
-#define SCREEN_PROLOGUE(pScreen, field)\
- ((pScreen)->field = \
- ((XvScreenPtr) \
- (pScreen)->devPrivates[XvScreenIndex].ptr)->field)
+#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, XvScreenKey))->field)
#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
((pScreen)->field = wrapper)
@@ -242,7 +239,7 @@ extern int SProcXvDispatch(ClientPtr);
extern void XvExtensionInit(void);
extern int XvScreenInit(ScreenPtr);
-extern int XvGetScreenIndex(void);
+extern DevPrivateKey XvGetScreenKey(void);
extern unsigned long XvGetRTPort(void);
extern int XvdiSendPortNotify(XvPortPtr, Atom, INT32);
extern int XvdiVideoStopped(XvPortPtr, int);
diff --git a/Xext/xvmain.c b/Xext/xvmain.c
index ddf3d1d6b..a2fc10802 100644
--- a/Xext/xvmain.c
+++ b/Xext/xvmain.c
@@ -105,7 +105,7 @@ SOFTWARE.
#include "xvdisp.h"
#endif
-int XvScreenIndex = -1;
+static DevPrivateKey XvScreenKey = &XvScreenKey;
unsigned long XvExtensionGeneration = 0;
unsigned long XvScreenGeneration = 0;
unsigned long XvResourceGeneration = 0;
@@ -166,12 +166,6 @@ XvExtensionInit(void)
ErrorF("XvExtensionInit: Unable to allocate resource types\n");
return;
}
- XvScreenIndex = AllocateScreenPrivateIndex ();
- if (XvScreenIndex < 0)
- {
- ErrorF("XvExtensionInit: Unable to allocate screen private index\n");
- return;
- }
#ifdef PANORAMIX
XineramaRegisterConnectionBlockCallback(XineramifyXv);
#endif
@@ -265,19 +259,13 @@ XvScreenInit(ScreenPtr pScreen)
ErrorF("XvScreenInit: Unable to allocate resource types\n");
return BadAlloc;
}
- XvScreenIndex = AllocateScreenPrivateIndex ();
- if (XvScreenIndex < 0)
- {
- ErrorF("XvScreenInit: Unable to allocate screen private index\n");
- return BadAlloc;
- }
#ifdef PANORAMIX
XineramaRegisterConnectionBlockCallback(XineramifyXv);
#endif
XvScreenGeneration = serverGeneration;
}
- if (pScreen->devPrivates[XvScreenIndex].ptr)
+ if (dixLookupPrivate(&pScreen->devPrivates, XvScreenKey))
{
ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n");
}
@@ -291,7 +279,7 @@ XvScreenInit(ScreenPtr pScreen)
return BadAlloc;
}
- pScreen->devPrivates[XvScreenIndex].ptr = (pointer)pxvs;
+ dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs);
pxvs->DestroyPixmap = pScreen->DestroyPixmap;
@@ -313,7 +301,7 @@ XvCloseScreen(
XvScreenPtr pxvs;
- pxvs = (XvScreenPtr) pScreen->devPrivates[XvScreenIndex].ptr;
+ pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
pScreen->DestroyPixmap = pxvs->DestroyPixmap;
pScreen->DestroyWindow = pxvs->DestroyWindow;
@@ -323,7 +311,7 @@ XvCloseScreen(
xfree(pxvs);
- pScreen->devPrivates[XvScreenIndex].ptr = (pointer)NULL;
+ dixSetPrivate(&pScreen->devPrivates, XvScreenKey, NULL);
return (*pScreen->CloseScreen)(ii, pScreen);
@@ -334,10 +322,10 @@ XvResetProc(ExtensionEntry* extEntry)
{
}
-_X_EXPORT int
-XvGetScreenIndex(void)
+_X_EXPORT DevPrivateKey
+XvGetScreenKey(void)
{
- return XvScreenIndex;
+ return XvScreenKey;
}
_X_EXPORT unsigned long
@@ -361,7 +349,7 @@ XvDestroyPixmap(PixmapPtr pPix)
SCREEN_PROLOGUE(pScreen, DestroyPixmap);
- pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
+ pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
/* CHECK TO SEE IF THIS PORT IS IN USE */
@@ -413,7 +401,7 @@ XvDestroyWindow(WindowPtr pWin)
SCREEN_PROLOGUE(pScreen, DestroyWindow);
- pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr;
+ pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XvScreenKey);
/* CHECK TO SEE IF THIS PORT IS IN USE */
diff --git a/Xext/xvmc.c b/Xext/xvmc.c
index ae358936e..7ae8cc0da 100644
--- a/Xext/xvmc.c
+++ b/Xext/xvmc.c
@@ -39,7 +39,7 @@
#define DR_CLIENT_DRIVER_NAME_SIZE 48
#define DR_BUSID_SIZE 48
-int XvMCScreenIndex = -1;
+static DevPrivateKey XvMCScreenKey = NULL;
unsigned long XvMCGeneration = 0;
@@ -63,7 +63,7 @@ typedef struct {
} XvMCScreenRec, *XvMCScreenPtr;
#define XVMC_GET_PRIVATE(pScreen) \
- (XvMCScreenPtr)((pScreen)->devPrivates[XvMCScreenIndex].ptr)
+ (XvMCScreenPtr)(dixLookupPrivate(&(pScreen)->devPrivates, XvMCScreenKey))
static int
@@ -153,7 +153,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
return _XvBadPort;
}
- if(XvMCScreenIndex >= 0) { /* any adaptors at all */
+ if(XvMCScreenKey) { /* any adaptors at all */
ScreenPtr pScreen = pPort->pAdaptor->pScreen;
if((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */
for(i = 0; i < pScreenPriv->num_adaptors; i++) {
@@ -211,7 +211,7 @@ ProcXvMCCreateContext(ClientPtr client)
pScreen = pPort->pAdaptor->pScreen;
- if(XvMCScreenIndex < 0) /* no XvMC adaptors */
+ if(XvMCScreenKey == NULL) /* no XvMC adaptors */
return BadMatch;
if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) /* none this screen */
@@ -494,7 +494,7 @@ ProcXvMCListSubpictureTypes(ClientPtr client)
pScreen = pPort->pAdaptor->pScreen;
- if(XvMCScreenIndex < 0) /* No XvMC adaptors */
+ if(XvMCScreenKey == NULL) /* No XvMC adaptors */
return BadMatch;
if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen)))
@@ -679,7 +679,7 @@ XvMCExtensionInit(void)
{
ExtensionEntry *extEntry;
- if(XvMCScreenIndex < 0) /* nobody supports it */
+ if(XvMCScreenKey == NULL) /* nobody supports it */
return;
if(!(XvMCRTContext = CreateNewResourceType(XvMCDestroyContextRes)))
@@ -720,17 +720,12 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
{
XvMCScreenPtr pScreenPriv;
- if(XvMCGeneration != serverGeneration) {
- if((XvMCScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return BadAlloc;
-
- XvMCGeneration = serverGeneration;
- }
+ XvMCScreenKey = &XvMCScreenKey;
if(!(pScreenPriv = (XvMCScreenPtr)xalloc(sizeof(XvMCScreenRec))))
return BadAlloc;
- pScreen->devPrivates[XvMCScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = XvMCCloseScreen;
@@ -754,7 +749,7 @@ XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id)
XvMCAdaptorPtr adaptor = NULL;
int i;
- if(XvMCScreenIndex < 0) return NULL;
+ if(XvMCScreenKey == NULL) return NULL;
if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen)))
return NULL;
diff --git a/afb/afb.h b/afb/afb.h
index 31ccff9ee..5cfbddfb1 100644
--- a/afb/afb.h
+++ b/afb/afb.h
@@ -60,7 +60,6 @@ SOFTWARE.
#include "mfb.h"
extern int afbInverseAlu[];
-extern int afbScreenPrivateIndex;
/* warning: PixelType definition duplicated in maskbits.h */
#ifndef PixelType
#define PixelType CARD32
@@ -736,14 +735,15 @@ typedef struct {
} afbPrivGC;
typedef afbPrivGC *afbPrivGCPtr;
-extern int afbGCPrivateIndex; /* index into GC private array */
-extern int afbWindowPrivateIndex; /* index into Window private array */
+extern DevPrivateKey afbScreenPrivateKey;
+extern DevPrivateKey afbGCPrivateKey;
+extern DevPrivateKey afbWindowPrivateKey;
#ifdef PIXMAP_PER_WINDOW
-extern int frameWindowPrivateIndex; /* index into Window private array */
+extern DevPrivateKey frameWindowPrivateKey;
#endif
#define afbGetGCPrivate(pGC) \
- ((afbPrivGC *)((pGC)->devPrivates[afbGCPrivateIndex].ptr))
+ ((afbPrivGC *)dixLookupPrivate(&(pGC)->devPrivates, afbGCPrivateKey))
/* private field of window */
typedef struct {
@@ -759,7 +759,7 @@ typedef struct {
#define afbGetTypedWidth(pDrawable,wtype)( \
(((pDrawable)->type == DRAWABLE_WINDOW) ? \
- (int)(((PixmapPtr)((pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr))->devKind) : \
+ (int)(((PixmapPtr)dixLookupPrivate(&(pDrawable)->pScreen->devPrivates, afbScreenPrivateKey)->devKind) : \
(int)(((PixmapPtr)pDrawable)->devKind)) / sizeof (wtype))
#define afbGetByteWidth(pDrawable) afbGetTypedWidth(pDrawable, unsigned char)
@@ -769,7 +769,7 @@ typedef struct {
#define afbGetTypedWidthAndPointer(pDrawable, width, pointer, wtype, ptype) {\
PixmapPtr _pPix; \
if ((pDrawable)->type == DRAWABLE_WINDOW) \
- _pPix = (PixmapPtr)(pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
+ _pPix = (PixmapPtr)dixLookupPrivate(&(pDrawable)->pScreen->devPrivates, afbScreenPrivateKey); \
else \
_pPix = (PixmapPtr)(pDrawable); \
(pointer) = (ptype *) _pPix->devPrivate.ptr; \
@@ -779,7 +779,7 @@ typedef struct {
#define afbGetPixelWidthSizeDepthAndPointer(pDrawable, width, size, dep, pointer) {\
PixmapPtr _pPix; \
if ((pDrawable)->type == DRAWABLE_WINDOW) \
- _pPix = (PixmapPtr)(pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
+ _pPix = (PixmapPtr)dixLookupPrivate(&(pDrawable)->pScreen->devPrivates, afbScreenPrivateKey); \
else \
_pPix = (PixmapPtr)(pDrawable); \
(pointer) = (PixelType *)_pPix->devPrivate.ptr; \
@@ -795,7 +795,7 @@ typedef struct {
afbGetTypedWidthAndPointer(pDrawable, width, pointer, PixelType, PixelType)
#define afbGetWindowTypedWidthAndPointer(pWin, width, pointer, wtype, ptype) {\
- PixmapPtr _pPix = (PixmapPtr)(pWin)->drawable.pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
+ PixmapPtr _pPix = (PixmapPtr)dixLookupPrivate(&(pWin)->drawable.pScreen->devPrivates, afbScreenPrivateKey); \
(pointer) = (ptype *) _pPix->devPrivate.ptr; \
(width) = ((int) _pPix->devKind) / sizeof (wtype); \
}
diff --git a/afb/afbfillarc.c b/afb/afbfillarc.c
index fa685ba9a..cfc3133ee 100644
--- a/afb/afbfillarc.c
+++ b/afb/afbfillarc.c
@@ -321,7 +321,8 @@ afbPolyFillArcSolid(register DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parc
RegionPtr cclip;
unsigned char *rrops;
- priv = (afbPrivGC *) pGC->devPrivates[afbGCPrivateIndex].ptr;
+ priv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
rrops = priv->rrops;
cclip = pGC->pCompositeClip;
for (arc = parcs, i = narcs; --i >= 0; arc++) {
diff --git a/afb/afbfillrct.c b/afb/afbfillrct.c
index 06fb37365..b4936f097 100644
--- a/afb/afbfillrct.c
+++ b/afb/afbfillrct.c
@@ -93,7 +93,8 @@ afbPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *pre
unsigned char *rrops;
unsigned char *rropsOS;
- priv = (afbPrivGC *)pGC->devPrivates[afbGCPrivateIndex].ptr;
+ priv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
prgnClip = pGC->pCompositeClip;
rrops = priv->rrops;
rropsOS = priv->rropOS;
diff --git a/afb/afbfillsp.c b/afb/afbfillsp.c
index 539c3457c..0118b475a 100644
--- a/afb/afbfillsp.c
+++ b/afb/afbfillsp.c
@@ -123,7 +123,8 @@ afbSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
pBase);
- rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
+ rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
while (n--) {
addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
@@ -238,8 +239,8 @@ afbStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
tileHeight = pStipple->drawable.height;
psrc = (PixelType *)(pStipple->devPrivate.ptr);
- rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
-
+ rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
while (n--) {
src = psrc[ppt->y % tileHeight];
addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
@@ -484,8 +485,8 @@ afbOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
tileHeight = pTile->drawable.height;
psrc = (PixelType *)(pTile->devPrivate.ptr);
rop = pGC->alu;
- rropsOS = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rropOS;
-
+ rropsOS = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rropOS;
switch(rop) {
case GXcopy:
while (n--) {
@@ -793,8 +794,8 @@ afbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
tileWidth = pTile->drawable.width;
tileHeight = pTile->drawable.height;
- rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
-
+ rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
/* this replaces rotating the stipple. Instead, we just adjust the offset
* at which we start grabbing bits from the stipple.
* Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
diff --git a/afb/afbgc.c b/afb/afbgc.c
index 59c09e097..1d1fdc58b 100644
--- a/afb/afbgc.c
+++ b/afb/afbgc.c
@@ -154,7 +154,8 @@ afbCreateGC(pGC)
/* afb wants to translate before scan convesion */
pGC->miTranslate = 1;
- pPriv = (afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr);
+ pPriv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
afbReduceRop(pGC->alu, pGC->fgPixel, pGC->planemask, pGC->depth,
pPriv->rrops);
afbReduceOpaqueStipple(pGC->fgPixel, pGC->bgPixel, pGC->planemask,
@@ -295,8 +296,8 @@ afbValidateGC(pGC, changes, pDrawable)
(oldOrg.y != pGC->lastWinOrg.y);
- devPriv = ((afbPrivGCPtr)(pGC->devPrivates[afbGCPrivateIndex].ptr));
-
+ devPriv = (afbPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
/*
if the client clip is different or moved OR
diff --git a/afb/afbimggblt.c b/afb/afbimggblt.c
index de02aa46a..824f918bc 100644
--- a/afb/afbimggblt.c
+++ b/afb/afbimggblt.c
@@ -145,8 +145,8 @@ afbImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
register int nFirst;/* bits of glyph in current longword */
PixelType *pdstSave;
int oldFill;
- afbPrivGC *pPriv = (afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr);
-
+ afbPrivGC *pPriv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
xorg = pDrawable->x;
yorg = pDrawable->y;
afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthDst, sizeDst, depthDst,
diff --git a/afb/afbline.c b/afb/afbline.c
index 9e2e4b9f4..d05675869 100644
--- a/afb/afbline.c
+++ b/afb/afbline.c
@@ -147,7 +147,8 @@ afbLineSS(pDrawable, pGC, mode, npt, pptInit)
RegionPtr cclip;
cclip = pGC->pCompositeClip;
- rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
+ rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
pboxInit = REGION_RECTS(cclip);
nboxInit = REGION_NUM_RECTS(cclip);
@@ -487,7 +488,8 @@ afbLineSD(pDrawable, pGC, mode, npt, pptInit)
#endif
cclip = pGC->pCompositeClip;
- rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
+ rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
pboxInit = REGION_RECTS(cclip);
nboxInit = REGION_NUM_RECTS(cclip);
diff --git a/afb/afbpixmap.c b/afb/afbpixmap.c
index 5a81679e8..5ae50fb70 100644
--- a/afb/afbpixmap.c
+++ b/afb/afbpixmap.c
@@ -113,7 +113,7 @@ afbDestroyPixmap(pPixmap)
{
if(--pPixmap->refcnt)
return(TRUE);
- dixFreePrivates(*DEVPRIV_PTR(pPixmap));
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return(TRUE);
}
diff --git a/afb/afbply1rct.c b/afb/afbply1rct.c
index 86ec174f4..e9d4d5e09 100644
--- a/afb/afbply1rct.c
+++ b/afb/afbply1rct.c
@@ -100,8 +100,8 @@ afbFillPolygonSolid (pDrawable, pGC, shape, mode, count, ptsIn)
int depthDst;
register PixelType *pdst;
- devPriv = (afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr);
-
+ devPriv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
if (mode == CoordModePrevious || shape != Convex ||
REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
diff --git a/afb/afbplygblt.c b/afb/afbplygblt.c
index 289d50e1b..79b269b85 100644
--- a/afb/afbplygblt.c
+++ b/afb/afbplygblt.c
@@ -146,8 +146,8 @@ afbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
bbox.y1 = y - info.overallAscent;
bbox.y2 = y + info.overallDescent;
- rrops = ((afbPrivGCPtr) pGC->devPrivates[afbGCPrivateIndex].ptr)->rrops;
-
+ rrops = ((afbPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) {
case rgnOUT:
break;
diff --git a/afb/afbpntwin.c b/afb/afbpntwin.c
index 6082f7caa..89c4489c4 100644
--- a/afb/afbpntwin.c
+++ b/afb/afbpntwin.c
@@ -57,6 +57,7 @@ SOFTWARE.
#include "regionstr.h"
#include "pixmapstr.h"
#include "scrnintstr.h"
+#include "privates.h"
#include "afb.h"
#include "maskbits.h"
@@ -71,7 +72,8 @@ afbPaintWindow(pWin, pRegion, what)
register afbPrivWin *pPrivWin;
unsigned char rrops[AFB_MAX_DEPTH];
- pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
+ pPrivWin = (afbPrivWin *)dixLookupPrivate(&pWin->devPrivates,
+ afbWindowPrivateKey);
switch (what) {
case PW_BACKGROUND:
diff --git a/afb/afbpolypnt.c b/afb/afbpolypnt.c
index a9d96edfe..b8ea3ed3e 100644
--- a/afb/afbpolypnt.c
+++ b/afb/afbpolypnt.c
@@ -90,8 +90,8 @@ afbPolyPoint(pDrawable, pGC, mode, npt, pptInit)
register unsigned char *rrops;
afbPrivGC *pGCPriv;
- pGCPriv = (afbPrivGC *) pGC->devPrivates[afbGCPrivateIndex].ptr;
-
+ pGCPriv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey);
afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
pBaseSave);
diff --git a/afb/afbscrinit.c b/afb/afbscrinit.c
index 71e8d4c1e..8615d935b 100644
--- a/afb/afbscrinit.c
+++ b/afb/afbscrinit.c
@@ -69,13 +69,11 @@ SOFTWARE.
#include "servermd.h"
#ifdef PIXMAP_PER_WINDOW
-int frameWindowPrivateIndex;
+DevPrivateKey frameWindowPrivateKey = &frameWindowPrivateKey;
#endif
-int afbWindowPrivateIndex;
-int afbGCPrivateIndex;
-int afbScreenPrivateIndex;
-
-static unsigned long afbGeneration = 0;
+DevPrivateKey afbWindowPrivateKey = &afbWindowPrivateKey;
+DevPrivateKey afbGCPrivateKey = &afbGCPrivateKey;
+DevPrivateKey afbScreenPrivateKey = &afbScreenPrivateKey;
static Bool
afbCloseScreen(int index, ScreenPtr pScreen)
@@ -87,7 +85,7 @@ afbCloseScreen(int index, ScreenPtr pScreen)
xfree(depths[d].vids);
xfree(depths);
xfree(pScreen->visuals);
- xfree(pScreen->devPrivates[afbScreenPrivateIndex].ptr);
+ xfree(dixLookupPrivate(&pScreen->devPrivates, afbScreenPrivateKey));
return(TRUE);
}
@@ -98,7 +96,8 @@ afbCreateScreenResources(ScreenPtr pScreen)
pointer oldDevPrivate = pScreen->devPrivate;
- pScreen->devPrivate = pScreen->devPrivates[afbScreenPrivateIndex].ptr;
+ pScreen->devPrivate = dixLookupPrivate(&pScreen->devPrivates,
+ afbScreenPrivateKey);
retval = miCreateScreenResources(pScreen);
/* Modify screen's pixmap devKind value stored off devPrivate to
@@ -106,7 +105,8 @@ afbCreateScreenResources(ScreenPtr pScreen)
* of a chunky screen in longs as incorrectly setup by the mi routine.
*/
((PixmapPtr)pScreen->devPrivate)->devKind = BitmapBytePad(pScreen->width);
- pScreen->devPrivates[afbScreenPrivateIndex].ptr = pScreen->devPrivate;
+ dixSetPrivate(&pScreen->devPrivates, afbScreenPrivateKey,
+ pScreen->devPrivate);
pScreen->devPrivate = oldDevPrivate;
return(retval);
}
@@ -115,7 +115,8 @@ static PixmapPtr
afbGetWindowPixmap(WindowPtr pWin)
{
#ifdef PIXMAP_PER_WINDOW
- return (PixmapPtr)(pWin->devPrivates[frameWindowPrivateIndex].ptr);
+ return (PixmapPtr)dixLookupPrivate(&pWin->devPrivates,
+ frameWindowPrivateKey);
#else
ScreenPtr pScreen = pWin->drawable.pScreen;
@@ -127,33 +128,25 @@ static void
afbSetWindowPixmap(WindowPtr pWin, PixmapPtr pPix)
{
#ifdef PIXMAP_PER_WINDOW
- pWin->devPrivates[frameWindowPrivateIndex].ptr = (pointer)pPix;
+ dixSetPrivate(&pWin->devPrivates, frameWindowPrivateKey, pPix);
#else
(* pWin->drawable.pScreen->SetScreenPixmap)(pPix);
#endif
}
static Bool
-afbAllocatePrivates(ScreenPtr pScreen, int *pWinIndex, int *pGCIndex)
+afbAllocatePrivates(ScreenPtr pScreen,
+ DevPrivateKey *pWinKey, DevPrivateKey *pGCKey)
{
- if (afbGeneration != serverGeneration) {
-#ifdef PIXMAP_PER_WINDOW
- frameWindowPrivateIndex = AllocateWindowPrivateIndex();
-#endif
- afbWindowPrivateIndex = AllocateWindowPrivateIndex();
- afbGCPrivateIndex = AllocateGCPrivateIndex();
- afbGeneration = serverGeneration;
- }
- if (pWinIndex)
- *pWinIndex = afbWindowPrivateIndex;
- if (pGCIndex)
- *pGCIndex = afbGCPrivateIndex;
+ if (pWinKey)
+ *pWinKey = afbWindowPrivateKey;
+ if (pGCKey)
+ *pGCKey = afbGCPrivateKey;
- afbScreenPrivateIndex = AllocateScreenPrivateIndex();
pScreen->GetWindowPixmap = afbGetWindowPixmap;
pScreen->SetWindowPixmap = afbSetWindowPixmap;
- return(AllocateWindowPrivate(pScreen, afbWindowPrivateIndex, sizeof(afbPrivWin)) &&
- AllocateGCPrivate(pScreen, afbGCPrivateIndex, sizeof(afbPrivGC)));
+ return(dixRequestPrivate(afbWindowPrivateKey, sizeof(afbPrivWin)) &&
+ dixRequestPrivate(afbGCPrivateKey, sizeof(afbPrivGC)));
}
/* dts * (inch/dot) * (25.4 mm / inch) = mm */
@@ -179,7 +172,7 @@ afbScreenInit(register ScreenPtr pScreen, pointer pbits, int xsize, int ysize, i
ErrorF("afbInitVisuals: FALSE\n");
return FALSE;
}
- if (!afbAllocatePrivates(pScreen,(int *)NULL, (int *)NULL)) {
+ if (!afbAllocatePrivates(pScreen, NULL, NULL)) {
ErrorF("afbAllocatePrivates: FALSE\n");
return FALSE;
}
@@ -224,7 +217,8 @@ afbScreenInit(register ScreenPtr pScreen, pointer pbits, int xsize, int ysize, i
pScreen->CloseScreen = afbCloseScreen;
pScreen->CreateScreenResources = afbCreateScreenResources;
- pScreen->devPrivates[afbScreenPrivateIndex].ptr = pScreen->devPrivate;
+ dixSetPrivate(&pScreen->devPrivates, afbScreenPrivateKey,
+ pScreen->devPrivate);
pScreen->devPrivate = oldDevPrivate;
return TRUE;
diff --git a/afb/afbtegblt.c b/afb/afbtegblt.c
index ba889cb80..c89b23a5d 100644
--- a/afb/afbtegblt.c
+++ b/afb/afbtegblt.c
@@ -261,8 +261,8 @@ afbTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
xpos += FONTMAXBOUNDS(pfont,leftSideBearing);
ypos -= FONTASCENT(pfont);
- rrops = ((afbPrivGCPtr) pGC->devPrivates[afbGCPrivateIndex].ptr)->rropOS;
-
+ rrops = ((afbPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rropOS;
bbox.x1 = xpos;
bbox.x2 = xpos + (widthGlyph * nglyph);
bbox.y1 = ypos;
diff --git a/afb/afbwindow.c b/afb/afbwindow.c
index a4a1602bc..1d99fe14d 100644
--- a/afb/afbwindow.c
+++ b/afb/afbwindow.c
@@ -56,6 +56,7 @@ SOFTWARE.
#include <X11/X.h>
#include "scrnintstr.h"
#include "windowstr.h"
+#include "privates.h"
#include "afb.h"
#include "mistruct.h"
#include "regionstr.h"
@@ -67,14 +68,16 @@ afbCreateWindow(pWin)
{
register afbPrivWin *pPrivWin;
- pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
+ pPrivWin = (afbPrivWin *)dixLookupPrivate(&pWin->devPrivates,
+ afbWindowPrivateKey);
pPrivWin->pRotatedBorder = NullPixmap;
pPrivWin->pRotatedBackground = NullPixmap;
pPrivWin->fastBackground = FALSE;
pPrivWin->fastBorder = FALSE;
#ifdef PIXMAP_PER_WINDOW
- pWin->devPrivates[frameWindowPrivateIndex].ptr =
- pWin->pDrawable.pScreen->devPrivates[afbScreenPrivateIndex].ptr;
+ dixSetPrivate(&pWin->devPrivates, frameWindowPrivateKey,
+ dixLookupPrivate(&pWin->pDrawable.pScreen->devPrivates,
+ afbScreenPrivateKey));
#endif
return (TRUE);
@@ -88,8 +91,8 @@ afbDestroyWindow(pWin)
{
register afbPrivWin *pPrivWin;
- pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
-
+ pPrivWin = (afbPrivWin *)dixLookupPrivate(&pWin->devPrivates,
+ afbWindowPrivateKey);
if (pPrivWin->pRotatedBorder)
(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
if (pPrivWin->pRotatedBackground)
@@ -123,7 +126,8 @@ afbPositionWindow(pWin, x, y)
register afbPrivWin *pPrivWin;
int reset = 0;
- pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
+ pPrivWin = (afbPrivWin *)dixLookupPrivate(&pWin->devPrivates,
+ afbWindowPrivateKey);
if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground) {
afbXRotatePixmap(pPrivWin->pRotatedBackground,
pWin->drawable.x - pPrivWin->oldRotate.x);
@@ -230,7 +234,8 @@ afbChangeWindowAttributes(pWin, mask)
register afbPrivWin *pPrivWin;
WindowPtr pBgWin;
- pPrivWin = (afbPrivWin *)(pWin->devPrivates[afbWindowPrivateIndex].ptr);
+ pPrivWin = (afbPrivWin *)dixLookupPrivate(&pWin->devPrivates,
+ afbWindowPrivateKey);
/*
* When background state changes from ParentRelative and
* we had previously rotated the fast border pixmap to match
diff --git a/afb/afbzerarc.c b/afb/afbzerarc.c
index 2cc30687f..e53488e02 100644
--- a/afb/afbzerarc.c
+++ b/afb/afbzerarc.c
@@ -96,8 +96,8 @@ afbZeroArcSS(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
register PixelType *paddr;
register unsigned char *rrops;
- rrops = ((afbPrivGC *)(pGC->devPrivates[afbGCPrivateIndex].ptr))->rrops;
-
+ rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ afbGCPrivateKey))->rrops;
afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
addrl);
do360 = miZeroArcSetup(arc, &info, TRUE);
diff --git a/cfb/cfb.h b/cfb/cfb.h
index 3c165ff1d..44d4ad0fd 100644
--- a/cfb/cfb.h
+++ b/cfb/cfb.h
@@ -56,8 +56,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
pixmap.devKind = width_of_pixmap_in_bytes
*/
-extern int cfbGCPrivateIndex;
-extern int cfbWindowPrivateIndex;
+extern DevPrivateKey cfbGCPrivateKey;
+extern DevPrivateKey cfbWindowPrivateKey;
/* private field of GC */
typedef struct {
@@ -72,7 +72,7 @@ typedef struct {
typedef cfbPrivGC *cfbPrivGCPtr;
#define cfbGetGCPrivate(pGC) ((cfbPrivGCPtr)\
- (pGC)->devPrivates[cfbGCPrivateIndex].ptr)
+ dixLookupPrivate(&(pGC)->devPrivates, cfbGCPrivateKey))
#define cfbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
@@ -93,7 +93,7 @@ typedef struct {
} cfbPrivWin;
#define cfbGetWindowPrivate(_pWin) ((cfbPrivWin *)\
- (_pWin)->devPrivates[cfbWindowPrivateIndex].ptr)
+ dixLookupPrivate(&(_pWin)->devPrivates, cfbWindowPrivateKey))
/* cfb8bit.c */
@@ -314,8 +314,8 @@ extern int cfb8SegmentSS1RectXor(
extern Bool cfbAllocatePrivates(
ScreenPtr /*pScreen*/,
- int * /*window_index*/,
- int * /*gc_index*/
+ DevPrivateKey * /*window_key*/,
+ DevPrivateKey * /*gc_key*/
);
/* cfbbitblt.c */
@@ -1230,7 +1230,7 @@ extern void cfbZeroPolyArcSS8Xor(
#define CFB_NEED_SCREEN_PRIVATE
-extern int cfbScreenPrivateIndex;
+extern DevPrivateKey cfbScreenPrivateKey;
#endif
#ifndef CFB_PROTOTYPES_ONLY
diff --git a/cfb/cfballpriv.c b/cfb/cfballpriv.c
index e0ccdf4d0..e6ab93a87 100644
--- a/cfb/cfballpriv.c
+++ b/cfb/cfballpriv.c
@@ -45,48 +45,37 @@ in this Software without prior written authorization from The Open Group.
#include "mibstore.h"
#if 1 || PSZ==8
-int cfbWindowPrivateIndex = -1;
-int cfbGCPrivateIndex = -1;
+DevPrivateKey cfbWindowPrivateKey = &cfbWindowPrivateKey;
+DevPrivateKey cfbGCPrivateKey = &cfbGCPrivateKey;
#endif
#ifdef CFB_NEED_SCREEN_PRIVATE
-int cfbScreenPrivateIndex = -1;
-static unsigned long cfbGeneration = 0;
+DevPrivateKey cfbScreenPrivateKey = &cfbScreenPrivateKey;
#endif
Bool
-cfbAllocatePrivates(pScreen, window_index, gc_index)
+cfbAllocatePrivates(pScreen, window_key, gc_key)
ScreenPtr pScreen;
- int *window_index, *gc_index;
+ DevPrivateKey *window_key, *gc_key;
{
- if (!window_index || !gc_index ||
- (*window_index == -1 && *gc_index == -1))
+ if (!window_key || !gc_key || (!*window_key && !*gc_key))
{
if (!mfbAllocatePrivates(pScreen,
- &cfbWindowPrivateIndex, &cfbGCPrivateIndex))
+ &cfbWindowPrivateKey, &cfbGCPrivateKey))
return FALSE;
- if (window_index)
- *window_index = cfbWindowPrivateIndex;
- if (gc_index)
- *gc_index = cfbGCPrivateIndex;
+ if (window_key)
+ *window_key = cfbWindowPrivateKey;
+ if (gc_key)
+ *gc_key = cfbGCPrivateKey;
}
else
{
- cfbWindowPrivateIndex = *window_index;
- cfbGCPrivateIndex = *gc_index;
+ cfbWindowPrivateKey = *window_key;
+ cfbGCPrivateKey = *gc_key;
}
- if (!AllocateWindowPrivate(pScreen, cfbWindowPrivateIndex,
- sizeof(cfbPrivWin)) ||
- !AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
+ if (!dixRequestPrivate(cfbWindowPrivateKey, sizeof(cfbPrivWin)))
return FALSE;
-#ifdef CFB_NEED_SCREEN_PRIVATE
- if (cfbGeneration != serverGeneration)
- {
- cfbScreenPrivateIndex = AllocateScreenPrivateIndex ();
- cfbGeneration = serverGeneration;
- }
- if (cfbScreenPrivateIndex == -1)
+ if (!dixRequestPrivate(cfbGCPrivateKey, sizeof(cfbPrivGC)))
return FALSE;
-#endif
return TRUE;
}
diff --git a/cfb/cfbpixmap.c b/cfb/cfbpixmap.c
index ed01316ed..247331c6d 100644
--- a/cfb/cfbpixmap.c
+++ b/cfb/cfbpixmap.c
@@ -107,7 +107,7 @@ cfbDestroyPixmap(pPixmap)
{
if(--pPixmap->refcnt)
return TRUE;
- dixFreePrivates(*DEVPRIV_PTR(pPixmap));
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return TRUE;
}
diff --git a/cfb/cfbrrop.h b/cfb/cfbrrop.h
index eeb373a5e..e9ca881be 100644
--- a/cfb/cfbrrop.h
+++ b/cfb/cfbrrop.h
@@ -35,7 +35,8 @@ in this Software without prior written authorization from The Open Group.
#endif
#define RROP_FETCH_GC(gc) \
- RROP_FETCH_GCPRIV(((cfbPrivGCPtr)(gc)->devPrivates[cfbGCPrivateIndex].ptr))
+ RROP_FETCH_GCPRIV((cfbPrivGCPtr)dixLookupPrivate(&(gc)->devPrivates, \
+ cfbGCPrivateKey))
#ifndef RROP
#define RROP GXset
diff --git a/cfb/cfbscrinit.c b/cfb/cfbscrinit.c
index 83f5cf0a2..48e363971 100644
--- a/cfb/cfbscrinit.c
+++ b/cfb/cfbscrinit.c
@@ -59,7 +59,7 @@ cfbCloseScreen (index, pScreen)
xfree (depths);
xfree (pScreen->visuals);
#ifdef CFB_NEED_SCREEN_PRIVATE
- xfree (pScreen->devPrivates[cfbScreenPrivateIndex].ptr);
+ xfree (dixLookupPrivate(&pScreen->devPrivates, cfbScreenPrivateKey));
#else
xfree (pScreen->devPrivate);
#endif
@@ -88,7 +88,7 @@ cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
int dpix, dpiy; /* dots per inch */
int width; /* pixel width of frame buffer */
{
- if (!cfbAllocatePrivates(pScreen, (int *) 0, (int *) 0))
+ if (!cfbAllocatePrivates(pScreen, NULL, NULL))
return FALSE;
pScreen->defColormap = FakeClientID(0);
/* let CreateDefColormap do whatever it wants for pixels */
@@ -132,9 +132,11 @@ cfbCreateScreenResources(pScreen)
Bool retval;
pointer oldDevPrivate = pScreen->devPrivate;
- pScreen->devPrivate = pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
+ pScreen->devPrivate = dixLookupPrivate(&pScreen->devPrivates,
+ cfbScreenPrivateKey);
retval = miCreateScreenResources(pScreen);
- pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
+ dixSetPrivate(&pScreen->devPrivates, cfbScreenPrivateKey,
+ pScreen->devPrivate);
pScreen->devPrivate = oldDevPrivate;
return retval;
}
@@ -173,7 +175,8 @@ cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
pScreen->CloseScreen = cfbCloseScreen;
#ifdef CFB_NEED_SCREEN_PRIVATE
pScreen->CreateScreenResources = cfbCreateScreenResources;
- pScreen->devPrivates[cfbScreenPrivateIndex].ptr = pScreen->devPrivate;
+ dixSetPrivate(&pScreen->devPrivates, cfbScreenPrivateKey,
+ pScreen->devPrivate);
pScreen->devPrivate = oldDevPrivate;
#endif
pScreen->GetScreenPixmap = cfbGetScreenPixmap;
@@ -200,7 +203,8 @@ cfbGetScreenPixmap(pScreen)
ScreenPtr pScreen;
{
#ifdef CFB_NEED_SCREEN_PRIVATE
- return (PixmapPtr)pScreen->devPrivates[cfbScreenPrivateIndex].ptr;
+ return (PixmapPtr)dixLookupPrivate(&pScreen->devPrivates,
+ cfbScreenPrivateKey);
#else
return (PixmapPtr)pScreen->devPrivate;
#endif
@@ -212,8 +216,8 @@ cfbSetScreenPixmap(pPix)
{
#ifdef CFB_NEED_SCREEN_PRIVATE
if (pPix)
- pPix->drawable.pScreen->devPrivates[cfbScreenPrivateIndex].ptr =
- (pointer)pPix;
+ dixSetPrivate(&pPix->drawable.pScreen->devPrivates,
+ cfbScreenPrivateKey, pPix);
#else
if (pPix)
pPix->drawable.pScreen->devPrivate = (pointer)pPix;
diff --git a/cfb/cfbwindow.c b/cfb/cfbwindow.c
index e04b73df2..49cc6f079 100644
--- a/cfb/cfbwindow.c
+++ b/cfb/cfbwindow.c
@@ -75,8 +75,8 @@ cfbCreateWindow(pWin)
#ifdef PIXMAP_PER_WINDOW
/* Setup pointer to Screen pixmap */
- pWin->devPrivates[frameWindowPrivateIndex].ptr =
- (pointer) cfbGetScreenPixmap(pWin->drawable.pScreen);
+ dixSetPrivate(&pWin->devPrivates, frameWindowPrivateKey,
+ cfbGetScreenPixmap(pWin->drawable.pScreen));
#endif
return TRUE;
@@ -213,7 +213,7 @@ cfbCopyWindow(pWin, ptOldOrg, prgnSrc)
/* swap in correct PaintWindow* routine. If we can use a fast output
routine (i.e. the pixmap is paddable to 32 bits), also pre-rotate a copy
-of it in devPrivates[cfbWindowPrivateIndex].ptr.
+of it in devPrivates under cfbWindowPrivateKey.
*/
Bool
cfbChangeWindowAttributes(pWin, mask)
diff --git a/composite/compalloc.c b/composite/compalloc.c
index f555411bf..dbb7f3a05 100644
--- a/composite/compalloc.c
+++ b/composite/compalloc.c
@@ -137,7 +137,7 @@ compRedirectWindow (ClientPtr pClient, WindowPtr pWin, int update)
cw->oldy = COMP_ORIGIN_INVALID;
cw->damageRegistered = FALSE;
cw->damaged = FALSE;
- pWin->devPrivates[CompWindowPrivateIndex].ptr = cw;
+ dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, cw);
}
ccw->next = cw->clients;
cw->clients = ccw;
@@ -212,7 +212,7 @@ compFreeClientWindow (WindowPtr pWin, XID id)
REGION_UNINIT (pScreen, &cw->borderClip);
- pWin->devPrivates[CompWindowPrivateIndex].ptr = 0;
+ dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, NULL);
xfree (cw);
}
else if (cw->update == CompositeRedirectAutomatic &&
@@ -297,7 +297,7 @@ compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
}
csw->update = CompositeRedirectAutomatic;
csw->clients = 0;
- pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = csw;
+ dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, csw);
}
/*
* Redirect all existing windows
@@ -312,7 +312,7 @@ compRedirectSubwindows (ClientPtr pClient, WindowPtr pWin, int update)
if (!csw->clients)
{
xfree (csw);
- pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = 0;
+ dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, 0);
}
xfree (ccw);
return ret;
@@ -385,7 +385,7 @@ compFreeClientSubwindows (WindowPtr pWin, XID id)
*/
if (!csw->clients)
{
- pWin->devPrivates[CompSubwindowsPrivateIndex].ptr = 0;
+ dixSetPrivate(&pWin->devPrivates, CompSubwindowsPrivateKey, NULL);
xfree (csw);
}
}
diff --git a/composite/compext.c b/composite/compext.c
index 944f8d844..8d2a2d790 100644
--- a/composite/compext.c
+++ b/composite/compext.c
@@ -50,7 +50,7 @@
#define SERVER_COMPOSITE_MINOR 4
static CARD8 CompositeReqCode;
-static int CompositeClientPrivateIndex;
+static DevPrivateKey CompositeClientPrivateKey = &CompositeClientPrivateKey;
RESTYPE CompositeClientWindowType;
RESTYPE CompositeClientSubwindowsType;
static RESTYPE CompositeClientOverlayType;
@@ -63,7 +63,8 @@ typedef struct _CompositeClient {
int minor_version;
} CompositeClientRec, *CompositeClientPtr;
-#define GetCompositeClient(pClient) ((CompositeClientPtr) (pClient)->devPrivates[CompositeClientPrivateIndex].ptr)
+#define GetCompositeClient(pClient) ((CompositeClientPtr) \
+ dixLookupPrivate(&(pClient)->devPrivates, CompositeClientPrivateKey))
static void
CompositeClientCallback (CallbackListPtr *list,
@@ -712,9 +713,8 @@ CompositeExtensionInit (void)
if (!CompositeClientOverlayType)
return;
- CompositeClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (CompositeClientPrivateIndex,
- sizeof (CompositeClientRec)))
+ if (!dixRequestPrivate(CompositeClientPrivateKey,
+ sizeof(CompositeClientRec)))
return;
if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0))
return;
diff --git a/composite/compinit.c b/composite/compinit.c
index c557eebc4..757d92913 100644
--- a/composite/compinit.c
+++ b/composite/compinit.c
@@ -46,10 +46,9 @@
#include "compint.h"
-int CompScreenPrivateIndex;
-int CompWindowPrivateIndex;
-int CompSubwindowsPrivateIndex;
-static int CompGeneration;
+DevPrivateKey CompScreenPrivateKey = &CompScreenPrivateKey;
+DevPrivateKey CompWindowPrivateKey = &CompWindowPrivateKey;
+DevPrivateKey CompSubwindowsPrivateKey = &CompSubwindowsPrivateKey;
static Bool
@@ -87,7 +86,7 @@ compCloseScreen (int index, ScreenPtr pScreen)
cs->pOverlayWin = NULL;
xfree (cs);
- pScreen->devPrivates[CompScreenPrivateIndex].ptr = 0;
+ dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, NULL);
ret = (*pScreen->CloseScreen) (index, pScreen);
return ret;
@@ -375,25 +374,6 @@ compScreenInit (ScreenPtr pScreen)
{
CompScreenPtr cs;
- if (CompGeneration != serverGeneration)
- {
- CompScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (CompScreenPrivateIndex == -1)
- return FALSE;
- CompWindowPrivateIndex = AllocateWindowPrivateIndex ();
- if (CompWindowPrivateIndex == -1)
- return FALSE;
- CompSubwindowsPrivateIndex = AllocateWindowPrivateIndex ();
- if (CompSubwindowsPrivateIndex == -1)
- return FALSE;
- CompGeneration = serverGeneration;
- }
- if (!AllocateWindowPrivate (pScreen, CompWindowPrivateIndex, 0))
- return FALSE;
-
- if (!AllocateWindowPrivate (pScreen, CompSubwindowsPrivateIndex, 0))
- return FALSE;
-
if (GetCompScreen (pScreen))
return TRUE;
cs = (CompScreenPtr) xalloc (sizeof (CompScreenRec));
@@ -461,7 +441,7 @@ compScreenInit (ScreenPtr pScreen)
cs->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = compCloseScreen;
- pScreen->devPrivates[CompScreenPrivateIndex].ptr = (pointer) cs;
+ dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, cs);
RegisterRealChildHeadProc(CompositeRealChildHead);
diff --git a/composite/compint.h b/composite/compint.h
index 38b1777a2..79699e4c1 100644
--- a/composite/compint.h
+++ b/composite/compint.h
@@ -64,6 +64,7 @@
#include "globals.h"
#include "picturestr.h"
#include "extnsionst.h"
+#include "privates.h"
#include "mi.h"
#include "damage.h"
#include "damageextint.h"
@@ -159,13 +160,16 @@ typedef struct _CompScreen {
} CompScreenRec, *CompScreenPtr;
-extern int CompScreenPrivateIndex;
-extern int CompWindowPrivateIndex;
-extern int CompSubwindowsPrivateIndex;
+extern DevPrivateKey CompScreenPrivateKey;
+extern DevPrivateKey CompWindowPrivateKey;
+extern DevPrivateKey CompSubwindowsPrivateKey;
-#define GetCompScreen(s) ((CompScreenPtr) ((s)->devPrivates[CompScreenPrivateIndex].ptr))
-#define GetCompWindow(w) ((CompWindowPtr) ((w)->devPrivates[CompWindowPrivateIndex].ptr))
-#define GetCompSubwindows(w) ((CompSubwindowsPtr) ((w)->devPrivates[CompSubwindowsPrivateIndex].ptr))
+#define GetCompScreen(s) ((CompScreenPtr) \
+ dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey))
+#define GetCompWindow(w) ((CompWindowPtr) \
+ dixLookupPrivate(&(w)->devPrivates, CompWindowPrivateKey))
+#define GetCompSubwindows(w) ((CompSubwindowsPtr) \
+ dixLookupPrivate(&(w)->devPrivates, CompSubwindowsPrivateKey))
extern RESTYPE CompositeClientWindowType;
extern RESTYPE CompositeClientSubwindowsType;
diff --git a/configure.ac b/configure.ac
index 8ed2ef8bf..43bc357e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1027,7 +1027,6 @@ AC_DEFINE(XTEST, 1, [Support XTest extension])
AC_DEFINE(XSYNC, 1, [Support XSync extension])
AC_DEFINE(XCMISC, 1, [Support XCMisc extension])
AC_DEFINE(BIGREQS, 1, [Support BigRequests extension])
-AC_DEFINE(PIXPRIV, 1, [Support pixmap privates])
if test "x$WDTRACE" != "xno" ; then
DIX_LIB='$(top_builddir)/dix/dix.O'
diff --git a/damageext/damageext.c b/damageext/damageext.c
index e1724ecc7..159746536 100755
--- a/damageext/damageext.c
+++ b/damageext/damageext.c
@@ -29,7 +29,7 @@
static unsigned char DamageReqCode;
static int DamageEventBase;
static int DamageErrorBase;
-static int DamageClientPrivateIndex;
+static DevPrivateKey DamageClientPrivateKey = &DamageClientPrivateKey;
static RESTYPE DamageExtType;
static RESTYPE DamageExtWinType;
@@ -511,9 +511,7 @@ DamageExtensionInit(void)
if (!DamageExtWinType)
return;
- DamageClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (DamageClientPrivateIndex,
- sizeof (DamageClientRec)))
+ if (!dixRequestPrivate(DamageClientPrivateKey, sizeof (DamageClientRec)))
return;
if (!AddCallback (&ClientStateCallback, DamageClientCallback, 0))
return;
diff --git a/damageext/damageextint.h b/damageext/damageextint.h
index dfafc9319..e06f28c4e 100644
--- a/damageext/damageextint.h
+++ b/damageext/damageextint.h
@@ -48,7 +48,7 @@ typedef struct _DamageClient {
int critical;
} DamageClientRec, *DamageClientPtr;
-#define GetDamageClient(pClient) ((DamageClientPtr) (pClient)->devPrivates[DamageClientPrivateIndex].ptr)
+#define GetDamageClient(pClient) ((DamageClientPtr)dixLookupPrivate(&(pClient)->devPrivates, DamageClientPrivateKey))
typedef struct _DamageExt {
DamagePtr pDamage;
diff --git a/dbe/dbe.c b/dbe/dbe.c
index aec626b79..223b0c983 100644
--- a/dbe/dbe.c
+++ b/dbe/dbe.c
@@ -58,19 +58,16 @@
/* GLOBALS */
/* Per-screen initialization functions [init'ed by DbeRegisterFunction()] */
-static Bool (* DbeInitFunct[MAXSCREENS])(); /* pScreen, pDbeScreenPriv */
+static Bool (* DbeInitFunct[MAXSCREENS])(); /* pScreen, pDbeScreenPriv */
/* These are static globals copied to DBE's screen private for use by DDX */
-static int dbeScreenPrivIndex;
-static int dbeWindowPrivIndex;
+static DevPrivateKey dbeScreenPrivKey = &dbeScreenPrivKey;
+static DevPrivateKey dbeWindowPrivKey = &dbeWindowPrivKey;
/* These are static globals copied to DBE's screen private for use by DDX */
static RESTYPE dbeDrawableResType;
static RESTYPE dbeWindowPrivResType;
-/* This global is used by DbeAllocWinPrivPrivIndex() */
-static int winPrivPrivCount = 0;
-
/* Used to generate DBE's BadBuffer error. */
static int dbeErrorBase;
@@ -115,146 +112,6 @@ DbeRegisterFunction(ScreenPtr pScreen, Bool (*funct) (/* ??? */))
/******************************************************************************
*
- * DBE DIX Procedure: DbeAllocWinPriv
- *
- * Description:
- *
- * This function was cloned from AllocateWindow() in window.c.
- * This function allocates a window priv structure to be associated
- * with a double-buffered window.
- *
- *****************************************************************************/
-static DbeWindowPrivPtr
-DbeAllocWinPriv(ScreenPtr pScreen)
-{
- DbeWindowPrivPtr pDbeWindowPriv;
- DbeScreenPrivPtr pDbeScreenPriv;
- register char *ptr;
- register DevUnion *ppriv;
- register unsigned int *sizes;
- register unsigned int size;
- register int i;
-
- pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
- pDbeWindowPriv = (DbeWindowPrivPtr)xalloc(pDbeScreenPriv->totalWinPrivSize);
-
- if (pDbeWindowPriv)
- {
- ppriv = (DevUnion *)(pDbeWindowPriv + 1);
- pDbeWindowPriv->devPrivates = ppriv;
- sizes = pDbeScreenPriv->winPrivPrivSizes;
- ptr = (char *)(ppriv + pDbeScreenPriv->winPrivPrivLen);
- for (i = pDbeScreenPriv->winPrivPrivLen; --i >= 0; ppriv++, sizes++)
- {
- if ((size = *sizes))
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
- }
-
- return(pDbeWindowPriv);
-
-} /* DbeAllocWinPriv() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: DbeFallbackAllocWinPriv
- *
- * Description:
- *
- * This is a fallback function for AllocWinPriv().
- *
- *****************************************************************************/
-
-#if 0 /* NOT USED */
-static DbeWindowPrivPtr
-DbeFallbackAllocWinPriv(pScreen)
- ScreenPtr pScreen;
-{
- return (NULL);
-} /* DbeFallbackAllocWinPriv() */
-#endif
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: DbeAllocWinPrivPrivIndex
- *
- * Description:
- *
- * This function was cloned from AllocateWindowPrivateIndex() in window.c.
- * This function allocates a new window priv priv index by simply returning
- * an incremented private counter.
- *
- *****************************************************************************/
-
-static int
-DbeAllocWinPrivPrivIndex(void)
-{
- return winPrivPrivCount++;
-
-} /* DbeAllocWinPrivPrivIndex() */
-
-
-/******************************************************************************
- *
- * DBE DIX Procedure: DbeAllocWinPrivPriv
- *
- * Description:
- *
- * This function was cloned from AllocateWindowPrivate() in privates.c.
- * This function allocates a private structure to be hung off
- * a window private.
- *
- *****************************************************************************/
-
-static Bool
-DbeAllocWinPrivPriv(register ScreenPtr pScreen, int index, unsigned int amount)
-{
- DbeScreenPrivPtr pDbeScreenPriv;
- unsigned int oldamount;
-
-
- pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
-
- if (index >= pDbeScreenPriv->winPrivPrivLen)
- {
- unsigned *nsizes;
- nsizes = (unsigned *)xrealloc(pDbeScreenPriv->winPrivPrivSizes,
- (index + 1) * sizeof(unsigned));
- if (!nsizes)
- {
- return(FALSE);
- }
-
- while (pDbeScreenPriv->winPrivPrivLen <= index)
- {
- nsizes[pDbeScreenPriv->winPrivPrivLen++] = 0;
- pDbeScreenPriv->totalWinPrivSize += sizeof(DevUnion);
- }
-
- pDbeScreenPriv->winPrivPrivSizes = nsizes;
- }
-
- oldamount = pDbeScreenPriv->winPrivPrivSizes[index];
-
- if (amount > oldamount)
- {
- pDbeScreenPriv->winPrivPrivSizes[index] = amount;
- pDbeScreenPriv->totalWinPrivSize += (amount - oldamount);
- }
- return(TRUE);
-
-} /* DbeAllocWinPrivPriv() */
-
-
-/******************************************************************************
- *
* DBE DIX Procedure: DbeStubScreen
*
* Description:
@@ -269,9 +126,6 @@ DbeStubScreen(DbeScreenPrivPtr pDbeScreenPriv, int *nStubbedScreens)
{
/* Stub DIX. */
pDbeScreenPriv->SetupBackgroundPainter = NULL;
- pDbeScreenPriv->AllocWinPriv = NULL;
- pDbeScreenPriv->AllocWinPrivPrivIndex = NULL;
- pDbeScreenPriv->AllocWinPrivPriv = NULL;
/* Do not unwrap PositionWindow nor DestroyWindow. If the DDX
* initialization function failed, we assume that it did not wrap
@@ -439,11 +293,10 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
* Allocate a window priv.
*/
- if (!(pDbeWindowPriv =
- (*pDbeScreenPriv->AllocWinPriv)(pWin->drawable.pScreen)))
- {
+ pDbeWindowPriv = (DbeWindowPrivPtr)xalloc(sizeof(DbeWindowPrivRec));
+ if (!pDbeWindowPriv)
return(BadAlloc);
- }
+ bzero(pDbeWindowPriv, sizeof(DbeWindowPrivRec));
/* Make the window priv a DBE window priv resource. */
if (!AddResource(stuff->buffer, dbeWindowPrivResType,
@@ -474,7 +327,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
/* Actually connect the window priv to the window. */
- pWin->devPrivates[dbeWindowPrivIndex].ptr = (pointer)pDbeWindowPriv;
+ dixSetPrivate(&pWin->devPrivates, dbeWindowPrivKey, pDbeWindowPriv);
} /* if -- There is no buffer associated with the window. */
@@ -1592,10 +1445,11 @@ DbeWindowPrivDelete(pointer pDbeWinPriv, XID id)
if (pDbeWindowPriv->nBufferIDs == 0)
{
/* Reset the DBE window priv pointer. */
- pDbeWindowPriv->pWindow->devPrivates[dbeWindowPrivIndex].ptr =
- (pointer)NULL;
+ dixSetPrivate(&pDbeWindowPriv->pWindow->devPrivates, dbeWindowPrivKey,
+ NULL);
/* We are done with the window priv. */
+ dixFreePrivates(pDbeWindowPriv->devPrivates);
xfree(pDbeWindowPriv);
}
@@ -1622,12 +1476,6 @@ DbeResetProc(ExtensionEntry *extEntry)
ScreenPtr pScreen;
DbeScreenPrivPtr pDbeScreenPriv;
-
- if (dbeScreenPrivIndex < 0)
- {
- return;
- }
-
for (i = 0; i < screenInfo.numScreens; i++)
{
pScreen = screenInfo.screens[i];
@@ -1641,11 +1489,7 @@ DbeResetProc(ExtensionEntry *extEntry)
if (pDbeScreenPriv->ResetProc)
(*pDbeScreenPriv->ResetProc)(pScreen);
- if (pDbeScreenPriv->winPrivPrivSizes)
- {
- xfree(pDbeScreenPriv->winPrivPrivSizes);
- }
-
+ dixFreePrivates(pDbeScreenPriv->devPrivates);
xfree(pDbeScreenPriv);
}
}
@@ -1766,21 +1610,6 @@ DbeExtensionInit(void)
if(!noPanoramiXExtension) return;
#endif
- /* Allocate private pointers in windows and screens. */
-
- if ((dbeScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
- {
- return;
- }
-
- if ((dbeWindowPrivIndex = AllocateWindowPrivateIndex()) < 0)
- {
- return;
- }
-
- /* Initialize the priv priv counts between server generations. */
- winPrivPrivCount = 0;
-
/* Create the resource types. */
dbeDrawableResType =
CreateNewResourceType(DbeDrawableDelete) | RC_DRAWABLE;
@@ -1795,8 +1624,7 @@ DbeExtensionInit(void)
pScreen = screenInfo.screens[i];
- if (!AllocateWindowPrivate(pScreen, dbeWindowPrivIndex, 0) ||
- !(pDbeScreenPriv =
+ if (!(pDbeScreenPriv =
(DbeScreenPrivPtr)Xcalloc(sizeof(DbeScreenPrivRec))))
{
/* If we can not alloc a window or screen private,
@@ -1805,28 +1633,23 @@ DbeExtensionInit(void)
for (j = 0; j < i; j++)
{
- xfree(screenInfo.screens[j]->devPrivates[dbeScreenPrivIndex].ptr);
- screenInfo.screens[j]->devPrivates[dbeScreenPrivIndex].ptr = NULL;
+ xfree(dixLookupPrivate(&screenInfo.screens[j]->devPrivates,
+ dbeScreenPrivKey));
+ dixSetPrivate(&screenInfo.screens[j]->devPrivates,
+ dbeScreenPrivKey, NULL);
}
return;
}
- pScreen->devPrivates[dbeScreenPrivIndex].ptr = (pointer)pDbeScreenPriv;
-
- /* Store the DBE priv priv size info for later use when allocating
- * priv privs at the driver level.
- */
- pDbeScreenPriv->winPrivPrivLen = 0;
- pDbeScreenPriv->winPrivPrivSizes = (unsigned *)NULL;
- pDbeScreenPriv->totalWinPrivSize = sizeof(DbeWindowPrivRec);
+ dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, pDbeScreenPriv);
/* Copy the resource types */
pDbeScreenPriv->dbeDrawableResType = dbeDrawableResType;
pDbeScreenPriv->dbeWindowPrivResType = dbeWindowPrivResType;
/* Copy the private indices */
- pDbeScreenPriv->dbeScreenPrivIndex = dbeScreenPrivIndex;
- pDbeScreenPriv->dbeWindowPrivIndex = dbeWindowPrivIndex;
+ pDbeScreenPriv->dbeScreenPrivKey = dbeScreenPrivKey;
+ pDbeScreenPriv->dbeWindowPrivKey = dbeWindowPrivKey;
if(DbeInitFunct[i])
{
@@ -1834,9 +1657,6 @@ DbeExtensionInit(void)
/* Setup DIX. */
pDbeScreenPriv->SetupBackgroundPainter = DbeSetupBackgroundPainter;
- pDbeScreenPriv->AllocWinPriv = DbeAllocWinPriv;
- pDbeScreenPriv->AllocWinPrivPrivIndex = DbeAllocWinPrivPrivIndex;
- pDbeScreenPriv->AllocWinPrivPriv = DbeAllocWinPrivPriv;
/* Setup DDX. */
ddxInitSuccess = (*DbeInitFunct[i])(pScreen, pDbeScreenPriv);
@@ -1868,9 +1688,6 @@ DbeExtensionInit(void)
#ifndef DISABLE_MI_DBE_BY_DEFAULT
/* Setup DIX. */
pDbeScreenPriv->SetupBackgroundPainter = DbeSetupBackgroundPainter;
- pDbeScreenPriv->AllocWinPriv = DbeAllocWinPriv;
- pDbeScreenPriv->AllocWinPrivPrivIndex = DbeAllocWinPrivPrivIndex;
- pDbeScreenPriv->AllocWinPrivPriv = DbeAllocWinPrivPriv;
/* Setup DDX. */
ddxInitSuccess = miDbeInit(pScreen, pDbeScreenPriv);
@@ -1909,8 +1726,9 @@ DbeExtensionInit(void)
for (i = 0; i < screenInfo.numScreens; i++)
{
- xfree(screenInfo.screens[i]->devPrivates[dbeScreenPrivIndex].ptr);
- pScreen->devPrivates[dbeScreenPrivIndex].ptr = NULL;
+ xfree(dixLookupPrivate(&screenInfo.screens[i]->devPrivates,
+ dbeScreenPrivKey));
+ dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, NULL);
}
return;
}
diff --git a/dbe/dbestruct.h b/dbe/dbestruct.h
index 90f13428a..7d5a115ad 100644
--- a/dbe/dbestruct.h
+++ b/dbe/dbestruct.h
@@ -39,14 +39,13 @@
#define NEED_DBE_PROTOCOL
#include <X11/extensions/Xdbeproto.h>
#include "windowstr.h"
+#include "privates.h"
/* DEFINES */
-#define DBE_SCREEN_PRIV(pScreen) \
- ((dbeScreenPrivIndex < 0) ? \
- NULL : \
- ((DbeScreenPrivPtr)((pScreen)->devPrivates[dbeScreenPrivIndex].ptr)))
+#define DBE_SCREEN_PRIV(pScreen) ((DbeScreenPrivPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, dbeScreenPrivKey))
#define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \
DBE_SCREEN_PRIV((pDrawable)->pScreen)
@@ -63,10 +62,8 @@
#define DBE_SCREEN_PRIV_FROM_GC(pGC)\
DBE_SCREEN_PRIV((pGC)->pScreen)
-#define DBE_WINDOW_PRIV(pWindow)\
- ((dbeWindowPrivIndex < 0) ? \
- NULL : \
- ((DbeWindowPrivPtr)(pWindow->devPrivates[dbeWindowPrivIndex].ptr)))
+#define DBE_WINDOW_PRIV(pWin) ((DbeWindowPrivPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, dbeWindowPrivKey))
/* Initial size of the buffer ID array in the window priv. */
#define DBE_INIT_MAX_IDS 2
@@ -142,7 +139,7 @@ typedef struct _DbeWindowPrivRec
/* Device-specific private information.
*/
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
} DbeWindowPrivRec, *DbeWindowPrivPtr;
@@ -155,18 +152,13 @@ typedef struct _DbeWindowPrivRec
typedef struct _DbeScreenPrivRec
{
- /* Info for creating window privs */
- int winPrivPrivLen; /* Length of privs in DbeWindowPrivRec */
- unsigned int *winPrivPrivSizes; /* Array of private record sizes */
- unsigned int totalWinPrivSize; /* PrivRec + size of all priv priv ptrs */
-
/* Resources created by DIX to be used by DDX */
RESTYPE dbeDrawableResType;
RESTYPE dbeWindowPrivResType;
/* Private indices created by DIX to be used by DDX */
- int dbeScreenPrivIndex;
- int dbeWindowPrivIndex;
+ DevPrivateKey dbeScreenPrivKey;
+ DevPrivateKey dbeWindowPrivKey;
/* Wrapped functions
* It is the responsibilty of the DDX layer to wrap PositionWindow().
@@ -180,17 +172,6 @@ typedef struct _DbeScreenPrivRec
WindowPtr /*pWin*/,
GCPtr /*pGC*/
);
- DbeWindowPrivPtr (*AllocWinPriv)(
- ScreenPtr /*pScreen*/
-);
- int (*AllocWinPrivPrivIndex)(
- void
-);
- Bool (*AllocWinPrivPriv)(
- ScreenPtr /*pScreen*/,
- int /*index*/,
- unsigned /*amount*/
-);
/* Per-screen DDX routines */
Bool (*GetVisualInfo)(
@@ -223,7 +204,7 @@ typedef struct _DbeScreenPrivRec
/* Device-specific private information.
*/
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
} DbeScreenPrivRec, *DbeScreenPrivPtr;
diff --git a/dbe/midbe.c b/dbe/midbe.c
index 014e365ce..f26a09c6d 100644
--- a/dbe/midbe.c
+++ b/dbe/midbe.c
@@ -59,12 +59,11 @@
#include <stdio.h>
-static int miDbePrivPrivGeneration = 0;
-static int miDbeWindowPrivPrivIndex = -1;
+static DevPrivateKey miDbeWindowPrivPrivKey = &miDbeWindowPrivPrivKey;
static RESTYPE dbeDrawableResType;
static RESTYPE dbeWindowPrivResType;
-static int dbeScreenPrivIndex = -1;
-static int dbeWindowPrivIndex = -1;
+static DevPrivateKey dbeScreenPrivKey = &dbeScreenPrivKey;
+static DevPrivateKey dbeWindowPrivKey = &dbeWindowPrivKey;
/******************************************************************************
@@ -204,8 +203,8 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
/* Attach the priv priv to the priv. */
- pDbeWindowPriv->devPrivates[miDbeWindowPrivPrivIndex].ptr =
- (pointer)pDbeWindowPrivPriv;
+ dixSetPrivate(&pDbeWindowPriv->devPrivates, miDbeWindowPrivPrivKey,
+ pDbeWindowPrivPriv);
/* Clear the back buffer. */
@@ -778,30 +777,12 @@ miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
dbeWindowPrivResType = pDbeScreenPriv->dbeWindowPrivResType;
/* Copy private indices created by DIX */
- dbeScreenPrivIndex = pDbeScreenPriv->dbeScreenPrivIndex;
- dbeWindowPrivIndex = pDbeScreenPriv->dbeWindowPrivIndex;
+ dbeScreenPrivKey = pDbeScreenPriv->dbeScreenPrivKey;
+ dbeWindowPrivKey = pDbeScreenPriv->dbeWindowPrivKey;
- /* Reset the window priv privs if generations do not match. */
- if (miDbePrivPrivGeneration != serverGeneration)
- {
- /*
- **********************************************************************
- ** Allocate the window priv priv.
- **********************************************************************
- */
-
- miDbeWindowPrivPrivIndex = (*pDbeScreenPriv->AllocWinPrivPrivIndex)();
-
- /* Make sure we only do this code once. */
- miDbePrivPrivGeneration = serverGeneration;
-
- } /* if -- Reset priv privs. */
-
- if (!(*pDbeScreenPriv->AllocWinPrivPriv)(pScreen,
- miDbeWindowPrivPrivIndex, sizeof(MiDbeWindowPrivPrivRec)))
- {
+ if (!dixRequestPrivate(miDbeWindowPrivPrivKey,
+ sizeof(MiDbeWindowPrivPrivRec)))
return(FALSE);
- }
/* Wrap functions. */
pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
diff --git a/dbe/midbestr.h b/dbe/midbestr.h
index 1ad0104aa..ae9f206fc 100644
--- a/dbe/midbestr.h
+++ b/dbe/midbestr.h
@@ -42,19 +42,15 @@
/* DEFINES */
#define MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv) \
- (((miDbeWindowPrivPrivIndex < 0) || (!pDbeWindowPriv)) ? \
- NULL : \
- ((MiDbeWindowPrivPrivPtr) \
- ((pDbeWindowPriv)->devPrivates[miDbeWindowPrivPrivIndex].ptr)))
+ (!(pDbeWindowPriv) ? NULL : (MiDbeWindowPrivPrivPtr) \
+ dixLookupPrivate(&(pDbeWindowPriv)->devPrivates, miDbeWindowPrivPrivKey))
#define MI_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin)\
MI_DBE_WINDOW_PRIV_PRIV(DBE_WINDOW_PRIV(pWin))
#define MI_DBE_SCREEN_PRIV_PRIV(pDbeScreenPriv) \
- (((miDbeScreenPrivPrivIndex < 0) || (!pDbeScreenPriv)) ? \
- NULL : \
- ((MiDbeScreenPrivPrivPtr) \
- ((pDbeScreenPriv)->devPrivates[miDbeScreenPrivPrivIndex].ptr)))
+ (!(pDbeScreenPriv) ? NULL : (MiDbeScreenPrivPrivPtr) \
+ dixLookupPrivate(&(pDbeScreenPriv)->devPrivates, miDbeScreenPrivPrivKey))
/* TYPEDEFS */
diff --git a/dix/colormap.c b/dix/colormap.c
index 7d6e7da4f..98f2f1b22 100644
--- a/dix/colormap.c
+++ b/dix/colormap.c
@@ -67,7 +67,6 @@ SOFTWARE.
#include "xace.h"
extern XID clientErrorValue;
-extern int colormapPrivateCount;
static Pixel FindBestPixel(
EntryPtr /*pentFirst*/,
@@ -388,30 +387,11 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
pmap->numPixelsBlue[client] = size;
}
}
- if (!AddResource(mid, RT_COLORMAP, (pointer)pmap))
- return (BadAlloc);
- /* If the device wants a chance to initialize the colormap in any way,
- * this is it. In specific, if this is a Static colormap, this is the
- * time to fill in the colormap's values */
+ pmap->devPrivates = NULL;
pmap->flags |= BeingCreated;
-
- /*
- * Allocate the array of devPrivate's for this colormap.
- */
-
- if (colormapPrivateCount == 0)
- pmap->devPrivates = NULL;
- else
- {
- pmap->devPrivates = (DevUnion *) xcalloc (
- sizeof(DevUnion), colormapPrivateCount);
- if (!pmap->devPrivates)
- {
- FreeResource (mid, RT_NONE);
- return BadAlloc;
- }
- }
+ if (!AddResource(mid, RT_COLORMAP, (pointer)pmap))
+ return (BadAlloc);
/*
* Security creation/labeling check
@@ -423,6 +403,9 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
return i;
}
+ /* If the device wants a chance to initialize the colormap in any way,
+ * this is it. In specific, if this is a Static colormap, this is the
+ * time to fill in the colormap's values */
if (!(*pScreen->CreateColormap)(pmap))
{
FreeResource (mid, RT_NONE);
@@ -486,10 +469,7 @@ FreeColormap (pointer value, XID mid)
}
}
- dixFreePrivates(*DEVPRIV_PTR(pmap));
- if (pmap->devPrivates)
- xfree(pmap->devPrivates);
-
+ dixFreePrivates(pmap->devPrivates);
xfree(pmap);
return(Success);
}
diff --git a/dix/devices.c b/dix/devices.c
index 4ddfa63da..a62ab6580 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -85,8 +85,7 @@ SOFTWARE.
* This file handles input device-related stuff.
*/
-int CoreDevicePrivatesIndex = 0;
-static int CoreDevicePrivatesGeneration = -1;
+DevPrivateKey CoreDevicePrivateKey = &CoreDevicePrivateKey;
/**
* Create a new input device and init it to sane values. The device is added
@@ -151,14 +150,7 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart)
dev->xkb_interest = NULL;
#endif
dev->config_info = NULL;
- /* must pre-allocate one private for the new devPrivates support */
- dev->nPrivates = 1;
- dev->devPrivates = (DevUnion *)xcalloc(1, sizeof(DevUnion));
- if (!dev->devPrivates) {
- xfree(dev);
- return NULL;
- }
-
+ dev->devPrivates = NULL;
dev->unwrapProc = NULL;
dev->coreEvents = TRUE;
dev->inited = FALSE;
@@ -358,7 +350,7 @@ CoreKeyboardProc(DeviceIntPtr pDev, int what)
break;
case DEVICE_CLOSE:
- pDev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
+ dixSetPrivate(&pDev->devPrivates, CoreDevicePrivateKey, NULL);
break;
default:
@@ -390,7 +382,7 @@ CorePointerProc(DeviceIntPtr pDev, int what)
break;
case DEVICE_CLOSE:
- pDev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
+ dixSetPrivate(&pDev->devPrivates, CoreDevicePrivateKey, NULL);
break;
default:
@@ -411,11 +403,6 @@ InitCoreDevices(void)
{
DeviceIntPtr dev;
- if (CoreDevicePrivatesGeneration != serverGeneration) {
- CoreDevicePrivatesIndex = AllocateDevicePrivateIndex();
- CoreDevicePrivatesGeneration = serverGeneration;
- }
-
if (!inputInfo.keyboard) {
dev = AddInputDevice(CoreKeyboardProc, TRUE);
if (!dev)
@@ -433,9 +420,6 @@ InitCoreDevices(void)
dev->ActivateGrab = ActivateKeyboardGrab;
dev->DeactivateGrab = DeactivateKeyboardGrab;
dev->coreEvents = FALSE;
- if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex))
- FatalError("Couldn't allocate keyboard devPrivates\n");
- dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
(void)ActivateDevice(dev);
inputInfo.keyboard = dev;
}
@@ -457,9 +441,6 @@ InitCoreDevices(void)
dev->ActivateGrab = ActivatePointerGrab;
dev->DeactivateGrab = DeactivatePointerGrab;
dev->coreEvents = FALSE;
- if (!AllocateDevicePrivate(dev, CoreDevicePrivatesIndex))
- FatalError("Couldn't allocate pointer devPrivates\n");
- dev->devPrivates[CoreDevicePrivatesIndex].ptr = NULL;
(void)ActivateDevice(dev);
inputInfo.pointer = dev;
}
@@ -609,11 +590,8 @@ CloseDevice(DeviceIntPtr dev)
XkbRemoveResourceClient((DevicePtr)dev,dev->xkb_interest->resource);
#endif
- dixFreePrivates(*DEVPRIV_PTR(dev));
- if (dev->devPrivates)
- xfree(dev->devPrivates);
-
xfree(dev->sync.event);
+ dixFreePrivates(dev->devPrivates);
xfree(dev);
}
diff --git a/dix/dispatch.c b/dix/dispatch.c
index bb30619a2..1ad3c9437 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -3692,7 +3692,7 @@ CloseDownClient(ClientPtr client)
#ifdef SMART_SCHEDULE
SmartLastClient = NullClient;
#endif
- dixFreePrivates(*DEVPRIV_PTR(client));
+ dixFreePrivates(client->devPrivates);
xfree(client);
while (!clients[currentMaxClients-1])
@@ -3712,10 +3712,6 @@ KillAllClients(void)
}
}
-extern int clientPrivateLen;
-extern unsigned *clientPrivateSizes;
-extern unsigned totalClientSize;
-
void InitClient(ClientPtr client, int i, pointer ospriv)
{
client->index = i;
@@ -3735,6 +3731,7 @@ void InitClient(ClientPtr client, int i, pointer ospriv)
client->big_requests = FALSE;
client->priority = 0;
client->clientState = ClientStateInitial;
+ client->devPrivates = NULL;
#ifdef XKB
if (!noXkbExtension) {
client->xkbClientFlags = 0;
@@ -3755,54 +3752,6 @@ void InitClient(ClientPtr client, int i, pointer ospriv)
#endif
}
-int
-InitClientPrivates(ClientPtr client)
-{
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- int i;
-
- if (totalClientSize == sizeof(ClientRec))
- ppriv = (DevUnion *)NULL;
- else if (client->index)
- ppriv = (DevUnion *)(client + 1);
- else
- {
- ppriv = (DevUnion *)xalloc(totalClientSize - sizeof(ClientRec));
- if (!ppriv)
- return 0;
- }
- client->devPrivates = ppriv;
- sizes = clientPrivateSizes;
- ptr = (char *)(ppriv + clientPrivateLen);
- if (ppriv)
- bzero(ppriv, totalClientSize - sizeof(ClientRec));
- for (i = clientPrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
-
- /* Allow registrants to initialize the serverClient devPrivates */
- if (!client->index && ClientStateCallback)
- {
- NewClientInfoRec clientinfo;
-
- clientinfo.client = client;
- clientinfo.prefix = (xConnSetupPrefix *)NULL;
- clientinfo.setup = (xConnSetup *) NULL;
- CallCallbacks((&ClientStateCallback), (pointer)&clientinfo);
- }
- return 1;
-}
-
/************************
* int NextAvailableClient(ospriv)
*
@@ -3819,11 +3768,10 @@ ClientPtr NextAvailableClient(pointer ospriv)
i = nextFreeClientID;
if (i == MAXCLIENTS)
return (ClientPtr)NULL;
- clients[i] = client = (ClientPtr)xalloc(totalClientSize);
+ clients[i] = client = (ClientPtr)xalloc(sizeof(ClientRec));
if (!client)
return (ClientPtr)NULL;
InitClient(client, i, ospriv);
- InitClientPrivates(client);
if (!InitClientResources(client))
{
xfree(client);
diff --git a/dix/extension.c b/dix/extension.c
index ec47ef19c..c81c1a123 100644
--- a/dix/extension.c
+++ b/dix/extension.c
@@ -73,39 +73,6 @@ int lastEvent = EXTENSION_EVENT_BASE;
static int lastError = FirstExtensionError;
static unsigned int NumExtensions = 0;
-extern int extensionPrivateLen;
-extern unsigned *extensionPrivateSizes;
-extern unsigned totalExtensionSize;
-
-static void
-InitExtensionPrivates(ExtensionEntry *ext)
-{
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- int i;
-
- if (totalExtensionSize == sizeof(ExtensionEntry))
- ppriv = (DevUnion *)NULL;
- else
- ppriv = (DevUnion *)(ext + 1);
-
- ext->devPrivates = ppriv;
- sizes = extensionPrivateSizes;
- ptr = (char *)(ppriv + extensionPrivateLen);
- for (i = extensionPrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
-}
-
_X_EXPORT ExtensionEntry *
AddExtension(char *name, int NumEvents, int NumErrors,
int (*MainProc)(ClientPtr c1),
@@ -122,14 +89,13 @@ AddExtension(char *name, int NumEvents, int NumErrors,
(unsigned)(lastError + NumErrors > LAST_ERROR))
return((ExtensionEntry *) NULL);
- ext = (ExtensionEntry *) xalloc(totalExtensionSize);
+ ext = (ExtensionEntry *) xalloc(sizeof(ExtensionEntry));
if (!ext)
return((ExtensionEntry *) NULL);
- bzero(ext, totalExtensionSize);
- InitExtensionPrivates(ext);
ext->name = (char *)xalloc(strlen(name) + 1);
ext->num_aliases = 0;
ext->aliases = (char **)NULL;
+ ext->devPrivates = NULL;
if (!ext->name)
{
xfree(ext);
@@ -283,7 +249,7 @@ CloseDownExtensions(void)
for (j = extensions[i]->num_aliases; --j >= 0;)
xfree(extensions[i]->aliases[j]);
xfree(extensions[i]->aliases);
- dixFreePrivates(*DEVPRIV_PTR(extensions[i]));
+ dixFreePrivates(extensions[i]->devPrivates);
xfree(extensions[i]);
}
xfree(extensions);
diff --git a/dix/gc.c b/dix/gc.c
index ccd586bdd..d77932c9e 100644
--- a/dix/gc.c
+++ b/dix/gc.c
@@ -573,45 +573,13 @@ BUG:
should check for failure to create default tile
*/
-
-static GCPtr
-AllocateGC(ScreenPtr pScreen)
-{
- GCPtr pGC;
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- int i;
-
- pGC = (GCPtr)xalloc(pScreen->totalGCSize);
- if (pGC)
- {
- ppriv = (DevUnion *)(pGC + 1);
- pGC->devPrivates = ppriv;
- sizes = pScreen->GCPrivateSizes;
- ptr = (char *)(ppriv + pScreen->GCPrivateLen);
- for (i = pScreen->GCPrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
- }
- return pGC;
-}
-
_X_EXPORT GCPtr
CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus,
XID gcid, ClientPtr client)
{
GCPtr pGC;
- pGC = AllocateGC(pDrawable->pScreen);
+ pGC = (GCPtr)xalloc(sizeof(GC));
if (!pGC)
{
*pStatus = BadAlloc;
@@ -624,7 +592,7 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus,
pGC->planemask = ~0;
pGC->serialNumber = GC_CHANGE_SERIAL_BIT;
pGC->funcs = 0;
-
+ pGC->devPrivates = NULL;
pGC->fgPixel = 0;
pGC->bgPixel = 1;
pGC->lineWidth = 0;
@@ -918,7 +886,7 @@ FreeGC(pointer value, XID gid)
(*pGC->funcs->DestroyGC) (pGC);
if (pGC->dash != DefaultDash)
xfree(pGC->dash);
- dixFreePrivates(*DEVPRIV_PTR(pGC));
+ dixFreePrivates(pGC->devPrivates);
xfree(pGC);
return(Success);
}
@@ -941,7 +909,7 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth)
{
GCPtr pGC;
- pGC = AllocateGC(pScreen);
+ pGC = (GCPtr)xalloc(sizeof(GC));
if (!pGC)
return (GCPtr)NULL;
@@ -950,7 +918,7 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth)
pGC->alu = GXcopy; /* dst <- src */
pGC->planemask = ~0;
pGC->serialNumber = 0;
-
+ pGC->devPrivates = NULL;
pGC->fgPixel = 0;
pGC->bgPixel = 1;
pGC->lineWidth = 0;
diff --git a/dix/getevents.c b/dix/getevents.c
index 68993030d..a12bcfd78 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -725,7 +725,8 @@ SwitchCoreKeyboard(DeviceIntPtr pDev)
KeyClassPtr ckeyc = inputInfo.keyboard->key;
int i = 0;
- if (inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr != pDev) {
+ if (pDev != dixLookupPrivate(&inputInfo.keyboard->devPrivates,
+ CoreDevicePrivateKey)) {
memcpy(ckeyc->modifierMap, pDev->key->modifierMap, MAP_LENGTH);
if (ckeyc->modifierKeyMap)
xfree(ckeyc->modifierKeyMap);
@@ -769,7 +770,8 @@ SwitchCoreKeyboard(DeviceIntPtr pDev)
(ckeyc->curKeySyms.maxKeyCode -
ckeyc->curKeySyms.minKeyCode),
serverClient);
- inputInfo.keyboard->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
+ dixSetPrivate(&inputInfo.keyboard->devPrivates, CoreDevicePrivateKey,
+ pDev);
}
}
@@ -783,8 +785,10 @@ SwitchCoreKeyboard(DeviceIntPtr pDev)
_X_EXPORT void
SwitchCorePointer(DeviceIntPtr pDev)
{
- if (inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr != pDev)
- inputInfo.pointer->devPrivates[CoreDevicePrivatesIndex].ptr = pDev;
+ if (pDev != dixLookupPrivate(&inputInfo.pointer->devPrivates,
+ CoreDevicePrivateKey))
+ dixSetPrivate(&inputInfo.pointer->devPrivates,
+ CoreDevicePrivateKey, pDev);
}
diff --git a/dix/main.c b/dix/main.c
index 3e5d0e438..7f7bfa539 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -118,15 +118,12 @@ Equipment Corporation.
#include "dpmsproc.h"
#endif
-extern int InitClientPrivates(ClientPtr client);
-
extern void Dispatch(void);
char *ConnectionInfo;
xConnSetupPrefix connSetupPrefix;
extern FontPtr defaultFont;
-extern int screenPrivateCount;
extern void InitProcVectors(void);
extern Bool CreateGCperDepthArray(void);
@@ -136,8 +133,6 @@ static
#endif
Bool CreateConnectionBlock(void);
-static void FreeScreen(ScreenPtr);
-
_X_EXPORT PaddingInfo PixmapWidthPaddingInfo[33];
int connBlockScreenStart;
@@ -372,8 +367,6 @@ main(int argc, char *argv[], char *envp[])
if (screenInfo.numVideoScreens < 0)
screenInfo.numVideoScreens = screenInfo.numScreens;
InitExtensions(argc, argv);
- if (!InitClientPrivates(serverClient))
- FatalError("failed to allocate serverClient devprivates");
for (i = 0; i < screenInfo.numScreens; i++)
{
ScreenPtr pScreen = screenInfo.screens[i];
@@ -472,7 +465,8 @@ main(int argc, char *argv[], char *envp[])
FreeGCperDepth(i);
FreeDefaultStipple(i);
(* screenInfo.screens[i]->CloseScreen)(i, screenInfo.screens[i]);
- FreeScreen(screenInfo.screens[i]);
+ dixFreePrivates(screenInfo.screens[i]->devPrivates);
+ xfree(screenInfo.screens[i]);
screenInfo.numScreens = i;
}
CloseDownEvents();
@@ -482,8 +476,7 @@ main(int argc, char *argv[], char *envp[])
FreeAuditTimer();
- dixFreePrivates(*DEVPRIV_PTR(serverClient));
- xfree(serverClient->devPrivates);
+ dixFreePrivates(serverClient->devPrivates);
serverClient->devPrivates = NULL;
if (dispatchException & DE_TERMINATE)
@@ -695,32 +688,9 @@ AddScreen(
if (!pScreen)
return -1;
- pScreen->devPrivates = (DevUnion *)xcalloc(sizeof(DevUnion),
- screenPrivateCount);
- if (!pScreen->devPrivates && screenPrivateCount)
- {
- xfree(pScreen);
- return -1;
- }
-
- /* must pre-allocate one private for the new devPrivates support */
- pScreen->WindowPrivateLen = 1;
- pScreen->WindowPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
- pScreen->totalWindowSize = PadToLong(sizeof(WindowRec)) + sizeof(DevUnion);
- pScreen->GCPrivateLen = 1;
- pScreen->GCPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
- pScreen->totalGCSize = PadToLong(sizeof(GC)) + sizeof(DevUnion);
- pScreen->PixmapPrivateLen = 1;
- pScreen->PixmapPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
- pScreen->totalPixmapSize = BitmapBytePad(8 * (sizeof(PixmapRec) +
- sizeof(DevUnion)));
- if (!pScreen->WindowPrivateSizes || !pScreen->GCPrivateSizes ||
- !pScreen->PixmapPrivateSizes) {
- xfree(pScreen);
- return -1;
- }
-
+ pScreen->devPrivates = NULL;
pScreen->myNum = i;
+ pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8);
pScreen->ClipNotify = 0; /* for R4 ddx compatibility */
pScreen->CreateScreenResources = 0;
@@ -772,20 +742,10 @@ AddScreen(
screenInfo.numScreens++;
if (!(*pfnInit)(i, pScreen, argc, argv))
{
- FreeScreen(pScreen);
+ dixFreePrivates(pScreen->devPrivates);
+ xfree(pScreen);
screenInfo.numScreens--;
return -1;
}
return i;
}
-
-static void
-FreeScreen(ScreenPtr pScreen)
-{
- xfree(pScreen->WindowPrivateSizes);
- xfree(pScreen->GCPrivateSizes);
- xfree(pScreen->PixmapPrivateSizes);
- dixFreePrivates(*DEVPRIV_PTR(pScreen));
- xfree(pScreen->devPrivates);
- xfree(pScreen);
-}
diff --git a/dix/pixmap.c b/dix/pixmap.c
index c280a3b94..6096cc6b5 100644
--- a/dix/pixmap.c
+++ b/dix/pixmap.c
@@ -109,11 +109,6 @@ _X_EXPORT PixmapPtr
AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
{
PixmapPtr pPixmap;
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- int i;
if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize)
return NullPixmap;
@@ -121,27 +116,7 @@ AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
pPixmap = (PixmapPtr)xalloc(pScreen->totalPixmapSize + pixDataSize);
if (!pPixmap)
return NullPixmap;
- ppriv = (DevUnion *)(pPixmap + 1);
- pPixmap->devPrivates = ppriv;
- sizes = pScreen->PixmapPrivateSizes;
- ptr = (char *)(ppriv + pScreen->PixmapPrivateLen);
- for (i = pScreen->PixmapPrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ((size = *sizes) != 0)
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
-
-#ifdef _XSERVER64
- if (pPixmap) {
- pPixmap->drawable.pad0 = 0;
- pPixmap->drawable.pad1 = 0;
- }
-#endif
+ pPixmap->devPrivates = NULL;
return pPixmap;
}
diff --git a/dix/privates.c b/dix/privates.c
index 4dbba437c..38c552360 100644
--- a/dix/privates.c
+++ b/dix/privates.c
@@ -30,21 +30,13 @@ from The Open Group.
#include <dix-config.h>
#endif
-#include <X11/X.h>
#include <stddef.h>
-#include "scrnintstr.h"
-#include "misc.h"
-#include "os.h"
#include "windowstr.h"
#include "resource.h"
#include "privates.h"
-#include "dixstruct.h"
#include "gcstruct.h"
#include "colormapst.h"
-#include "servermd.h"
-#include "site.h"
#include "inputstr.h"
-#include "extnsionst.h"
typedef struct _PrivateDesc {
DevPrivateKey key;
@@ -218,18 +210,6 @@ dixLookupPrivateOffset(RESTYPE type)
return offsets[type];
}
-/*
- * Called from the main loop to reset the subsystem.
- */
-static int ResetExtensionPrivates(void);
-static int ResetClientPrivates(void);
-static void ResetScreenPrivates(void);
-static void ResetWindowPrivates(void);
-static void ResetGCPrivates(void);
-static void ResetPixmapPrivates(void);
-static void ResetColormapPrivates(void);
-static void ResetDevicePrivateIndex(void);
-
int
dixResetPrivates(void)
{
@@ -251,16 +231,6 @@ dixResetPrivates(void)
for (i=0; i < offsetsSize; i++)
offsets[i] = -1;
- /* reset legacy devPrivates support */
- if (!ResetExtensionPrivates() || !ResetClientPrivates())
- return FALSE;
- ResetScreenPrivates();
- ResetWindowPrivates();
- ResetGCPrivates();
- ResetPixmapPrivates();
- ResetColormapPrivates();
- ResetDevicePrivateIndex();
-
/* register basic resource offsets */
return dixRegisterPrivateOffset(RT_WINDOW,
offsetof(WindowRec, devPrivates)) &&
@@ -271,421 +241,3 @@ dixResetPrivates(void)
dixRegisterPrivateOffset(RT_COLORMAP,
offsetof(ColormapRec, devPrivates));
}
-
-/*
- * Following is the old devPrivates support. These functions and variables
- * are deprecated, and should no longer be used.
- */
-
-/*
- * See the Wrappers and devPrivates section in "Definition of the
- * Porting Layer for the X v11 Sample Server" (doc/Server/ddx.tbl.ms)
- * for information on how to use devPrivates.
- */
-
-/*
- * extension private machinery
- */
-
-static int extensionPrivateCount;
-int extensionPrivateLen;
-unsigned *extensionPrivateSizes;
-unsigned totalExtensionSize;
-
-static int
-ResetExtensionPrivates(void)
-{
- extensionPrivateCount = 1;
- extensionPrivateLen = 1;
- xfree(extensionPrivateSizes);
- extensionPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
- if (!extensionPrivateSizes)
- return FALSE;
- totalExtensionSize = PadToLong(sizeof(ExtensionEntry)) + sizeof(DevUnion);
- return TRUE;
-}
-
-_X_EXPORT int
-AllocateExtensionPrivateIndex(void)
-{
- return extensionPrivateCount++;
-}
-
-_X_EXPORT Bool
-AllocateExtensionPrivate(int index2, unsigned amount)
-{
- unsigned oldamount;
-
- /* Round up sizes for proper alignment */
- amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
-
- if (index2 >= extensionPrivateLen)
- {
- unsigned *nsizes;
- nsizes = (unsigned *)xrealloc(extensionPrivateSizes,
- (index2 + 1) * sizeof(unsigned));
- if (!nsizes)
- return FALSE;
- while (extensionPrivateLen <= index2)
- {
- nsizes[extensionPrivateLen++] = 0;
- totalExtensionSize += sizeof(DevUnion);
- }
- extensionPrivateSizes = nsizes;
- }
- oldamount = extensionPrivateSizes[index2];
- if (amount > oldamount)
- {
- extensionPrivateSizes[index2] = amount;
- totalExtensionSize += (amount - oldamount);
- }
- return TRUE;
-}
-
-/*
- * client private machinery
- */
-
-static int clientPrivateCount;
-int clientPrivateLen;
-unsigned *clientPrivateSizes;
-unsigned totalClientSize;
-
-static int
-ResetClientPrivates(void)
-{
- clientPrivateCount = 1;
- clientPrivateLen = 1;
- xfree(clientPrivateSizes);
- clientPrivateSizes = (unsigned *)xcalloc(1, sizeof(unsigned));
- if (!clientPrivateSizes)
- return FALSE;
- totalClientSize = PadToLong(sizeof(ClientRec)) + sizeof(DevUnion);
- return TRUE;
-}
-
-_X_EXPORT int
-AllocateClientPrivateIndex(void)
-{
- return clientPrivateCount++;
-}
-
-_X_EXPORT Bool
-AllocateClientPrivate(int index2, unsigned amount)
-{
- unsigned oldamount;
-
- /* Round up sizes for proper alignment */
- amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
-
- if (index2 >= clientPrivateLen)
- {
- unsigned *nsizes;
- nsizes = (unsigned *)xrealloc(clientPrivateSizes,
- (index2 + 1) * sizeof(unsigned));
- if (!nsizes)
- return FALSE;
- while (clientPrivateLen <= index2)
- {
- nsizes[clientPrivateLen++] = 0;
- totalClientSize += sizeof(DevUnion);
- }
- clientPrivateSizes = nsizes;
- }
- oldamount = clientPrivateSizes[index2];
- if (amount > oldamount)
- {
- clientPrivateSizes[index2] = amount;
- totalClientSize += (amount - oldamount);
- }
- return TRUE;
-}
-
-/*
- * screen private machinery
- */
-
-int screenPrivateCount;
-
-static void
-ResetScreenPrivates(void)
-{
- screenPrivateCount = 1;
-}
-
-/* this can be called after some screens have been created,
- * so we have to worry about resizing existing devPrivates
- */
-_X_EXPORT int
-AllocateScreenPrivateIndex(void)
-{
- int idx;
- int i;
- ScreenPtr pScreen;
- DevUnion *nprivs;
-
- idx = screenPrivateCount++;
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- pScreen = screenInfo.screens[i];
- nprivs = (DevUnion *)xrealloc(pScreen->devPrivates,
- screenPrivateCount * sizeof(DevUnion));
- if (!nprivs)
- {
- screenPrivateCount--;
- return -1;
- }
- /* Zero the new private */
- bzero(&nprivs[idx], sizeof(DevUnion));
- pScreen->devPrivates = nprivs;
- }
- return idx;
-}
-
-
-/*
- * window private machinery
- */
-
-static int windowPrivateCount;
-
-static void
-ResetWindowPrivates(void)
-{
- windowPrivateCount = 1;
-}
-
-_X_EXPORT int
-AllocateWindowPrivateIndex(void)
-{
- return windowPrivateCount++;
-}
-
-_X_EXPORT Bool
-AllocateWindowPrivate(ScreenPtr pScreen, int index2, unsigned amount)
-{
- unsigned oldamount;
-
- /* Round up sizes for proper alignment */
- amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
-
- if (index2 >= pScreen->WindowPrivateLen)
- {
- unsigned *nsizes;
- nsizes = (unsigned *)xrealloc(pScreen->WindowPrivateSizes,
- (index2 + 1) * sizeof(unsigned));
- if (!nsizes)
- return FALSE;
- while (pScreen->WindowPrivateLen <= index2)
- {
- nsizes[pScreen->WindowPrivateLen++] = 0;
- pScreen->totalWindowSize += sizeof(DevUnion);
- }
- pScreen->WindowPrivateSizes = nsizes;
- }
- oldamount = pScreen->WindowPrivateSizes[index2];
- if (amount > oldamount)
- {
- pScreen->WindowPrivateSizes[index2] = amount;
- pScreen->totalWindowSize += (amount - oldamount);
- }
- return TRUE;
-}
-
-
-/*
- * gc private machinery
- */
-
-static int gcPrivateCount;
-
-static void
-ResetGCPrivates(void)
-{
- gcPrivateCount = 1;
-}
-
-_X_EXPORT int
-AllocateGCPrivateIndex(void)
-{
- return gcPrivateCount++;
-}
-
-_X_EXPORT Bool
-AllocateGCPrivate(ScreenPtr pScreen, int index2, unsigned amount)
-{
- unsigned oldamount;
-
- /* Round up sizes for proper alignment */
- amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
-
- if (index2 >= pScreen->GCPrivateLen)
- {
- unsigned *nsizes;
- nsizes = (unsigned *)xrealloc(pScreen->GCPrivateSizes,
- (index2 + 1) * sizeof(unsigned));
- if (!nsizes)
- return FALSE;
- while (pScreen->GCPrivateLen <= index2)
- {
- nsizes[pScreen->GCPrivateLen++] = 0;
- pScreen->totalGCSize += sizeof(DevUnion);
- }
- pScreen->GCPrivateSizes = nsizes;
- }
- oldamount = pScreen->GCPrivateSizes[index2];
- if (amount > oldamount)
- {
- pScreen->GCPrivateSizes[index2] = amount;
- pScreen->totalGCSize += (amount - oldamount);
- }
- return TRUE;
-}
-
-
-/*
- * pixmap private machinery
- */
-static int pixmapPrivateCount;
-
-static void
-ResetPixmapPrivates(void)
-{
- pixmapPrivateCount = 1;
-}
-
-_X_EXPORT int
-AllocatePixmapPrivateIndex(void)
-{
- return pixmapPrivateCount++;
-}
-
-_X_EXPORT Bool
-AllocatePixmapPrivate(ScreenPtr pScreen, int index2, unsigned amount)
-{
- unsigned oldamount;
-
- /* Round up sizes for proper alignment */
- amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
-
- if (index2 >= pScreen->PixmapPrivateLen)
- {
- unsigned *nsizes;
- nsizes = (unsigned *)xrealloc(pScreen->PixmapPrivateSizes,
- (index2 + 1) * sizeof(unsigned));
- if (!nsizes)
- return FALSE;
- while (pScreen->PixmapPrivateLen <= index2)
- {
- nsizes[pScreen->PixmapPrivateLen++] = 0;
- pScreen->totalPixmapSize += sizeof(DevUnion);
- }
- pScreen->PixmapPrivateSizes = nsizes;
- }
- oldamount = pScreen->PixmapPrivateSizes[index2];
- if (amount > oldamount)
- {
- pScreen->PixmapPrivateSizes[index2] = amount;
- pScreen->totalPixmapSize += (amount - oldamount);
- }
- pScreen->totalPixmapSize = BitmapBytePad(pScreen->totalPixmapSize * 8);
- return TRUE;
-}
-
-
-/*
- * colormap private machinery
- */
-
-int colormapPrivateCount;
-
-static void
-ResetColormapPrivates(void)
-{
- colormapPrivateCount = 1;
-}
-
-
-_X_EXPORT int
-AllocateColormapPrivateIndex (InitCmapPrivFunc initPrivFunc)
-{
- int index;
- int i;
- ColormapPtr pColormap;
- DevUnion *privs;
-
- index = colormapPrivateCount++;
-
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- /*
- * AllocateColormapPrivateIndex may be called after the
- * default colormap has been created on each screen!
- *
- * We must resize the devPrivates array for the default
- * colormap on each screen, making room for this new private.
- * We also call the initialization function 'initPrivFunc' on
- * the new private allocated for each default colormap.
- */
-
- ScreenPtr pScreen = screenInfo.screens[i];
-
- pColormap = (ColormapPtr) LookupIDByType (
- pScreen->defColormap, RT_COLORMAP);
-
- if (pColormap)
- {
- privs = (DevUnion *) xrealloc (pColormap->devPrivates,
- colormapPrivateCount * sizeof(DevUnion));
- if (!privs) {
- colormapPrivateCount--;
- return -1;
- }
- bzero(&privs[index], sizeof(DevUnion));
- pColormap->devPrivates = privs;
- if (!(*initPrivFunc)(pColormap,index))
- {
- colormapPrivateCount--;
- return -1;
- }
- }
- }
-
- return index;
-}
-
-/*
- * device private machinery
- */
-
-static int devicePrivateIndex = 0;
-
-_X_EXPORT int
-AllocateDevicePrivateIndex(void)
-{
- return devicePrivateIndex++;
-}
-
-_X_EXPORT Bool
-AllocateDevicePrivate(DeviceIntPtr device, int index)
-{
- if (device->nPrivates < ++index) {
- DevUnion *nprivs = (DevUnion *) xrealloc(device->devPrivates,
- index * sizeof(DevUnion));
- if (!nprivs)
- return FALSE;
- device->devPrivates = nprivs;
- bzero(&nprivs[device->nPrivates], sizeof(DevUnion)
- * (index - device->nPrivates));
- device->nPrivates = index;
- return TRUE;
- } else {
- return TRUE;
- }
-}
-
-static void
-ResetDevicePrivateIndex(void)
-{
- devicePrivateIndex = 1;
-}
diff --git a/dix/window.c b/dix/window.c
index f04beea79..1a598faca 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -345,41 +345,6 @@ MakeRootTile(WindowPtr pWin)
}
-WindowPtr
-AllocateWindow(ScreenPtr pScreen)
-{
- WindowPtr pWin;
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- int i;
-
- pWin = (WindowPtr)xalloc(pScreen->totalWindowSize);
- if (pWin)
- {
- ppriv = (DevUnion *)(pWin + 1);
- pWin->devPrivates = ppriv;
- sizes = pScreen->WindowPrivateSizes;
- ptr = (char *)(ppriv + pScreen->WindowPrivateLen);
- for (i = pScreen->WindowPrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
-#if _XSERVER64
- pWin->drawable.pad0 = 0;
- pWin->drawable.pad1 = 0;
-#endif
- }
- return pWin;
-}
-
/*****
* CreateRootWindow
* Makes a window at initialization time for specified screen
@@ -392,7 +357,7 @@ CreateRootWindow(ScreenPtr pScreen)
BoxRec box;
PixmapFormatRec *format;
- pWin = AllocateWindow(pScreen);
+ pWin = (WindowPtr)xalloc(sizeof(WindowRec));
if (!pWin)
return FALSE;
@@ -405,6 +370,7 @@ CreateRootWindow(ScreenPtr pScreen)
pWin->drawable.pScreen = pScreen;
pWin->drawable.type = DRAWABLE_WINDOW;
+ pWin->devPrivates = NULL;
pWin->drawable.depth = pScreen->rootDepth;
for (format = screenInfo.formats;
@@ -689,13 +655,14 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
return NullWindow;
}
- pWin = AllocateWindow(pScreen);
+ pWin = (WindowPtr)xalloc(sizeof(WindowRec));
if (!pWin)
{
*error = BadAlloc;
return NullWindow;
}
pWin->drawable = pParent->drawable;
+ pWin->devPrivates = NULL;
pWin->drawable.depth = depth;
if (depth == pParent->drawable.depth)
pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel;
@@ -968,7 +935,7 @@ DeleteWindow(pointer value, XID wid)
if (pWin->prevSib)
pWin->prevSib->nextSib = pWin->nextSib;
}
- dixFreePrivates(*DEVPRIV_PTR(pWin));
+ dixFreePrivates(pWin->devPrivates);
xfree(pWin);
return Success;
}
diff --git a/exa/exa.c b/exa/exa.c
index 99707fa5c..4260cbade 100644
--- a/exa/exa.c
+++ b/exa/exa.c
@@ -40,9 +40,8 @@
#include "exa.h"
#include "cw.h"
-static int exaGeneration;
-int exaScreenPrivateIndex;
-int exaPixmapPrivateIndex;
+DevPrivateKey exaScreenPrivateKey = &exaScreenPrivateKey;
+DevPrivateKey exaPixmapPrivateKey = &exaPixmapPrivateKey;
/**
* exaGetPixmapOffset() returns the offset (in bytes) within the framebuffer of
@@ -619,12 +618,6 @@ exaDriverInit (ScreenPtr pScreen,
#ifdef RENDER
ps = GetPictureScreenIfSet(pScreen);
#endif
- if (exaGeneration != serverGeneration)
- {
- exaScreenPrivateIndex = AllocateScreenPrivateIndex();
- exaPixmapPrivateIndex = AllocatePixmapPrivateIndex();
- exaGeneration = serverGeneration;
- }
pExaScr = xcalloc (sizeof (ExaScreenPrivRec), 1);
@@ -636,7 +629,7 @@ exaDriverInit (ScreenPtr pScreen,
pExaScr->info = pScreenInfo;
- pScreen->devPrivates[exaScreenPrivateIndex].ptr = (pointer) pExaScr;
+ dixSetPrivate(&pScreen->devPrivates, exaScreenPrivateKey, pExaScr);
pExaScr->migration = ExaMigrationAlways;
@@ -698,8 +691,7 @@ exaDriverInit (ScreenPtr pScreen,
if ((pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS) &&
pExaScr->info->offScreenBase < pExaScr->info->memorySize)
{
- if (!AllocatePixmapPrivate(pScreen, exaPixmapPrivateIndex,
- sizeof (ExaPixmapPrivRec))) {
+ if (!dixRequestPrivate(exaPixmapPrivateKey, sizeof(ExaPixmapPrivRec))) {
LogMessage(X_WARNING,
"EXA(%d): Failed to allocate pixmap private\n",
pScreen->myNum);
@@ -716,11 +708,7 @@ exaDriverInit (ScreenPtr pScreen,
pExaScr->info->memorySize - pExaScr->info->offScreenBase);
}
else
- {
LogMessage(X_INFO, "EXA(%d): No offscreen pixmaps\n", pScreen->myNum);
- if (!AllocatePixmapPrivate(pScreen, exaPixmapPrivateIndex, 0))
- return FALSE;
- }
DBG_PIXMAP(("============== %ld < %ld\n", pExaScr->info->offScreenBase,
pExaScr->info->memorySize));
diff --git a/exa/exa_priv.h b/exa/exa_priv.h
index a456da05e..b577094bc 100644
--- a/exa/exa_priv.h
+++ b/exa/exa_priv.h
@@ -132,9 +132,9 @@ typedef struct {
(PixmapWidthPaddingInfo[d].padRoundUp+1)))
#endif
-extern int exaScreenPrivateIndex;
-extern int exaPixmapPrivateIndex;
-#define ExaGetScreenPriv(s) ((ExaScreenPrivPtr)(s)->devPrivates[exaScreenPrivateIndex].ptr)
+extern DevPrivateKey exaScreenPrivateKey;
+extern DevPrivateKey exaPixmapPrivateKey;
+#define ExaGetScreenPriv(s) ((ExaScreenPrivPtr)dixLookupPrivate(&(s)->devPrivates, exaScreenPrivateKey))
#define ExaScreenPriv(s) ExaScreenPrivPtr pExaScr = ExaGetScreenPriv(s)
/** Align an offset to an arbitrary alignment */
@@ -150,8 +150,8 @@ extern int exaPixmapPrivateIndex;
#define EXA_PIXMAP_SCORE_PINNED 1000
#define EXA_PIXMAP_SCORE_INIT 1001
-#define ExaGetPixmapPriv(p) ((ExaPixmapPrivPtr)(p)->devPrivates[exaPixmapPrivateIndex].ptr)
-#define ExaSetPixmapPriv(p,a) ((p)->devPrivates[exaPixmapPrivateIndex].ptr = (pointer) (a))
+#define ExaGetPixmapPriv(p) ((ExaPixmapPrivPtr)dixLookupPrivate(&(p)->devPrivates, exaPixmapPrivateKey))
+#define ExaSetPixmapPriv(p,a) dixSetPrivate(&(p)->devPrivates, exaPixmapPrivateKey, a)
#define ExaPixmapPriv(p) ExaPixmapPrivPtr pExaPixmap = ExaGetPixmapPriv(p)
typedef struct {
diff --git a/fb/fb.h b/fb/fb.h
index aba2bd252..da85ecf3d 100644
--- a/fb/fb.h
+++ b/fb/fb.h
@@ -37,6 +37,7 @@
#include "miscstruct.h"
#include "servermd.h"
#include "windowstr.h"
+#include "privates.h"
#include "mi.h"
#include "migc.h"
#include "mibstore.h"
@@ -599,13 +600,9 @@ extern void fbSetBits (FbStip *bits, int stride, FbStip data);
} \
}
-/* XXX fb*PrivateIndex should be static, but it breaks the ABI */
-
-extern int fbGCPrivateIndex;
-extern int fbGetGCPrivateIndex(void);
+extern DevPrivateKey fbGetGCPrivateKey(void);
#ifndef FB_NO_WINDOW_PIXMAPS
-extern int fbWinPrivateIndex;
-extern int fbGetWinPrivateIndex(void);
+extern DevPrivateKey fbGetWinPrivateKey(void);
#endif
extern const GCOps fbGCOps;
extern const GCFuncs fbGCFuncs;
@@ -641,8 +638,7 @@ typedef void (*FinishWrapProcPtr)(DrawablePtr pDraw);
#ifdef FB_SCREEN_PRIVATE
-extern int fbScreenPrivateIndex;
-extern int fbGetScreenPrivateIndex(void);
+extern DevPrivateKey fbGetScreenPrivateKey(void);
/* private field of a screen */
typedef struct {
@@ -655,7 +651,7 @@ typedef struct {
} FbScreenPrivRec, *FbScreenPrivPtr;
#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
- (pScreen)->devPrivates[fbGetScreenPrivateIndex()].ptr)
+ dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey()))
#endif
/* private field of GC */
@@ -670,7 +666,7 @@ typedef struct {
} FbGCPrivRec, *FbGCPrivPtr;
#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
- (pGC)->devPrivates[fbGetGCPrivateIndex()].ptr)
+ dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey()))
#define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
#define fbGetExpose(pGC) ((pGC)->fExpose)
@@ -682,7 +678,7 @@ typedef struct {
#define fbGetWindowPixmap(d) fbGetScreenPixmap(((DrawablePtr) (d))->pScreen)
#else
#define fbGetWindowPixmap(pWin) ((PixmapPtr)\
- ((WindowPtr) (pWin))->devPrivates[fbGetWinPrivateIndex()].ptr)
+ dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey()))
#endif
#ifdef ROOTLESS
@@ -835,7 +831,7 @@ fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
* fballpriv.c
*/
Bool
-fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex);
+fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCIndex);
/*
* fbarc.c
diff --git a/fb/fballpriv.c b/fb/fballpriv.c
index 8efb8fa99..68cb2e4c0 100644
--- a/fb/fballpriv.c
+++ b/fb/fballpriv.c
@@ -27,51 +27,33 @@
#include "fb.h"
#ifdef FB_SCREEN_PRIVATE
-int fbScreenPrivateIndex;
-int fbGetScreenPrivateIndex(void)
+static DevPrivateKey fbScreenPrivateKey = &fbScreenPrivateKey;
+DevPrivateKey fbGetScreenPrivateKey(void)
{
- return fbScreenPrivateIndex;
+ return fbScreenPrivateKey;
}
#endif
-int fbGCPrivateIndex;
-int fbGetGCPrivateIndex(void)
+static DevPrivateKey fbGCPrivateKey = &fbGCPrivateKey;
+DevPrivateKey fbGetGCPrivateKey(void)
{
- return fbGCPrivateIndex;
+ return fbGCPrivateKey;
}
#ifndef FB_NO_WINDOW_PIXMAPS
-int fbWinPrivateIndex;
-int fbGetWinPrivateIndex(void)
+static DevPrivateKey fbWinPrivateKey = &fbWinPrivateKey;
+DevPrivateKey fbGetWinPrivateKey(void)
{
- return fbWinPrivateIndex;
+ return fbWinPrivateKey;
}
#endif
-int fbGeneration;
Bool
-fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex)
+fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
{
- if (fbGeneration != serverGeneration)
- {
- fbGCPrivateIndex = miAllocateGCPrivateIndex ();
-#ifndef FB_NO_WINDOW_PIXMAPS
- fbWinPrivateIndex = AllocateWindowPrivateIndex();
-#endif
-#ifdef FB_SCREEN_PRIVATE
- fbScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (fbScreenPrivateIndex == -1)
- return FALSE;
-#endif
-
- fbGeneration = serverGeneration;
- }
- if (pGCIndex)
- *pGCIndex = fbGCPrivateIndex;
- if (!AllocateGCPrivate(pScreen, fbGCPrivateIndex, sizeof(FbGCPrivRec)))
+ if (pGCKey)
+ *pGCKey = fbGCPrivateKey;
+
+ if (!dixRequestPrivate(fbGCPrivateKey, sizeof(FbGCPrivRec)))
return FALSE;
-#ifndef FB_NO_WINDOW_PIXMAPS
- if (!AllocateWindowPrivate(pScreen, fbWinPrivateIndex, 0))
- return FALSE;
-#endif
#ifdef FB_SCREEN_PRIVATE
{
FbScreenPrivPtr pScreenPriv;
@@ -79,7 +61,7 @@ fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex)
pScreenPriv = (FbScreenPrivPtr) xalloc (sizeof (FbScreenPrivRec));
if (!pScreenPriv)
return FALSE;
- pScreen->devPrivates[fbScreenPrivateIndex].ptr = (pointer) pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, fbScreenPrivateKey, pScreenPriv);
}
#endif
return TRUE;
diff --git a/fb/fboverlay.c b/fb/fboverlay.c
index 5d7481eed..0d3c24073 100644
--- a/fb/fboverlay.c
+++ b/fb/fboverlay.c
@@ -33,12 +33,11 @@
#include "fboverlay.h"
#include "shmint.h"
-int fbOverlayGeneration;
-int fbOverlayScreenPrivateIndex = -1;
+static DevPrivateKey fbOverlayScreenPrivateKey = &fbOverlayScreenPrivateKey;
-int fbOverlayGetScreenPrivateIndex(void)
+DevPrivateKey fbOverlayGetScreenPrivateKey(void)
{
- return fbOverlayScreenPrivateIndex;
+ return fbOverlayScreenPrivateKey;
}
/*
@@ -65,7 +64,7 @@ fbOverlayCreateWindow(WindowPtr pWin)
pPixmap = pScrPriv->layer[i].u.run.pixmap;
if (pWin->drawable.depth == pPixmap->drawable.depth)
{
- pWin->devPrivates[fbWinPrivateIndex].ptr = (pointer) pPixmap;
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pPixmap);
/*
* Make sure layer keys are written correctly by
* having non-root layers set to full while the
@@ -108,7 +107,7 @@ fbOverlayWindowLayer(WindowPtr pWin)
int i;
for (i = 0; i < pScrPriv->nlayers; i++)
- if (pWin->devPrivates[fbWinPrivateIndex].ptr ==
+ if (dixLookupPrivate(&pWin->devPrivates, fbGetWinPrivateKey()) ==
(pointer) pScrPriv->layer[i].u.run.pixmap)
return i;
return 0;
@@ -358,12 +357,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
VisualID defaultVisual;
FbOverlayScrPrivPtr pScrPriv;
- if (fbOverlayGeneration != serverGeneration)
- {
- fbOverlayScreenPrivateIndex = AllocateScreenPrivateIndex ();
- fbOverlayGeneration = serverGeneration;
- }
-
pScrPriv = xalloc (sizeof (FbOverlayScrPrivRec));
if (!pScrPriv)
return FALSE;
@@ -433,7 +426,7 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
pScrPriv->layer[1].u.init.width = width2;
pScrPriv->layer[1].u.init.depth = depth2;
- pScreen->devPrivates[fbOverlayScreenPrivateIndex].ptr = (pointer) pScrPriv;
+ dixSetPrivate(&pScreen->devPrivates, fbOverlayScreenPrivateKey, pScrPriv);
/* overwrite miCloseScreen with our own */
pScreen->CloseScreen = fbOverlayCloseScreen;
diff --git a/fb/fboverlay.h b/fb/fboverlay.h
index af0acb889..85a28ec2f 100644
--- a/fb/fboverlay.h
+++ b/fb/fboverlay.h
@@ -25,9 +25,9 @@
#ifndef _FBOVERLAY_H_
#define _FBOVERLAY_H_
-extern int fbOverlayGeneration;
-extern int fbOverlayScreenPrivateIndex; /* XXX should be static */
-extern int fbOverlayGetScreenPrivateIndex(void);
+#include "privates.h"
+
+extern DevPrivateKey fbOverlayGetScreenPrivateKey(void);
#ifndef FB_OVERLAY_MAX
#define FB_OVERLAY_MAX 2
@@ -58,8 +58,7 @@ typedef struct _fbOverlayScrPriv {
} FbOverlayScrPrivRec, *FbOverlayScrPrivPtr;
#define fbOverlayGetScrPriv(s) \
- ((fbOverlayGetScreenPrivateIndex() != -1) ? \
- (s)->devPrivates[fbOverlayGetScreenPrivateIndex()].ptr : NULL)
+ dixLookupPrivate(&(s)->devPrivates, fbOverlayGetScreenPrivateKey())
Bool
fbOverlayCreateWindow(WindowPtr pWin);
diff --git a/fb/fbpixmap.c b/fb/fbpixmap.c
index 2b77c4f34..cd8cbcd5d 100644
--- a/fb/fbpixmap.c
+++ b/fb/fbpixmap.c
@@ -96,7 +96,7 @@ fbDestroyPixmap (PixmapPtr pPixmap)
{
if(--pPixmap->refcnt)
return TRUE;
- dixFreePrivates(*DEVPRIV_PTR(pPixmap));
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return TRUE;
}
diff --git a/fb/fbpseudocolor.c b/fb/fbpseudocolor.c
index 271e98145..1b9b18a7e 100644
--- a/fb/fbpseudocolor.c
+++ b/fb/fbpseudocolor.c
@@ -125,13 +125,11 @@ typedef struct {
} xxScrPrivRec, *xxScrPrivPtr;
#define xxGetScrPriv(s) ((xxScrPrivPtr) \
- (xxScrPrivateIndex != -1) \
- ? (s)->devPrivates[xxScrPrivateIndex].ptr\
- : NULL)
+ dixLookupPrivate(&(s)->devPrivates, xxScrPrivateKey))
#define xxScrPriv(s) xxScrPrivPtr pScrPriv = xxGetScrPriv(s)
#define xxGetCmapPriv(s) ((xxCmapPrivPtr) \
- (s)->devPrivates[xxColormapPrivateIndex].ptr)
+ dixLookupPrivate(&(s)->devPrivates, xxColormapPrivateKey))
#define xxCmapPriv(s) xxCmapPrivPtr pCmapPriv = xxGetCmapPriv(s);
typedef struct _xxGCPriv {
@@ -140,13 +138,12 @@ typedef struct _xxGCPriv {
} xxGCPrivRec, *xxGCPrivPtr;
#define xxGetGCPriv(pGC) ((xxGCPrivPtr) \
- (pGC)->devPrivates[xxGCPrivateIndex].ptr)
+ dixLookupPrivate(&(pGC)->devPrivates, xxGCPrivateKey))
#define xxGCPriv(pGC) xxGCPrivPtr pGCPriv = xxGetGCPriv(pGC)
-int xxScrPrivateIndex = -1;
-int xxGCPrivateIndex;
-int xxColormapPrivateIndex = -1;
-int xxGeneration;
+static DevPrivateKey xxScrPrivateKey = &xxScrPrivateKey;
+static DevPrivateKey xxGCPrivateKey = &xxGCPrivateKey;
+static DevPrivateKey xxColormapPrivateKey = &xxColormapPrivateKey;
#define wrap(priv,real,mem,func) {\
@@ -356,26 +353,20 @@ xxMyVisual(ScreenPtr pScreen, VisualID vid)
}
static Bool
-xxInitColormapDummy(ColormapPtr pmap, int index)
-{
- return TRUE;
-}
-
-static Bool
xxInitColormapPrivate(ColormapPtr pmap)
{
xxScrPriv(pmap->pScreen);
xxCmapPrivPtr pCmapPriv;
pointer cmap;
- pmap->devPrivates[xxColormapPrivateIndex].ptr = (pointer) -1;
+ dixSetPrivate(&pmap->devPrivates, xxColormapPrivateKey, (pointer) -1);
if (xxMyVisual(pmap->pScreen,pmap->pVisual->vid)) {
DBG("CreateColormap\n");
pCmapPriv = (xxCmapPrivPtr) xalloc (sizeof (xxCmapPrivRec));
if (!pCmapPriv)
return FALSE;
- pmap->devPrivates[xxColormapPrivateIndex].ptr = (pointer) pCmapPriv;
+ dixSetPrivate(&pmap->devPrivates, xxColormapPrivateKey, pCmapPriv);
cmap = xalloc(sizeof (CARD32) * (1 << pScrPriv->myDepth));
if (!cmap)
return FALSE;
@@ -677,7 +668,7 @@ xxCreateWindow(WindowPtr pWin)
DBG("CreateWindow\n");
- pWin->devPrivates[fbWinPrivateIndex].ptr = (pointer) pScrPriv->pPixmap;
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pScrPriv->pPixmap);
PRINT_RECTS(pScrPriv->region);
if (!pWin->parent) {
REGION_EMPTY (pWin->drawable.pScreen, &pScrPriv->region);
@@ -746,9 +737,10 @@ xxCopyWindow(WindowPtr pWin,
xxPickMyWindows(pWin,&rgn);
unwrap (pScrPriv, pScreen, CopyWindow);
- pWin->devPrivates[fbWinPrivateIndex].ptr = fbGetScreenPixmap(pScreen);
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(),
+ fbGetScreenPixmap(pScreen));
pScreen->CopyWindow(pWin, ptOldOrg, prgnSrc);
- pWin->devPrivates[fbWinPrivateIndex].ptr = pPixmap;
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(), pPixmap);
wrap(pScrPriv, pScreen, CopyWindow, xxCopyWindow);
REGION_INTERSECT(pScreen,&rgn,&rgn,&rgn_new);
@@ -1098,21 +1090,7 @@ xxSetup(ScreenPtr pScreen, int myDepth, int baseDepth, char* addr, xxSyncFunc sy
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
- if (xxGeneration != serverGeneration) {
- xxScrPrivateIndex = AllocateScreenPrivateIndex ();
- if (xxScrPrivateIndex == -1)
- return FALSE;
- xxColormapPrivateIndex
- = AllocateColormapPrivateIndex (xxInitColormapDummy);
- if (xxColormapPrivateIndex == -1)
- return FALSE;
- xxGCPrivateIndex = AllocateGCPrivateIndex ();
- if (xxGCPrivateIndex == -1)
- return FALSE;
- xxGeneration = serverGeneration;
- }
-
- if (!AllocateGCPrivate (pScreen, xxGCPrivateIndex, sizeof (xxGCPrivRec)))
+ if (!dixRequestPrivate(xxGCPrivateKey, sizeof (xxGCPrivRec)))
return FALSE;
pScrPriv = (xxScrPrivPtr) xalloc (sizeof (xxScrPrivRec));
@@ -1190,7 +1168,7 @@ xxSetup(ScreenPtr pScreen, int myDepth, int baseDepth, char* addr, xxSyncFunc sy
}
#endif
pScrPriv->addr = addr;
- pScreen->devPrivates[xxScrPrivateIndex].ptr = (pointer) pScrPriv;
+ dixSetPrivate(&pScreen->devPrivates, xxScrPrivateKey, pScrPriv);
pDefMap = (ColormapPtr) LookupIDByType(pScreen->defColormap, RT_COLORMAP);
if (!xxInitColormapPrivate(pDefMap))
diff --git a/fb/fbscreen.c b/fb/fbscreen.c
index 661268c74..c99ba08e2 100644
--- a/fb/fbscreen.c
+++ b/fb/fbscreen.c
@@ -38,7 +38,7 @@ fbCloseScreen (int index, ScreenPtr pScreen)
xfree (pScreen->visuals);
xfree (pScreen->devPrivate);
#ifdef FB_SCREEN_PRIVATE
- xfree (pScreen->devPrivates[fbScreenPrivateIndex].ptr);
+ xfree (dixLookupPrivate(&pScreen->devPrivates, fbGetScreenPrivateKey()));
#endif
return TRUE;
}
@@ -93,7 +93,7 @@ _fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap)
#ifdef FB_NO_WINDOW_PIXMAPS
FatalError ("Attempted to set window pixmap without fb support\n");
#else
- pWindow->devPrivates[fbWinPrivateIndex].ptr = (pointer) pPixmap;
+ dixSetPrivate(&pWindow->devPrivates, fbGetWinPrivateKey(), pPixmap);
#endif
}
@@ -107,7 +107,7 @@ fbSetupScreen(ScreenPtr pScreen,
int width, /* pixel width of frame buffer */
int bpp) /* bits per pixel for screen */
{
- if (!fbAllocatePrivates(pScreen, (int *) 0))
+ if (!fbAllocatePrivates(pScreen, NULL))
return FALSE;
pScreen->defColormap = FakeClientID(0);
/* let CreateDefColormap do whatever it wants for pixels */
diff --git a/fb/fbwindow.c b/fb/fbwindow.c
index 144f08362..594cc612f 100644
--- a/fb/fbwindow.c
+++ b/fb/fbwindow.c
@@ -32,8 +32,8 @@ Bool
fbCreateWindow(WindowPtr pWin)
{
#ifndef FB_NO_WINDOW_PIXMAPS
- pWin->devPrivates[fbWinPrivateIndex].ptr =
- (pointer) fbGetScreenPixmap(pWin->drawable.pScreen);
+ dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(),
+ fbGetScreenPixmap(pWin->drawable.pScreen));
#endif
#ifdef FB_SCREEN_PRIVATE
if (pWin->drawable.bitsPerPixel == 32)
diff --git a/fb/wfbrename.h b/fb/wfbrename.h
index 5ea9092f8..a6296fb1d 100644
--- a/fb/wfbrename.h
+++ b/fb/wfbrename.h
@@ -84,14 +84,14 @@
#define fbFixCoordModePrevious wfbFixCoordModePrevious
#define fbGCFuncs wfbGCFuncs
#define fbGCOps wfbGCOps
-#define fbGCPrivateIndex wfbGCPrivateIndex
+#define fbGCPrivateKey wfbGCPrivateKey
#define fbGeneration wfbGeneration
-#define fbGetGCPrivateIndex wfbGetGCPrivateIndex
+#define fbGetGCPrivateKey wfbGetGCPrivateKey
#define fbGetImage wfbGetImage
-#define fbGetScreenPrivateIndex wfbGetScreenPrivateIndex
+#define fbGetScreenPrivateKey wfbGetScreenPrivateKey
#define fbGetSpans wfbGetSpans
#define _fbGetWindowPixmap _wfbGetWindowPixmap
-#define fbGetWinPrivateIndex wfbGetWinPrivateIndex
+#define fbGetWinPrivateKey wfbGetWinPrivateKey
#define fbGlyph16 wfbGlyph16
#define fbGlyph24 wfbGlyph24
#define fbGlyph32 wfbGlyph32
@@ -117,10 +117,10 @@
#define fbOverlayCreateWindow wfbOverlayCreateWindow
#define fbOverlayFinishScreenInit wfbOverlayFinishScreenInit
#define fbOverlayGeneration wfbOverlayGeneration
-#define fbOverlayGetScreenPrivateIndex wfbOverlayGetScreenPrivateIndex
+#define fbOverlayGetScreenPrivateKey wfbOverlayGetScreenPrivateKey
#define fbOverlayPaintKey wfbOverlayPaintKey
#define fbOverlayPaintWindow wfbOverlayPaintWindow
-#define fbOverlayScreenPrivateIndex wfbOverlayScreenPrivateIndex
+#define fbOverlayScreenPrivateKey wfbOverlayScreenPrivateKey
#define fbOverlaySetupScreen wfbOverlaySetupScreen
#define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion
#define fbOverlayWindowExposures wfbOverlayWindowExposures
@@ -160,7 +160,7 @@
#define fbResolveColor wfbResolveColor
#define fbRestoreAreas wfbRestoreAreas
#define fbSaveAreas wfbSaveAreas
-#define fbScreenPrivateIndex wfbScreenPrivateIndex
+#define fbScreenPrivateKey wfbScreenPrivateKey
#define fbSegment wfbSegment
#define fbSelectBres wfbSelectBres
#define fbSetSpans wfbSetSpans
@@ -185,14 +185,14 @@
#define fbUnrealizeFont wfbUnrealizeFont
#define fbValidateGC wfbValidateGC
#define fbWalkCompositeRegion wfbWalkCompositeRegion
-#define fbWinPrivateIndex wfbWinPrivateIndex
+#define fbWinPrivateKey wfbWinPrivateKey
#define fbZeroLine wfbZeroLine
#define fbZeroSegment wfbZeroSegment
#define free_pixman_pict wfb_free_pixman_pict
#define image_from_pict wfb_image_from_pict
-#define xxScrPrivateIndex wfbxxScrPrivateIndex
-#define xxGCPrivateIndex wfbxxGCPrivateIndex
-#define xxColormapPrivateIndex wfbxxColormapPrivateIndex
+#define xxScrPrivateKey wfbxxScrPrivateKey
+#define xxGCPrivateKey wfbxxGCPrivateKey
+#define xxColormapPrivateKey wfbxxColormapPrivateKey
#define xxGeneration wfbxxGeneration
#define xxPrintVisuals wfbxxPrintVisuals
#define xxGCFuncs wfbxxGCFuncs
diff --git a/hw/darwin/darwin.h b/hw/darwin/darwin.h
index fc4a58a95..70101eca5 100644
--- a/hw/darwin/darwin.h
+++ b/hw/darwin/darwin.h
@@ -88,8 +88,8 @@ void DarwinModeBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class);
#define kern_assert(x) { if ((x) != KERN_SUCCESS) \
FatalError("assert failed on line %d of %s with kernel return 0x%x!\n", \
__LINE__, __FILE__, x); }
-#define SCREEN_PRIV(pScreen) \
- ((DarwinFramebufferPtr)pScreen->devPrivates[darwinScreenIndex].ptr)
+#define SCREEN_PRIV(pScreen) ((DarwinFramebufferPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, darwinScreenKey))
#define MIN_KEYCODE XkbMinLegalKeyCode // unfortunately, this isn't 0...
@@ -98,7 +98,7 @@ void DarwinModeBell(int volume, DeviceIntPtr pDevice, pointer ctrl, int class);
/*
* Global variables from darwin.c
*/
-extern int darwinScreenIndex; // index into pScreen.devPrivates
+extern DevPrivateKey darwinScreenKey; // index into pScreen.devPrivates
extern int darwinScreensFound;
extern io_connect_t darwinParamConnect;
extern int darwinEventReadFD;
diff --git a/hw/darwin/iokit/xfIOKit.h b/hw/darwin/iokit/xfIOKit.h
index 27d27bc70..7d9a48702 100644
--- a/hw/darwin/iokit/xfIOKit.h
+++ b/hw/darwin/iokit/xfIOKit.h
@@ -45,10 +45,10 @@ typedef struct {
unsigned char *shadowPtr;
} XFIOKitScreenRec, *XFIOKitScreenPtr;
-#define XFIOKIT_SCREEN_PRIV(pScreen) \
- ((XFIOKitScreenPtr)pScreen->devPrivates[xfIOKitScreenIndex].ptr)
+#define XFIOKIT_SCREEN_PRIV(pScreen) ((XFIOKitScreenPtr) \
+ dixLookupPrivate(&pScreen->devPrivates, xfIOKitScreenKey))
-extern int xfIOKitScreenIndex; // index into pScreen.devPrivates
+extern DevPrivateKey xfIOKitScreenKey; // index into pScreen.devPrivates
extern io_connect_t xfIOKitInputConnect;
Bool XFIOKitInitCursor(ScreenPtr pScreen);
diff --git a/hw/darwin/iokit/xfIOKitCursor.c b/hw/darwin/iokit/xfIOKitCursor.c
index 8388513a3..224710114 100644
--- a/hw/darwin/iokit/xfIOKitCursor.c
+++ b/hw/darwin/iokit/xfIOKitCursor.c
@@ -73,8 +73,8 @@
#include <assert.h>
#define DUMP_DARWIN_CURSOR FALSE
-#define CURSOR_PRIV(pScreen) \
- ((XFIOKitCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
+#define CURSOR_PRIV(pScreen) ((XFIOKitCursorScreenPtr) \
+ dixLookupPrivate(&pScreen->devPrivates, darwinCursorScreenKey))
// The cursors format are documented in IOFramebufferShared.h.
#define RGBto34WithGamma(red, green, blue) \
@@ -99,8 +99,7 @@ typedef struct {
ColormapPtr pInstalledMap;
} XFIOKitCursorScreenRec, *XFIOKitCursorScreenPtr;
-static int darwinCursorScreenIndex = -1;
-static unsigned long darwinCursorGeneration = 0;
+static DevPrivateKey darwinCursorScreenKey = &darwinCursorScreenKey;
/*
===========================================================================
@@ -679,17 +678,10 @@ XFIOKitInitCursor(
return FALSE;
}
- // allocate private storage for this screen's hardware cursor info
- if (darwinCursorGeneration != serverGeneration) {
- if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- darwinCursorGeneration = serverGeneration;
- }
-
ScreenPriv = xcalloc( 1, sizeof(XFIOKitCursorScreenRec) );
if (!ScreenPriv) return FALSE;
- pScreen->devPrivates[darwinCursorScreenIndex].ptr = (pointer) ScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, darwinCursorScreenKey, ScreenPriv);
// check if a hardware cursor is supported
if (!iokitScreen->cursorShmem->hardwareCursorCapable) {
@@ -722,7 +714,7 @@ XFIOKitInitCursor(
// initialize hardware cursor handling
PointPriv = (miPointerScreenPtr)
- pScreen->devPrivates[miPointerScreenIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
PointPriv->spriteFuncs = &darwinSpriteFuncsRec;
diff --git a/hw/darwin/quartz/fullscreen/fullscreen.c b/hw/darwin/quartz/fullscreen/fullscreen.c
index 02f6e89a8..ee16e55e5 100644
--- a/hw/darwin/quartz/fullscreen/fullscreen.c
+++ b/hw/darwin/quartz/fullscreen/fullscreen.c
@@ -49,18 +49,17 @@ typedef struct {
} FSScreenRec, *FSScreenPtr;
#define FULLSCREEN_PRIV(pScreen) \
- ((FSScreenPtr)pScreen->devPrivates[fsScreenIndex].ptr)
+ ((FSScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, fsScreenKey))
-static int fsScreenIndex;
+static DevPrivateKey fsScreenKey = &fsScreenKey;
static CGDirectDisplayID *quartzDisplayList = NULL;
static int quartzNumScreens = 0;
static FSScreenPtr quartzScreens[MAXSCREENS];
-static int darwinCmapPrivateIndex = -1;
-static unsigned long darwinCmapGeneration = 0;
+static DevPrivateKey darwinCmapPrivateKey = &darwinCmapPrivateKey;
-#define CMAP_PRIV(pCmap) \
- ((CGDirectPaletteRef) (pCmap)->devPrivates[darwinCmapPrivateIndex].ptr)
+#define CMAP_PRIV(pCmap) ((CGDirectPaletteRef) \
+ dixLookupPrivate(&(pCmap)->devPrivates, darwinCmapPrivateKey))
/*
=============================================================================
@@ -95,16 +94,6 @@ FSCreateColormap(
{
CGDirectPaletteRef pallete;
- // Allocate private storage for the hardware dependent colormap info.
- if (darwinCmapGeneration != serverGeneration) {
- if ((darwinCmapPrivateIndex =
- AllocateColormapPrivateIndex(FSInitCmapPrivates)) < 0)
- {
- return FALSE;
- }
- darwinCmapGeneration = serverGeneration;
- }
-
pallete = CGPaletteCreateDefaultColorPalette();
if (!pallete) return FALSE;
@@ -283,17 +272,10 @@ static void FSResumeScreen(
*/
static void FSDisplayInit(void)
{
- static unsigned long generation = 0;
CGDisplayCount quartzDisplayCount = 0;
ErrorF("Display mode: Full screen Quartz -- Direct Display\n");
- // Allocate private storage for each screen's mode specific info
- if (generation != serverGeneration) {
- fsScreenIndex = AllocateScreenPrivateIndex();
- generation = serverGeneration;
- }
-
// Find all the CoreGraphics displays
CGGetActiveDisplayList(0, NULL, &quartzDisplayCount);
quartzDisplayList = xalloc(quartzDisplayCount * sizeof(CGDirectDisplayID));
diff --git a/hw/darwin/quartz/fullscreen/quartzCursor.c b/hw/darwin/quartz/fullscreen/quartzCursor.c
index 77fa008f2..bee83b875 100644
--- a/hw/darwin/quartz/fullscreen/quartzCursor.c
+++ b/hw/darwin/quartz/fullscreen/quartzCursor.c
@@ -56,8 +56,7 @@ typedef struct {
miPointerSpriteFuncPtr spriteFuncs;
} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
-static int darwinCursorScreenIndex = -1;
-static unsigned long darwinCursorGeneration = 0;
+static DevPrivateKey darwinCursorScreenKey = &darwinCursorScreenKey;
static CursorPtr quartzLatentCursor = NULL;
static QD_Cursor gQDArrow; // QuickDraw arrow cursor
@@ -66,8 +65,8 @@ static CCrsrHandle currentCursor = NULL;
static pthread_mutex_t cursorMutex;
static pthread_cond_t cursorCondition;
-#define CURSOR_PRIV(pScreen) \
- ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
+#define CURSOR_PRIV(pScreen) ((QuartzCursorScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, darwinCursorScreenKey))
#define HIDE_QD_CURSOR(pScreen, visible) \
if (visible) { \
@@ -592,13 +591,6 @@ QuartzInitCursor(
return FALSE;
}
- // allocate private storage for this screen's QuickDraw cursor info
- if (darwinCursorGeneration != serverGeneration) {
- if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- darwinCursorGeneration = serverGeneration;
- }
-
ScreenPriv = xcalloc( 1, sizeof(QuartzCursorScreenRec) );
if (!ScreenPriv) return FALSE;
@@ -611,7 +603,7 @@ QuartzInitCursor(
// initialize QuickDraw cursor handling
GetQDGlobalsArrow(&gQDArrow);
PointPriv = (miPointerScreenPtr)
- pScreen->devPrivates[miPointerScreenIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
diff --git a/hw/darwin/quartz/quartz.c b/hw/darwin/quartz/quartz.c
index 038b21eff..eac765257 100644
--- a/hw/darwin/quartz/quartz.c
+++ b/hw/darwin/quartz/quartz.c
@@ -62,7 +62,7 @@ int quartzUseAGL = 1;
int quartzEnableKeyEquivalents = 1;
int quartzServerVisible = TRUE;
int quartzServerQuitting = FALSE;
-int quartzScreenIndex = 0;
+DevPrivateKey quartzScreenKey = &quartzScreenKey;
int aquaMenuBarHeight = 0;
int noPseudoramiXExtension = TRUE;
QuartzModeProcsPtr quartzProcs = NULL;
@@ -121,14 +121,6 @@ void DarwinModeInitOutput(
int argc,
char **argv )
{
- static unsigned long generation = 0;
-
- // Allocate private storage for each screen's Quartz specific info
- if (generation != serverGeneration) {
- quartzScreenIndex = AllocateScreenPrivateIndex();
- generation = serverGeneration;
- }
-
if (serverGeneration == 0) {
QuartzAudioInit();
}
diff --git a/hw/darwin/quartz/quartzCommon.h b/hw/darwin/quartz/quartzCommon.h
index f5dff662c..5e199d362 100644
--- a/hw/darwin/quartz/quartzCommon.h
+++ b/hw/darwin/quartz/quartzCommon.h
@@ -58,7 +58,7 @@ typedef struct {
} QuartzScreenRec, *QuartzScreenPtr;
#define QUARTZ_PRIV(pScreen) \
- ((QuartzScreenPtr)pScreen->devPrivates[quartzScreenIndex].ptr)
+ ((QuartzScreenPtr)dixLookupPrivate(&pScreen->devPrivates, quartzScreenKey))
// Data stored at startup for Cocoa front end
extern int quartzEventWriteFD;
@@ -73,7 +73,7 @@ extern int quartzEnableKeyEquivalents;
// Other shared data
extern int quartzServerVisible;
extern int quartzServerQuitting;
-extern int quartzScreenIndex;
+extern DevPrivateKey quartzScreenKey;
extern int aquaMenuBarHeight;
// Name of GLX bundle for native OpenGL
diff --git a/hw/darwin/quartz/quartzCursor.c b/hw/darwin/quartz/quartzCursor.c
index 6ed6a7677..a121ce17c 100644
--- a/hw/darwin/quartz/quartzCursor.c
+++ b/hw/darwin/quartz/quartzCursor.c
@@ -57,8 +57,7 @@ typedef struct {
miPointerSpriteFuncPtr spriteFuncs;
} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
-static int darwinCursorScreenIndex = -1;
-static unsigned long darwinCursorGeneration = 0;
+static DevPrivateKey darwinCursorScreenKey = &darwinCursorScreenKey;
static CursorPtr quartzLatentCursor = NULL;
static QD_Cursor gQDArrow; // QuickDraw arrow cursor
@@ -67,8 +66,8 @@ static CCrsrHandle currentCursor = NULL;
static pthread_mutex_t cursorMutex;
static pthread_cond_t cursorCondition;
-#define CURSOR_PRIV(pScreen) \
- ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
+#define CURSOR_PRIV(pScreen) ((QuartzCursorScreenPtr) \
+ dixLookupPrivate(&pScreen->devPrivates, darwinCursorScreenKey))
#define HIDE_QD_CURSOR(pScreen, visible) \
if (visible) { \
@@ -595,13 +594,6 @@ QuartzInitCursor(
return FALSE;
}
- // allocate private storage for this screen's QuickDraw cursor info
- if (darwinCursorGeneration != serverGeneration) {
- if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- darwinCursorGeneration = serverGeneration;
- }
-
ScreenPriv = xcalloc( 1, sizeof(QuartzCursorScreenRec) );
if (!ScreenPriv) return FALSE;
@@ -614,7 +606,7 @@ QuartzInitCursor(
// initialize QuickDraw cursor handling
GetQDGlobalsArrow(&gQDArrow);
PointPriv = (miPointerScreenPtr)
- pScreen->devPrivates[miPointerScreenIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
diff --git a/hw/darwin/quartz/xpr/dri.c b/hw/darwin/quartz/xpr/dri.c
index 08ee38221..8c6ed99ac 100644
--- a/hw/darwin/quartz/xpr/dri.c
+++ b/hw/darwin/quartz/xpr/dri.c
@@ -65,9 +65,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <AvailabilityMacros.h>
-static int DRIScreenPrivIndex = -1;
-static int DRIWindowPrivIndex = -1;
-static int DRIPixmapPrivIndex = -1;
+static DevPrivateKey DRIScreenPrivKey = &DRIScreenPrivKey;
+static DevPrivateKey DRIWindowPrivKey = &DRIWindowPrivKey;
+static DevPrivateKey DRIPixmapPrivKey = &DRIPixmapPrivKey;
static RESTYPE DRIDrawablePrivResType;
@@ -179,11 +179,11 @@ DRIScreenInit(ScreenPtr pScreen)
pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec));
if (!pDRIPriv) {
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
return FALSE;
}
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv);
pDRIPriv->directRenderingSupport = TRUE;
pDRIPriv->nrWindows = 0;
@@ -214,13 +214,6 @@ DRIFinishScreenInit(ScreenPtr pScreen)
{
DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen);
- /* Allocate zero sized private area for each window. Should a window
- * become a DRI window, we'll hang a DRIWindowPrivateRec off of this
- * private index.
- */
- if (!AllocateWindowPrivate(pScreen, DRIWindowPrivIndex, 0))
- return FALSE;
-
/* Wrap DRI support */
pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree;
pScreen->ValidateTree = DRIValidateTree;
@@ -249,31 +242,13 @@ DRICloseScreen(ScreenPtr pScreen)
if (pDRIPriv && pDRIPriv->directRenderingSupport) {
xfree(pDRIPriv);
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
}
}
Bool
DRIExtensionInit(void)
{
- static unsigned long DRIGeneration = 0;
-
- if (DRIGeneration != serverGeneration) {
- if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- DRIGeneration = serverGeneration;
- }
-
- /*
- * Allocate a window private index with a zero sized private area for
- * each window, then should a window become a DRI window, we'll hang
- * a DRIWindowPrivateRec off of this private index. Do same for pixmaps.
- */
- if ((DRIWindowPrivIndex = AllocateWindowPrivateIndex()) < 0)
- return FALSE;
- if ((DRIPixmapPrivIndex = AllocatePixmapPrivateIndex()) < 0)
- return FALSE;
-
DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete);
return TRUE;
@@ -417,7 +392,8 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
}
/* save private off of preallocated index */
- pWin->devPrivates[DRIWindowPrivIndex].ptr = (pointer)pDRIDrawablePriv;
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
+ pDRIDrawablePriv);
}
}
@@ -450,7 +426,8 @@ DRICreateSurface(ScreenPtr pScreen, Drawable id,
}
/* save private off of preallocated index */
- pPix->devPrivates[DRIPixmapPrivIndex].ptr = (pointer)pDRIDrawablePriv;
+ dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey,
+ pDRIDrawablePriv);
}
}
#endif
@@ -577,9 +554,9 @@ DRIDrawablePrivDelete(pointer pResource, XID id)
xfree(pDRIDrawablePriv);
if (pDrawable->type == DRAWABLE_WINDOW) {
- pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL;
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
} else if (pDrawable->type == DRAWABLE_PIXMAP) {
- pPix->devPrivates[DRIPixmapPrivIndex].ptr = NULL;
+ dixSetPrivate(&pPix->devPrivates, DRIPixmapPrivKey, NULL);
}
--pDRIPriv->nrWindows;
diff --git a/hw/darwin/quartz/xpr/dristruct.h b/hw/darwin/quartz/xpr/dristruct.h
index 9a3d01c9b..19d78a973 100644
--- a/hw/darwin/quartz/xpr/dristruct.h
+++ b/hw/darwin/quartz/xpr/dristruct.h
@@ -40,15 +40,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define DRI_MAX_DRAWABLES 256
-#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) \
- ((DRIWindowPrivIndex < 0) ? \
- NULL : \
- ((DRIDrawablePrivPtr)((pWin)->devPrivates[DRIWindowPrivIndex].ptr)))
+#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey))
-#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) \
- ((DRIPixmapPrivIndex < 0) ? \
- NULL : \
- ((DRIDrawablePrivPtr)((pPix)->devPrivates[DRIPixmapPrivIndex].ptr)))
+#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pPix)->devPrivates, DRIPixmapPrivKey))
typedef struct _DRIDrawablePrivRec
{
@@ -61,13 +57,12 @@ typedef struct _DRIDrawablePrivRec
x_list *notifiers; /* list of (FUN . DATA) */
} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
-#define DRI_SCREEN_PRIV(pScreen) \
- ((DRIScreenPrivIndex < 0) ? \
- NULL : \
- ((DRIScreenPrivPtr)((pScreen)->devPrivates[DRIScreenPrivIndex].ptr)))
+#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey))
#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
- (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr))
+ dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \
+ DRIScreenPrivKey))
typedef struct _DRIScreenPrivRec
diff --git a/hw/darwin/quartz/xpr/xprCursor.c b/hw/darwin/quartz/xpr/xprCursor.c
index e7f23b78b..c0516e84c 100644
--- a/hw/darwin/quartz/xpr/xprCursor.c
+++ b/hw/darwin/quartz/xpr/xprCursor.c
@@ -53,11 +53,10 @@ typedef struct {
miPointerSpriteFuncPtr spriteFuncs;
} QuartzCursorScreenRec, *QuartzCursorScreenPtr;
-static int darwinCursorScreenIndex = -1;
-static unsigned long darwinCursorGeneration = 0;
+static DevPrivateKey darwinCursorScreenKey = &darwinCursorScreenKey;
-#define CURSOR_PRIV(pScreen) \
- ((QuartzCursorScreenPtr)pScreen->devPrivates[darwinCursorScreenIndex].ptr)
+#define CURSOR_PRIV(pScreen) ((QuartzCursorScreenPtr) \
+ dixLookupPrivate(&pScreen->devPrivates, darwinCursorScreenKey))
static Bool
@@ -360,15 +359,6 @@ QuartzInitCursor(ScreenPtr pScreen)
if (!miDCInitialize(pScreen, &quartzScreenFuncsRec))
return FALSE;
- /* allocate private storage for this screen's QuickDraw cursor info */
- if (darwinCursorGeneration != serverGeneration)
- {
- if ((darwinCursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
-
- darwinCursorGeneration = serverGeneration;
- }
-
ScreenPriv = xcalloc(1, sizeof(QuartzCursorScreenRec));
if (ScreenPriv == NULL)
return FALSE;
@@ -379,7 +369,8 @@ QuartzInitCursor(ScreenPtr pScreen)
ScreenPriv->QueryBestSize = pScreen->QueryBestSize;
pScreen->QueryBestSize = QuartzCursorQueryBestSize;
- PointPriv = (miPointerScreenPtr) pScreen->devPrivates[miPointerScreenIndex].ptr;
+ PointPriv = (miPointerScreenPtr)
+ dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
ScreenPriv->spriteFuncs = PointPriv->spriteFuncs;
PointPriv->spriteFuncs = &quartzSpriteFuncsRec;
diff --git a/hw/dmx/dmxcmap.c b/hw/dmx/dmxcmap.c
index 949d7d689..4aa586aff 100644
--- a/hw/dmx/dmxcmap.c
+++ b/hw/dmx/dmxcmap.c
@@ -46,24 +46,10 @@
#include "micmap.h"
-static int dmxInitColormapPrivateFunc(ColormapPtr pColormap, int index)
-{
- return TRUE;
-}
-
static Bool dmxAllocateColormapPrivates(ColormapPtr pColormap)
{
- static unsigned long dmxColormapGeneration;
dmxColormapPrivPtr pCmapPriv;
- if (dmxColormapGeneration != serverGeneration) {
- if ((dmxColormapPrivateIndex
- = AllocateColormapPrivateIndex(dmxInitColormapPrivateFunc)) < 0)
- return FALSE;
-
- dmxColormapGeneration = serverGeneration;
- }
-
pCmapPriv = (dmxColormapPrivPtr)xalloc(sizeof(*pCmapPriv));
if (!pCmapPriv)
return FALSE;
diff --git a/hw/dmx/dmxcmap.h b/hw/dmx/dmxcmap.h
index 228f8662e..f968f8622 100644
--- a/hw/dmx/dmxcmap.h
+++ b/hw/dmx/dmxcmap.h
@@ -56,15 +56,14 @@ extern Bool dmxBECreateColormap(ColormapPtr pColormap);
extern Bool dmxBEFreeColormap(ColormapPtr pColormap);
/** Private index. \see dmxcmap.c \see dmxscrinit.c \see dmxwindow.c */
-extern int dmxColormapPrivateIndex;
+extern DevPrivateKey dmxColormapPrivateKey;
/** Set colormap private structure. */
#define DMX_SET_COLORMAP_PRIV(_pCMap, _pCMapPriv) \
- (_pCMap)->devPrivates[dmxColormapPrivateIndex].ptr \
- = (pointer)(_pCMapPriv);
+ dixSetPrivate(&(_pCMap)->devPrivates, dmxColormapPrivateKey, _pCMapPriv)
/** Get colormap private structure. */
-#define DMX_GET_COLORMAP_PRIV(_pCMap) \
- (dmxColormapPrivPtr)(_pCMap)->devPrivates[dmxColormapPrivateIndex].ptr
+#define DMX_GET_COLORMAP_PRIV(_pCMap) (dmxColormapPrivPtr) \
+ dixLookupPrivate(&(_pCMap)->devPrivates, dmxColormapPrivateKey)
#endif /* DMXCMAP_H */
diff --git a/hw/dmx/dmxdpms.c b/hw/dmx/dmxdpms.c
index ea0d66c3c..8c745a6aa 100644
--- a/hw/dmx/dmxdpms.c
+++ b/hw/dmx/dmxdpms.c
@@ -177,7 +177,7 @@ void dmxDPMSWakeup(void)
if (screenIsSaved == SCREEN_SAVER_ON)
SaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
#ifdef DPMSExtension
- if (DPMSPowerLevel) DPMSSet(0);
+ if (DPMSPowerLevel) DPMSSet(serverClient, 0);
#endif
}
@@ -190,11 +190,11 @@ Bool DPMSSupported(void)
}
/** This is used by clients (e.g., xset) to set the DPMS level. */
-void DPMSSet(int level)
+int DPMSSet(ClientPtr client, int level)
{
int i;
- if (!dpmsSupported) return;
+ if (!dpmsSupported) return Success;
if (level < 0) level = DPMSModeOn;
if (level > 3) level = DPMSModeOff;
@@ -208,5 +208,6 @@ void DPMSSet(int level)
dmxSync(dmxScreen, FALSE);
}
}
+ return Success;
}
#endif
diff --git a/hw/dmx/dmxgc.c b/hw/dmx/dmxgc.c
index 981f64d0a..ce1730cff 100644
--- a/hw/dmx/dmxgc.c
+++ b/hw/dmx/dmxgc.c
@@ -82,13 +82,9 @@ static GCOps dmxGCOps = {
dmxPushPixels
};
-/** Initialize the GC on \a pScreen, which currently involves allocating
- * the GC private associated with this screen. */
+/** Initialize the GC on \a pScreen */
Bool dmxInitGC(ScreenPtr pScreen)
{
- if (!AllocateGCPrivate(pScreen, dmxGCPrivateIndex, sizeof(dmxGCPrivRec)))
- return FALSE;
-
return TRUE;
}
diff --git a/hw/dmx/dmxgc.h b/hw/dmx/dmxgc.h
index 3d49f6735..2da3ba85e 100644
--- a/hw/dmx/dmxgc.h
+++ b/hw/dmx/dmxgc.h
@@ -64,11 +64,11 @@ extern void dmxBECreateGC(ScreenPtr pScreen, GCPtr pGC);
extern Bool dmxBEFreeGC(GCPtr pGC);
/** Private index. \see dmxgc.c \see dmxscrinit.c */
-extern int dmxGCPrivateIndex;
+extern DevPrivateKey dmxGCPrivateKey;
/** Get private. */
#define DMX_GET_GC_PRIV(_pGC) \
- (dmxGCPrivPtr)(_pGC)->devPrivates[dmxGCPrivateIndex].ptr
+ (dmxGCPrivPtr)dixLookupPrivate(&(_pGC)->devPrivates, dmxGCPrivateKey)
#define DMX_GC_FUNC_PROLOGUE(_pGC) \
do { \
diff --git a/hw/dmx/dmxpict.c b/hw/dmx/dmxpict.c
index 478542a13..f2110b534 100644
--- a/hw/dmx/dmxpict.c
+++ b/hw/dmx/dmxpict.c
@@ -144,8 +144,7 @@ Bool dmxPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
if (!miPictureInit(pScreen, formats, nformats))
return FALSE;
- if (!AllocatePicturePrivate(pScreen, dmxPictPrivateIndex,
- sizeof(dmxPictPrivRec)))
+ if (!dixRequestPrivate(dmxPictPrivateKey, sizeof(dmxPictPrivRec)))
return FALSE;
ps = GetPictureScreen(pScreen);
diff --git a/hw/dmx/dmxpict.h b/hw/dmx/dmxpict.h
index c178ef39c..a81eb7d37 100644
--- a/hw/dmx/dmxpict.h
+++ b/hw/dmx/dmxpict.h
@@ -116,19 +116,19 @@ extern Bool dmxBEFreeGlyphSet(ScreenPtr pScreen, GlyphSetPtr glyphSet);
extern int dmxBECreatePicture(PicturePtr pPicture);
extern Bool dmxBEFreePicture(PicturePtr pPicture);
-extern int dmxPictPrivateIndex; /**< Index for picture private data */
-extern int dmxGlyphSetPrivateIndex; /**< Index for glyphset private data */
+extern DevPrivateKey dmxPictPrivateKey; /**< Index for picture private data */
+extern DevPrivateKey dmxGlyphSetPrivateKey; /**< Index for glyphset private data */
/** Get the picture private data given a picture pointer */
#define DMX_GET_PICT_PRIV(_pPict) \
- (dmxPictPrivPtr)(_pPict)->devPrivates[dmxPictPrivateIndex].ptr
+ (dmxPictPrivPtr)dixLookupPrivate(&(_pPict)->devPrivates, dmxPictPrivateKey)
/** Set the glyphset private data given a glyphset pointer */
#define DMX_SET_GLYPH_PRIV(_pGlyph, _pPriv) \
- GlyphSetSetPrivate((_pGlyph), dmxGlyphSetPrivateIndex, (_pPriv))
+ GlyphSetSetPrivate((_pGlyph), dmxGlyphSetPrivateKey, (_pPriv))
/** Get the glyphset private data given a glyphset pointer */
#define DMX_GET_GLYPH_PRIV(_pGlyph) \
- (dmxGlyphPrivPtr)GlyphSetGetPrivate((_pGlyph), dmxGlyphSetPrivateIndex)
+ (dmxGlyphPrivPtr)GlyphSetGetPrivate((_pGlyph), dmxGlyphSetPrivateKey)
#endif /* DMXPICT_H */
diff --git a/hw/dmx/dmxpixmap.c b/hw/dmx/dmxpixmap.c
index 323ae606a..f8d012630 100644
--- a/hw/dmx/dmxpixmap.c
+++ b/hw/dmx/dmxpixmap.c
@@ -49,8 +49,7 @@
/** Initialize a private area in \a pScreen for pixmap information. */
Bool dmxInitPixmap(ScreenPtr pScreen)
{
- if (!AllocatePixmapPrivate(pScreen, dmxPixPrivateIndex,
- sizeof(dmxPixPrivRec)))
+ if (!dixRequestPrivate(dmxPixPrivateKey, sizeof(dmxPixPrivRec)))
return FALSE;
return TRUE;
@@ -173,7 +172,7 @@ Bool dmxDestroyPixmap(PixmapPtr pPixmap)
dmxSync(dmxScreen, FALSE);
}
}
- dixFreePrivates(*DEVPRIV_PTR(pPixmap));
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
#if 0
diff --git a/hw/dmx/dmxpixmap.h b/hw/dmx/dmxpixmap.h
index 4ecd10fd8..3cfd99e6d 100644
--- a/hw/dmx/dmxpixmap.h
+++ b/hw/dmx/dmxpixmap.h
@@ -57,10 +57,10 @@ extern void dmxBECreatePixmap(PixmapPtr pPixmap);
extern Bool dmxBEFreePixmap(PixmapPtr pPixmap);
/** Private index. \see dmxpicmap.h \see dmxscrinit.c */
-extern int dmxPixPrivateIndex;
+extern DevPrivateKey dmxPixPrivateKey;
/** Get pixmap private pointer. */
#define DMX_GET_PIXMAP_PRIV(_pPix) \
- (dmxPixPrivPtr)(_pPix)->devPrivates[dmxPixPrivateIndex].ptr
+ (dmxPixPrivPtr)dixLookupPrivate(&(_pPix)->devPrivates, dmxPixPrivateKey)
#endif /* DMXPIXMAP_H */
diff --git a/hw/dmx/dmxscrinit.c b/hw/dmx/dmxscrinit.c
index 8ae448a5e..9b15bb38c 100644
--- a/hw/dmx/dmxscrinit.c
+++ b/hw/dmx/dmxscrinit.c
@@ -67,15 +67,15 @@ static Bool dmxSaveScreen(ScreenPtr pScreen, int what);
static unsigned long dmxGeneration;
static unsigned long *dmxCursorGeneration;
-int dmxGCPrivateIndex; /**< Private index for GCs */
-int dmxWinPrivateIndex; /**< Private index for Windows */
-int dmxPixPrivateIndex; /**< Private index for Pixmaps */
+DevPrivateKey dmxGCPrivateKey = &dmxGCPrivateKey; /**< Private index for GCs */
+DevPrivateKey dmxWinPrivateKey = &dmxWinPrivateKey; /**< Private index for Windows */
+DevPrivateKey dmxPixPrivateKey = &dmxPixPrivateKey; /**< Private index for Pixmaps */
int dmxFontPrivateIndex; /**< Private index for Fonts */
-int dmxScreenPrivateIndex; /**< Private index for Screens */
-int dmxColormapPrivateIndex; /**< Private index for Colormaps */
+DevPrivateKey dmxScreenPrivateKey = &dmxScreenPrivateKey; /**< Private index for Screens */
+DevPrivateKey dmxColormapPrivateKey = &dmxColormapPrivateKey; /**< Private index for Colormaps */
#ifdef RENDER
-int dmxPictPrivateIndex; /**< Private index for Picts */
-int dmxGlyphSetPrivateIndex; /**< Private index for GlyphSets */
+DevPrivateKey dmxPictPrivateKey = &dmxPictPrivateKey; /**< Private index for Picts */
+DevPrivateKey dmxGlyphSetPrivateKey = &dmxGlyphSetPrivateKey; /**< Private index for GlyphSets */
#endif
/** Initialize the parts of screen \a idx that require access to the
@@ -208,43 +208,11 @@ Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[])
int i, j;
if (dmxGeneration != serverGeneration) {
-#ifdef RENDER
- /* Allocate picture private index */
- dmxPictPrivateIndex = AllocatePicturePrivateIndex();
- if (dmxPictPrivateIndex == -1)
- return FALSE;
-
- /* Allocate glyph set private index */
- dmxGlyphSetPrivateIndex = AllocateGlyphSetPrivateIndex();
- if (dmxGlyphSetPrivateIndex == -1)
- return FALSE;
-#endif
-
- /* Allocate GC private index */
- dmxGCPrivateIndex = AllocateGCPrivateIndex();
- if (dmxGCPrivateIndex == -1)
- return FALSE;
-
- /* Allocate window private index */
- dmxWinPrivateIndex = AllocateWindowPrivateIndex();
- if (dmxWinPrivateIndex == -1)
- return FALSE;
-
- /* Allocate pixmap private index */
- dmxPixPrivateIndex = AllocatePixmapPrivateIndex();
- if (dmxPixPrivateIndex == -1)
- return FALSE;
-
/* Allocate font private index */
dmxFontPrivateIndex = AllocateFontPrivateIndex();
if (dmxFontPrivateIndex == -1)
return FALSE;
- /* Allocate screen private index */
- dmxScreenPrivateIndex = AllocateScreenPrivateIndex();
- if (dmxScreenPrivateIndex == -1)
- return FALSE;
-
dmxGeneration = serverGeneration;
}
diff --git a/hw/dmx/dmxscrinit.h b/hw/dmx/dmxscrinit.h
index 46a0a00a4..a4642350c 100644
--- a/hw/dmx/dmxscrinit.h
+++ b/hw/dmx/dmxscrinit.h
@@ -41,7 +41,7 @@
#include "scrnintstr.h"
/** Private index. \see dmxscrrinit.c \see input/dmxconcole.c */
-extern int dmxScreenPrivateIndex;
+extern DevPrivateKey dmxScreenPrivateKey;
extern Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[]);
diff --git a/hw/dmx/dmxwindow.c b/hw/dmx/dmxwindow.c
index b66f2a3bb..fa6b9a279 100644
--- a/hw/dmx/dmxwindow.c
+++ b/hw/dmx/dmxwindow.c
@@ -64,8 +64,7 @@ static void dmxDoSetShape(WindowPtr pWindow);
/** Initialize the private area for the window functions. */
Bool dmxInitWindow(ScreenPtr pScreen)
{
- if (!AllocateWindowPrivate(pScreen, dmxWinPrivateIndex,
- sizeof(dmxWinPrivRec)))
+ if (!dixRequestPrivate(dmxWinPrivateKey, sizeof(dmxWinPrivRec)))
return FALSE;
return TRUE;
diff --git a/hw/dmx/dmxwindow.h b/hw/dmx/dmxwindow.h
index f976c7954..1a984331e 100644
--- a/hw/dmx/dmxwindow.h
+++ b/hw/dmx/dmxwindow.h
@@ -107,11 +107,11 @@ extern void dmxSetShape(WindowPtr pWindow);
#endif
/** Private index. \see dmxwindow.c \see dmxscrinit.c */
-extern int dmxWinPrivateIndex;
+extern DevPrivateKey dmxWinPrivateKey;
/** Get window private pointer. */
-#define DMX_GET_WINDOW_PRIV(_pWin) \
- ((dmxWinPrivPtr)(_pWin)->devPrivates[dmxWinPrivateIndex].ptr)
+#define DMX_GET_WINDOW_PRIV(_pWin) ((dmxWinPrivPtr) \
+ dixLookupPrivate(&(_pWin)->devPrivates, dmxWinPrivateKey))
/* All of these macros are only used in dmxwindow.c */
#define DMX_WINDOW_FUNC_PROLOGUE(_pGC) \
diff --git a/hw/dmx/input/dmxconsole.c b/hw/dmx/input/dmxconsole.c
index cc820a204..b2a2ec302 100644
--- a/hw/dmx/input/dmxconsole.c
+++ b/hw/dmx/input/dmxconsole.c
@@ -612,7 +612,8 @@ static Bool dmxCloseConsoleScreen(int idx, ScreenPtr pScreen)
{
myPrivate *priv, *last;
- for (last = priv = pScreen->devPrivates[dmxScreenPrivateIndex].ptr;
+ for (last = priv = (myPrivate *)dixLookupPrivate(&pScreen->devPrivates,
+ dmxScreenPrivateKey);
priv;
priv = priv->next) dmxCloseConsole(last = priv);
@@ -846,13 +847,15 @@ void dmxConsoleInit(DevicePtr pDev)
dmxConsoleDraw(priv, 1, 1);
- if (screenInfo.screens[0]->devPrivates[dmxScreenPrivateIndex].ptr)
- priv->next = (screenInfo.screens[0]
- ->devPrivates[dmxScreenPrivateIndex].ptr);
+ if (dixLookupPrivate(&screenInfo.screens[0]->devPrivates,
+ dmxScreenPrivateKey))
+ priv->next = dixLookupPrivate(&screenInfo.screens[0]->devPrivates,
+ dmxScreenPrivateKey);
else
DMX_WRAP(CloseScreen, dmxCloseConsoleScreen,
priv, screenInfo.screens[0]);
- screenInfo.screens[0]->devPrivates[dmxScreenPrivateIndex].ptr = priv;
+ dixSetPrivate(&screenInfo.screens[0]->devPrivates, dmxScreenPrivateKey,
+ priv);
}
/** Fill in the \a info structure for the specified \a pDev. Only used
diff --git a/hw/kdrive/savage/s3draw.c b/hw/kdrive/savage/s3draw.c
index 258dbcf79..39cc256b3 100644
--- a/hw/kdrive/savage/s3draw.c
+++ b/hw/kdrive/savage/s3draw.c
@@ -78,9 +78,8 @@ short s3alu[16] = {
#define PixTransStore(t) *pix_trans = (t)
#endif
-int s3GCPrivateIndex;
-int s3WindowPrivateIndex;
-int s3Generation;
+DevPrivateKey s3GCPrivateKey = &s3GCPrivateKey;
+DevPrivateKey s3WindowPrivateKey = &s3WindowPrivateKey;
/*
s3DoBitBlt
@@ -2182,7 +2181,7 @@ s3CreateWindow (WindowPtr pWin)
KdScreenPriv(pWin->drawable.pScreen);
s3ScreenInfo(pScreenPriv);
- pWin->devPrivates[s3WindowPrivateIndex].ptr = 0;
+ dixSetPrivate(&pWin->devPrivates, s3WindowPrivateKey, NULL);
return KdCreateWindow (pWin);
}
@@ -3095,15 +3094,7 @@ s3DrawInit (ScreenPtr pScreen)
}
else
{
- if (serverGeneration != s3Generation)
- {
- s3GCPrivateIndex = AllocateGCPrivateIndex ();
- s3WindowPrivateIndex = AllocateWindowPrivateIndex ();
- s3Generation = serverGeneration;
- }
- if (!AllocateWindowPrivate(pScreen, s3WindowPrivateIndex, 0))
- return FALSE;
- if (!AllocateGCPrivate(pScreen, s3GCPrivateIndex, sizeof (s3PrivGCRec)))
+ if (!dixRequestPrivate(s3GCPrivateKey, sizeof (s3PrivGCRec)))
return FALSE;
pScreen->CreateGC = s3CreateGC;
pScreen->CreateWindow = s3CreateWindow;
diff --git a/hw/kdrive/savage/s3draw.h b/hw/kdrive/savage/s3draw.h
index 068904370..eab8e395e 100644
--- a/hw/kdrive/savage/s3draw.h
+++ b/hw/kdrive/savage/s3draw.h
@@ -24,8 +24,8 @@
#ifndef _S3DRAW_H_
#define _S3DRAW_H_
-extern int s3GCPrivateIndex;
-extern int s3WindowPrivateIndex;
+extern DevPrivateKey s3GCPrivateKey;
+extern DevPrivateKey s3WindowPrivateKey;
typedef struct _s3Pattern {
S3PatternCache *cache;
@@ -42,16 +42,16 @@ typedef struct _s3PrivGC {
s3PatternPtr pPattern; /* pattern */
} s3PrivGCRec, *s3PrivGCPtr;
-#define s3GetGCPrivate(g) ((s3PrivGCPtr) \
- (g)->devPrivates[s3GCPrivateIndex].ptr)
+#define s3GetGCPrivate(g) ((s3PrivGCPtr) \
+ dixLookupPrivate(&(g)->devPrivates, s3GCPrivateKey))
-#define s3GCPrivate(g) s3PrivGCPtr s3Priv = s3GetGCPrivate(g)
+#define s3GCPrivate(g) s3PrivGCPtr s3Priv = s3GetGCPrivate(g)
-#define s3GetWindowPrivate(w) ((s3PatternPtr) \
- (w)->devPrivates[s3WindowPrivateIndex].ptr)
+#define s3GetWindowPrivate(w) ((s3PatternPtr) \
+ dixLookupPrivate(&(w)->devPrivates, s3WindowPrivateKey))
-#define s3SetWindowPrivate(w,p) (\
- (w)->devPrivates[s3WindowPrivateIndex].ptr = (pointer) p)
+#define s3SetWindowPrivate(w,p) \
+ dixSetPrivate(&(w)->devPrivates, s3WindowPrivateKey, p)
void _s3LoadPattern (ScreenPtr pScreen, int fb, s3PatternPtr pPattern);
diff --git a/hw/kdrive/src/kaa.c b/hw/kdrive/src/kaa.c
index c9805ddb6..da618bee5 100644
--- a/hw/kdrive/src/kaa.c
+++ b/hw/kdrive/src/kaa.c
@@ -42,9 +42,8 @@
#define DBG_PIXMAP(a)
#endif
-int kaaGeneration;
-int kaaScreenPrivateIndex;
-int kaaPixmapPrivateIndex;
+DevPrivateKey kaaScreenPrivateKey = &kaaScreenPrivateKey;
+DevPrivateKey kaaPixmapPrivateKey = &kaaPixmapPrivateKey;
#define KAA_PIXMAP_SCORE_MOVE_IN 10
#define KAA_PIXMAP_SCORE_MAX 20
@@ -1066,13 +1065,6 @@ kaaDrawInit (ScreenPtr pScreen,
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
- if (kaaGeneration != serverGeneration)
- {
- kaaScreenPrivateIndex = AllocateScreenPrivateIndex();
- kaaPixmapPrivateIndex = AllocatePixmapPrivateIndex();
- kaaGeneration = serverGeneration;
- }
-
pKaaScr = xalloc (sizeof (KaaScreenPrivRec));
if (!pKaaScr)
@@ -1080,7 +1072,7 @@ kaaDrawInit (ScreenPtr pScreen,
pKaaScr->info = pScreenInfo;
- pScreen->devPrivates[kaaScreenPrivateIndex].ptr = (pointer) pKaaScr;
+ dixSetPrivate(&pScreen->devPrivates, kaaScreenPrivateKey, pKaaScr);
/*
* Hook up asynchronous drawing
@@ -1106,17 +1098,11 @@ kaaDrawInit (ScreenPtr pScreen,
if ((pKaaScr->info->flags & KAA_OFFSCREEN_PIXMAPS) &&
screen->off_screen_base < screen->memory_size)
{
- if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex,
- sizeof (KaaPixmapPrivRec)))
+ if (!dixRequestPrivate(kaaPixmapPrivateKey, sizeof (KaaPixmapPrivRec)))
return FALSE;
pScreen->CreatePixmap = kaaCreatePixmap;
pScreen->DestroyPixmap = kaaDestroyPixmap;
}
- else
- {
- if (!AllocatePixmapPrivate(pScreen, kaaPixmapPrivateIndex, 0))
- return FALSE;
- }
return TRUE;
}
diff --git a/hw/kdrive/src/kaa.h b/hw/kdrive/src/kaa.h
index db890a75b..90b963b10 100644
--- a/hw/kdrive/src/kaa.h
+++ b/hw/kdrive/src/kaa.h
@@ -27,11 +27,14 @@
#include "picturestr.h"
-#define KaaGetScreenPriv(s) ((KaaScreenPrivPtr)(s)->devPrivates[kaaScreenPrivateIndex].ptr)
+#define KaaGetScreenPriv(s) ((KaaScreenPrivPtr) \
+ dixLookupPrivate(&(s)->devPrivates, kaaScreenPrivateKey))
#define KaaScreenPriv(s) KaaScreenPrivPtr pKaaScr = KaaGetScreenPriv(s)
-#define KaaGetPixmapPriv(p) ((KaaPixmapPrivPtr)(p)->devPrivates[kaaPixmapPrivateIndex].ptr)
-#define KaaSetPixmapPriv(p,a) ((p)->devPrivates[kaaPixmapPrivateIndex].ptr = (pointer) (a))
+#define KaaGetPixmapPriv(p) ((KaaPixmapPrivPtr) \
+ dixLookupPrivate(&(p)->devPrivates, kaaPixmapPrivateKey))
+#define KaaSetPixmapPriv(p,a) \
+ dixSetPrivate(&(p)->devPrivates, kaaPixmapPrivateKey, a)
#define KaaPixmapPriv(p) KaaPixmapPrivPtr pKaaPixmap = KaaGetPixmapPriv(p)
typedef struct {
@@ -46,8 +49,8 @@ typedef struct {
Bool dirty;
} KaaPixmapPrivRec, *KaaPixmapPrivPtr;
-extern int kaaScreenPrivateIndex;
-extern int kaaPixmapPrivateIndex;
+extern DevPrivateKey kaaScreenPrivateKey;
+extern DevPrivateKey kaaPixmapPrivateKey;
void
diff --git a/hw/kdrive/src/kdrive.h b/hw/kdrive/src/kdrive.h
index 2da008df9..d6646f0ef 100644
--- a/hw/kdrive/src/kdrive.h
+++ b/hw/kdrive/src/kdrive.h
@@ -498,7 +498,7 @@ typedef struct _KaaScreenInfo {
(PixmapWidthPaddingInfo[d].padRoundUp+1)))
#endif
-extern int kdScreenPrivateIndex;
+extern DevPrivateKey kdScreenPrivateKey;
extern unsigned long kdGeneration;
extern Bool kdEnabled;
extern Bool kdSwitchPending;
@@ -510,9 +510,9 @@ extern char *kdSwitchCmd;
extern KdOsFuncs *kdOsFuncs;
#define KdGetScreenPriv(pScreen) ((KdPrivScreenPtr) \
- (pScreen)->devPrivates[kdScreenPrivateIndex].ptr)
-#define KdSetScreenPriv(pScreen,v) ((pScreen)->devPrivates[kdScreenPrivateIndex].ptr = \
- (pointer) v)
+ dixLookupPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey))
+#define KdSetScreenPriv(pScreen,v) \
+ dixSetPrivate(&(pScreen)->devPrivates, kdScreenPrivateKey, v)
#define KdScreenPriv(pScreen) KdPrivScreenPtr pScreenPriv = KdGetScreenPriv(pScreen)
/* kaa.c */
diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c
index b8fbd731b..fa506861c 100644
--- a/hw/kdrive/src/kxv.c
+++ b/hw/kdrive/src/kxv.c
@@ -104,23 +104,22 @@ static void KdXVClipNotify(WindowPtr pWin, int dx, int dy);
static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr*, int);
-int KdXVWindowIndex = -1;
-int KdXvScreenIndex = -1;
-static unsigned long KdXVGeneration = 0;
+DevPrivateKey KdXVWindowKey = &KdXVWindowKey;
+DevPrivateKey KdXvScreenKey = &KdXvScreenKey;
static unsigned long PortResource = 0;
-int (*XvGetScreenIndexProc)(void) = XvGetScreenIndex;
+int (*XvGetScreenKeyProc)(void) = XvGetScreenKey;
unsigned long (*XvGetRTPortProc)(void) = XvGetRTPort;
int (*XvScreenInitProc)(ScreenPtr) = XvScreenInit;
-#define GET_XV_SCREEN(pScreen) \
- ((XvScreenPtr)((pScreen)->devPrivates[KdXvScreenIndex].ptr))
+#define GET_XV_SCREEN(pScreen) ((XvScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, KdXvScreenKey))
#define GET_KDXV_SCREEN(pScreen) \
((KdXVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
-#define GET_KDXV_WINDOW(pWin) \
- ((KdXVWindowPtr)((pWin)->devPrivates[KdXVWindowIndex].ptr))
+#define GET_KDXV_WINDOW(pWin) ((KdXVWindowPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, KdXVWindowKey))
static KdXVInitGenericAdaptorPtr *GenDrivers = NULL;
static int NumGenDrivers = 0;
@@ -192,21 +191,12 @@ KdXVScreenInit(
/* fprintf(stderr,"KdXVScreenInit initializing %d adaptors\n",num); */
- if(KdXVGeneration != serverGeneration) {
- if((KdXVWindowIndex = AllocateWindowPrivateIndex()) < 0)
- return FALSE;
- KdXVGeneration = serverGeneration;
- }
-
- if(!AllocateWindowPrivate(pScreen,KdXVWindowIndex,0))
- return FALSE;
-
- if(!XvGetScreenIndexProc || !XvGetRTPortProc || !XvScreenInitProc)
+ if(!XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
return FALSE;
if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
- KdXvScreenIndex = (*XvGetScreenIndexProc)();
+ KdXvScreenIndex = (*XvGetScreenKeyProc)();
PortResource = (*XvGetRTPortProc)();
pxvs = GET_XV_SCREEN(pScreen);
@@ -938,7 +928,7 @@ KdXVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
if(!winPriv) return BadAlloc;
winPriv->PortRec = portPriv;
winPriv->next = PrivRoot;
- pWin->devPrivates[KdXVWindowIndex].ptr = (pointer)winPriv;
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv);
}
return Success;
}
@@ -956,8 +946,7 @@ KdXVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
if(prevPriv)
prevPriv->next = winPriv->next;
else
- pWin->devPrivates[KdXVWindowIndex].ptr =
- (pointer)winPriv->next;
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv->next);
xfree(winPriv);
break;
}
@@ -981,7 +970,8 @@ KdXVCreateWindow(WindowPtr pWin)
ret = (*pScreen->CreateWindow)(pWin);
pScreen->CreateWindow = KdXVCreateWindow;
- if(ret) pWin->devPrivates[KdXVWindowIndex].ptr = NULL;
+ if (ret)
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
return ret;
}
@@ -1010,7 +1000,7 @@ KdXVDestroyWindow(WindowPtr pWin)
xfree(tmp);
}
- pWin->devPrivates[KdXVWindowIndex].ptr = NULL;
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, NULL);
pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
ret = (*pScreen->DestroyWindow)(pWin);
@@ -1067,8 +1057,7 @@ KdXVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
pPriv->pDraw = NULL;
if(!pPrev)
- pWin->devPrivates[KdXVWindowIndex].ptr =
- (pointer)(WinPriv->next);
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, WinPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
@@ -1117,8 +1106,7 @@ KdXVClipNotify(WindowPtr pWin, int dx, int dy)
pPriv->pDraw = NULL;
if(!pPrev)
- pWin->devPrivates[KdXVWindowIndex].ptr =
- (pointer)(WinPriv->next);
+ dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 69d619e6f..f8febc5a4 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -57,9 +57,9 @@
/* General parameters */
extern int xf86DoConfigure;
extern Bool xf86DoConfigurePass1;
-extern int xf86ScreenIndex; /* Index into pScreen.devPrivates */
-extern int xf86CreateRootWindowIndex; /* Index into pScreen.devPrivates */
-extern int xf86PixmapIndex;
+extern DevPrivateKey xf86ScreenKey;
+extern DevPrivateKey xf86CreateRootWindowKey;
+extern DevPrivateKey xf86PixmapKey;
extern ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
extern const unsigned char byte_reversed[256];
extern ScrnInfoPtr xf86CurrentScreen;
@@ -72,8 +72,8 @@ extern Bool sbusSlotClaimed;
extern confDRIRec xf86ConfigDRI;
extern Bool xf86inSuspend;
-#define XF86SCRNINFO(p) ((ScrnInfoPtr)((p)->devPrivates[xf86ScreenIndex].ptr))
-
+#define XF86SCRNINFO(p) ((ScrnInfoPtr)dixLookupPrivate(&(p)->devPrivates, \
+ xf86ScreenKey))
#define XF86FLIP_PIXELS() \
do { \
if (xf86GetFlipPixels()) { \
diff --git a/hw/xfree86/common/xf86DGA.c b/hw/xfree86/common/xf86DGA.c
index 9474ec8e0..68f538fae 100644
--- a/hw/xfree86/common/xf86DGA.c
+++ b/hw/xfree86/common/xf86DGA.c
@@ -49,8 +49,7 @@
#include "mi.h"
-static unsigned long DGAGeneration = 0;
-static int DGAScreenIndex = -1;
+static DevPrivateKey DGAScreenKey = NULL;
static int mieq_installed = 0;
static Bool DGACloseScreen(int i, ScreenPtr pScreen);
@@ -68,8 +67,8 @@ DGACopyModeInfo(
_X_EXPORT int *XDGAEventBase = NULL;
-#define DGA_GET_SCREEN_PRIV(pScreen) \
- ((DGAScreenPtr)((pScreen)->devPrivates[DGAScreenIndex].ptr))
+#define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, DGAScreenKey))
typedef struct _FakedVisualList{
@@ -116,11 +115,7 @@ DGAInit(
if(!modes || num <= 0)
return FALSE;
- if(DGAGeneration != serverGeneration) {
- if((DGAScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- DGAGeneration = serverGeneration;
- }
+ DGAScreenKey = &DGAScreenKey;
if(!(pScreenPriv = (DGAScreenPtr)xalloc(sizeof(DGAScreenRec))))
return FALSE;
@@ -148,7 +143,7 @@ DGAInit(
modes[i].flags &= ~DGA_PIXMAP_AVAILABLE;
#endif
- pScreen->devPrivates[DGAScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, DGAScreenKey, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = DGACloseScreen;
pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
@@ -176,7 +171,7 @@ DGAReInitModes(
int i;
/* No DGA? Ignore call (but don't make it look like it failed) */
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return TRUE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
@@ -350,7 +345,7 @@ xf86SetDGAMode(
DGAModePtr pMode = NULL;
/* First check if DGAInit was successful on this screen */
- if (DGAScreenIndex < 0)
+ if (DGAScreenKey == NULL)
return BadValue;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if (!pScreenPriv)
@@ -485,7 +480,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
DGAModePtr pMode;
PixmapPtr pPix;
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -535,11 +530,12 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
_X_EXPORT Bool
DGAAvailable(int index)
{
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return FALSE;
- if (!xf86NoSharedResources(((ScrnInfoPtr)screenInfo.screens[index]->
- devPrivates[xf86ScreenIndex].ptr)->scrnIndex,MEM))
+ if (!xf86NoSharedResources(((ScrnInfoPtr)dixLookupPrivate(
+ &screenInfo.screens[index]->devPrivates,
+ xf86ScreenKey))->scrnIndex, MEM))
return FALSE;
if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
@@ -553,7 +549,7 @@ DGAActive(int index)
{
DGAScreenPtr pScreenPriv;
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -574,7 +570,7 @@ DGAShutdown()
ScrnInfoPtr pScrn;
int i;
- if(DGAScreenIndex < 0)
+ if(DGAScreenKey == NULL)
return;
for(i = 0; i < screenInfo.numScreens; i++) {
@@ -904,7 +900,7 @@ DGAVTSwitch(void)
/* Alternatively, this could send events to DGA clients */
- if(DGAScreenIndex >= 0) {
+ if(DGAScreenKey) {
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if(pScreenPriv && pScreenPriv->current)
@@ -921,7 +917,7 @@ DGAStealKeyEvent(int index, int key_code, int is_down)
DGAScreenPtr pScreenPriv;
dgaEvent de;
- if(DGAScreenIndex < 0) /* no DGA */
+ if(DGAScreenKey == NULL) /* no DGA */
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -945,7 +941,7 @@ DGAStealMotionEvent(int index, int dx, int dy)
DGAScreenPtr pScreenPriv;
dgaEvent de;
- if(DGAScreenIndex < 0) /* no DGA */
+ if(DGAScreenKey == NULL) /* no DGA */
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -980,7 +976,7 @@ DGAStealButtonEvent(int index, int button, int is_down)
DGAScreenPtr pScreenPriv;
dgaEvent de;
- if (DGAScreenIndex < 0)
+ if (DGAScreenKey == NULL)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@@ -1006,7 +1002,7 @@ Bool
DGAIsDgaEvent (xEvent *e)
{
int coreEquiv;
- if (DGAScreenIndex < 0 || XDGAEventBase == 0)
+ if (DGAScreenKey == NULL || XDGAEventBase == 0)
return FALSE;
coreEquiv = e->u.u.type - *XDGAEventBase;
if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify)
@@ -1275,7 +1271,7 @@ DGAHandleEvent(int screen_num, xEvent *event, DeviceIntPtr device, int nevents)
int coreEquiv;
/* no DGA */
- if (DGAScreenIndex < 0 || XDGAEventBase == 0)
+ if (DGAScreenKey == NULL || XDGAEventBase == 0)
return;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c
index a4ae67e46..536d38e8f 100644
--- a/hw/xfree86/common/xf86DPMS.c
+++ b/hw/xfree86/common/xf86DPMS.c
@@ -47,8 +47,7 @@
#ifdef DPMSExtension
-static int DPMSGeneration = 0;
-static int DPMSIndex = -1;
+static DevPrivateKey DPMSKey = NULL;
static Bool DPMSClose(int i, ScreenPtr pScreen);
static int DPMSCount = 0;
#endif
@@ -62,18 +61,15 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
DPMSPtr pDPMS;
pointer DPMSOpt;
- if (serverGeneration != DPMSGeneration) {
- if ((DPMSIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- DPMSGeneration = serverGeneration;
- }
+ DPMSKey = &DPMSKey;
if (DPMSDisabledSwitch)
DPMSEnabled = FALSE;
- if (!(pScreen->devPrivates[DPMSIndex].ptr = xcalloc(sizeof(DPMSRec), 1)))
+ if (!dixSetPrivate(&pScreen->devPrivates, DPMSKey,
+ xcalloc(sizeof(DPMSRec), 1)))
return FALSE;
- pDPMS = (DPMSPtr)pScreen->devPrivates[DPMSIndex].ptr;
+ pDPMS = (DPMSPtr)dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
pScrn->DPMSSet = set;
pDPMS->Flags = flags;
DPMSOpt = xf86FindOption(pScrn->options, "dpms");
@@ -110,10 +106,10 @@ DPMSClose(int i, ScreenPtr pScreen)
DPMSPtr pDPMS;
/* This shouldn't happen */
- if (DPMSIndex < 0)
+ if (DPMSKey == NULL)
return FALSE;
- pDPMS = (DPMSPtr)pScreen->devPrivates[DPMSIndex].ptr;
+ pDPMS = (DPMSPtr)dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
/* This shouldn't happen */
if (!pDPMS)
@@ -132,9 +128,9 @@ DPMSClose(int i, ScreenPtr pScreen)
}
xfree((pointer)pDPMS);
- pScreen->devPrivates[DPMSIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DPMSKey, NULL);
if (--DPMSCount == 0)
- DPMSIndex = -1;
+ DPMSKey = NULL;
return pScreen->CloseScreen(i, pScreen);
}
@@ -153,7 +149,7 @@ DPMSSet(ClientPtr client, int level)
DPMSPowerLevel = level;
- if (DPMSIndex < 0)
+ if (DPMSKey == NULL)
return Success;
if (level != DPMSModeOn) {
@@ -165,7 +161,8 @@ DPMSSet(ClientPtr client, int level)
/* For each screen, set the DPMS level */
for (i = 0; i < xf86NumScreens; i++) {
pScrn = xf86Screens[i];
- pDPMS = (DPMSPtr)screenInfo.screens[i]->devPrivates[DPMSIndex].ptr;
+ pDPMS = (DPMSPtr)dixLookupPrivate(&screenInfo.screens[i]->devPrivates,
+ DPMSKey);
if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) {
xf86EnableAccess(pScrn);
pScrn->DPMSSet(pScrn, level, 0);
@@ -186,14 +183,15 @@ DPMSSupported(void)
DPMSPtr pDPMS;
ScrnInfoPtr pScrn;
- if (DPMSIndex < 0) {
+ if (DPMSKey == NULL) {
return FALSE;
}
/* For each screen, check if DPMS is supported */
for (i = 0; i < xf86NumScreens; i++) {
pScrn = xf86Screens[i];
- pDPMS = (DPMSPtr)screenInfo.screens[i]->devPrivates[DPMSIndex].ptr;
+ pDPMS = (DPMSPtr)dixLookupPrivate(&screenInfo.screens[i]->devPrivates,
+ DPMSKey);
if (pDPMS && pScrn->DPMSSet)
return TRUE;
}
diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c
index 7dc45b75d..4b5105632 100644
--- a/hw/xfree86/common/xf86Globals.c
+++ b/hw/xfree86/common/xf86Globals.c
@@ -46,10 +46,12 @@
/* Globals that video drivers may access */
-_X_EXPORT int xf86ScreenIndex = -1; /* Index of ScrnInfo in pScreen.devPrivates */
-int xf86CreateRootWindowIndex = -1; /* Index into pScreen.devPrivates */
+/* Index into pScreen.devPrivates */
+DevPrivateKey xf86CreateRootWindowKey = &xf86CreateRootWindowKey;
+/* Index of ScrnInfo in pScreen.devPrivates */
+_X_EXPORT DevPrivateKey xf86ScreenKey = &xf86ScreenKey;
+_X_EXPORT DevPrivateKey xf86PixmapKey = &xf86PixmapKey;
_X_EXPORT ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
-_X_EXPORT int xf86PixmapIndex = 0;
_X_EXPORT const unsigned char byte_reversed[256] =
{
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index 90f744c64..06af74f43 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -139,8 +139,8 @@ xf86CreateRootWindow(WindowPtr pWin)
int err = Success;
ScreenPtr pScreen = pWin->drawable.pScreen;
RootWinPropPtr pProp;
- CreateWindowProcPtr CreateWindow =
- (CreateWindowProcPtr)(pScreen->devPrivates[xf86CreateRootWindowIndex].ptr);
+ CreateWindowProcPtr CreateWindow = (CreateWindowProcPtr)
+ dixLookupPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey);
#ifdef DEBUG
ErrorF("xf86CreateRootWindow(%p)\n", pWin);
@@ -156,7 +156,7 @@ xf86CreateRootWindow(WindowPtr pWin)
/* Unhook this function ... */
pScreen->CreateWindow = CreateWindow;
- pScreen->devPrivates[xf86CreateRootWindowIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, xf86CreateRootWindowKey, NULL);
/* ... and call the previous CreateWindow fuction, if any */
if (NULL!=pScreen->CreateWindow) {
@@ -476,7 +476,6 @@ void
InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
{
int i, j, k, scr_index;
- static unsigned long generation = 0;
char **modulelist;
pointer *optionlist;
screenLayoutPtr layout;
@@ -487,14 +486,6 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
xf86Initialising = TRUE;
- /* Do this early? */
- if (generation != serverGeneration) {
- xf86ScreenIndex = AllocateScreenPrivateIndex();
- xf86CreateRootWindowIndex = AllocateScreenPrivateIndex();
- xf86PixmapIndex = AllocatePixmapPrivateIndex();
- generation = serverGeneration;
- }
-
if (serverGeneration == 1) {
pScreenInfo->numScreens = 0;
@@ -1060,8 +1051,8 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
* Hook in our ScrnInfoRec, and initialise some other pScreen
* fields.
*/
- screenInfo.screens[scr_index]->devPrivates[xf86ScreenIndex].ptr
- = (pointer)xf86Screens[i];
+ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
+ xf86ScreenKey, xf86Screens[i]);
xf86Screens[i]->pScreen = screenInfo.screens[scr_index];
/* The driver should set this, but make sure it is set anyway */
xf86Screens[i]->vtSema = TRUE;
@@ -1077,8 +1068,9 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
i, xf86Screens[i]->pScreen->CreateWindow );
#endif
- screenInfo.screens[scr_index]->devPrivates[xf86CreateRootWindowIndex].ptr
- = (void*)(xf86Screens[i]->pScreen->CreateWindow);
+ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates,
+ xf86CreateRootWindowKey,
+ xf86Screens[i]->pScreen->CreateWindow);
xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow;
#ifdef RENDER
diff --git a/hw/xfree86/common/xf86RandR.c b/hw/xfree86/common/xf86RandR.c
index 288d72193..4432ad96b 100644
--- a/hw/xfree86/common/xf86RandR.c
+++ b/hw/xfree86/common/xf86RandR.c
@@ -45,10 +45,9 @@ typedef struct _xf86RandRInfo {
Rotation rotation;
} XF86RandRInfoRec, *XF86RandRInfoPtr;
-static int xf86RandRIndex = -1;
-static int xf86RandRGeneration;
+static DevPrivateKey xf86RandRKey = NULL;
-#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) (p)->devPrivates[xf86RandRIndex].ptr)
+#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey))
static int
xf86RandRModeRefresh (DisplayModePtr mode)
@@ -338,14 +337,14 @@ xf86RandRCloseScreen (int index, ScreenPtr pScreen)
scrp->currentMode = scrp->modes;
pScreen->CloseScreen = randrp->CloseScreen;
xfree (randrp);
- pScreen->devPrivates[xf86RandRIndex].ptr = 0;
+ dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, NULL);
return (*pScreen->CloseScreen) (index, pScreen);
}
_X_EXPORT Rotation
xf86GetRotation(ScreenPtr pScreen)
{
- if (xf86RandRIndex == -1)
+ if (xf86RandRKey == NULL)
return RR_Rotate_0;
return XF86RANDRINFO(pScreen)->rotation;
@@ -359,7 +358,7 @@ xf86RandRSetNewVirtualAndDimensions(ScreenPtr pScreen,
{
XF86RandRInfoPtr randrp;
- if (xf86RandRIndex == -1)
+ if (xf86RandRKey == NULL)
return FALSE;
randrp = XF86RANDRINFO(pScreen);
@@ -401,11 +400,8 @@ xf86RandRInit (ScreenPtr pScreen)
if (!noPanoramiXExtension)
return TRUE;
#endif
- if (xf86RandRGeneration != serverGeneration)
- {
- xf86RandRIndex = AllocateScreenPrivateIndex();
- xf86RandRGeneration = serverGeneration;
- }
+
+ xf86RandRKey = &xf86RandRKey;
randrp = xalloc (sizeof (XF86RandRInfoRec));
if (!randrp)
@@ -433,7 +429,7 @@ xf86RandRInit (ScreenPtr pScreen)
randrp->rotation = RR_Rotate_0;
- pScreen->devPrivates[xf86RandRIndex].ptr = randrp;
+ dixSetPrivate(&pScreen->devPrivates, xf86RandRKey, randrp);
return TRUE;
}
diff --git a/hw/xfree86/common/xf86VidMode.c b/hw/xfree86/common/xf86VidMode.c
index fb9151346..763e5c540 100644
--- a/hw/xfree86/common/xf86VidMode.c
+++ b/hw/xfree86/common/xf86VidMode.c
@@ -47,12 +47,11 @@
#include "vidmodeproc.h"
#include "xf86cmap.h"
-static int VidModeGeneration = 0;
-static int VidModeIndex = -1;
+static DevPrivateKey VidModeKey = NULL;
static int VidModeCount = 0;
static Bool VidModeClose(int i, ScreenPtr pScreen);
-#define VMPTR(p) ((VidModePtr)(p)->devPrivates[VidModeIndex].ptr)
+#define VMPTR(p) ((VidModePtr)dixLookupPrivate(&(p)->devPrivates, VidModeKey))
#endif
@@ -75,15 +74,10 @@ VidModeExtensionInit(ScreenPtr pScreen)
return FALSE;
}
- if (serverGeneration != VidModeGeneration) {
- if ((VidModeIndex = AllocateScreenPrivateIndex()) < 0) {
- DEBUG_P("AllocateScreenPrivateIndex() failed");
- return FALSE;
- }
- VidModeGeneration = serverGeneration;
- }
+ VidModeKey = &VidModeKey;
- if (!(pScreen->devPrivates[VidModeIndex].ptr = xcalloc(sizeof(VidModeRec), 1))) {
+ if (!dixSetPrivate(&pScreen->devPrivates, VidModeKey,
+ xcalloc(sizeof(VidModeRec), 1))) {
DEBUG_P("xcalloc failed");
return FALSE;
}
@@ -118,10 +112,9 @@ VidModeClose(int i, ScreenPtr pScreen)
pScreen->CloseScreen = pVidMode->CloseScreen;
if (--VidModeCount == 0) {
- if (pScreen->devPrivates[VidModeIndex].ptr)
- xfree(pScreen->devPrivates[VidModeIndex].ptr);
- pScreen->devPrivates[VidModeIndex].ptr = NULL;
- VidModeIndex = -1;
+ xfree(dixLookupPrivate(&pScreen->devPrivates, VidModeKey));
+ dixSetPrivate(&pScreen->devPrivates, VidModeKey, NULL);
+ VidModeKey = NULL;
}
return pScreen->CloseScreen(i, pScreen);
}
@@ -134,8 +127,8 @@ VidModeAvailable(int scrnIndex)
DEBUG_P("VidModeAvailable");
- if (VidModeIndex < 0) {
- DEBUG_P("VidModeIndex < 0");
+ if (VidModeKey == NULL) {
+ DEBUG_P("VidModeKey == NULL");
return FALSE;
}
diff --git a/hw/xfree86/common/xf86cmap.c b/hw/xfree86/common/xf86cmap.c
index ea6a26dcd..764647ee4 100644
--- a/hw/xfree86/common/xf86cmap.c
+++ b/hw/xfree86/common/xf86cmap.c
@@ -60,7 +60,7 @@
#include "xf86cmap.h"
#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
- ((CMapScreenPtr) (pScreen)->devPrivates[CMapScreenIndex].ptr)->field)
+ ((CMapScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, CMapScreenKey))->field)
#define SCREEN_EPILOGUE(pScreen, field, wrapper)\
((pScreen)->field = wrapper)
@@ -102,9 +102,8 @@ typedef struct {
int overscan;
} CMapColormapRec, *CMapColormapPtr;
-static unsigned long CMapGeneration = 0;
-static int CMapScreenIndex = -1;
-static int CMapColormapIndex = -1;
+static DevPrivateKey CMapScreenKey = NULL;
+static DevPrivateKey CMapColormapKey = &CMapColormapKey;
static void CMapInstallColormap(ColormapPtr);
static void CMapStoreColors(ColormapPtr, int, xColorItem *);
@@ -119,7 +118,6 @@ static int CMapChangeGamma(int, Gamma);
static void ComputeGamma(CMapScreenPtr);
static Bool CMapAllocateColormapPrivate(ColormapPtr);
-static Bool CMapInitDefMap(ColormapPtr,int);
static void CMapRefreshColors(ColormapPtr, int, int*);
static void CMapSetOverscan(ColormapPtr, int, int *);
static void CMapReinstallMap(ColormapPtr);
@@ -145,13 +143,7 @@ _X_EXPORT Bool xf86HandleColormaps(
if(!maxColors || !sigRGBbits || !loadPalette)
return FALSE;
- if(CMapGeneration != serverGeneration) {
- if(((CMapScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((CMapColormapIndex = AllocateColormapPrivateIndex(
- CMapInitDefMap)) < 0))
- return FALSE;
- CMapGeneration = serverGeneration;
- }
+ CMapScreenKey = &CMapScreenKey;
elements = 1 << sigRGBbits;
@@ -169,7 +161,7 @@ _X_EXPORT Bool xf86HandleColormaps(
return FALSE;
}
- pScreen->devPrivates[CMapScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, CMapScreenKey, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreenPriv->CreateColormap = pScreen->CreateColormap;
@@ -225,12 +217,6 @@ _X_EXPORT Bool xf86HandleColormaps(
return TRUE;
}
-static Bool
-CMapInitDefMap(ColormapPtr cmap, int index)
-{
- return TRUE;
-}
-
/**** Screen functions ****/
@@ -254,8 +240,8 @@ CMapColormapUseMax(VisualPtr pVisual, CMapScreenPtr pScreenPriv)
static Bool
CMapAllocateColormapPrivate(ColormapPtr pmap)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
CMapColormapPtr pColPriv;
CMapLinkPtr pLink;
int numColors;
@@ -274,7 +260,7 @@ CMapAllocateColormapPrivate(ColormapPtr pmap)
return FALSE;
}
- pmap->devPrivates[CMapColormapIndex].ptr = (pointer)pColPriv;
+ dixSetPrivate(&pmap->devPrivates, CMapColormapKey, pColPriv);
pColPriv->numColors = numColors;
pColPriv->colors = colors;
@@ -296,8 +282,8 @@ static Bool
CMapCreateColormap (ColormapPtr pmap)
{
ScreenPtr pScreen = pmap->pScreen;
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
Bool ret = FALSE;
pScreen->CreateColormap = pScreenPriv->CreateColormap;
@@ -314,10 +300,10 @@ static void
CMapDestroyColormap (ColormapPtr cmap)
{
ScreenPtr pScreen = cmap->pScreen;
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
- CMapColormapPtr pColPriv =
- (CMapColormapPtr) cmap->devPrivates[CMapColormapIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &cmap->devPrivates, CMapColormapKey);
CMapLinkPtr prevLink = NULL, pLink = pScreenPriv->maps;
if(pColPriv) {
@@ -356,8 +342,8 @@ CMapStoreColors(
){
ScreenPtr pScreen = pmap->pScreen;
VisualPtr pVisual = pmap->pVisual;
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
int *indices = pScreenPriv->PreAllocIndices;
int num = ndef;
@@ -373,8 +359,8 @@ CMapStoreColors(
return;
if(pVisual->class == DirectColor) {
- CMapColormapPtr pColPriv =
- (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
int i;
if (CMapColormapUseMax(pVisual, pScreenPriv)) {
@@ -431,8 +417,8 @@ CMapInstallColormap(ColormapPtr pmap)
{
ScreenPtr pScreen = pmap->pScreen;
int index = pScreen->myNum;
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
if (pmap == miInstalledMaps[index])
return;
@@ -462,8 +448,8 @@ static Bool
CMapEnterVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
if((*pScreenPriv->EnterVT)(index, flags)) {
if(miInstalledMaps[index])
@@ -478,8 +464,8 @@ static Bool
CMapSwitchMode(int index, DisplayModePtr mode, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
if((*pScreenPriv->SwitchMode)(index, mode, flags)) {
if(miInstalledMaps[index])
@@ -494,8 +480,8 @@ static int
CMapSetDGAMode(int index, int num, DGADevicePtr dev)
{
ScreenPtr pScreen = screenInfo.screens[index];
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
int ret;
ret = (*pScreenPriv->SetDGAMode)(index, num, dev);
@@ -516,10 +502,10 @@ CMapSetDGAMode(int index, int num, DGADevicePtr dev)
static void
CMapReinstallMap(ColormapPtr pmap)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
- CMapColormapPtr cmapPriv =
- (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr cmapPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
int i = cmapPriv->numColors;
int *indices = pScreenPriv->PreAllocIndices;
@@ -547,10 +533,10 @@ CMapReinstallMap(ColormapPtr pmap)
static void
CMapRefreshColors(ColormapPtr pmap, int defs, int* indices)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
- CMapColormapPtr pColPriv =
- (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
VisualPtr pVisual = pmap->pVisual;
ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
int numColors, i;
@@ -681,10 +667,10 @@ CMapCompareColors(LOCO *color1, LOCO *color2)
static void
CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pmap->pScreen->devPrivates[CMapScreenIndex].ptr;
- CMapColormapPtr pColPriv =
- (CMapColormapPtr) pmap->devPrivates[CMapColormapIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pmap->pScreen->devPrivates, CMapScreenKey);
+ CMapColormapPtr pColPriv = (CMapColormapPtr)dixLookupPrivate(
+ &pmap->devPrivates, CMapColormapKey);
ScrnInfoPtr pScrn = xf86Screens[pmap->pScreen->myNum];
VisualPtr pVisual = pmap->pVisual;
int i;
@@ -819,8 +805,8 @@ CMapSetOverscan(ColormapPtr pmap, int defs, int *indices)
static void
CMapUnwrapScreen(ScreenPtr pScreen)
{
- CMapScreenPtr pScreenPriv =
- (CMapScreenPtr) pScreen->devPrivates[CMapScreenIndex].ptr;
+ CMapScreenPtr pScreenPriv = (CMapScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, CMapScreenKey);
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
pScreen->CloseScreen = pScreenPriv->CloseScreen;
@@ -904,10 +890,11 @@ CMapChangeGamma(
CMapLinkPtr pLink;
/* Is this sufficient checking ? */
- if(CMapScreenIndex == -1)
+ if(CMapScreenKey == NULL)
return BadImplementation;
- pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
if(!pScreenPriv)
return BadImplementation;
@@ -925,8 +912,8 @@ CMapChangeGamma(
/* mark all colormaps on this screen */
pLink = pScreenPriv->maps;
while(pLink) {
- pColPriv =
- (CMapColormapPtr) pLink->cmap->devPrivates[CMapColormapIndex].ptr;
+ pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates,
+ CMapColormapKey);
pColPriv->recalculate = TRUE;
pLink = pLink->next;
}
@@ -997,10 +984,11 @@ xf86ChangeGammaRamp(
CMapScreenPtr pScreenPriv;
CMapLinkPtr pLink;
- if(CMapScreenIndex == -1)
+ if(CMapScreenKey == NULL)
return BadImplementation;
- pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
if(!pScreenPriv)
return BadImplementation;
@@ -1012,8 +1000,8 @@ xf86ChangeGammaRamp(
/* mark all colormaps on this screen */
pLink = pScreenPriv->maps;
while(pLink) {
- pColPriv =
- (CMapColormapPtr) pLink->cmap->devPrivates[CMapColormapIndex].ptr;
+ pColPriv = (CMapColormapPtr)dixLookupPrivate(&pLink->cmap->devPrivates,
+ CMapColormapKey);
pColPriv->recalculate = TRUE;
pLink = pLink->next;
}
@@ -1056,9 +1044,10 @@ xf86GetGammaRampSize(ScreenPtr pScreen)
{
CMapScreenPtr pScreenPriv;
- if(CMapScreenIndex == -1) return 0;
+ if(CMapScreenKey == NULL) return 0;
- pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
if(!pScreenPriv) return 0;
return pScreenPriv->gammaElements;
@@ -1076,10 +1065,11 @@ xf86GetGammaRamp(
LOCO *entry;
int shift, sigbits;
- if(CMapScreenIndex == -1)
+ if(CMapScreenKey == NULL)
return BadImplementation;
- pScreenPriv = (CMapScreenPtr)pScreen->devPrivates[CMapScreenIndex].ptr;
+ pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ CMapScreenKey);
if(!pScreenPriv)
return BadImplementation;
diff --git a/hw/xfree86/common/xf86fbman.c b/hw/xfree86/common/xf86fbman.c
index 537d53d7d..9fd2e6c70 100644
--- a/hw/xfree86/common/xf86fbman.c
+++ b/hw/xfree86/common/xf86fbman.c
@@ -42,21 +42,15 @@
#define DEBUG
*/
-static int xf86FBMangerIndex = -1;
-static unsigned long xf86ManagerGeneration = 0;
+static DevPrivateKey xf86FBManagerKey = NULL;
_X_EXPORT Bool xf86RegisterOffscreenManager(
ScreenPtr pScreen,
FBManagerFuncsPtr funcs
){
- if(xf86ManagerGeneration != serverGeneration) {
- if((xf86FBMangerIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- xf86ManagerGeneration = serverGeneration;
- }
-
- pScreen->devPrivates[xf86FBMangerIndex].ptr = (pointer)funcs;
+ xf86FBManagerKey = &xf86FBManagerKey;
+ dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs);
return TRUE;
}
@@ -65,9 +59,9 @@ _X_EXPORT Bool xf86RegisterOffscreenManager(
_X_EXPORT Bool
xf86FBManagerRunning(ScreenPtr pScreen)
{
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!pScreen->devPrivates[xf86FBMangerIndex].ptr)
+ if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey))
return FALSE;
return TRUE;
@@ -81,9 +75,10 @@ xf86RegisterFreeBoxCallback(
){
FBManagerFuncsPtr funcs;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return FALSE;
return (*funcs->RegisterFreeBoxCallback)(pScreen, FreeBoxCallback, devPriv);
@@ -101,9 +96,10 @@ xf86AllocateOffscreenArea(
){
FBManagerFuncsPtr funcs;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return NULL;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return NULL;
return (*funcs->AllocateOffscreenArea)(
@@ -122,9 +118,10 @@ xf86AllocateOffscreenLinear(
){
FBManagerFuncsPtr funcs;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return NULL;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return NULL;
return (*funcs->AllocateOffscreenLinear)(
@@ -139,10 +136,10 @@ xf86FreeOffscreenArea(FBAreaPtr area)
if(!area) return;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return;
- if(!(funcs =
- (FBManagerFuncsPtr)area->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
+ &area->pScreen->devPrivates, xf86FBManagerKey)))
return;
(*funcs->FreeOffscreenArea)(area);
@@ -158,10 +155,10 @@ xf86FreeOffscreenLinear(FBLinearPtr linear)
if(!linear) return;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return;
- if(!(funcs =
- (FBManagerFuncsPtr)linear->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
+ &linear->pScreen->devPrivates, xf86FBManagerKey)))
return;
(*funcs->FreeOffscreenLinear)(linear);
@@ -179,10 +176,10 @@ xf86ResizeOffscreenArea(
if(!resize) return FALSE;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs =
- (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
+ &resize->pScreen->devPrivates, xf86FBManagerKey)))
return FALSE;
return (*funcs->ResizeOffscreenArea)(resize, w, h);
@@ -197,10 +194,10 @@ xf86ResizeOffscreenLinear(
if(!resize) return FALSE;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs =
- (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(
+ &resize->pScreen->devPrivates, xf86FBManagerKey)))
return FALSE;
return (*funcs->ResizeOffscreenLinear)(resize, size);
@@ -220,9 +217,10 @@ xf86QueryLargestOffscreenArea(
*w = 0;
*h = 0;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return FALSE;
return (*funcs->QueryLargestOffscreenArea)(
@@ -240,9 +238,10 @@ xf86QueryLargestOffscreenLinear(
*size = 0;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return FALSE;
return (*funcs->QueryLargestOffscreenLinear)(
@@ -255,9 +254,10 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
{
FBManagerFuncsPtr funcs;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return FALSE;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return FALSE;
return (*funcs->PurgeOffscreenAreas)(pScreen);
@@ -269,8 +269,7 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
\************************************************************/
-static unsigned long xf86FBGeneration = 0;
-static int xf86FBScreenIndex = -1;
+static DevPrivateKey xf86FBScreenKey = &xf86FBScreenKey;
typedef struct _FBLink {
FBArea area;
@@ -320,8 +319,8 @@ localRegisterFreeBoxCallback(
FreeBoxCallbackProcPtr *newCallbacks;
DevUnion *newPrivates;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
newCallbacks = xrealloc( offman->FreeBoxesUpdateCallback,
sizeof(FreeBoxCallbackProcPtr) * (offman->NumCallbacks + 1));
@@ -446,8 +445,8 @@ localAllocateOffscreenArea(
FBManagerPtr offman;
FBAreaPtr area = NULL;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
if((area = AllocateArea(offman, w, h, gran, moveCB, removeCB, privData)))
SendCallFreeBoxCallbacks(offman);
@@ -464,8 +463,8 @@ localFreeOffscreenArea(FBAreaPtr area)
ScreenPtr pScreen;
pScreen = area->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->UsedAreas;
if(!pLink) return;
@@ -505,8 +504,8 @@ localResizeOffscreenArea(
FBLinkPtr pLink, newLink, pLinkPrev = NULL;
pScreen = resize->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
/* find this link */
if(!(pLink = offman->UsedAreas))
return FALSE;
@@ -625,8 +624,8 @@ localQueryLargestOffscreenArea(
if((preferences < 0) || (preferences > 3))
return FALSE;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
if(severity < 0) severity = 0;
if(severity > 2) severity = 2;
@@ -731,8 +730,8 @@ localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
RegionRec FreedRegion;
Bool anyUsed = FALSE;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->UsedAreas;
if(!pLink) return TRUE;
@@ -780,8 +779,8 @@ LinearRemoveCBWrapper(FBAreaPtr area)
FBLinearLinkPtr pLink, pLinkPrev = NULL;
ScreenPtr pScreen = area->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->LinearAreas;
if(!pLink) return;
@@ -911,7 +910,8 @@ localAllocateOffscreenLinear(
BoxPtr extents;
int w, h, pitch;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
/* Try to allocate from linear memory first...... */
#ifdef DEBUG
@@ -991,8 +991,8 @@ localFreeOffscreenLinear(FBLinearPtr linear)
FBLinearLinkPtr pLink, pLinkPrev = NULL;
ScreenPtr pScreen = linear->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->LinearAreas;
if(!pLink) return;
@@ -1049,8 +1049,8 @@ localResizeOffscreenLinear(FBLinearPtr resize, int length)
FBLinearLinkPtr pLink;
ScreenPtr pScreen = resize->pScreen;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pLink = offman->LinearAreas;
if(!pLink) return FALSE;
@@ -1099,7 +1099,8 @@ localQueryLargestOffscreenLinear(
int priority
)
{
- FBManagerPtr offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+ FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
FBLinearLinkPtr pLink;
FBLinearLinkPtr pLinkRet;
@@ -1130,7 +1131,8 @@ localQueryLargestOffscreenLinear(
FBManagerPtr offman;
BoxPtr extents;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
if((extents->x2 - extents->x1) == w)
*size = w * h;
@@ -1162,9 +1164,8 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen)
{
FBLinkPtr pLink, tmp;
FBLinearLinkPtr pLinearLink, tmp2;
- FBManagerPtr offman =
- (FBManagerPtr) pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ FBManagerPtr offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
pScreen->CloseScreen = offman->CloseScreen;
@@ -1188,7 +1189,7 @@ xf86FBCloseScreen (int i, ScreenPtr pScreen)
xfree(offman->FreeBoxesUpdateCallback);
xfree(offman->devPrivates);
xfree(offman);
- pScreen->devPrivates[xf86FBScreenIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, NULL);
return (*pScreen->CloseScreen) (i, pScreen);
}
@@ -1332,19 +1333,13 @@ xf86InitFBManagerRegion(
if(REGION_NIL(FullRegion))
return FALSE;
- if(xf86FBGeneration != serverGeneration) {
- if((xf86FBScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- xf86FBGeneration = serverGeneration;
- }
-
if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
return FALSE;
offman = xalloc(sizeof(FBManager));
if(!offman) return FALSE;
- pScreen->devPrivates[xf86FBScreenIndex].ptr = (pointer)offman;
+ dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, offman);
offman->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = xf86FBCloseScreen;
@@ -1380,11 +1375,11 @@ xf86InitFBManagerLinear(
return FALSE;
/* we expect people to have called the Area setup first for pixmap cache */
- if (!pScreen->devPrivates[xf86FBScreenIndex].ptr)
+ if (!dixLookupPrivate(&pScreen->devPrivates, xf86FBScreenKey))
return FALSE;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
offman->LinearAreas = xalloc(sizeof(FBLinearLink));
if (!offman->LinearAreas)
return FALSE;
@@ -1424,13 +1419,14 @@ xf86AllocateLinearOffscreenArea (
BoxPtr extents;
int w, h;
- if(xf86FBMangerIndex < 0)
+ if(xf86FBManagerKey == NULL)
return NULL;
- if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ if(!(funcs = (FBManagerFuncsPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBManagerKey)))
return NULL;
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
+ offman = (FBManagerPtr)dixLookupPrivate(&pScreen->devPrivates,
+ xf86FBScreenKey);
extents = REGION_EXTENTS(pScreen, offman->InitialBoxes);
w = extents->x2 - extents->x1;
diff --git a/hw/xfree86/common/xf86sbusBus.c b/hw/xfree86/common/xf86sbusBus.c
index 2e06ffac4..4ec099a19 100644
--- a/hw/xfree86/common/xf86sbusBus.c
+++ b/hw/xfree86/common/xf86sbusBus.c
@@ -602,8 +602,7 @@ xf86SbusUseBuiltinMode(ScrnInfoPtr pScrn, sbusDevicePtr psdp)
pScrn->virtualY = psdp->height;
}
-static int sbusPaletteIndex = -1;
-static unsigned long sbusPaletteGeneration = 0;
+static DevPrivateKey sbusPaletteKey = &sbusPaletteKey;
typedef struct _sbusCmap {
sbusDevicePtr psdp;
CloseScreenProcPtr CloseScreen;
@@ -613,7 +612,8 @@ typedef struct _sbusCmap {
unsigned char origBlue[16];
} sbusCmapRec, *sbusCmapPtr;
-#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr)((pScreen)->devPrivates[sbusPaletteIndex].ptr))
+#define SBUSCMAPPTR(pScreen) ((sbusCmapPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, sbusPaletteKey))
static void
xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
@@ -673,13 +673,8 @@ xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp)
struct fbcmap fbcmap;
unsigned char data[2];
- if(sbusPaletteGeneration != serverGeneration) {
- if((sbusPaletteIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- sbusPaletteGeneration = serverGeneration;
- }
cmap = xnfcalloc(1, sizeof(sbusCmapRec));
- pScreen->devPrivates[sbusPaletteIndex].ptr = cmap;
+ dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, cmap);
cmap->psdp = psdp;
fbcmap.index = 0;
fbcmap.count = 16;
diff --git a/hw/xfree86/common/xf86xv.c b/hw/xfree86/common/xf86xv.c
index 70a946922..f972b1f18 100644
--- a/hw/xfree86/common/xf86xv.c
+++ b/hw/xfree86/common/xf86xv.c
@@ -110,23 +110,22 @@ static void xf86XVAdjustFrame(int index, int x, int y, int flags);
static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int);
-static int XF86XVWindowIndex = -1;
-int XF86XvScreenIndex = -1;
-static unsigned long XF86XVGeneration = 0;
+static DevPrivateKey XF86XVWindowKey = &XF86XVWindowKey;
+DevPrivateKey XF86XvScreenKey;
static unsigned long PortResource = 0;
-int (*XvGetScreenIndexProc)(void) = NULL;
+DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL;
unsigned long (*XvGetRTPortProc)(void) = NULL;
int (*XvScreenInitProc)(ScreenPtr) = NULL;
#define GET_XV_SCREEN(pScreen) \
- ((XvScreenPtr)((pScreen)->devPrivates[XF86XvScreenIndex].ptr))
+ ((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XF86XvScreenKey))
#define GET_XF86XV_SCREEN(pScreen) \
- ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
+ ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
#define GET_XF86XV_WINDOW(pWin) \
- ((XF86XVWindowPtr)((pWin)->devPrivates[XF86XVWindowIndex].ptr))
+ ((XF86XVWindowPtr)dixLookupPrivate(&(pWin)->devPrivates, XF86XVWindowKey))
static xf86XVInitGenericAdaptorPtr *GenDrivers = NULL;
static int NumGenDrivers = 0;
@@ -233,21 +232,12 @@ xf86XVScreenInit(
XvScreenPtr pxvs;
if(num <= 0 ||
- !XvGetScreenIndexProc || !XvGetRTPortProc || !XvScreenInitProc)
- return FALSE;
-
- if(XF86XVGeneration != serverGeneration) {
- if((XF86XVWindowIndex = AllocateWindowPrivateIndex()) < 0)
- return FALSE;
- XF86XVGeneration = serverGeneration;
- }
-
- if(!AllocateWindowPrivate(pScreen,XF86XVWindowIndex,0))
+ !XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
return FALSE;
if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
- XF86XvScreenIndex = (*XvGetScreenIndexProc)();
+ XF86XvScreenKey = (*XvGetScreenKeyProc)();
PortResource = (*XvGetRTPortProc)();
pxvs = GET_XV_SCREEN(pScreen);
@@ -977,7 +967,7 @@ xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
memset(winPriv, 0, sizeof(XF86XVWindowRec));
winPriv->PortRec = portPriv;
winPriv->next = PrivRoot;
- pWin->devPrivates[XF86XVWindowIndex].ptr = (pointer)winPriv;
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, winPriv);
}
portPriv->pDraw = (DrawablePtr)pWin;
@@ -998,8 +988,8 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
if(prevPriv)
prevPriv->next = winPriv->next;
else
- pWin->devPrivates[XF86XVWindowIndex].ptr =
- (pointer)winPriv->next;
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
+ winPriv->next);
xfree(winPriv);
break;
}
@@ -1037,7 +1027,7 @@ xf86XVDestroyWindow(WindowPtr pWin)
xfree(tmp);
}
- pWin->devPrivates[XF86XVWindowIndex].ptr = NULL;
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey, NULL);
pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
ret = (*pScreen->DestroyWindow)(pWin);
@@ -1094,8 +1084,8 @@ xf86XVWindowExposures(WindowPtr pWin, RegionPtr reg1, RegionPtr reg2)
pPriv->pDraw = NULL;
if(!pPrev)
- pWin->devPrivates[XF86XVWindowIndex].ptr =
- (pointer)(WinPriv->next);
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
+ WinPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
@@ -1146,8 +1136,8 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
pPriv->pDraw = NULL;
if(!pPrev)
- pWin->devPrivates[XF86XVWindowIndex].ptr =
- (pointer)(WinPriv->next);
+ dixSetPrivate(&pWin->devPrivates, XF86XVWindowKey,
+ WinPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
diff --git a/hw/xfree86/common/xf86xvmc.c b/hw/xfree86/common/xf86xvmc.c
index f8ff0bed4..05267a240 100644
--- a/hw/xfree86/common/xf86xvmc.c
+++ b/hw/xfree86/common/xf86xvmc.c
@@ -56,11 +56,10 @@ typedef struct {
XvMCAdaptorPtr dixinfo;
} xf86XvMCScreenRec, *xf86XvMCScreenPtr;
-static unsigned long XF86XvMCGeneration = 0;
-static int XF86XvMCScreenIndex = -1;
+static DevPrivateKey XF86XvMCScreenKey = &XF86XvMCScreenKey;
-#define XF86XVMC_GET_PRIVATE(pScreen) \
- (xf86XvMCScreenPtr)((pScreen)->devPrivates[XF86XvMCScreenIndex].ptr)
+#define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey)
static int
@@ -164,19 +163,12 @@ _X_EXPORT Bool xf86XvMCScreenInit(
{
XvMCAdaptorPtr pAdapt;
xf86XvMCScreenPtr pScreenPriv;
- XvScreenPtr pxvs =
- (XvScreenPtr)(pScreen->devPrivates[XF86XvScreenIndex].ptr);
-
+ XvScreenPtr pxvs = (XvScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ XF86XvScreenKey);
int i, j;
if(!XvMCScreenInitProc) return FALSE;
- if(XF86XvMCGeneration != serverGeneration) {
- if((XF86XvMCScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- XF86XvMCGeneration = serverGeneration;
- }
-
if(!(pAdapt = xalloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
return FALSE;
@@ -185,7 +177,7 @@ _X_EXPORT Bool xf86XvMCScreenInit(
return FALSE;
}
- pScreen->devPrivates[XF86XvMCScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, XF86XvMCScreenKey, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = xf86XvMCCloseScreen;
diff --git a/hw/xfree86/common/xf86xvpriv.h b/hw/xfree86/common/xf86xvpriv.h
index e716c9c6a..4200dac80 100644
--- a/hw/xfree86/common/xf86xvpriv.h
+++ b/hw/xfree86/common/xf86xvpriv.h
@@ -30,10 +30,11 @@
#define _XF86XVPRIV_H_
#include "xf86xv.h"
+#include "privates.h"
/*** These are DDX layer privates ***/
-extern int XF86XvScreenIndex;
+extern DevPrivateKey XF86XvScreenKey;
typedef struct {
DestroyWindowProcPtr DestroyWindow;
diff --git a/hw/xfree86/dixmods/extmod/xf86dga2.c b/hw/xfree86/dixmods/extmod/xf86dga2.c
index fa9530860..295e05e9e 100644
--- a/hw/xfree86/dixmods/extmod/xf86dga2.c
+++ b/hw/xfree86/dixmods/extmod/xf86dga2.c
@@ -62,8 +62,7 @@ unsigned char DGAReqCode = 0;
int DGAErrorBase;
int DGAEventBase;
-static int DGAGeneration = 0;
-static int DGAClientPrivateIndex;
+static DevPrivateKey DGAClientPrivateKey = &DGAClientPrivateKey;
static int DGACallbackRefCount = 0;
/* This holds the client's version information */
@@ -72,7 +71,11 @@ typedef struct {
int minor;
} DGAPrivRec, *DGAPrivPtr;
-#define DGAPRIV(c) ((c)->devPrivates[DGAClientPrivateIndex].ptr)
+#define DGA_GETPRIV(c) ((DGAPrivPtr) \
+ dixLookupPrivate(&(c)->devPrivates, DGAClientPrivateKey))
+#define DGA_SETPRIV(c,p) \
+ dixSetPrivate(&(c)->devPrivates, DGAClientPrivateKey, p)
+
void
XFree86DGAExtensionInit(INITARGS)
@@ -97,23 +100,6 @@ XFree86DGAExtensionInit(INITARGS)
for (i = KeyPress; i <= MotionNotify; i++)
SetCriticalEvent (DGAEventBase + i);
}
-
- /*
- * Allocate a client private index to hold the client's version
- * information.
- */
- if (DGAGeneration != serverGeneration) {
- DGAClientPrivateIndex = AllocateClientPrivateIndex();
- /*
- * Allocate 0 length, and use the private to hold a pointer to
- * our DGAPrivRec.
- */
- if (!AllocateClientPrivate(DGAClientPrivateIndex, 0)) {
- ErrorF("XFree86DGAExtensionInit: AllocateClientPrivate failed\n");
- return;
- }
- DGAGeneration = serverGeneration;
- }
}
@@ -590,12 +576,12 @@ ProcXDGASetClientVersion(ClientPtr client)
DGAPrivPtr pPriv;
REQUEST_SIZE_MATCH(xXDGASetClientVersionReq);
- if ((pPriv = DGAPRIV(client)) == NULL) {
+ if ((pPriv = DGA_GETPRIV(client)) == NULL) {
pPriv = xalloc(sizeof(DGAPrivRec));
/* XXX Need to look into freeing this */
if (!pPriv)
return BadAlloc;
- DGAPRIV(client) = pPriv;
+ DGA_SETPRIV(client, pPriv);
}
pPriv->major = stuff->major;
pPriv->minor = stuff->minor;
diff --git a/hw/xfree86/dixmods/extmod/xf86misc.c b/hw/xfree86/dixmods/extmod/xf86misc.c
index 3a6f83eca..66278a298 100644
--- a/hw/xfree86/dixmods/extmod/xf86misc.c
+++ b/hw/xfree86/dixmods/extmod/xf86misc.c
@@ -41,8 +41,7 @@
#endif
static int miscErrorBase;
-static int MiscGeneration = 0;
-static int MiscClientPrivateIndex;
+static DevPrivateKey MiscClientPrivateKey = &MiscClientPrivateKey;
/* This holds the client's version information */
typedef struct {
@@ -50,7 +49,10 @@ typedef struct {
int minor;
} MiscPrivRec, *MiscPrivPtr;
-#define MPRIV(c) ((c)->devPrivates[MiscClientPrivateIndex].ptr)
+#define M_GETPRIV(c) ((MiscPrivPtr) \
+ dixLookupPrivate(&(c)->devPrivates, MiscClientPrivateKey))
+#define M_SETPRIV(c,p) \
+ dixSetPrivate(&(c)->devPrivates, MiscClientPrivateKey, p)
static void XF86MiscResetProc(
ExtensionEntry* /* extEntry */
@@ -61,7 +63,7 @@ ClientVersion(ClientPtr client, int *major, int *minor)
{
MiscPrivPtr pPriv;
- pPriv = MPRIV(client);
+ pPriv = M_GETPRIV(client);
if (!pPriv) {
if (major) *major = 0;
if (minor) *minor = 0;
@@ -123,24 +125,6 @@ XFree86MiscExtensionInit(void)
if (!xf86GetModInDevEnabled())
return;
- /*
- * Allocate a client private index to hold the client's version
- * information.
- */
- if (MiscGeneration != serverGeneration) {
- MiscClientPrivateIndex = AllocateClientPrivateIndex();
- /*
- * Allocate 0 length, and use the private to hold a pointer to our
- * MiscPrivRec.
- */
- if (!AllocateClientPrivate(MiscClientPrivateIndex, 0)) {
- ErrorF("XFree86MiscExtensionInit: "
- "AllocateClientPrivate failed\n");
- return;
- }
- MiscGeneration = serverGeneration;
- }
-
if (
(extEntry = AddExtension(XF86MISCNAME,
XF86MiscNumberEvents,
@@ -205,7 +189,9 @@ ProcXF86MiscSetSaver(client)
if (stuff->screen > screenInfo.numScreens)
return BadValue;
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
+ vptr = (ScrnInfoPtr)
+ dixLookupPrivate(&screenInfo.screens[stuff->screen]->devPrivates,
+ xf86ScreenKey);
REQUEST_SIZE_MATCH(xXF86MiscSetSaverReq);
@@ -233,7 +219,9 @@ ProcXF86MiscGetSaver(client)
if (stuff->screen > screenInfo.numScreens)
return BadValue;
- vptr = (ScrnInfoPtr) screenInfo.screens[stuff->screen]->devPrivates[xf86ScreenIndex].ptr;
+ vptr = (ScrnInfoPtr)
+ dixLookupPrivate(&screenInfo.screens[stuff->screen]->devPrivates,
+ xf86ScreenKey);
REQUEST_SIZE_MATCH(xXF86MiscGetSaverReq);
rep.type = X_Reply;
@@ -497,11 +485,11 @@ ProcXF86MiscSetClientVersion(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86MiscSetClientVersionReq);
- if ((pPriv = MPRIV(client)) == NULL) {
+ if ((pPriv = M_GETPRIV(client)) == NULL) {
pPriv = xalloc(sizeof(MiscPrivRec));
if (!pPriv)
return BadAlloc;
- MPRIV(client) = pPriv;
+ M_SETPRIV(client, pPriv);
}
if (xf86GetVerbosity() > 1)
ErrorF("SetClientVersion: %i %i\n",stuff->major,stuff->minor);
diff --git a/hw/xfree86/dixmods/extmod/xf86vmode.c b/hw/xfree86/dixmods/extmod/xf86vmode.c
index 44ec9f11d..fa3284839 100644
--- a/hw/xfree86/dixmods/extmod/xf86vmode.c
+++ b/hw/xfree86/dixmods/extmod/xf86vmode.c
@@ -52,8 +52,7 @@ from Kaleb S. KEITHLEY
#define DEFAULT_XF86VIDMODE_VERBOSITY 3
static int VidModeErrorBase;
-static int VidModeGeneration = 0;
-static int VidModeClientPrivateIndex;
+static DevPrivateKey VidModeClientPrivateKey = &VidModeClientPrivateKey;
/* This holds the client's version information */
typedef struct {
@@ -61,7 +60,10 @@ typedef struct {
int minor;
} VidModePrivRec, *VidModePrivPtr;
-#define VMPRIV(c) ((c)->devPrivates[VidModeClientPrivateIndex].ptr)
+#define VM_GETPRIV(c) ((VidModePrivPtr) \
+ dixLookupPrivate(&(c)->devPrivates, VidModeClientPrivateKey))
+#define VM_SETPRIV(c,p) \
+ dixSetPrivate(&(c)->devPrivates, VidModeClientPrivateKey, p)
static void XF86VidModeResetProc(
ExtensionEntry* /* extEntry */
@@ -145,10 +147,12 @@ typedef struct _XF86VidModeScreenPrivate {
Bool hasWindow;
} XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr;
-static int ScreenPrivateIndex;
+static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKey;
-#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr)(s)->devPrivates[ScreenPrivateIndex].ptr)
-#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (pointer) v);
+#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
+ dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
+#define SetScreenPrivate(s,v) \
+ dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v)
#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = GetScreenPrivate(s)
#define New(t) (xalloc (sizeof (t)))
@@ -172,7 +176,6 @@ XFree86VidModeExtensionInit(void)
#ifdef XF86VIDMODE_EVENTS
EventType = CreateNewResourceType(XF86VidModeFreeEvents);
- ScreenPrivateIndex = AllocateScreenPrivateIndex ();
#endif
for(i = 0; i < screenInfo.numScreens; i++) {
@@ -187,27 +190,9 @@ XFree86VidModeExtensionInit(void)
if (!enabled)
return;
- /*
- * Allocate a client private index to hold the client's version
- * information.
- */
- if (VidModeGeneration != serverGeneration) {
- VidModeClientPrivateIndex = AllocateClientPrivateIndex();
- /*
- * Allocate 0 length, and use the private to hold a pointer to our
- * VidModePrivRec.
- */
- if (!AllocateClientPrivate(VidModeClientPrivateIndex, 0)) {
- ErrorF("XFree86VidModeExtensionInit: "
- "AllocateClientPrivate failed\n");
- return;
- }
- VidModeGeneration = serverGeneration;
- }
-
if (
#ifdef XF86VIDMODE_EVENTS
- EventType && ScreenPrivateIndex != -1 &&
+ EventType &&
#endif
(extEntry = AddExtension(XF86VIDMODENAME,
XF86VidModeNumberEvents,
@@ -239,7 +224,7 @@ ClientMajorVersion(ClientPtr client)
{
VidModePrivPtr pPriv;
- pPriv = VMPRIV(client);
+ pPriv = VM_GETPRIV(client);
if (!pPriv)
return 0;
else
@@ -1682,11 +1667,11 @@ ProcXF86VidModeSetClientVersion(ClientPtr client)
REQUEST_SIZE_MATCH(xXF86VidModeSetClientVersionReq);
- if ((pPriv = VMPRIV(client)) == NULL) {
+ if ((pPriv = VM_GETPRIV(client)) == NULL) {
pPriv = xalloc(sizeof(VidModePrivRec));
if (!pPriv)
return BadAlloc;
- VMPRIV(client) = pPriv;
+ VM_SETPRIV(client, pPriv);
}
pPriv->major = stuff->major;
pPriv->minor = stuff->minor;
diff --git a/hw/xfree86/dixmods/extmod/xvmod.c b/hw/xfree86/dixmods/extmod/xvmod.c
index 7c1450c7a..6b3f1149a 100644
--- a/hw/xfree86/dixmods/extmod/xvmod.c
+++ b/hw/xfree86/dixmods/extmod/xvmod.c
@@ -16,7 +16,7 @@ void
XvRegister()
{
XvScreenInitProc = XvScreenInit;
- XvGetScreenIndexProc = XvGetScreenIndex;
+ XvGetScreenKeyProc = XvGetScreenKey;
XvGetRTPortProc = XvGetRTPort;
XvMCScreenInitProc = XvMCScreenInit;
}
diff --git a/hw/xfree86/dixmods/extmod/xvmodproc.h b/hw/xfree86/dixmods/extmod/xvmodproc.h
index 81356a149..b39c915b4 100644
--- a/hw/xfree86/dixmods/extmod/xvmodproc.h
+++ b/hw/xfree86/dixmods/extmod/xvmodproc.h
@@ -5,7 +5,7 @@
#include "xvmcext.h"
-extern int (*XvGetScreenIndexProc)(void);
+extern DevPrivateKey (*XvGetScreenKeyProc)(void);
extern unsigned long (*XvGetRTPortProc)(void);
extern int (*XvScreenInitProc)(ScreenPtr);
extern int (*XvMCScreenInitProc)(ScreenPtr, int, XvMCAdaptorPtr);
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
index d1bbfcd14..84c0508bc 100644
--- a/hw/xfree86/dri/dri.c
+++ b/hw/xfree86/dri/dri.c
@@ -79,8 +79,8 @@ extern Bool noPanoramiXExtension;
#endif
static int DRIEntPrivIndex = -1;
-static int DRIScreenPrivIndex = -1;
-static int DRIWindowPrivIndex = -1;
+static DevPrivateKey DRIScreenPrivKey = &DRIScreenPrivKey;
+static DevPrivateKey DRIWindowPrivKey = &DRIWindowPrivKey;
static unsigned long DRIGeneration = 0;
static unsigned int DRIDrawableValidationStamp = 0;
@@ -343,20 +343,18 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
pDRIEntPriv = DRI_ENT_PRIV(pScrn);
- if (DRIGeneration != serverGeneration) {
- if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
+ DRIScreenPrivKey = &DRIScreenPrivKey;
+ if (DRIGeneration != serverGeneration)
DRIGeneration = serverGeneration;
- }
pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec));
if (!pDRIPriv) {
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
- DRIScreenPrivIndex = -1;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ DRIScreenPrivKey = NULL;
return FALSE;
}
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, pDRIPriv);
pDRIPriv->drmFD = pDRIEntPriv->drmFD;
pDRIPriv->directRenderingSupport = TRUE;
pDRIPriv->pDriverInfo = pDRIInfo;
@@ -381,7 +379,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
&pDRIPriv->hSAREA) < 0)
{
pDRIPriv->directRenderingSupport = FALSE;
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
drmClose(pDRIPriv->drmFD);
DRIDrvMsg(pScreen->myNum, X_INFO,
"[drm] drmAddMap failed\n");
@@ -398,7 +396,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
(drmAddressPtr)(&pDRIPriv->pSAREA)) < 0)
{
pDRIPriv->directRenderingSupport = FALSE;
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
drmClose(pDRIPriv->drmFD);
DRIDrvMsg(pScreen->myNum, X_INFO,
"[drm] drmMap failed\n");
@@ -428,7 +426,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
&pDRIPriv->pDriverInfo->hFrameBuffer) < 0)
{
pDRIPriv->directRenderingSupport = FALSE;
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize);
drmClose(pDRIPriv->drmFD);
DRIDrvMsg(pScreen->myNum, X_INFO,
@@ -744,8 +742,8 @@ DRICloseScreen(ScreenPtr pScreen)
}
xfree(pDRIPriv);
- pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL;
- DRIScreenPrivIndex = -1;
+ dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
+ DRIScreenPrivKey = NULL;
}
}
@@ -772,30 +770,13 @@ drmServerInfo DRIDRMServerInfo = {
Bool
DRIExtensionInit(void)
{
- int i;
- ScreenPtr pScreen;
-
- if (DRIScreenPrivIndex < 0 || DRIGeneration != serverGeneration) {
+ if (!DRIScreenPrivKey || DRIGeneration != serverGeneration) {
return FALSE;
}
- /* Allocate a window private index with a zero sized private area for
- * each window, then should a window become a DRI window, we'll hang
- * a DRIWindowPrivateRec off of this private index.
- */
- if ((DRIWindowPrivIndex = AllocateWindowPrivateIndex()) < 0)
- return FALSE;
-
DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete);
DRIContextPrivResType = CreateNewResourceType(DRIContextPrivDelete);
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- pScreen = screenInfo.screens[i];
- if (!AllocateWindowPrivate(pScreen, DRIWindowPrivIndex, 0))
- return FALSE;
- }
-
RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL);
return TRUE;
@@ -1302,9 +1283,8 @@ DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable,
pDRIDrawablePriv->nrects = REGION_NUM_RECTS(&pWin->clipList);
/* save private off of preallocated index */
- pWin->devPrivates[DRIWindowPrivIndex].ptr =
- (pointer)pDRIDrawablePriv;
-
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey,
+ pDRIDrawablePriv);
pDRIPriv->nrWindows++;
if (pDRIDrawablePriv->nrects)
@@ -1362,7 +1342,7 @@ DRIDrawablePrivDestroy(WindowPtr pWin)
drmDestroyDrawable(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable);
xfree(pDRIDrawablePriv);
- pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL;
+ dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, NULL);
}
static Bool
diff --git a/hw/xfree86/dri/dristruct.h b/hw/xfree86/dri/dristruct.h
index c3b0aeede..ae970d834 100644
--- a/hw/xfree86/dri/dristruct.h
+++ b/hw/xfree86/dri/dristruct.h
@@ -37,15 +37,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xf86drm.h"
-#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) \
- ((DRIWindowPrivIndex < 0) ? \
- NULL : \
- ((DRIDrawablePrivPtr)((pWin)->devPrivates[DRIWindowPrivIndex].ptr)))
-
-#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) \
- ((DRIPixmapPrivIndex < 0) ? \
- NULL : \
- ((DRIDrawablePrivPtr)((pPix)->devPrivates[DRIWindowPrivIndex].ptr)))
+#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey))
+#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \
+ dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey))
typedef struct _DRIDrawablePrivRec
{
@@ -65,13 +60,12 @@ struct _DRIContextPrivRec
void** pContextStore;
};
-#define DRI_SCREEN_PRIV(pScreen) \
- ((DRIScreenPrivIndex < 0) ? \
- NULL : \
- ((DRIScreenPrivPtr)((pScreen)->devPrivates[DRIScreenPrivIndex].ptr)))
+#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey))
#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
- (screenInfo.screens[screenIndex]->devPrivates[DRIScreenPrivIndex].ptr))
+ dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \
+ DRIScreenPrivKey))
#define DRI_ENT_PRIV(pScrn) \
((DRIEntPrivIndex < 0) ? \
diff --git a/hw/xfree86/exa/examodule.c b/hw/xfree86/exa/examodule.c
index 4dce58fd8..aac32949c 100644
--- a/hw/xfree86/exa/examodule.c
+++ b/hw/xfree86/exa/examodule.c
@@ -42,8 +42,7 @@ typedef struct _ExaXorgScreenPrivRec {
OptionInfoPtr options;
} ExaXorgScreenPrivRec, *ExaXorgScreenPrivPtr;
-static int exaXorgServerGeneration;
-static int exaXorgScreenPrivateIndex;
+static DevPrivateKey exaXorgScreenPrivateKey = &exaXorgScreenPrivateKey;
typedef enum {
EXAOPT_MIGRATION_HEURISTIC,
@@ -69,8 +68,8 @@ static Bool
exaXorgCloseScreen (int i, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
- ExaXorgScreenPrivPtr pScreenPriv =
- pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr;
+ ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr)
+ dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey);
pScreen->CloseScreen = pScreenPriv->SavedCloseScreen;
@@ -86,8 +85,8 @@ static void
exaXorgEnableDisableFBAccess (int index, Bool enable)
{
ScreenPtr pScreen = screenInfo.screens[index];
- ExaXorgScreenPrivPtr pScreenPriv =
- pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr;
+ ExaXorgScreenPrivPtr pScreenPriv = (ExaXorgScreenPrivPtr)
+ dixLookupPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey);
if (!enable)
exaEnableDisableFBAccess (index, enable);
@@ -111,11 +110,6 @@ exaDDXDriverInit(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
ExaXorgScreenPrivPtr pScreenPriv;
- if (exaXorgServerGeneration != serverGeneration) {
- exaXorgScreenPrivateIndex = AllocateScreenPrivateIndex();
- exaXorgServerGeneration = serverGeneration;
- }
-
pScreenPriv = xcalloc (1, sizeof(ExaXorgScreenPrivRec));
if (pScreenPriv == NULL)
return;
@@ -166,7 +160,7 @@ exaDDXDriverInit(ScreenPtr pScreen)
pExaScr->info->DownloadFromScreen = NULL;
}
- pScreen->devPrivates[exaXorgScreenPrivateIndex].ptr = pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey, pScreenPriv);
pScreenPriv->SavedEnableDisableFBAccess = pScrn->EnableDisableFBAccess;
pScrn->EnableDisableFBAccess = exaXorgEnableDisableFBAccess;
diff --git a/hw/xfree86/loader/dixsym.c b/hw/xfree86/loader/dixsym.c
index 1af076b88..4b3b66a89 100644
--- a/hw/xfree86/loader/dixsym.c
+++ b/hw/xfree86/loader/dixsym.c
@@ -238,7 +238,7 @@ _X_HIDDEN void *dixLookupTab[] = {
#ifdef XV
/* XXX These are exported from the DDX, not DIX. */
SYMVAR(XvScreenInitProc)
- SYMVAR(XvGetScreenIndexProc)
+ SYMVAR(XvGetScreenKeyProc)
SYMVAR(XvGetRTPortProc)
SYMVAR(XvMCScreenInitProc)
#endif
@@ -270,20 +270,6 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(dixFreePrivates)
SYMFUNC(dixRegisterPrivateOffset)
SYMFUNC(dixLookupPrivateOffset)
- SYMFUNC(AllocateExtensionPrivate)
- SYMFUNC(AllocateExtensionPrivateIndex)
- SYMFUNC(AllocateClientPrivate)
- SYMFUNC(AllocateClientPrivateIndex)
- SYMFUNC(AllocateGCPrivate)
- SYMFUNC(AllocateGCPrivateIndex)
- SYMFUNC(AllocateWindowPrivate)
- SYMFUNC(AllocateWindowPrivateIndex)
- SYMFUNC(AllocateScreenPrivateIndex)
- SYMFUNC(AllocateColormapPrivateIndex)
- SYMFUNC(AllocateDevicePrivateIndex)
- SYMFUNC(AllocateDevicePrivate)
- SYMFUNC(AllocatePixmapPrivateIndex)
- SYMFUNC(AllocatePixmapPrivate)
/* resource.c */
SYMFUNC(AddResource)
SYMFUNC(ChangeResourceValue)
@@ -521,7 +507,7 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(PictureTransformPoint3d)
SYMFUNC(PictureGetSubpixelOrder)
SYMFUNC(PictureSetSubpixelOrder)
- SYMVAR(PictureScreenPrivateIndex)
+ SYMVAR(PictureScreenPrivateKey)
/* mipict.c */
SYMFUNC(miPictureInit)
SYMFUNC(miComputeCompositeRegion)
diff --git a/hw/xfree86/loader/misym.c b/hw/xfree86/loader/misym.c
index 78ae10e02..e87d35408 100644
--- a/hw/xfree86/loader/misym.c
+++ b/hw/xfree86/loader/misym.c
@@ -200,9 +200,9 @@ _X_HIDDEN void *miLookupTab[] = {
SYMFUNC(miOverlaySetRootClip)
SYMVAR(miEmptyBox)
SYMVAR(miEmptyData)
- SYMVAR(miZeroLineScreenIndex)
+ SYMVAR(miZeroLineScreenKey)
SYMVAR(miSpritePointerFuncs)
- SYMVAR(miPointerScreenIndex)
+ SYMVAR(miPointerScreenKey)
SYMVAR(miInstalledMaps)
SYMVAR(miInitVisualsProc)
#ifdef RENDER
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 9b8dac82e..7beef3193 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -1099,8 +1099,8 @@ _X_HIDDEN void *xfree86LookupTab[] = {
SYMVAR(xf86HUGE_VAL)
/* General variables (from xf86.h) */
- SYMVAR(xf86ScreenIndex)
- SYMVAR(xf86PixmapIndex)
+ SYMVAR(xf86ScreenKey)
+ SYMVAR(xf86PixmapKey)
SYMVAR(xf86Screens)
SYMVAR(byte_reversed)
SYMVAR(xf86inSuspend)
diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index 38435c924..d58cc7070 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -59,11 +59,11 @@ static Bool xf86RandR12Init12 (ScreenPtr pScreen);
static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen);
#endif
-static int xf86RandR12Index;
-static int xf86RandR12Generation;
+static int xf86RandR12Generation;
+static DevPrivateKey xf86RandR12Key = &xf86RandR12Key;
-#define XF86RANDRINFO(p) \
- ((XF86RandRInfoPtr)(p)->devPrivates[xf86RandR12Index].ptr)
+#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \
+ dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key))
static int
xf86RandR12ModeRefresh (DisplayModePtr mode)
@@ -482,10 +482,7 @@ xf86RandR12Init (ScreenPtr pScreen)
return TRUE;
#endif
if (xf86RandR12Generation != serverGeneration)
- {
- xf86RandR12Index = AllocateScreenPrivateIndex();
xf86RandR12Generation = serverGeneration;
- }
randrp = xalloc (sizeof (XF86RandRInfoRec));
if (!randrp)
@@ -511,7 +508,7 @@ xf86RandR12Init (ScreenPtr pScreen)
randrp->maxX = randrp->maxY = 0;
- pScreen->devPrivates[xf86RandR12Index].ptr = randrp;
+ dixSetPrivate(&pScreen->devPrivates, xf86RandR12Key, randrp);
#if RANDR_12_INTERFACE
if (!xf86RandR12Init12 (pScreen))
diff --git a/hw/xfree86/os-support/solaris/sun_mouse.c b/hw/xfree86/os-support/solaris/sun_mouse.c
index aa509d08b..b1b7797f1 100644
--- a/hw/xfree86/os-support/solaris/sun_mouse.c
+++ b/hw/xfree86/os-support/solaris/sun_mouse.c
@@ -121,8 +121,11 @@ static void vuidMouseSendScreenSize(ScreenPtr pScreen, VuidMsePtr pVuidMse);
static void vuidMouseAdjustFrame(int index, int x, int y, int flags);
static int vuidMouseGeneration = 0;
-static int vuidMouseScreenIndex;
-#define vuidMouseScreenPrivate(s) ((s)->devPrivates[vuidMouseScreenIndex].ptr)
+static DevPrivateKey vuidMouseScreenKey = &vuidMouseScreenKey;
+#define vuidGetMouseScreenPrivate(s) ((VuidMsePtr) \
+ dixLookupPrivate(&(s)->devPrivates, vuidMouseScreenKey))
+#define vuidSetMouseScreenPrivate(s,p) \
+ dixSetPrivate(&(s)->devPrivates, vuidMouseScreenKey, p)
#endif /* HAVE_ABSOLUTE_MOUSE_SCALING */
static inline
@@ -455,7 +458,7 @@ static void vuidMouseAdjustFrame(int index, int x, int y, int flags)
ScrnInfoPtr pScrn = xf86Screens[index];
ScreenPtr pScreen = pScrn->pScreen;
xf86AdjustFrameProc *wrappedAdjustFrame
- = (xf86AdjustFrameProc *) vuidMouseScreenPrivate(pScreen);
+ = (xf86AdjustFrameProc *) vuidMouseGetScreenPrivate(pScreen);
VuidMsePtr m;
if(wrappedAdjustFrame) {
@@ -496,15 +499,12 @@ vuidMouseProc(DeviceIntPtr pPointer, int what)
case DEVICE_INIT:
#ifdef HAVE_ABSOLUTE_MOUSE_SCALING
if (vuidMouseGeneration != serverGeneration) {
- if ((vuidMouseScreenIndex = AllocateScreenPrivateIndex()) >= 0) {
for (i = 0; i < screenInfo.numScreens; i++) {
ScreenPtr pScreen = screenInfo.screens[i];
ScrnInfoPtr pScrn = XF86SCRNINFO(pScreen);
- vuidMouseScreenPrivate(pScreen)
- = (pointer) pScrn->AdjustFrame;
+ vuidMouseSetScreenPrivate(pScreen, pScrn->AdjustFrame);
pScrn->AdjustFrame = vuidMouseAdjustFrame;
}
- }
vuidMouseGeneration = serverGeneration;
}
#endif
diff --git a/hw/xfree86/rac/xf86RAC.c b/hw/xfree86/rac/xf86RAC.c
index 8492cdb69..5302a86b2 100644
--- a/hw/xfree86/rac/xf86RAC.c
+++ b/hw/xfree86/rac/xf86RAC.c
@@ -39,9 +39,8 @@
pScreen->x = y;}
#define UNWRAP_SCREEN(x) pScreen->x = pScreenPriv->x
-#define SCREEN_PROLOG(x) \
- pScreen->x = \
- ((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr)->x
+#define SCREEN_PROLOG(x) pScreen->x = ((RACScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey))->x
#define SCREEN_EPILOG(x,y) pScreen->x = y;
#define WRAP_PICT_COND(x,y,cond) if (ps)\
@@ -50,9 +49,8 @@
ps->x = y;}
#define UNWRAP_PICT(x) if (ps) {ps->x = pScreenPriv->x;}
-#define PICTURE_PROLOGUE(field) \
- ps->field = \
- ((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr)->field
+#define PICTURE_PROLOGUE(field) ps->field = \
+ ((RACScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey))->field
#define PICTURE_EPILOGUE(field, wrap) \
ps->field = wrap
@@ -65,9 +63,9 @@
#define UNWRAP_SCREEN_INFO(x) pScrn->x = pScreenPriv->x
#define SPRITE_PROLOG miPointerScreenPtr PointPriv = \
-(miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr;\
- RACScreenPtr pScreenPriv = \
-((RACScreenPtr) (pScreen)->devPrivates[RACScreenIndex].ptr);\
+ (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); \
+ RACScreenPtr pScreenPriv = \
+ ((RACScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, RACScreenKey));\
PointPriv->spriteFuncs = pScreenPriv->miSprite;
#define SPRITE_EPILOG pScreenPriv->miSprite = PointPriv->spriteFuncs;\
PointPriv->spriteFuncs = &RACSpriteFuncs;
@@ -82,7 +80,7 @@
(x)->ops = &RACGCOps;\
(x)->funcs = &RACGCFuncs;
#define GC_UNWRAP(x)\
- RACGCPtr pGCPriv = (RACGCPtr) (x)->devPrivates[RACGCIndex].ptr;\
+ RACGCPtr pGCPriv = (RACGCPtr)dixLookupPrivate(&(x)->devPrivates, RACGCKey);\
(x)->ops = pGCPriv->wrapOps;\
(x)->funcs = pGCPriv->wrapFuncs;
@@ -255,9 +253,8 @@ static miPointerSpriteFuncRec RACSpriteFuncs = {
RACSpriteMoveCursor
};
-static int RACScreenIndex = -1;
-static int RACGCIndex = -1;
-static unsigned long RACGeneration = 0;
+static DevPrivateKey RACScreenKey = &RACScreenKey;
+static DevPrivateKey RACGCKey = &RACGCKey;
Bool
@@ -271,24 +268,17 @@ xf86RACInit(ScreenPtr pScreen, unsigned int flag)
#endif
pScrn = xf86Screens[pScreen->myNum];
- PointPriv = (miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr;
-
+ PointPriv = (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miPointerScreenKey);
DPRINT_S("RACInit",pScreen->myNum);
- if (RACGeneration != serverGeneration) {
- if ( ((RACScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((RACGCIndex = AllocateGCPrivateIndex()) < 0))
- return FALSE;
-
- RACGeneration = serverGeneration;
- }
- if (!AllocateGCPrivate(pScreen, RACGCIndex, sizeof(RACGCRec)))
+ if (!dixRequestPrivate(RACGCKey, sizeof(RACGCRec)))
return FALSE;
if (!(pScreenPriv = xalloc(sizeof(RACScreenRec))))
return FALSE;
- pScreen->devPrivates[RACScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, RACScreenKey, pScreenPriv);
WRAP_SCREEN(CloseScreen, RACCloseScreen);
WRAP_SCREEN(SaveScreen, RACSaveScreen);
@@ -327,10 +317,10 @@ static Bool
RACCloseScreen (int i, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- RACScreenPtr pScreenPriv =
- (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
- miPointerScreenPtr PointPriv
- = (miPointerScreenPtr)pScreen->devPrivates[miPointerScreenIndex].ptr;
+ RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, RACScreenKey);
+ miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, miPointerScreenKey);
#ifdef RENDER
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
@@ -620,8 +610,8 @@ static void
RACAdjustFrame(int index, int x, int y, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- RACScreenPtr pScreenPriv =
- (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
+ RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, RACScreenKey);
DPRINT_S("RACAdjustFrame",index);
xf86EnableAccess(xf86Screens[index]);
@@ -633,8 +623,8 @@ static Bool
RACSwitchMode(int index, DisplayModePtr mode, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- RACScreenPtr pScreenPriv =
- (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
+ RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, RACScreenKey);
DPRINT_S("RACSwitchMode",index);
xf86EnableAccess(xf86Screens[index]);
@@ -646,8 +636,8 @@ static Bool
RACEnterVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- RACScreenPtr pScreenPriv =
- (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
+ RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, RACScreenKey);
DPRINT_S("RACEnterVT",index);
xf86EnableAccess(xf86Screens[index]);
@@ -659,8 +649,8 @@ static void
RACLeaveVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- RACScreenPtr pScreenPriv =
- (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
+ RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, RACScreenKey);
DPRINT_S("RACLeaveVT",index);
xf86EnableAccess(xf86Screens[index]);
@@ -672,8 +662,8 @@ static void
RACFreeScreen(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- RACScreenPtr pScreenPriv =
- (RACScreenPtr) pScreen->devPrivates[RACScreenIndex].ptr;
+ RACScreenPtr pScreenPriv = (RACScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, RACScreenKey);
DPRINT_S("RACFreeScreen",index);
xf86EnableAccess(xf86Screens[index]);
@@ -685,7 +675,7 @@ static Bool
RACCreateGC(GCPtr pGC)
{
ScreenPtr pScreen = pGC->pScreen;
- RACGCPtr pGCPriv = (RACGCPtr) (pGC)->devPrivates[RACGCIndex].ptr;
+ RACGCPtr pGCPriv = (RACGCPtr)dixLookupPrivate(&pGC->devPrivates, RACGCKey);
Bool ret;
DPRINT_S("RACCreateGC",pScreen->myNum);
diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c
index 457807698..1c2d6a869 100644
--- a/hw/xfree86/ramdac/xf86Cursor.c
+++ b/hw/xfree86/ramdac/xf86Cursor.c
@@ -8,8 +8,7 @@
#include "colormapst.h"
#include "cursorstr.h"
-int xf86CursorScreenIndex = -1;
-static unsigned long xf86CursorGeneration = 0;
+DevPrivateKey xf86CursorScreenKey = &xf86CursorScreenKey;
/* sprite functions */
@@ -48,12 +47,6 @@ xf86InitCursor(
xf86CursorScreenPtr ScreenPriv;
miPointerScreenPtr PointPriv;
- if (xf86CursorGeneration != serverGeneration) {
- if ((xf86CursorScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- xf86CursorGeneration = serverGeneration;
- }
-
if (!xf86InitHardwareCursor(pScreen, infoPtr))
return FALSE;
@@ -61,7 +54,7 @@ xf86InitCursor(
if (!ScreenPriv)
return FALSE;
- pScreen->devPrivates[xf86CursorScreenIndex].ptr = ScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, xf86CursorScreenKey, ScreenPriv);
ScreenPriv->SWCursor = TRUE;
ScreenPriv->isUp = FALSE;
@@ -84,7 +77,7 @@ xf86InitCursor(
ScreenPriv->PalettedCursor = TRUE;
}
- PointPriv = pScreen->devPrivates[miPointerScreenIndex].ptr;
+ PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
ScreenPriv->showTransparent = PointPriv->showTransparent;
if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT)
@@ -113,10 +106,10 @@ static Bool
xf86CursorCloseScreen(int i, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- miPointerScreenPtr PointPriv =
- pScreen->devPrivates[miPointerScreenIndex].ptr;
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, miPointerScreenKey);
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (ScreenPriv->isUp && pScrn->vtSema)
xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
@@ -146,8 +139,8 @@ xf86CursorQueryBestSize(
unsigned short *height,
ScreenPtr pScreen)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (class == CursorShape) {
if(*width > ScreenPriv->CursorInfoPtr->MaxWidth)
@@ -161,8 +154,8 @@ xf86CursorQueryBestSize(
static void
xf86CursorInstallColormap(ColormapPtr pMap)
{
- xf86CursorScreenPtr ScreenPriv =
- pMap->pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pMap->pScreen->devPrivates, xf86CursorScreenKey);
ScreenPriv->pInstalledMap = pMap;
@@ -175,8 +168,8 @@ xf86CursorRecolorCursor(
CursorPtr pCurs,
Bool displayed)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (!displayed)
return;
@@ -195,8 +188,8 @@ xf86CursorEnableDisableFBAccess(
Bool enable)
{
ScreenPtr pScreen = screenInfo.screens[index];
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (!enable && ScreenPriv->CurrentCursor != NullCursor) {
CursorPtr currentCursor = ScreenPriv->CurrentCursor;
@@ -226,10 +219,10 @@ xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags)
{
Bool ret;
ScreenPtr pScreen = screenInfo.screens[index];
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
- miPointerScreenPtr PointPriv =
- pScreen->devPrivates[miPointerScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
+ miPointerScreenPtr PointPriv = (miPointerScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, miPointerScreenKey);
if (ScreenPriv->isUp) {
xf86SetCursor(pScreen, NullCursor, ScreenPriv->x, ScreenPriv->y);
@@ -254,8 +247,8 @@ xf86CursorSwitchMode(int index, DisplayModePtr mode, int flags)
static Bool
xf86CursorRealizeCursor(ScreenPtr pScreen, CursorPtr pCurs)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (pCurs->refcnt <= 1)
pCurs->devPriv[pScreen->myNum] = NULL;
@@ -266,8 +259,8 @@ xf86CursorRealizeCursor(ScreenPtr pScreen, CursorPtr pCurs)
static Bool
xf86CursorUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCurs)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (pCurs->refcnt <= 1) {
xfree(pCurs->devPriv[pScreen->myNum]);
@@ -280,8 +273,8 @@ xf86CursorUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCurs)
static void
xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
miPointerScreenPtr PointPriv;
@@ -306,8 +299,8 @@ xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
ScreenPriv->HotX = pCurs->bits->xhot;
ScreenPriv->HotY = pCurs->bits->yhot;
- PointPriv = pScreen->devPrivates[miPointerScreenIndex].ptr;
-
+ PointPriv = (miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miPointerScreenKey);
if (infoPtr->pScrn->vtSema && (ScreenPriv->ForceHWCursorCount || ((
#ifdef ARGB_CURSOR
pCurs->bits->argb && infoPtr->UseHWCursorARGB &&
@@ -351,8 +344,8 @@ xf86CursorSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
static void
xf86CursorMoveCursor(ScreenPtr pScreen, int x, int y)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
ScreenPriv->x = x;
ScreenPriv->y = y;
@@ -369,8 +362,8 @@ xf86CursorMoveCursor(ScreenPtr pScreen, int x, int y)
void
xf86ForceHWCursor (ScreenPtr pScreen, Bool on)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
if (on)
{
diff --git a/hw/xfree86/ramdac/xf86CursorPriv.h b/hw/xfree86/ramdac/xf86CursorPriv.h
index 472e2b06b..f82be2edc 100644
--- a/hw/xfree86/ramdac/xf86CursorPriv.h
+++ b/hw/xfree86/ramdac/xf86CursorPriv.h
@@ -45,6 +45,6 @@ Bool xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr);
CARD32 xf86ReverseBitOrder(CARD32 data);
-extern int xf86CursorScreenIndex;
+extern DevPrivateKey xf86CursorScreenKey;
#endif /* _XF86CURSORPRIV_H */
diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c
index 91caea047..0a753be3f 100644
--- a/hw/xfree86/ramdac/xf86HWCurs.c
+++ b/hw/xfree86/ramdac/xf86HWCurs.c
@@ -113,8 +113,8 @@ xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
void
xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
unsigned char *bits;
@@ -157,8 +157,8 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
void
xf86SetTransparentCursor(ScreenPtr pScreen)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
if (!ScreenPriv->transparentData)
@@ -178,8 +178,8 @@ xf86SetTransparentCursor(ScreenPtr pScreen)
void
xf86MoveCursor(ScreenPtr pScreen, int x, int y)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX;
@@ -191,8 +191,8 @@ xf86MoveCursor(ScreenPtr pScreen, int x, int y)
void
xf86RecolorCursor(ScreenPtr pScreen, CursorPtr pCurs, Bool displayed)
{
- xf86CursorScreenPtr ScreenPriv =
- pScreen->devPrivates[xf86CursorScreenIndex].ptr;
+ xf86CursorScreenPtr ScreenPriv = (xf86CursorScreenPtr)dixLookupPrivate(
+ &pScreen->devPrivates, xf86CursorScreenKey);
xf86CursorInfoPtr infoPtr = ScreenPriv->CursorInfoPtr;
#ifdef ARGB_CURSOR
diff --git a/hw/xfree86/shadowfb/shadow.c b/hw/xfree86/shadowfb/shadow.c
index c1b6ed1ce..ba6e3a8ee 100644
--- a/hw/xfree86/shadowfb/shadow.c
+++ b/hw/xfree86/shadowfb/shadow.c
@@ -101,14 +101,13 @@ typedef struct {
} ShadowGCRec, *ShadowGCPtr;
-static int ShadowScreenIndex = -1;
-static int ShadowGCIndex = -1;
-static unsigned long ShadowGeneration = 0;
+static DevPrivateKey ShadowScreenKey = &ShadowScreenKey;
+static DevPrivateKey ShadowGCKey = &ShadowGCKey;
#define GET_SCREEN_PRIVATE(pScreen) \
- (ShadowScreenPtr)((pScreen)->devPrivates[ShadowScreenIndex].ptr)
+ (ShadowScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, ShadowScreenKey)
#define GET_GC_PRIVATE(pGC) \
- (ShadowGCPtr)((pGC)->devPrivates[ShadowGCIndex].ptr)
+ (ShadowGCPtr)dixLookupPrivate(&(pGC)->devPrivates, ShadowGCKey);
#define SHADOW_GC_FUNC_PROLOGUE(pGC)\
ShadowGCPtr pGCPriv = GET_GC_PRIVATE(pGC);\
@@ -179,20 +178,13 @@ ShadowFBInit2 (
if(!preRefreshArea && !postRefreshArea) return FALSE;
- if (ShadowGeneration != serverGeneration) {
- if(((ShadowScreenIndex = AllocateScreenPrivateIndex ()) < 0) ||
- ((ShadowGCIndex = AllocateGCPrivateIndex()) < 0))
- return FALSE;
- ShadowGeneration = serverGeneration;
- }
-
- if(!AllocateGCPrivate(pScreen, ShadowGCIndex, sizeof(ShadowGCRec)))
+ if(!dixRequestPrivate(ShadowGCKey, sizeof(ShadowGCRec)))
return FALSE;
if(!(pPriv = (ShadowScreenPtr)xalloc(sizeof(ShadowScreenRec))))
return FALSE;
- pScreen->devPrivates[ShadowScreenIndex].ptr = (pointer)pPriv;
+ dixSetPrivate(&pScreen->devPrivates, ShadowScreenKey, pPriv);
pPriv->pScrn = pScrn;
pPriv->preRefresh = preRefreshArea;
diff --git a/hw/xfree86/xaa/xaaDashLine.c b/hw/xfree86/xaa/xaaDashLine.c
index 1a4732baa..63233e05d 100644
--- a/hw/xfree86/xaa/xaaDashLine.c
+++ b/hw/xfree86/xaa/xaaDashLine.c
@@ -35,7 +35,8 @@ XAAPolyLinesDashed(
#endif
){
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
BoxPtr pboxInit = REGION_RECTS(pGC->pCompositeClip);
int nboxInit = REGION_NUM_RECTS(pGC->pCompositeClip);
unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
diff --git a/hw/xfree86/xaa/xaaGC.c b/hw/xfree86/xaa/xaaGC.c
index f3434c9f4..65a482fe7 100644
--- a/hw/xfree86/xaa/xaaGC.c
+++ b/hw/xfree86/xaa/xaaGC.c
@@ -38,7 +38,8 @@ Bool
XAACreateGC(GCPtr pGC)
{
ScreenPtr pScreen = pGC->pScreen;
- XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
Bool ret;
XAA_SCREEN_PROLOGUE(pScreen,CreateGC);
diff --git a/hw/xfree86/xaa/xaaGCmisc.c b/hw/xfree86/xaa/xaaGCmisc.c
index a7a3f4081..5823cc064 100644
--- a/hw/xfree86/xaa/xaaGCmisc.c
+++ b/hw/xfree86/xaa/xaaGCmisc.c
@@ -305,7 +305,8 @@ XAAValidatePolylines(
DrawablePtr pDraw )
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
if(pGC->lineStyle == LineSolid) changes &= ~GCDashList;
if(!changes) return;
diff --git a/hw/xfree86/xaa/xaaInit.c b/hw/xfree86/xaa/xaaInit.c
index 93f6995aa..614ecf751 100644
--- a/hw/xfree86/xaa/xaaInit.c
+++ b/hw/xfree86/xaa/xaaInit.c
@@ -38,22 +38,20 @@ static int XAASetDGAMode(int index, int num, DGADevicePtr devRet);
static void XAAEnableDisableFBAccess (int index, Bool enable);
static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask);
-static int XAAScreenIndex = -1;
-static int XAAGCIndex = -1;
-static int XAAPixmapIndex = -1;
+static DevPrivateKey XAAScreenKey = &XAAScreenKey;
+static DevPrivateKey XAAGCKey = &XAAGCKey;
+static DevPrivateKey XAAPixmapKey = &XAAPixmapKey;
-static unsigned long XAAGeneration = 0;
-
-int XAAGetScreenIndex(void) {
- return XAAScreenIndex;
+DevPrivateKey XAAGetScreenKey(void) {
+ return XAAScreenKey;
}
-int XAAGetGCIndex(void) {
- return XAAGCIndex;
+DevPrivateKey XAAGetGCKey(void) {
+ return XAAGCKey;
}
-int XAAGetPixmapIndex(void) {
- return XAAPixmapIndex;
+DevPrivateKey XAAGetPixmapKey(void) {
+ return XAAPixmapKey;
}
/* temp kludge */
@@ -103,25 +101,16 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
if (!infoRec)
return TRUE;
- if (XAAGeneration != serverGeneration) {
- if ( ((XAAScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((XAAGCIndex = AllocateGCPrivateIndex()) < 0) ||
- ((XAAPixmapIndex = AllocatePixmapPrivateIndex()) < 0))
- return FALSE;
-
- XAAGeneration = serverGeneration;
- }
-
- if (!AllocateGCPrivate(pScreen, XAAGCIndex, sizeof(XAAGCRec)))
+ if (!dixRequestPrivate(XAAGCKey, sizeof(XAAGCRec)))
return FALSE;
- if (!AllocatePixmapPrivate(pScreen, XAAPixmapIndex, sizeof(XAAPixmapRec)))
+ if (!dixRequestPrivate(XAAPixmapKey, sizeof(XAAPixmapRec)))
return FALSE;
if (!(pScreenPriv = xalloc(sizeof(XAAScreenRec))))
return FALSE;
- pScreen->devPrivates[XAAScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, XAAScreenKey, pScreenPriv);
if(!xf86FBManagerRunning(pScreen))
infoRec->Flags &= ~(PIXMAP_CACHE | OFFSCREEN_PIXMAPS);
@@ -226,7 +215,7 @@ XAACloseScreen (int i, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
XAAScreenPtr pScreenPriv =
- (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr;
+ (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
pScrn->EnterVT = pScreenPriv->EnterVT;
pScrn->LeaveVT = pScreenPriv->LeaveVT;
@@ -524,7 +513,7 @@ XAAEnterVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
XAAScreenPtr pScreenPriv =
- (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr;
+ (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
return((*pScreenPriv->EnterVT)(index, flags));
}
@@ -534,7 +523,7 @@ XAALeaveVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
XAAScreenPtr pScreenPriv =
- (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr;
+ (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec;
if(infoRec->NeedToSync) {
@@ -557,7 +546,7 @@ XAASetDGAMode(int index, int num, DGADevicePtr devRet)
ScreenPtr pScreen = screenInfo.screens[index];
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
XAAScreenPtr pScreenPriv =
- (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr;
+ (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
int ret;
if (!num && infoRec->dgaSaves) { /* restore old pixmap cache state */
@@ -619,7 +608,7 @@ XAAEnableDisableFBAccess (int index, Bool enable)
ScreenPtr pScreen = screenInfo.screens[index];
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
XAAScreenPtr pScreenPriv =
- (XAAScreenPtr) pScreen->devPrivates[XAAScreenIndex].ptr;
+ (XAAScreenPtr)dixLookupPrivate(&pScreen->devPrivates, XAAScreenKey);
if(!enable) {
if((infoRec->Flags & OFFSCREEN_PIXMAPS) && (infoRec->OffscreenPixmaps))
diff --git a/hw/xfree86/xaa/xaaLineMisc.c b/hw/xfree86/xaa/xaaLineMisc.c
index 537b08b97..cefb59a8e 100644
--- a/hw/xfree86/xaa/xaaLineMisc.c
+++ b/hw/xfree86/xaa/xaaLineMisc.c
@@ -64,7 +64,8 @@ void
XAAComputeDash(GCPtr pGC)
{
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
- XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ XAAGetGCKey());
Bool EvenDash = (pGC->numInDashList & 0x01) ? FALSE : TRUE;
int PatternLength = 0;
unsigned char* DashPtr = (unsigned char*)pGC->dash;
diff --git a/hw/xfree86/xaa/xaaOverlayDF.c b/hw/xfree86/xaa/xaaOverlayDF.c
index 5897e323b..77c9cb1c9 100644
--- a/hw/xfree86/xaa/xaaOverlayDF.c
+++ b/hw/xfree86/xaa/xaaOverlayDF.c
@@ -152,11 +152,10 @@ typedef struct {
int (*TiledFillChooser)(GCPtr);
} XAAOverlayRec, *XAAOverlayPtr;
-static int XAAOverlayIndex = -1;
-static unsigned long XAAOverlayGeneration = 0;
+static DevPrivateKey XAAOverlayKey = &XAAOverlayKey;
#define GET_OVERLAY_PRIV(pScreen) \
- ((XAAOverlayPtr)((pScreen)->devPrivates[XAAOverlayIndex].ptr))
+ (XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey)
#define SWITCH_DEPTH(d) \
if(pOverPriv->currentDepth != d) { \
@@ -174,18 +173,10 @@ XAAInitDualFramebufferOverlay(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
XAAOverlayPtr pOverPriv;
- if (XAAOverlayGeneration != serverGeneration) {
- if((XAAOverlayIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
-
- XAAOverlayGeneration = serverGeneration;
- }
-
-
if(!(pOverPriv = xalloc(sizeof(XAAOverlayRec))))
return FALSE;
- pScreen->devPrivates[XAAOverlayIndex].ptr = (pointer)pOverPriv;
+ dixSetPrivate(&pScreen->devPrivates, XAAOverlayKey, pOverPriv);
pOverPriv->pScrn = pScrn;
pOverPriv->callback = callback;
diff --git a/hw/xfree86/xaa/xaaStateChange.c b/hw/xfree86/xaa/xaaStateChange.c
index 711f7791f..39ad046c5 100644
--- a/hw/xfree86/xaa/xaaStateChange.c
+++ b/hw/xfree86/xaa/xaaStateChange.c
@@ -276,18 +276,17 @@ typedef struct _XAAStateWrapRec {
#endif
} XAAStateWrapRec, *XAAStateWrapPtr;
-static int XAAStateIndex = -1;
-static unsigned long XAAStateGeneration = 0;
+static DevPrivateKey XAAStateKey = &XAAStateKey;
/* Wrap functions start here */
#define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\
-(XAAStateWrapPtr)(pGC->pScreen->devPrivates[XAAStateIndex].ptr)
+(XAAStateWrapPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAStateKey)
#define GET_STATEPRIV_SCREEN(pScreen) XAAStateWrapPtr pStatePriv =\
-(XAAStateWrapPtr)(pScreen->devPrivates[XAAStateIndex].ptr)
+(XAAStateWrapPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAStateKey)
#define GET_STATEPRIV_PSCRN(pScrn) XAAStateWrapPtr pStatePriv =\
-(XAAStateWrapPtr)(pScrn->pScreen->devPrivates[XAAStateIndex].ptr)
+(XAAStateWrapPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAStateKey)
#define STATE_CHECK_SP(pStatePriv) {\
ScrnInfoPtr pScrn = pStatePriv->pScrn;\
@@ -1526,12 +1525,8 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
XAAStateWrapPtr pStatePriv;
int i = 0;
- if (XAAStateGeneration != serverGeneration) {
- if((XAAStateIndex = AllocateScreenPrivateIndex()) < 0) return FALSE;
- XAAStateGeneration = serverGeneration;
- }
if(!(pStatePriv = xalloc(sizeof(XAAStateWrapRec)))) return FALSE;
- pScreen->devPrivates[XAAStateIndex].ptr = (pointer)pStatePriv;
+ dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv);
pStatePriv->RestoreAccelState = infoRec->RestoreAccelState;
pStatePriv->pScrn = pScrn;
diff --git a/hw/xfree86/xaa/xaaWrapper.c b/hw/xfree86/xaa/xaaWrapper.c
index 6d8107b61..642ef8c39 100644
--- a/hw/xfree86/xaa/xaaWrapper.c
+++ b/hw/xfree86/xaa/xaaWrapper.c
@@ -90,10 +90,8 @@ typedef struct {
int depth;
} xaaWrapperScrPrivRec, *xaaWrapperScrPrivPtr;
-#define xaaWrapperGetScrPriv(s) ((xaaWrapperScrPrivPtr)( \
- (xaaWrapperScrPrivateIndex != -1) \
- ? (s)->devPrivates[xaaWrapperScrPrivateIndex].ptr\
- : NULL))
+#define xaaWrapperGetScrPriv(s) ((xaaWrapperScrPrivPtr) \
+ dixLookupPrivate(&(s)->devPrivates, xaaWrapperScrPrivateKey))
#define xaaWrapperScrPriv(s) xaaWrapperScrPrivPtr pScrPriv = xaaWrapperGetScrPriv(s)
#define wrap(priv,real,mem,func) {\
@@ -131,13 +129,12 @@ typedef struct _xaaWrapperGCPriv {
} xaaWrapperGCPrivRec, *xaaWrapperGCPrivPtr;
#define xaaWrapperGetGCPriv(pGC) ((xaaWrapperGCPrivPtr) \
- (pGC)->devPrivates[xaaWrapperGCPrivateIndex].ptr)
+ dixLookupPrivate(&(pGC)->devPrivates, xaaWrapperGCPrivateKey))
#define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC)
-static int xaaWrapperScrPrivateIndex = -1;
-static int xaaWrapperGCPrivateIndex = -1;
-static int xaaWrapperGeneration = -1;
+static DevPrivateKey xaaWrapperScrPrivateKey = &xaaWrapperScrPrivateKey;
+static DevPrivateKey xaaWrapperGCPrivateKey = &xaaWrapperGCPrivateKey;
static Bool
xaaWrapperCreateScreenResources(ScreenPtr pScreen)
@@ -305,18 +302,8 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f
#ifdef RENDER
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
- if (xaaWrapperGeneration != serverGeneration) {
- xaaWrapperScrPrivateIndex = AllocateScreenPrivateIndex ();
- if (xaaWrapperScrPrivateIndex == -1)
- return FALSE;
- xaaWrapperGCPrivateIndex = AllocateGCPrivateIndex ();
- if (xaaWrapperGCPrivateIndex == -1)
- return FALSE;
- xaaWrapperGeneration = serverGeneration;
- }
- if (!AllocateGCPrivate (pScreen, xaaWrapperGCPrivateIndex,
- sizeof (xaaWrapperGCPrivRec)))
+ if (!dixRequestPrivate(xaaWrapperGCPrivateKey, sizeof(xaaWrapperGCPrivRec)))
return FALSE;
pScrPriv = (xaaWrapperScrPrivPtr) xalloc (sizeof (xaaWrapperScrPrivRec));
@@ -370,7 +357,7 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f
}
#endif
pScrPriv->depth = depth;
- pScreen->devPrivates[xaaWrapperScrPrivateIndex].ptr = (pointer) pScrPriv;
+ dixSetPrivate(&pScreen->devPrivates, xaaWrapperScrPrivateKey, pScrPriv);
*func = XAASync;
@@ -521,8 +508,8 @@ xaaWrapperGlyphs (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
void
XAASync(ScreenPtr pScreen)
{
- XAAScreenPtr pScreenPriv =
- (XAAScreenPtr) pScreen->devPrivates[XAAGetScreenIndex()].ptr;
+ XAAScreenPtr pScreenPriv = (XAAScreenPtr)
+ dixLookupPrivate(&pScreen->devPrivates, XAAGetScreenKey());
XAAInfoRecPtr infoRec = pScreenPriv->AccelInfoRec;
if(infoRec->NeedToSync) {
diff --git a/hw/xfree86/xaa/xaalocal.h b/hw/xfree86/xaa/xaalocal.h
index 3ddea241c..1e536c1fa 100644
--- a/hw/xfree86/xaa/xaalocal.h
+++ b/hw/xfree86/xaa/xaalocal.h
@@ -1639,9 +1639,9 @@ XAAGetPixelFromRGBA (
extern GCOps XAAFallbackOps;
extern GCOps *XAAGetFallbackOps(void);
extern GCFuncs XAAGCFuncs;
-extern int XAAGetScreenIndex(void);
-extern int XAAGetGCIndex(void);
-extern int XAAGetPixmapIndex(void);
+extern DevPrivateKey XAAGetScreenKey(void);
+extern DevPrivateKey XAAGetGCKey(void);
+extern DevPrivateKey XAAGetPixmapKey(void);
extern unsigned int XAAShiftMasks[32];
@@ -1650,28 +1650,28 @@ extern unsigned int byte_expand3[256], byte_reversed_expand3[256];
CARD32 XAAReverseBitOrder(CARD32 data);
#define GET_XAASCREENPTR_FROM_SCREEN(pScreen)\
- (pScreen)->devPrivates[XAAGetScreenIndex()].ptr
+ dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey())
#define GET_XAASCREENPTR_FROM_GC(pGC)\
- (pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr
+ dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey())
#define GET_XAASCREENPTR_FROM_DRAWABLE(pDraw)\
- (pDraw)->pScreen->devPrivates[XAAGetScreenIndex()].ptr
+ dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey())
#define GET_XAAINFORECPTR_FROM_SCREEN(pScreen)\
- ((XAAScreenPtr)((pScreen)->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec
+((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->AccelInfoRec
#define GET_XAAINFORECPTR_FROM_GC(pGC)\
-((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec
+((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec
#define GET_XAAINFORECPTR_FROM_DRAWABLE(pDraw)\
-((XAAScreenPtr)((pDraw)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec
+((XAAScreenPtr)dixLookupPrivate(&(pDraw)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec
#define GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn)\
-((XAAScreenPtr)((pScrn)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec
+((XAAScreenPtr)dixLookupPrivate(&(pScrn)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec
#define XAA_GET_PIXMAP_PRIVATE(pix)\
- (XAAPixmapPtr)((pix)->devPrivates[XAAGetPixmapIndex()].ptr)
+ (XAAPixmapPtr)dixLookupPrivate(&(pix)->devPrivates, XAAGetPixmapKey())
#define CHECK_RGB_EQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff))
diff --git a/hw/xfree86/xaa/xaawrap.h b/hw/xfree86/xaa/xaawrap.h
index 32c17a60c..38c97d70b 100644
--- a/hw/xfree86/xaa/xaawrap.h
+++ b/hw/xfree86/xaa/xaawrap.h
@@ -1,14 +1,14 @@
#define XAA_SCREEN_PROLOGUE(pScreen, field)\
((pScreen)->field = \
- ((XAAScreenPtr) (pScreen)->devPrivates[XAAGetScreenIndex()].ptr)->field)
+ ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field)
#define XAA_SCREEN_EPILOGUE(pScreen, field, wrapper)\
((pScreen)->field = wrapper)
#define XAA_GC_FUNC_PROLOGUE(pGC)\
- XAAGCPtr pGCPriv = (XAAGCPtr) (pGC)->devPrivates[XAAGetGCIndex()].ptr;\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
(pGC)->funcs = pGCPriv->wrapFuncs;\
if(pGCPriv->flags)\
(pGC)->ops = pGCPriv->wrapOps
@@ -24,13 +24,13 @@
#define XAA_GC_OP_PROLOGUE(pGC)\
- XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
GCFuncs *oldFuncs = pGC->funcs;\
pGC->funcs = pGCPriv->wrapFuncs;\
pGC->ops = pGCPriv->wrapOps
#define XAA_GC_OP_PROLOGUE_WITH_RETURN(pGC)\
- XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
GCFuncs *oldFuncs = pGC->funcs;\
if(!REGION_NUM_RECTS(pGC->pCompositeClip)) return; \
pGC->funcs = pGCPriv->wrapFuncs;\
@@ -44,7 +44,7 @@
#define XAA_PIXMAP_OP_PROLOGUE(pGC, pDraw)\
- XAAGCPtr pGCPriv = (XAAGCPtr)(pGC->devPrivates[XAAGetGCIndex()].ptr);\
+ XAAGCPtr pGCPriv = (XAAGCPtr)dixLookupPrivate(&(pGC)->devPrivates, XAAGetGCKey()); \
XAAPixmapPtr pixPriv = XAA_GET_PIXMAP_PRIVATE((PixmapPtr)(pDraw));\
GCFuncs *oldFuncs = pGC->funcs;\
pGC->funcs = pGCPriv->wrapFuncs;\
@@ -64,7 +64,7 @@
#ifdef RENDER
#define XAA_RENDER_PROLOGUE(pScreen,field)\
(GetPictureScreen(pScreen)->field = \
- ((XAAScreenPtr) (pScreen)->devPrivates[XAAGetScreenIndex()].ptr)->field)
+ ((XAAScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAGetScreenKey()))->field)
#define XAA_RENDER_EPILOGUE(pScreen, field, wrapper)\
(GetPictureScreen(pScreen)->field = wrapper)
@@ -74,7 +74,7 @@
#define SYNC_CHECK(pGC) {\
XAAInfoRecPtr infoRec =\
-((XAAScreenPtr)((pGC)->pScreen->devPrivates[XAAGetScreenIndex()].ptr))->AccelInfoRec;\
+((XAAScreenPtr)dixLookupPrivate(&(pGC)->pScreen->devPrivates, XAAGetScreenKey()))->AccelInfoRec; \
if(infoRec->NeedToSync) {\
(*infoRec->Sync)(infoRec->pScrn);\
infoRec->NeedToSync = FALSE;\
diff --git a/hw/xfree86/xf4bpp/mfbfillarc.c b/hw/xfree86/xf4bpp/mfbfillarc.c
index d5b5372f5..89aeadd2b 100644
--- a/hw/xfree86/xf4bpp/mfbfillarc.c
+++ b/hw/xfree86/xf4bpp/mfbfillarc.c
@@ -253,7 +253,8 @@ xf4bppPolyFillArcSolid
mfbPrivGC *priv;
int rop;
- priv = (mfbPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr;
+ priv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
rop = priv->rop;
if ((rop == RROP_NOP) || !(pGC->planemask & 1))
#else
diff --git a/hw/xfree86/xf4bpp/mfbimggblt.c b/hw/xfree86/xf4bpp/mfbimggblt.c
index bf53f4ce9..711a16ee5 100644
--- a/hw/xfree86/xf4bpp/mfbimggblt.c
+++ b/hw/xfree86/xf4bpp/mfbimggblt.c
@@ -149,7 +149,8 @@ xf4bppImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
- pPrivGC = pGC->devPrivates[mfbGetGCPrivateIndex()].ptr;
+ pPrivGC = (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
oldfillStyle = pPrivGC->colorRrop.fillStyle; /* GJA */
oldfg = pPrivGC->colorRrop.fgPixel; /* GJA */
oldalu = pPrivGC->colorRrop.alu; /* GJA */
diff --git a/hw/xfree86/xf4bpp/mfbzerarc.c b/hw/xfree86/xf4bpp/mfbzerarc.c
index c7a8c4d56..61fc7b184 100644
--- a/hw/xfree86/xf4bpp/mfbzerarc.c
+++ b/hw/xfree86/xf4bpp/mfbzerarc.c
@@ -108,7 +108,8 @@ v16ZeroArcSS
int pmask;
register int *paddr;
- if (((mfbPrivGC *)(pGC->devPrivates[mfbGetGCPrivateIndex()].ptr))->rop ==
+ if (((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->rop ==
RROP_BLACK)
pixel = 0;
else
diff --git a/hw/xfree86/xf4bpp/ppcArea.c b/hw/xfree86/xf4bpp/ppcArea.c
index e95696260..df7856a35 100644
--- a/hw/xfree86/xf4bpp/ppcArea.c
+++ b/hw/xfree86/xf4bpp/ppcArea.c
@@ -49,7 +49,7 @@ int alu ;
unsigned long int fg, bg, pm ;
int xSrc, ySrc ;
PixmapPtr pPixmap ;
-ppcPrivGC *pPrivGC = pGC->devPrivates[mfbGetGCPrivateIndex()].ptr;
+ppcPrivGC *pPrivGC = dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey());
TRACE( ( "xf4bppFillArea(0x%x,%d,0x%x,0x%x)\n", pWin, nboxes, pBox, pGC ) ) ;
diff --git a/hw/xfree86/xf4bpp/ppcGC.c b/hw/xfree86/xf4bpp/ppcGC.c
index b59dab312..ca3c5e984 100644
--- a/hw/xfree86/xf4bpp/ppcGC.c
+++ b/hw/xfree86/xf4bpp/ppcGC.c
@@ -183,7 +183,7 @@ register GCPtr pGC ;
* a pointer to a ppcPrivGC in its slot.
*/
*pPriv = vgaPrototypeGCPriv;
- (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr) = (pointer) pPriv;
+ dixSetPrivate(&pGC->devPrivates, mfbGetGCPrivateKey(), pPriv);
/* Set the vgaGCOps */
*pOps = vgaGCOps;
@@ -209,7 +209,7 @@ xf4bppDestroyGC( pGC )
if ( pGC->freeCompClip && pGC->pCompositeClip )
REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
if(pGC->ops->devPrivate.val) xfree( pGC->ops );
- xfree( pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ;
+ xfree(dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()));
return ;
}
@@ -220,7 +220,7 @@ ppcChangePixmapGC
register Mask changes
)
{
-register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ;
+register ppcPrivGCPtr devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey());
register unsigned long int idx ; /* used for stepping through bitfields */
#define LOWBIT( x ) ( x & - x ) /* Two's complement */
@@ -298,8 +298,8 @@ xf4bppValidateGC( pGC, changes, pDrawable )
register ppcPrivGCPtr devPriv ;
WindowPtr pWin ;
- devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ;
-
+ devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
if ( pDrawable->type != devPriv->lastDrawableType ) {
devPriv->lastDrawableType = pDrawable->type ;
xf4bppChangeGCtype( pGC, devPriv ) ;
diff --git a/hw/xfree86/xf4bpp/ppcIO.c b/hw/xfree86/xf4bpp/ppcIO.c
index 8d726e758..bd20218d3 100644
--- a/hw/xfree86/xf4bpp/ppcIO.c
+++ b/hw/xfree86/xf4bpp/ppcIO.c
@@ -219,7 +219,7 @@ xf4bppScreenInit( pScreen, pbits, virtx, virty, dpix, dpiy, width )
pScreen-> ResolveColor = xf4bppResolveColor;
mfbFillInScreen(pScreen);
- if (!mfbAllocatePrivates(pScreen, (int*)NULL, (int*)NULL))
+ if (!mfbAllocatePrivates(pScreen, NULL, NULL))
return FALSE;
if (!miScreenInit(pScreen, pbits, virtx, virty, dpix, dpiy, width,
diff --git a/hw/xfree86/xf4bpp/ppcPixFS.c b/hw/xfree86/xf4bpp/ppcPixFS.c
index f24168bb0..91b753255 100644
--- a/hw/xfree86/xf4bpp/ppcPixFS.c
+++ b/hw/xfree86/xf4bpp/ppcPixFS.c
@@ -124,7 +124,7 @@ xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()))->colorRrop.alu ) == GXnoop )
return ;
n = nInit * miFindMaxBand(pGC->pCompositeClip) ;
@@ -142,8 +142,8 @@ xf4bppSolidPixmapFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit,
ppt, pwidth, fSorted ) ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
- fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ;
npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
for ( ; n-- ; ppt++, pwidth++ ) {
@@ -258,14 +258,14 @@ int fSorted ;
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
pptFree, pwidth, ppt, fSorted ) ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
- fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ;
pTile = pGC->stipple ;
tlwidth = pTile->devKind ;
@@ -356,15 +356,15 @@ int fSorted ;
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
pptFree, pwidth, ppt, fSorted ) ;
- fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
- bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.bgPixel ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ;
+ bg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.bgPixel ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
pTile = pGC->stipple ;
@@ -459,14 +459,14 @@ int fSorted ;
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
pptFree, pwidth, ppt, fSorted ) ;
/* the following code is for 8 bits per pixel addressable memory only */
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
npm = ( ~ pm ) & ( ( 1 << pDrawable->depth ) - 1 ) ;
pTile = pGC->tile.pixmap ;
tileWidth = pTile->drawable.width ;
diff --git a/hw/xfree86/xf4bpp/ppcPixmap.c b/hw/xfree86/xf4bpp/ppcPixmap.c
index ec181cfaf..2079e2ee6 100644
--- a/hw/xfree86/xf4bpp/ppcPixmap.c
+++ b/hw/xfree86/xf4bpp/ppcPixmap.c
@@ -137,6 +137,7 @@ xf4bppCopyPixmap(pSrc)
pDst = xalloc(sizeof(PixmapRec) + size);
if (!pDst)
return NullPixmap;
+ pDst->devPrivates = NULL;
pDst->drawable = pSrc->drawable;
pDst->drawable.id = 0;
pDst->drawable.serialNumber = NEXT_SERIAL_NUMBER;
diff --git a/hw/xfree86/xf4bpp/ppcPntWin.c b/hw/xfree86/xf4bpp/ppcPntWin.c
index 5d7a07e12..482b34b5d 100644
--- a/hw/xfree86/xf4bpp/ppcPntWin.c
+++ b/hw/xfree86/xf4bpp/ppcPntWin.c
@@ -100,7 +100,7 @@ xf4bppPaintWindow(pWin, pRegion, what)
{
register mfbPrivWin *pPrivWin;
- pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbGetWindowPrivateIndex()].ptr);
+ pPrivWin = (mfbPrivWin *)dixLookupPrivate(&pWin->devPrivates, mfbGetWindowPrivateKey());
TRACE(("xf4bppPaintWindow( pWin= 0x%x, pRegion= 0x%x, what= %d )\n",
pWin,pRegion,what));
diff --git a/hw/xfree86/xf4bpp/ppcPolyPnt.c b/hw/xfree86/xf4bpp/ppcPolyPnt.c
index 1d6905563..c61fd6d26 100644
--- a/hw/xfree86/xf4bpp/ppcPolyPnt.c
+++ b/hw/xfree86/xf4bpp/ppcPolyPnt.c
@@ -102,7 +102,7 @@ if ( pDrawable->type == DRAWABLE_PIXMAP ) {
return ;
}
-devPriv = (ppcPrivGC *) ( pGC->devPrivates[mfbGetGCPrivateIndex()].ptr ) ;
+devPriv = (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey());
if ( ( alu = devPriv->colorRrop.alu ) == GXnoop )
return ;
diff --git a/hw/xfree86/xf4bpp/ppcWinFS.c b/hw/xfree86/xf4bpp/ppcWinFS.c
index e19ce0d40..982bf424c 100644
--- a/hw/xfree86/xf4bpp/ppcWinFS.c
+++ b/hw/xfree86/xf4bpp/ppcWinFS.c
@@ -96,7 +96,7 @@ xf4bppSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
n = nInit * miFindMaxBand( pGC->pCompositeClip ) ;
@@ -114,8 +114,8 @@ xf4bppSolidWindowFS( pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted )
n = miClipSpans( pGC->pCompositeClip, pptInit, pwidthInit, nInit,
ppt, pwidth, fSorted ) ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
- fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ;
for ( ; n-- ; ppt++, pwidth++ )
if ( *pwidth )
@@ -163,14 +163,14 @@ int fSorted ;
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
pptFree, pwidth, ppt, fSorted ) ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
- fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ;
xSrc = pGC->patOrg.x + pDrawable->x ;
ySrc = pGC->patOrg.y + pDrawable->y ;
@@ -215,15 +215,15 @@ int fSorted ;
return ;
}
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
pptFree, pwidth, ppt, fSorted ) ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
- fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.fgPixel ;
- bg = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.bgPixel ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
+ fg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.fgPixel ;
+ bg = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.bgPixel ;
xSrc = pGC->patOrg.x + pDrawable->x ;
ySrc = pGC->patOrg.y + pDrawable->y ;
@@ -260,7 +260,7 @@ int fSorted ;
TRACE( ( "xf4bppTileWindowFS(pDrawable=0x%x,pGC=0x%x,nInit=%d,pptInit=0x%x,pwidthInit=0x%x,fSorted=%d)\n",
pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted ) ) ;
- if ( ( alu = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.alu ) == GXnoop )
+ if ( ( alu = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.alu ) == GXnoop )
return ;
SETSPANPTRS( nInit, n, pwidthInit, pwidthFree, pptInit,
@@ -268,7 +268,7 @@ int fSorted ;
xSrc = pGC->patOrg.x + pDrawable->x ;
ySrc = pGC->patOrg.y + pDrawable->y ;
- pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGetGCPrivateIndex()].ptr )->colorRrop.planemask ;
+ pm = ( (ppcPrivGC *)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey()) )->colorRrop.planemask ;
for ( ; n-- ; ppt++, pwidth++ )
xf4bppTileRect( (WindowPtr)pDrawable, pGC->tile.pixmap, alu, pm,
diff --git a/hw/xfree86/xf4bpp/ppcWindow.c b/hw/xfree86/xf4bpp/ppcWindow.c
index 01768d9ff..055466738 100644
--- a/hw/xfree86/xf4bpp/ppcWindow.c
+++ b/hw/xfree86/xf4bpp/ppcWindow.c
@@ -218,7 +218,7 @@ register WindowPtr pWin ;
TRACE(("xf4bppCreateWindowForXYhardware (pWin= 0x%x)\n", pWin));
- pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbGetWindowPrivateIndex()].ptr);
+ pPrivWin = (mfbPrivWin *)dixLookupPrivate(&pWin->devPrivates, mfbGetWindowPrivateKey());
pPrivWin->pRotatedBorder = NullPixmap;
pPrivWin->pRotatedBackground = NullPixmap;
pPrivWin->fastBackground = 0;
diff --git a/hw/xfree86/xf4bpp/vgaGC.c b/hw/xfree86/xf4bpp/vgaGC.c
index 5a8604090..6495e5638 100644
--- a/hw/xfree86/xf4bpp/vgaGC.c
+++ b/hw/xfree86/xf4bpp/vgaGC.c
@@ -107,7 +107,7 @@ xf4bppChangeWindowGC( pGC, changes )
register GC *pGC ;
register Mask changes ;
{
-register ppcPrivGCPtr devPriv = (ppcPrivGCPtr) (pGC->devPrivates[mfbGetGCPrivateIndex()].ptr) ;
+register ppcPrivGCPtr devPriv = (ppcPrivGCPtr)dixLookupPrivate(&pGC->devPrivates, mfbGetGCPrivateKey());
register unsigned long int idx ; /* used for stepping through bitfields */
#define LOWBIT( x ) ( x & - x ) /* Two's complement */
diff --git a/hw/xfree86/xf8_32bpp/cfb8_32.h b/hw/xfree86/xf8_32bpp/cfb8_32.h
index 31028a30b..281e5f2e0 100644
--- a/hw/xfree86/xf8_32bpp/cfb8_32.h
+++ b/hw/xfree86/xf8_32bpp/cfb8_32.h
@@ -22,10 +22,8 @@ typedef struct {
} cfb8_32ScreenRec, *cfb8_32ScreenPtr;
-extern int cfb8_32GCPrivateIndex; /* XXX */
-extern int cfb8_32GetGCPrivateIndex(void);
-extern int cfb8_32ScreenPrivateIndex; /* XXX */
-extern int cfb8_32GetScreenPrivateIndex(void);
+extern DevPrivateKey cfb8_32GetGCPrivateKey(void);
+extern DevPrivateKey cfb8_32GetScreenPrivateKey(void);
RegionPtr
cfb8_32CopyArea(
@@ -198,11 +196,11 @@ cfb8_32ChangeWindowAttributes(
);
-#define CFB8_32_GET_GC_PRIVATE(pGC)\
- (cfb8_32GCPtr)((pGC)->devPrivates[cfb8_32GetGCPrivateIndex()].ptr)
+#define CFB8_32_GET_GC_PRIVATE(pGC) ((cfb8_32GCPtr) \
+ dixLookupPrivate(&(pGC)->devPrivates, cfb8_32GetGCPrivateKey()))
-#define CFB8_32_GET_SCREEN_PRIVATE(pScreen)\
- (cfb8_32ScreenPtr)((pScreen)->devPrivates[cfb8_32GetScreenPrivateIndex()].ptr)
+#define CFB8_32_GET_SCREEN_PRIVATE(pScreen) ((cfb8_32ScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, cfb8_32GetScreenPrivateKey()))
Bool xf86Overlay8Plus32Init (ScreenPtr pScreen);
diff --git a/hw/xfree86/xf8_32bpp/cfbscrinit.c b/hw/xfree86/xf8_32bpp/cfbscrinit.c
index 29dc6691f..fffd8d392 100644
--- a/hw/xfree86/xf8_32bpp/cfbscrinit.c
+++ b/hw/xfree86/xf8_32bpp/cfbscrinit.c
@@ -31,42 +31,41 @@
/* CAUTION: We require that cfb8 and cfb32 were NOT
compiled with CFB_NEED_SCREEN_PRIVATE */
-int cfb8_32GCPrivateIndex;
-int cfb8_32GetGCPrivateIndex(void) { return cfb8_32GCPrivateIndex; }
-int cfb8_32ScreenPrivateIndex;
-int cfb8_32GetScreenPrivateIndex(void) { return cfb8_32ScreenPrivateIndex; }
-static unsigned long cfb8_32Generation = 0;
+static DevPrivateKey cfb8_32GCPrivateKey = &cfb8_32GCPrivateKey;
+DevPrivateKey cfb8_32GetGCPrivateKey(void)
+{
+ return cfb8_32GCPrivateKey;
+}
+
+static DevPrivateKey cfb8_32ScreenPrivateKey = &cfb8_32ScreenPrivateKey;
+DevPrivateKey cfb8_32GetScreenPrivateKey(void)
+{
+ return cfb8_32ScreenPrivateKey;
+}
static Bool
cfb8_32AllocatePrivates(ScreenPtr pScreen)
{
cfb8_32ScreenPtr pScreenPriv;
- if(cfb8_32Generation != serverGeneration) {
- if(((cfb8_32GCPrivateIndex = AllocateGCPrivateIndex()) < 0) ||
- ((cfb8_32ScreenPrivateIndex = AllocateScreenPrivateIndex()) < 0))
- return FALSE;
- cfb8_32Generation = serverGeneration;
- }
-
if (!(pScreenPriv = xalloc(sizeof(cfb8_32ScreenRec))))
return FALSE;
- pScreen->devPrivates[cfb8_32ScreenPrivateIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, cfb8_32ScreenPrivateKey, pScreenPriv);
/* All cfb will have the same GC and Window private indicies */
- if(!mfbAllocatePrivates(pScreen,&cfbWindowPrivateIndex, &cfbGCPrivateIndex))
+ if(!mfbAllocatePrivates(pScreen, &cfbWindowPrivateKey, &cfbGCPrivateKey))
return FALSE;
/* The cfb indicies are the mfb indicies. Reallocating them resizes them */
- if(!AllocateWindowPrivate(pScreen,cfbWindowPrivateIndex,sizeof(cfbPrivWin)))
+ if(!dixRequestPrivate(cfbWindowPrivateKey, sizeof(cfbPrivWin)))
return FALSE;
- if(!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
+ if(!dixRequestPrivate(cfbGCPrivateKey, sizeof(cfbPrivGC)))
return FALSE;
- if(!AllocateGCPrivate(pScreen, cfb8_32GCPrivateIndex, sizeof(cfb8_32GCRec)))
+ if(!dixRequestPrivate(cfb8_32GCPrivateKey, sizeof(cfb8_32GCRec)))
return FALSE;
return TRUE;
@@ -166,7 +165,7 @@ cfb8_32CloseScreen (int i, ScreenPtr pScreen)
xfree(pScreenPriv->visualData);
xfree((pointer) pScreenPriv);
- pScreen->devPrivates[cfb8_32ScreenPrivateIndex].ptr = NULL;
+ dixSetPrivate(&pScreen->devPrivates, cfb8_32ScreenPrivateKey, NULL);
return(cfb32CloseScreen(i, pScreen));
}
diff --git a/hw/xfree86/xf8_32bpp/xf86overlay.c b/hw/xfree86/xf8_32bpp/xf86overlay.c
index c5585ca6d..bab014b8c 100644
--- a/hw/xfree86/xf8_32bpp/xf86overlay.c
+++ b/hw/xfree86/xf8_32bpp/xf86overlay.c
@@ -180,23 +180,22 @@ typedef struct {
} OverlayPixmapRec, *OverlayPixmapPtr;
-static int OverlayScreenIndex = -1;
-static int OverlayGCIndex = -1;
-static int OverlayPixmapIndex = -1;
-static unsigned long OverlayGeneration = 0;
+static DevPrivateKey OverlayScreenKey = &OverlayScreenKey;
+static DevPrivateKey OverlayGCKey = &OverlayGCKey;
+static DevPrivateKey OverlayPixmapKey = &OverlayPixmapKey;
/** Macros **/
#define TILE_EXISTS(pGC) (!(pGC)->tileIsPixel && (pGC)->tile.pixmap)
-#define OVERLAY_GET_PIXMAP_PRIVATE(pPix) \
- (OverlayPixmapPtr)((pPix)->devPrivates[OverlayPixmapIndex].ptr)
+#define OVERLAY_GET_PIXMAP_PRIVATE(pPix) ((OverlayPixmapPtr) \
+ dixLookupPrivate(&(pPix)->devPrivates, OverlayPixmapKey))
-#define OVERLAY_GET_SCREEN_PRIVATE(pScreen) \
- (OverlayScreenPtr)((pScreen)->devPrivates[OverlayScreenIndex].ptr)
+#define OVERLAY_GET_SCREEN_PRIVATE(pScreen) ((OverlayScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, OverlayScreenKey))
-#define OVERLAY_GET_GC_PRIVATE(pGC) \
- (OverlayGCPtr)((pGC)->devPrivates[OverlayGCIndex].ptr)
+#define OVERLAY_GET_GC_PRIVATE(pGC) ((OverlayGCPtr) \
+ dixLookupPrivate(&(pGC)->devPrivates, OverlayGCKey))
#define OVERLAY_GC_FUNC_PROLOGUE(pGC)\
OverlayGCPtr pGCPriv = OVERLAY_GET_GC_PRIVATE(pGC);\
@@ -258,26 +257,16 @@ xf86Overlay8Plus32Init (ScreenPtr pScreen)
{
OverlayScreenPtr pScreenPriv;
- if(OverlayGeneration != serverGeneration) {
- if(((OverlayScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((OverlayGCIndex = AllocateGCPrivateIndex()) < 0) ||
- ((OverlayPixmapIndex = AllocatePixmapPrivateIndex()) < 0))
- return FALSE;
-
- OverlayGeneration = serverGeneration;
- }
-
- if (!AllocateGCPrivate(pScreen, OverlayGCIndex, sizeof(OverlayGCRec)))
+ if (!dixRequestPrivate(OverlayGCKey, sizeof(OverlayGCRec)))
return FALSE;
- if (!AllocatePixmapPrivate(pScreen, OverlayPixmapIndex,
- sizeof(OverlayPixmapRec)))
+ if (!dixRequestPrivate(OverlayPixmapKey, sizeof(OverlayPixmapRec)))
return FALSE;
if (!(pScreenPriv = xalloc(sizeof(OverlayScreenRec))))
return FALSE;
- pScreen->devPrivates[OverlayScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, OverlayScreenKey, pScreenPriv);
pScreenPriv->CreateGC = pScreen->CreateGC;
pScreenPriv->CloseScreen = pScreen->CloseScreen;
diff --git a/hw/xgl/egl/xegl.c b/hw/xgl/egl/xegl.c
index c671dbe7c..1cf615bb6 100644
--- a/hw/xgl/egl/xegl.c
+++ b/hw/xgl/egl/xegl.c
@@ -42,14 +42,13 @@
#define XEGL_DEFAULT_SCREEN_WIDTH 800
#define XEGL_DEFAULT_SCREEN_HEIGHT 600
-int xeglScreenGeneration = -1;
-int xeglScreenPrivateIndex;
+DevPrivateKey xeglScreenPrivateKey = &xeglScreenPrivateKey;
-#define XEGL_GET_SCREEN_PRIV(pScreen) \
- ((xeglScreenPtr) (pScreen)->devPrivates[xeglScreenPrivateIndex].ptr)
+#define XEGL_GET_SCREEN_PRIV(pScreen) ((xeglScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, xeglScreenPrivateKey))
-#define XEGL_SET_SCREEN_PRIV(pScreen, v) \
- ((pScreen)->devPrivates[xeglScreenPrivateIndex].ptr = (pointer) v)
+#define XEGL_SET_SCREEN_PRIV(pScreen, v) \
+ dixSetPrivate(&(pScreen)->devPrivates, xeglScreenPrivateKey, v)
#define XEGL_SCREEN_PRIV(pScreen) \
xeglScreenPtr pScreenPriv = XEGL_GET_SCREEN_PRIV (pScreen)
@@ -66,15 +65,6 @@ xeglAllocatePrivates (ScreenPtr pScreen)
{
xeglScreenPtr pScreenPriv;
- if (xeglScreenGeneration != serverGeneration)
- {
- xeglScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (xeglScreenPrivateIndex < 0)
- return FALSE;
-
- xeglScreenGeneration = serverGeneration;
- }
-
pScreenPriv = xalloc (sizeof (xeglScreenRec));
if (!pScreenPriv)
return FALSE;
diff --git a/hw/xgl/egl/xegl.h b/hw/xgl/egl/xegl.h
index be9b48c9c..0a07397bf 100644
--- a/hw/xgl/egl/xegl.h
+++ b/hw/xgl/egl/xegl.h
@@ -109,7 +109,7 @@ extern KdMouseInfo *kdMouseInfo;
extern KdOsFuncs *kdOsFuncs;
extern Bool kdDontZap;
extern Bool kdDisableZaphod;
-extern int xeglScreenPrivateIndex;
+extern DevPrivateKey xeglScreenPrivateKey;
extern KdMouseFuncs LinuxEvdevMouseFuncs;
extern KdKeyboardFuncs LinuxEvdevKeyboardFuncs;
@@ -117,8 +117,8 @@ extern KdKeyboardFuncs LinuxEvdevKeyboardFuncs;
(RR_Rotate_0 | RR_Rotate_90 | RR_Rotate_180 | RR_Rotate_270)
#define RR_Reflect_All (RR_Reflect_X | RR_Reflect_Y)
-#define KdGetScreenPriv(pScreen) \
- ((xeglScreenPtr) ((pScreen)->devPrivates[xeglScreenPrivateIndex].ptr))
+#define KdGetScreenPriv(pScreen) ((xeglScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, xeglScreenPrivateKey))
#define KdScreenPriv(pScreen) \
xeglScreenPtr pScreenPriv = KdGetScreenPriv (pScreen)
diff --git a/hw/xgl/glx/xglx.c b/hw/xgl/glx/xglx.c
index 92974f0d4..657afc075 100644
--- a/hw/xgl/glx/xglx.c
+++ b/hw/xgl/glx/xglx.c
@@ -105,14 +105,13 @@ typedef struct _xglxScreen {
CloseScreenProcPtr CloseScreen;
} xglxScreenRec, *xglxScreenPtr;
-int xglxScreenGeneration = -1;
-int xglxScreenPrivateIndex;
+DevPrivateKey xglxScreenPrivateKey = &xglxScreenPrivateKey;
-#define XGLX_GET_SCREEN_PRIV(pScreen) \
- ((xglxScreenPtr) (pScreen)->devPrivates[xglxScreenPrivateIndex].ptr)
+#define XGLX_GET_SCREEN_PRIV(pScreen) ((xglxScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, xglxScreenPrivateKey))
-#define XGLX_SET_SCREEN_PRIV(pScreen, v) \
- ((pScreen)->devPrivates[xglxScreenPrivateIndex].ptr = (pointer) v)
+#define XGLX_SET_SCREEN_PRIV(pScreen, v) \
+ dixSetPrivate(&(pScreen)->devPrivates, xglxScreenPrivateKey, v)
#define XGLX_SCREEN_PRIV(pScreen) \
xglxScreenPtr pScreenPriv = XGLX_GET_SCREEN_PRIV (pScreen)
@@ -148,15 +147,6 @@ xglxAllocatePrivates (ScreenPtr pScreen)
{
xglxScreenPtr pScreenPriv;
- if (xglxScreenGeneration != serverGeneration)
- {
- xglxScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (xglxScreenPrivateIndex < 0)
- return FALSE;
-
- xglxScreenGeneration = serverGeneration;
- }
-
pScreenPriv = xalloc (sizeof (xglxScreenRec));
if (!pScreenPriv)
return FALSE;
diff --git a/hw/xgl/xgl.h b/hw/xgl/xgl.h
index 5710bbf5a..ea28ea11d 100644
--- a/hw/xgl/xgl.h
+++ b/hw/xgl/xgl.h
@@ -224,10 +224,11 @@ typedef struct _xglGlyph {
xglAreaPtr pArea;
} xglGlyphRec, *xglGlyphPtr;
-extern int xglGlyphPrivateIndex;
+extern DevPrivateKey xglGlyphPrivateKey;
#define XGL_GET_GLYPH_PRIV(pScreen, pGlyph) ((xglGlyphPtr) \
- (GetGlyphPrivatesForScreen (pGlyph, pScreen))[xglGlyphPrivateIndex].ptr)
+ dixLookupPrivate(GetGlyphPrivatesForScreen (pGlyph, pScreen), \
+ xglGlyphPrivateKey))
#define XGL_GLYPH_PRIV(pScreen, pGlyph) \
xglGlyphPtr pGlyphPriv = XGL_GET_GLYPH_PRIV (pScreen, pGlyph)
@@ -295,13 +296,13 @@ typedef struct _xglScreen {
#endif
} xglScreenRec, *xglScreenPtr;
-extern int xglScreenPrivateIndex;
+extern DevPrivateKey xglScreenPrivateKey;
-#define XGL_GET_SCREEN_PRIV(pScreen) \
- ((xglScreenPtr) (pScreen)->devPrivates[xglScreenPrivateIndex].ptr)
+#define XGL_GET_SCREEN_PRIV(pScreen) ((xglScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, xglScreenPrivateKey))
-#define XGL_SET_SCREEN_PRIV(pScreen, v) \
- ((pScreen)->devPrivates[xglScreenPrivateIndex].ptr = (pointer) v)
+#define XGL_SET_SCREEN_PRIV(pScreen, v) \
+ dixSetPrivate(&(pScreen)->devPrivates, xglScreenPrivateKey, v)
#define XGL_SCREEN_PRIV(pScreen) \
xglScreenPtr pScreenPriv = XGL_GET_SCREEN_PRIV (pScreen)
@@ -336,10 +337,10 @@ typedef struct _xglGC {
GCOpsPtr ops;
} xglGCRec, *xglGCPtr;
-extern int xglGCPrivateIndex;
+extern DevPrivateKey xglGCPrivateKey;
-#define XGL_GET_GC_PRIV(pGC) \
- ((xglGCPtr) (pGC)->devPrivates[xglGCPrivateIndex].ptr)
+#define XGL_GET_GC_PRIV(pGC) ((xglGCPtr) \
+ dixLookupPrivate(&(pGC)->devPrivates, xglGCPrivateKey))
#define XGL_GC_PRIV(pGC) \
xglGCPtr pGCPriv = XGL_GET_GC_PRIV (pGC)
@@ -396,10 +397,10 @@ typedef struct _xglPixmap {
} xglPixmapRec, *xglPixmapPtr;
-extern int xglPixmapPrivateIndex;
+extern DevPrivateKey xglPixmapPrivateKey;
-#define XGL_GET_PIXMAP_PRIV(pPixmap) \
- ((xglPixmapPtr) (pPixmap)->devPrivates[xglPixmapPrivateIndex].ptr)
+#define XGL_GET_PIXMAP_PRIV(pPixmap) ((xglPixmapPtr) \
+ dixLookupPrivate(&(pPixmap)->devPrivates, xglPixmapPrivateKey))
#define XGL_PIXMAP_PRIV(pPixmap) \
xglPixmapPtr pPixmapPriv = XGL_GET_PIXMAP_PRIV (pPixmap)
@@ -411,10 +412,10 @@ typedef struct _xglWin {
PixmapPtr pPixmap;
} xglWinRec, *xglWinPtr;
-extern int xglWinPrivateIndex;
+extern DevPrivateKey xglWinPrivateKey;
-#define XGL_GET_WINDOW_PRIV(pWin) \
- ((xglWinPtr) (pWin)->devPrivates[xglWinPrivateIndex].ptr)
+#define XGL_GET_WINDOW_PRIV(pWin) ((xglWinPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, xglWinPrivateKey))
#define XGL_WINDOW_PRIV(pWin) \
xglWinPtr pWinPriv = XGL_GET_WINDOW_PRIV (pWin)
diff --git a/hw/xgl/xglpixmap.c b/hw/xgl/xglpixmap.c
index 166c33eb9..59ed00a72 100644
--- a/hw/xgl/xglpixmap.c
+++ b/hw/xgl/xglpixmap.c
@@ -310,7 +310,7 @@ xglDestroyPixmap (PixmapPtr pPixmap)
xglFiniPixmap (pPixmap);
- dixFreePrivates(*DEVPRIV_PTR(pPixmap));
+ dixFreePrivates(pPixmap->devPrivates);
xfree (pPixmap);
return TRUE;
diff --git a/hw/xgl/xglxv.c b/hw/xgl/xglxv.c
index aaa66c738..bfa16e3ca 100644
--- a/hw/xgl/xglxv.c
+++ b/hw/xgl/xglxv.c
@@ -35,11 +35,11 @@
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvproto.h>
-static unsigned int xglXvScreenIndex = 0;
+static DevPrivateKey xglXvScreenKey;
static unsigned long portResource = 0;
-#define XGL_GET_XV_SCREEN(pScreen) \
- ((XvScreenPtr) ((pScreen)->devPrivates[xglXvScreenIndex].ptr))
+#define XGL_GET_XV_SCREEN(pScreen) ((XvScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, xglXvScreenKey))
#define XGL_XV_SCREEN(pScreen) \
XvScreenPtr pXvScreen = XGL_GET_XV_SCREEN (pScreen)
@@ -591,7 +591,7 @@ xglXvScreenInit (ScreenPtr pScreen)
if (status != Success)
return FALSE;
- xglXvScreenIndex = XvGetScreenIndex ();
+ xglXvScreenKey = XvGetScreenKey ();
portResource = XvGetRTPort ();
pXvScreen = XGL_GET_XV_SCREEN (pScreen);
diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c
index a52ce1f35..06e6e0205 100644
--- a/hw/xnest/GC.c
+++ b/hw/xnest/GC.c
@@ -35,7 +35,7 @@ is" without express or implied warranty.
#include "XNFont.h"
#include "Color.h"
-int xnestGCPrivateIndex;
+DevPrivateKey xnestGCPrivateKey = &xnestGCPrivateKey;
static GCFuncs xnestFuncs = {
xnestValidateGC,
diff --git a/hw/xnest/Init.c b/hw/xnest/Init.c
index 5bf0300c6..324cf9696 100644
--- a/hw/xnest/Init.c
+++ b/hw/xnest/Init.c
@@ -74,8 +74,6 @@ InitOutput(ScreenInfo *screenInfo, int argc, char *argv[])
break;
}
- xnestWindowPrivateIndex = AllocateWindowPrivateIndex();
- xnestGCPrivateIndex = AllocateGCPrivateIndex();
xnestFontPrivateIndex = AllocateFontPrivateIndex();
if (!xnestNumScreens) xnestNumScreens = 1;
diff --git a/hw/xnest/Pixmap.c b/hw/xnest/Pixmap.c
index c4b8aa65e..c9c662af3 100644
--- a/hw/xnest/Pixmap.c
+++ b/hw/xnest/Pixmap.c
@@ -33,7 +33,7 @@ is" without express or implied warranty.
#include "Screen.h"
#include "XNPixmap.h"
-int xnestPixmapPrivateIndex;
+DevPrivateKey xnestPixmapPrivateKey = &xnestPixmapPrivateKey;
PixmapPtr
xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth)
@@ -56,8 +56,8 @@ xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth)
pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pPixmap->refcnt = 1;
pPixmap->devKind = PixmapBytePad(width, depth);
- pPixmap->devPrivates[xnestPixmapPrivateIndex].ptr =
- (pointer)((char *)pPixmap + pScreen->totalPixmapSize);
+ dixSetPrivate(&pPixmap->devPrivates, xnestPixmapPrivateKey,
+ (char *)pPixmap + pScreen->totalPixmapSize);
if (width && height)
xnestPixmapPriv(pPixmap)->pixmap =
XCreatePixmap(xnestDisplay,
@@ -75,7 +75,7 @@ xnestDestroyPixmap(PixmapPtr pPixmap)
if(--pPixmap->refcnt)
return TRUE;
XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
- dixFreePrivates(*DEVPRIV_PTR(pPixmap));
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return TRUE;
}
diff --git a/hw/xnest/Screen.c b/hw/xnest/Screen.c
index d08e48245..f91454928 100644
--- a/hw/xnest/Screen.c
+++ b/hw/xnest/Screen.c
@@ -49,8 +49,6 @@ Window xnestScreenSaverWindows[MAXSCREENS];
extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
#endif
-static int xnestScreenGeneration = -1;
-
ScreenPtr
xnestScreen(Window window)
{
@@ -146,21 +144,13 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[])
VisualID defaultVisual;
int rootDepth;
- if (!(AllocateWindowPrivate(pScreen, xnestWindowPrivateIndex,
- sizeof(xnestPrivWin)) &&
- AllocateGCPrivate(pScreen, xnestGCPrivateIndex,
- sizeof(xnestPrivGC))))
+ if (!dixRequestPrivate(xnestWindowPrivateKey, sizeof(xnestPrivWin)))
+ return False;
+ if (!dixRequestPrivate(xnestGCPrivateKey, sizeof(xnestPrivGC)))
return False;
-
- if (xnestScreenGeneration != serverGeneration) {
- if ((xnestPixmapPrivateIndex = AllocatePixmapPrivateIndex()) < 0)
- return False;
- xnestScreenGeneration = serverGeneration;
- }
-
- if (!AllocatePixmapPrivate(pScreen,xnestPixmapPrivateIndex,
- sizeof (xnestPrivPixmap)))
+ if (!dixRequestPrivate(xnestPixmapPrivateKey, sizeof (xnestPrivPixmap)))
return False;
+
visuals = (VisualPtr)xalloc(xnestNumVisuals * sizeof(VisualRec));
numVisuals = 0;
diff --git a/hw/xnest/Window.c b/hw/xnest/Window.c
index f87a1baa7..0955e61b9 100644
--- a/hw/xnest/Window.c
+++ b/hw/xnest/Window.c
@@ -39,7 +39,7 @@ is" without express or implied warranty.
#include "Events.h"
#include "Args.h"
-int xnestWindowPrivateIndex;
+DevPrivateKey xnestWindowPrivateKey = &xnestWindowPrivateKey;
static int
xnestFindWindowMatch(WindowPtr pWin, pointer ptr)
diff --git a/hw/xnest/XNGC.h b/hw/xnest/XNGC.h
index d3ac3df0b..19535fe3a 100644
--- a/hw/xnest/XNGC.h
+++ b/hw/xnest/XNGC.h
@@ -22,10 +22,10 @@ typedef struct {
int nClipRects;
} xnestPrivGC;
-extern int xnestGCPrivateIndex;
+extern DevPrivateKey xnestGCPrivateKey;
-#define xnestGCPriv(pGC) \
- ((xnestPrivGC *)((pGC)->devPrivates[xnestGCPrivateIndex].ptr))
+#define xnestGCPriv(pGC) ((xnestPrivGC *) \
+ dixLookupPrivate(&(pGC)->devPrivates, xnestGCPrivateKey))
#define xnestGC(pGC) (xnestGCPriv(pGC)->gc)
diff --git a/hw/xnest/XNPixmap.h b/hw/xnest/XNPixmap.h
index 6971b1162..3b0833993 100644
--- a/hw/xnest/XNPixmap.h
+++ b/hw/xnest/XNPixmap.h
@@ -15,14 +15,14 @@ is" without express or implied warranty.
#ifndef XNESTPIXMAP_H
#define XNESTPIXMAP_H
-extern int xnestPixmapPrivateIndex;
+extern DevPrivateKey xnestPixmapPrivateKey;
typedef struct {
Pixmap pixmap;
} xnestPrivPixmap;
-#define xnestPixmapPriv(pPixmap) \
- ((xnestPrivPixmap *)((pPixmap)->devPrivates[xnestPixmapPrivateIndex].ptr))
+#define xnestPixmapPriv(pPixmap) ((xnestPrivPixmap *) \
+ dixLookupPrivate(&(pPixmap)->devPrivates, xnestPixmapPrivateKey))
#define xnestPixmap(pPixmap) (xnestPixmapPriv(pPixmap)->pixmap)
diff --git a/hw/xnest/XNWindow.h b/hw/xnest/XNWindow.h
index 21be5f5e3..1aaf4e153 100644
--- a/hw/xnest/XNWindow.h
+++ b/hw/xnest/XNWindow.h
@@ -35,10 +35,10 @@ typedef struct {
Window window;
} xnestWindowMatch;
-extern int xnestWindowPrivateIndex;
+extern DevPrivateKey xnestWindowPrivateKey;
-#define xnestWindowPriv(pWin) \
- ((xnestPrivWin *)((pWin)->devPrivates[xnestWindowPrivateIndex].ptr))
+#define xnestWindowPriv(pWin) ((xnestPrivWin *) \
+ dixLookupPrivate(&(pWin)->devPrivates, xnestWindowPrivateKey))
#define xnestWindow(pWin) (xnestWindowPriv(pWin)->window)
diff --git a/hw/xprint/attributes.c b/hw/xprint/attributes.c
index d8ee5adf8..9756e281d 100644
--- a/hw/xprint/attributes.c
+++ b/hw/xprint/attributes.c
@@ -124,7 +124,7 @@ SysAttrs systemAttributes;
* attrCtxtPrivIndex hold the attribute store's context private index.
* This index is allocated at the time the attribute store is initialized.
*/
-static int attrCtxtPrivIndex;
+static DevPrivateKey attrCtxtPrivKey = &attrCtxtPrivKey;
/*
* The ContextAttrs structure descibes the context private space reserved
@@ -521,8 +521,7 @@ XpBuildAttributeStore(
{
if(attrList != (PrAttrPtr)NULL)
FreeAttrList();
- attrCtxtPrivIndex = XpAllocateContextPrivateIndex();
- XpAllocateContextPrivate(attrCtxtPrivIndex, sizeof(ContextAttrs));
+ dixRequestPrivate(attrCtxtPrivKey, sizeof(ContextAttrs));
BuildSystemAttributes();
attrGeneration = serverGeneration;
@@ -592,7 +591,8 @@ XpInitAttributes(XpContextPtr pContext)
PrAttrPtr pPrAttr = attrList;
/* Initialize all the pointers to NULL */
- pCtxtAttrs = (ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ pCtxtAttrs = (ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
(void)memset((void *)pCtxtAttrs, 0, (size_t) sizeof(ContextAttrs));
for(pPrAttr = attrList; pPrAttr != (PrAttrPtr)NULL; pPrAttr = pPrAttr->next)
@@ -612,8 +612,8 @@ XpDestroyAttributes(
{
ContextAttrPtr pCtxtAttrs;
- pCtxtAttrs = (ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
-
+ pCtxtAttrs = (ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
if(pCtxtAttrs->printerAttrs != (XrmDatabase)NULL)
XrmDestroyDatabase(pCtxtAttrs->printerAttrs);
if(pCtxtAttrs->docAttrs != (XrmDatabase)NULL)
@@ -661,7 +661,8 @@ XpGetOneAttribute(
}
else
{
- pCtxtAttrs=(ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ pCtxtAttrs=(ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
switch(class)
{
case XPPrinterAttr:
@@ -714,7 +715,8 @@ XpPutOneAttribute(
XrmBinding bindings[1];
XrmQuark quarks[2];
- pCtxtAttrs = (ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ pCtxtAttrs = (ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
switch(class)
{
case XPPrinterAttr:
@@ -900,7 +902,8 @@ XpGetAttributes(
db = systemAttributes.server;
else
{
- pCtxtAttrs=(ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ pCtxtAttrs=(ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
switch(class)
{
case XPServerAttr:
@@ -952,7 +955,8 @@ XpAugmentAttributes(
db = XrmGetStringDatabase(attributes);
if(db == (XrmDatabase)NULL) return BadAlloc;
- pCtxtAttrs = (ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ pCtxtAttrs = (ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
switch(class)
{
case XPPrinterAttr:
@@ -988,7 +992,8 @@ XpSetAttributes(
db = XrmGetStringDatabase(attributes);
if(db == (XrmDatabase)NULL) return BadAlloc;
- pCtxtAttrs=(ContextAttrPtr)pContext->devPrivates[attrCtxtPrivIndex].ptr;
+ pCtxtAttrs=(ContextAttrPtr)dixLookupPrivate(&pContext->devPrivates,
+ attrCtxtPrivKey);
switch(class)
{
case XPPrinterAttr:
diff --git a/hw/xprint/pcl/Pcl.h b/hw/xprint/pcl/Pcl.h
index 217e30438..216353be8 100644
--- a/hw/xprint/pcl/Pcl.h
+++ b/hw/xprint/pcl/Pcl.h
@@ -83,10 +83,10 @@ typedef char *XPointer;
/******
* externally visible variables from PclInit.c
******/
-extern int PclScreenPrivateIndex, PclWindowPrivateIndex;
-extern int PclContextPrivateIndex;
-extern int PclPixmapPrivateIndex;
-extern int PclGCPrivateIndex;
+extern DevPrivateKey PclScreenPrivateKey, PclWindowPrivateKey;
+extern DevPrivateKey PclContextPrivateKey;
+extern DevPrivateKey PclPixmapPrivateKey;
+extern DevPrivateKey PclGCPrivateKey;
/******
* externally visible variables from PclAttVal.c
diff --git a/hw/xprint/pcl/PclArc.c b/hw/xprint/pcl/PclArc.c
index 0d8289e33..20d3f723d 100644
--- a/hw/xprint/pcl/PclArc.c
+++ b/hw/xprint/pcl/PclArc.c
@@ -85,7 +85,7 @@ PclDoArc(
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
XpGetReproductionArea( pCon, &repro );
/*
diff --git a/hw/xprint/pcl/PclColor.c b/hw/xprint/pcl/PclColor.c
index 8b05da056..5e8ffa63c 100644
--- a/hw/xprint/pcl/PclColor.c
+++ b/hw/xprint/pcl/PclColor.c
@@ -129,8 +129,8 @@ PclCreateColormap(ColormapPtr pColor)
PclCmapToContexts *new;
PclScreenPrivPtr sPriv;
- sPriv = (PclScreenPrivPtr)pColor->pScreen
- ->devPrivates[PclScreenPrivateIndex].ptr;
+ sPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&pColor->pScreen->devPrivates, PclScreenPrivateKey);
/*
* Use existing code to initialize the values in the colormap
@@ -175,8 +175,8 @@ PclDestroyColormap(ColormapPtr pColor)
/*
* Find the colormap <-> contexts mapping
*/
- sPriv = (PclScreenPrivPtr)pColor->pScreen
- ->devPrivates[PclScreenPrivateIndex].ptr;
+ sPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&pColor->pScreen->devPrivates, PclScreenPrivateKey);
pCmap = sPriv->colormaps;
while( pCmap )
{
@@ -195,8 +195,8 @@ PclDestroyColormap(ColormapPtr pColor)
con = pCmap->contexts;
while( con )
{
- cPriv = con->context->devPrivates[PclContextPrivateIndex].ptr;
-
+ cPriv = dixLookupPrivate(&con->context->devPrivates,
+ PclContextPrivateKey);
pPal = cPriv->palettes;
while( pPal )
{
@@ -259,8 +259,8 @@ PclStoreColors(ColormapPtr pColor,
char t[80];
int i;
- sPriv = (PclScreenPrivPtr)pColor->pScreen
- ->devPrivates[PclScreenPrivateIndex].ptr;
+ sPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&pColor->pScreen->devPrivates, PclScreenPrivateKey);
p = sPriv->colormaps;
while( p )
{
@@ -278,8 +278,8 @@ PclStoreColors(ColormapPtr pColor,
* For each context, get the palette ID and update the
* appropriate palette.
*/
- cPriv = con->context
- ->devPrivates[PclContextPrivateIndex].ptr;
+ cPriv = dixLookupPrivate(&con->context->devPrivates,
+ PclContextPrivateKey);
pMap = PclFindPaletteMap( cPriv, pColor, NULL );
/*
@@ -407,7 +407,8 @@ PclUpdateColormap(DrawablePtr pDrawable,
unsigned short r, g, b, rr, gg, bb;
int i;
- cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+ cPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
c = wColormap( win );
cmap = (ColormapPtr)LookupIDByType( c, RT_COLORMAP );
@@ -436,8 +437,9 @@ PclUpdateColormap(DrawablePtr pDrawable,
/*
* Add the colormap to the screen-level colormap<->context mapping.
*/
- sPriv = (PclScreenPrivPtr)cmap->pScreen
- ->devPrivates[PclScreenPrivateIndex].ptr;
+ sPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&cmap->pScreen->devPrivates,
+ PclScreenPrivateKey);
pCmap = sPriv->colormaps;
while( pCmap && ( pCmap->colormapId != cmap->mid ) )
pCmap = pCmap->next;
diff --git a/hw/xprint/pcl/PclGC.c b/hw/xprint/pcl/PclGC.c
index ba82c566a..e64e779db 100644
--- a/hw/xprint/pcl/PclGC.c
+++ b/hw/xprint/pcl/PclGC.c
@@ -144,7 +144,8 @@ PclGetDrawablePrivateStuff(
return FALSE;
else
{
- cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+ cPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
*gc = cPriv->lastGC;
*valid = cPriv->validGC;
*file = cPriv->pPageFile;
@@ -171,7 +172,8 @@ PclSetDrawablePrivateGC(
{
case DRAWABLE_PIXMAP:
pix = (PixmapPtr)pDrawable;
- pixPriv = pix->devPrivates[PclPixmapPrivateIndex].ptr;
+ pixPriv = (PclPixmapPrivPtr)
+ dixLookupPrivate(&pix->devPrivates, PclPixmapPrivateKey);
pixPriv->lastGC = gc;
pixPriv->validGC = 1;
@@ -179,8 +181,8 @@ PclSetDrawablePrivateGC(
case DRAWABLE_WINDOW:
pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
- pPriv = ((PclContextPrivPtr)
- (pCon->devPrivates[PclContextPrivateIndex].ptr));
+ pPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
pPriv->validGC = 1;
pPriv->lastGC = gc;
@@ -316,13 +318,14 @@ PclUpdateDrawableGC(
XpContextPtr pCon;
PclContextPrivPtr cPriv;
PclGCPrivPtr gcPriv = (PclGCPrivPtr)
- (pGC->devPrivates[PclGCPrivateIndex].ptr);
+ dixLookupPrivate(&pGC->devPrivates, PclGCPrivateKey);
if( !PclGetDrawablePrivateStuff( pDrawable, &dGC, &valid, outFile ) )
return FALSE;
pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
- cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+ cPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
/*
* Here's where we update the colormap. Since there can be
diff --git a/hw/xprint/pcl/PclInit.c b/hw/xprint/pcl/PclInit.c
index 183225274..478a34244 100644
--- a/hw/xprint/pcl/PclInit.c
+++ b/hw/xprint/pcl/PclInit.c
@@ -67,11 +67,11 @@ static void AllocatePclPrivates(ScreenPtr pScreen);
static int PclInitContext(XpContextPtr pCon);
static Bool PclDestroyContext(XpContextPtr pCon);
-int PclScreenPrivateIndex;
-int PclContextPrivateIndex;
-int PclPixmapPrivateIndex;
-int PclWindowPrivateIndex;
-int PclGCPrivateIndex;
+DevPrivateKey PclScreenPrivateKey = &PclScreenPrivateKey;
+DevPrivateKey PclContextPrivateKey = &PclContextPrivateKey;
+DevPrivateKey PclPixmapPrivateKey = &PclPixmapPrivateKey;
+DevPrivateKey PclWindowPrivateKey = &PclWindowPrivateKey;
+DevPrivateKey PclGCPrivateKey = &PclGCPrivateKey;
#ifdef XP_PCL_COLOR
/*
@@ -119,7 +119,8 @@ Bool
PclCloseScreen(int index,
ScreenPtr pScreen)
{
- PclScreenPrivPtr pPriv = pScreen->devPrivates[PclScreenPrivateIndex].ptr;
+ PclScreenPrivPtr pPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&pScreen->devPrivates, PclScreenPrivateKey);
pScreen->CloseScreen = pPriv->CloseScreen;
xfree( pPriv );
@@ -157,8 +158,8 @@ InitializePclDriver(
*/
AllocatePclPrivates(pScreen);
- pPriv =
- (PclScreenPrivPtr)pScreen->devPrivates[PclScreenPrivateIndex].ptr;
+ pPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&pScreen->devPrivates, PclScreenPrivateKey);
maxDim = MAX( pScreen->height, pScreen->width );
xRes = pScreen->width / ( pScreen->mmWidth / 25.4 );
@@ -260,33 +261,13 @@ InitializePclDriver(
static void
AllocatePclPrivates(ScreenPtr pScreen)
{
- static unsigned long PclGeneration = 0;
+ dixRequestPrivate(PclWindowPrivateKey, sizeof( PclWindowPrivRec ) );
+ dixRequestPrivate(PclContextPrivateKey, sizeof( PclContextPrivRec ) );
+ dixRequestPrivate(PclGCPrivateKey, sizeof( PclGCPrivRec ) );
+ dixRequestPrivate(PclPixmapPrivateKey, sizeof( PclPixmapPrivRec ) );
- if((unsigned long) PclGeneration != serverGeneration)
- {
- PclScreenPrivateIndex = AllocateScreenPrivateIndex();
-
- PclWindowPrivateIndex = AllocateWindowPrivateIndex();
- AllocateWindowPrivate( pScreen, PclWindowPrivateIndex,
- sizeof( PclWindowPrivRec ) );
-
- PclContextPrivateIndex = XpAllocateContextPrivateIndex();
- XpAllocateContextPrivate( PclContextPrivateIndex,
- sizeof( PclContextPrivRec ) );
-
- PclGCPrivateIndex = AllocateGCPrivateIndex();
- AllocateGCPrivate( pScreen, PclGCPrivateIndex,
- sizeof( PclGCPrivRec ) );
-
- PclPixmapPrivateIndex = AllocatePixmapPrivateIndex();
- AllocatePixmapPrivate( pScreen, PclPixmapPrivateIndex,
- sizeof( PclPixmapPrivRec ) );
-
- PclGeneration = serverGeneration;
- }
-
- pScreen->devPrivates[PclScreenPrivateIndex].ptr = (pointer)xalloc(
- sizeof(PclScreenPrivRec));
+ dixSetPrivate(&pScreen->devPrivates, PclScreenPrivateKey,
+ xalloc(sizeof(PclScreenPrivRec)));
}
/*
@@ -349,8 +330,8 @@ PclInitContext(XpContextPtr pCon)
/*
* Set up the context privates
*/
- pConPriv =
- (PclContextPrivPtr)pCon->devPrivates[PclContextPrivateIndex].ptr;
+ pConPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
pConPriv->jobFileName = (char *)NULL;
pConPriv->pageFileName = (char *)NULL;
@@ -483,7 +464,7 @@ static Bool
PclDestroyContext(XpContextPtr pCon)
{
PclContextPrivPtr pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
PclPaletteMapPtr p, t;
PclCmapToContexts *pCmap;
ScreenPtr screen;
@@ -541,7 +522,8 @@ PclDestroyContext(XpContextPtr pCon)
* Remove the context from the screen-level colormap<->contexts mappings
*/
screen = screenInfo.screens[pCon->screenNum];
- sPriv = (PclScreenPrivPtr)screen->devPrivates[PclScreenPrivateIndex].ptr;
+ sPriv = (PclScreenPrivPtr)
+ dixLookupPrivate(&screen->devPrivates, PclScreenPrivateKey);
pCmap = sPriv->colormaps;
while( pCmap )
{
@@ -583,8 +565,8 @@ PclGetContextFromWindow(WindowPtr win)
while( win )
{
- pPriv =
- (PclWindowPrivPtr)win->devPrivates[PclWindowPrivateIndex].ptr;
+ pPriv = (PclWindowPrivPtr)
+ dixLookupPrivate(&win->devPrivates, PclWindowPrivateKey);
if( pPriv->validContext )
return pPriv->context;
diff --git a/hw/xprint/pcl/PclLine.c b/hw/xprint/pcl/PclLine.c
index 52a586d17..68d55a525 100644
--- a/hw/xprint/pcl/PclLine.c
+++ b/hw/xprint/pcl/PclLine.c
@@ -107,7 +107,7 @@ PclPolyLine(
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
/*
* Allocate the storage required to deal with the clipping
@@ -223,7 +223,7 @@ PclPolySegment(
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
/*
* Allocate the storage for the temporary regions.
diff --git a/hw/xprint/pcl/PclPixel.c b/hw/xprint/pcl/PclPixel.c
index f41af272f..d219838f0 100644
--- a/hw/xprint/pcl/PclPixel.c
+++ b/hw/xprint/pcl/PclPixel.c
@@ -125,13 +125,15 @@ PclPolyPoint( pDrawable, pGC, mode, nPoints, pPoints )
if( pDrawable->type == DRAWABLE_WINDOW )
{
pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
- cPriv = pCon->devPrivates[PclContextPrivateIndex].ptr;
+ cPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
cPriv->changeMask = GCLineWidth | GCLineStyle;
}
else
{
- pPriv =
- ((PixmapPtr)pDrawable)->devPrivates[PclPixmapPrivateIndex].ptr;
+ pPriv = (PclPixmapPrivPtr)
+ dixLookupPrivate(&((PixmapPtr)pDrawable)->devPrivates,
+ PclPixmapPrivateKey);
pPriv->changeMask = GCLineWidth | GCLineStyle;
}
#endif
diff --git a/hw/xprint/pcl/PclPolygon.c b/hw/xprint/pcl/PclPolygon.c
index 9867758bb..7d95d6484 100644
--- a/hw/xprint/pcl/PclPolygon.c
+++ b/hw/xprint/pcl/PclPolygon.c
@@ -76,7 +76,7 @@ PclPolyRectangle(
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
/*
* Allocate the storage required to deal with the clipping
@@ -170,7 +170,7 @@ PclFillPolygon(
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
/*
* Generate the PCL code to draw the filled polygon, by defining
@@ -283,7 +283,7 @@ PclPolyFillRect(
pCon = PclGetContextFromWindow( (WindowPtr) pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
/*
* Allocate the storage required to deal with the clipping
diff --git a/hw/xprint/pcl/PclPrint.c b/hw/xprint/pcl/PclPrint.c
index 176a0025a..ac8ea1537 100644
--- a/hw/xprint/pcl/PclPrint.c
+++ b/hw/xprint/pcl/PclPrint.c
@@ -72,8 +72,8 @@ PclStartJob(
Bool sendClientData,
ClientPtr client)
{
- PclContextPrivPtr pConPriv =
- (PclContextPrivPtr)pCon->devPrivates[PclContextPrivateIndex].ptr;
+ PclContextPrivPtr pConPriv = (PclContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
PclPaletteMap *pal;
/*
@@ -130,7 +130,7 @@ PclEndJob(
Bool cancel)
{
PclContextPrivPtr priv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
#ifdef CCP_DEBUG
FILE *xpoutput;
@@ -250,9 +250,9 @@ PclStartPage(
WindowPtr pWin)
{
PclContextPrivPtr pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
- PclWindowPrivPtr pWinPriv =
- (PclWindowPrivPtr)pWin->devPrivates[PclWindowPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
+ PclWindowPrivPtr pWinPriv = (PclWindowPrivPtr)
+ dixLookupPrivate(&pWin->devPrivates, PclWindowPrivateKey);
xRectangle repro;
char t[80];
XpOid orient, plex, tray, medium;
@@ -488,7 +488,7 @@ PclEndPage(
WindowPtr pWin)
{
PclContextPrivPtr pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
struct stat statBuf;
@@ -532,7 +532,7 @@ PclStartDoc(XpContextPtr pCon,
XPDocumentType type)
{
PclContextPrivPtr pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
#ifndef XP_PCL_LJ3
/*
@@ -592,7 +592,7 @@ PclDocumentData(
{
int type = 0;
PclContextPrivPtr pPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
XpOidDocFmtList *formats;
XpOidDocFmt *f;
char t[80];
@@ -700,7 +700,7 @@ PclGetDocumentData(
int maxBufferSize)
{
PclContextPrivPtr pPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
pPriv->getDocClient = client;
pPriv->getDocBufSize = maxBufferSize;
diff --git a/hw/xprint/pcl/PclText.c b/hw/xprint/pcl/PclText.c
index 246c0195b..324de3014 100644
--- a/hw/xprint/pcl/PclText.c
+++ b/hw/xprint/pcl/PclText.c
@@ -123,7 +123,7 @@ char font_type;
pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
pSoftFontInfo = pConPriv->pSoftFontInfo;
font_type = isInternal(pGC->font);
if ( font_type == DOWNLOAD_FONT ) {
@@ -293,7 +293,7 @@ char font_type;
pCon = PclGetContextFromWindow( (WindowPtr)pDrawable );
pConPriv = (PclContextPrivPtr)
- pCon->devPrivates[PclContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PclContextPrivateKey);
pSoftFontInfo = pConPriv->pSoftFontInfo;
font_type = isInternal(pGC->font);
diff --git a/hw/xprint/pcl/PclWindow.c b/hw/xprint/pcl/PclWindow.c
index 80f4e91b1..997cfe4f0 100644
--- a/hw/xprint/pcl/PclWindow.c
+++ b/hw/xprint/pcl/PclWindow.c
@@ -97,9 +97,9 @@ PclCreateWindow(
Bool status = Success;
ScreenPtr pScreen = pWin->drawable.pScreen;
PclScreenPrivPtr pScreenPriv = (PclScreenPrivPtr)
- pScreen->devPrivates[PclScreenPrivateIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, PclScreenPrivateKey);
PclWindowPrivPtr pWinPriv = (PclWindowPrivPtr)
- pWin->devPrivates[PclWindowPrivateIndex].ptr;
+ dixLookupPrivate(&pWin->devPrivates, PclWindowPrivateKey);
/*
* Initialize this window's private struct.
@@ -142,7 +142,8 @@ PclCreateWindow(
/*
* Invalidate the window's private print context.
*/
- pPriv = (PclWindowPrivPtr)pWin->devPrivates[PclWindowPrivateIndex].ptr;
+ pPriv = (PclWindowPrivPtr)
+ dixLookupPrivate(&pWin->devPrivates, PclWindowPrivateKey);
pPriv->validContext = 0;
return TRUE;
diff --git a/hw/xprint/pcl/Pclmap.h b/hw/xprint/pcl/Pclmap.h
index ae88b5a42..79724213f 100644
--- a/hw/xprint/pcl/Pclmap.h
+++ b/hw/xprint/pcl/Pclmap.h
@@ -82,11 +82,11 @@ copyright holders.
#define InitializePclDriver CATNAME(Initialize, PclDriver)
#define PclCloseScreen PCLNAME(CloseScreen)
#define PclGetContextFromWindow PCLNAME(GetContextFromWindow)
-#define PclScreenPrivateIndex PCLNAME(ScreenPrivateIndex)
-#define PclWindowPrivateIndex PCLNAME(WindowPrivateIndex)
-#define PclContextPrivateIndex PCLNAME(ContextPrivateIndex)
-#define PclPixmapPrivateIndex PCLNAME(PixmapPrivateIndex)
-#define PclGCPrivateIndex PCLNAME(GCPrivateIndex)
+#define PclScreenPrivateKey PCLNAME(ScreenPrivateKey)
+#define PclWindowPrivateKey PCLNAME(WindowPrivateKey)
+#define PclContextPrivateKey PCLNAME(ContextPrivateKey)
+#define PclPixmapPrivateKey PCLNAME(PixmapPrivateKey)
+#define PclGCPrivateKey PCLNAME(GCPrivateKey)
/* PclPrint.c */
#define PclStartJob PCLNAME(StartJob)
diff --git a/hw/xprint/ps/Ps.h b/hw/xprint/ps/Ps.h
index 3adad39e4..db1dd9129 100644
--- a/hw/xprint/ps/Ps.h
+++ b/hw/xprint/ps/Ps.h
@@ -121,10 +121,10 @@ typedef char *XPointer;
* Public index variables from PsInit.c
*/
-extern int PsScreenPrivateIndex;
-extern int PsWindowPrivateIndex;
-extern int PsContextPrivateIndex;
-extern int PsPixmapPrivateIndex;
+extern DevPrivateKey PsScreenPrivateKey;
+extern DevPrivateKey PsWindowPrivateKey;
+extern DevPrivateKey PsContextPrivateKey;
+extern DevPrivateKey PsPixmapPrivateKey;
extern XpValidatePoolsRec PsValidatePoolsRec;
/*
diff --git a/hw/xprint/ps/PsGC.c b/hw/xprint/ps/PsGC.c
index 3ec07a77a..19898c90e 100644
--- a/hw/xprint/ps/PsGC.c
+++ b/hw/xprint/ps/PsGC.c
@@ -162,9 +162,11 @@ PsGetDrawablePrivateStuff(
c = wColormap((WindowPtr)pDrawable);
cmap = (ColormapPtr)LookupIDByType(c, RT_COLORMAP);
- cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr;
+ cPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
sPriv = (PsScreenPrivPtr)
- pDrawable->pScreen->devPrivates[PsScreenPrivateIndex].ptr;
+ dixLookupPrivate(&pDrawable->pScreen->devPrivates,
+ PsScreenPrivateKey);
*gc = cPriv->lastGC;
*valid = cPriv->validGC;
*psOut = cPriv->pPsOut;
@@ -189,7 +191,8 @@ PsGetPsContextPriv( DrawablePtr pDrawable )
pCon = PsGetContextFromWindow((WindowPtr)pDrawable);
if (pCon != NULL)
{
- return pCon->devPrivates[PsContextPrivateIndex].ptr;
+ return (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
}
}
return NULL;
@@ -257,8 +260,9 @@ PsUpdateDrawableGC(
PsOut_Offset(*psOut, pDrawable->x, pDrawable->y);
PsOut_Clip(*psOut, pGC->clientClipType, (PsClipPtr)pGC->clientClip);
}
- cPriv = ( PsGetContextFromWindow( (WindowPtr)pDrawable ) )
- ->devPrivates[PsContextPrivateIndex].ptr;
+ cPriv = (PsContextPrivPtr)dixLookupPrivate(
+ &PsGetContextFromWindow((WindowPtr)pDrawable)->devPrivates,
+ PsContextPrivateKey);
break;
}
return TRUE;
diff --git a/hw/xprint/ps/PsInit.c b/hw/xprint/ps/PsInit.c
index 639908f73..6c86fa221 100644
--- a/hw/xprint/ps/PsInit.c
+++ b/hw/xprint/ps/PsInit.c
@@ -97,10 +97,10 @@ static void AllocatePsPrivates(ScreenPtr pScreen);
static int PsInitContext(XpContextPtr pCon);
static int PsDestroyContext(XpContextPtr pCon);
-int PsScreenPrivateIndex;
-int PsContextPrivateIndex;
-int PsPixmapPrivateIndex;
-int PsWindowPrivateIndex;
+DevPrivateKey PsScreenPrivateKey = &PsScreenPrivateKey;
+DevPrivateKey PsContextPrivateKey = &PsContextPrivateKey;
+DevPrivateKey PsPixmapPrivateKey = &PsPixmapPrivateKey;
+DevPrivateKey PsWindowPrivateKey = &PsWindowPrivateKey;
#ifdef GLXEXT
extern void GlxWrapInitVisuals(miInitVisualsProcPtr *);
@@ -152,7 +152,8 @@ InitializePsDriver(ndx, pScreen, argc, argv)
AllocatePsPrivates(pScreen);
#if 0
- pPriv = (PsScreenPrivPtr)pScreen->devPrivates[PsScreenPrivateIndex].ptr;
+ pPriv = (PsScreenPrivPtr)
+ dixLookupPrivate(&pScreen->devPrivates, PsScreenPrivateKey);
pPriv->resDB = rmdb;
#endif
@@ -476,28 +477,12 @@ InitializePsDriver(ndx, pScreen, argc, argv)
static void
AllocatePsPrivates(ScreenPtr pScreen)
{
- static unsigned long PsGeneration = 0;
+ dixRequestPrivate(PsWindowPrivateKey, sizeof(PsWindowPrivRec));
+ dixRequestPrivate(PsContextPrivateKey, sizeof(PsContextPrivRec));
+ dixRequestPrivate(PsPixmapPrivateKey, sizeof(PsPixmapPrivRec));
- if((unsigned long)PsGeneration != serverGeneration)
- {
- PsScreenPrivateIndex = AllocateScreenPrivateIndex();
-
- PsWindowPrivateIndex = AllocateWindowPrivateIndex();
- AllocateWindowPrivate(pScreen, PsWindowPrivateIndex,
- sizeof(PsWindowPrivRec));
-
- PsContextPrivateIndex = XpAllocateContextPrivateIndex();
- XpAllocateContextPrivate(PsContextPrivateIndex,
- sizeof(PsContextPrivRec));
-
- PsPixmapPrivateIndex = AllocatePixmapPrivateIndex();
- AllocatePixmapPrivate(pScreen, PsPixmapPrivateIndex,
- sizeof(PsPixmapPrivRec));
-
- PsGeneration = serverGeneration;
- }
- pScreen->devPrivates[PsScreenPrivateIndex].ptr =
- (pointer)xalloc(sizeof(PsScreenPrivRec));
+ dixSetPrivate(&pScreen->devPrivates, PsScreenPrivateKey,
+ xalloc(sizeof(PsScreenPrivRec)));
}
/*
@@ -552,8 +537,8 @@ PsInitContext(pCon)
/*
* Set up the context privates
*/
- pConPriv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ pConPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
memset(pConPriv, 0, sizeof(PsContextPrivRec));
pConPriv->jobFileName = (char *)NULL;
@@ -622,8 +607,8 @@ static Bool
PsDestroyContext(pCon)
XpContextPtr pCon;
{
- PsContextPrivPtr pConPriv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ PsContextPrivPtr pConPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
if( pConPriv->pJobFile!=(FILE *)NULL )
{
@@ -655,7 +640,8 @@ PsGetContextFromWindow(win)
while( win )
{
- pPriv = (PsWindowPrivPtr)win->devPrivates[PsWindowPrivateIndex].ptr;
+ pPriv = (PsWindowPrivPtr)
+ dixLookupPrivate(&win->devPrivates, PsWindowPrivateKey);
if( pPriv->validContext ) return pPriv->context;
win = win->parent;
}
diff --git a/hw/xprint/ps/PsPixmap.c b/hw/xprint/ps/PsPixmap.c
index 220feab2b..1fa4e4056 100644
--- a/hw/xprint/ps/PsPixmap.c
+++ b/hw/xprint/ps/PsPixmap.c
@@ -111,14 +111,11 @@ PsCreatePixmap(
pPixmap->drawable.height = height;
pPixmap->devKind = 0;
pPixmap->refcnt = 1;
-
- pPixmap->devPrivates = (DevUnion *)xcalloc(1, sizeof(DevUnion));
- if( !pPixmap->devPrivates )
- { xfree(pPixmap); return NullPixmap; }
+ pPixmap->devPrivates = NULL;
pPixmap->devPrivate.ptr = (PsPixmapPrivPtr)xcalloc(1, sizeof(PsPixmapPrivRec));
if( !pPixmap->devPrivate.ptr )
- { xfree(pPixmap->devPrivates); xfree(pPixmap); return NullPixmap; }
+ { xfree(pPixmap); return NullPixmap; }
return pPixmap;
}
@@ -201,7 +198,7 @@ PsDestroyPixmap(PixmapPtr pPixmap)
PsScrubPixmap(pPixmap);
xfree(priv);
- dixFreePrivates(*DEVPRIV_PTR(pPixmap));
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return TRUE;
}
diff --git a/hw/xprint/ps/PsPrint.c b/hw/xprint/ps/PsPrint.c
index 4571c07d7..386646858 100644
--- a/hw/xprint/ps/PsPrint.c
+++ b/hw/xprint/ps/PsPrint.c
@@ -165,8 +165,8 @@ PsStartJob(
Bool sendClientData,
ClientPtr client)
{
- PsContextPrivPtr pConPriv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ PsContextPrivPtr pConPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
/*
* Create a temporary file to store the printer output.
@@ -191,8 +191,8 @@ PsEndJob(
struct stat buffer;
int error;
- PsContextPrivPtr priv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ PsContextPrivPtr priv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
if (cancel == True) {
if (priv->getDocClient != (ClientPtr) NULL) {
@@ -291,10 +291,10 @@ PsStartPage(
{
int iorient, iplex, icount, ires;
unsigned short iwd, iht;
- PsContextPrivPtr pConPriv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
- PsWindowPrivPtr pWinPriv =
- (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
+ PsContextPrivPtr pConPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
+ PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr)
+ dixLookupPrivate(&pWin->devPrivates, PsWindowPrivateKey);
/*
* Put a pointer to the context in the window private structure
@@ -337,10 +337,10 @@ PsEndPage(
XpContextPtr pCon,
WindowPtr pWin)
{
- PsWindowPrivPtr pWinPriv =
- (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
- PsContextPrivPtr pConPriv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr)
+ dixLookupPrivate(&pWin->devPrivates, PsWindowPrivateKey);
+ PsContextPrivPtr pConPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
PsOut_EndPage(pConPriv->pPsOut);
@@ -366,8 +366,8 @@ PsStartDoc(XpContextPtr pCon, XPDocumentType type)
int iorient, iplex, icount, ires;
unsigned short iwd, iht;
char *title;
- PsContextPrivPtr pConPriv =
- (PsContextPrivPtr)pCon->devPrivates[PsContextPrivateIndex].ptr;
+ PsContextPrivPtr pConPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
/* get job level attributes */
title = XpGetOneAttribute(pCon, XPJobAttr, "job-name");
@@ -420,7 +420,8 @@ PsDocumentData(
len_opt)
return BadValue;
- cPriv = pCon->devPrivates[PsContextPrivateIndex].ptr;
+ cPriv = (PsContextPrivPtr)
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
psOut = cPriv->pPsOut;
if (pDraw)
@@ -448,7 +449,7 @@ PsGetDocumentData(
int maxBufferSize)
{
PsContextPrivPtr pPriv = (PsContextPrivPtr)
- pCon->devPrivates[PsContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, PsContextPrivateKey);
pPriv->getDocClient = client;
pPriv->getDocBufSize = maxBufferSize;
diff --git a/hw/xprint/ps/PsWindow.c b/hw/xprint/ps/PsWindow.c
index 26075a80a..d107e5c26 100644
--- a/hw/xprint/ps/PsWindow.c
+++ b/hw/xprint/ps/PsWindow.c
@@ -123,9 +123,9 @@ PsCreateWindow(WindowPtr pWin)
Bool status = Success;
ScreenPtr pScreen = pWin->drawable.pScreen;
PsScreenPrivPtr pScreenPriv = (PsScreenPrivPtr)
- pScreen->devPrivates[PsScreenPrivateIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, PsScreenPrivateKey);
PsWindowPrivPtr pWinPriv = (PsWindowPrivPtr)
- pWin->devPrivates[PsWindowPrivateIndex].ptr;
+ dixLookupPrivate(&pWin->devPrivates, PsWindowPrivateKey);
/*
* Initialize this window's private struct.
@@ -165,7 +165,8 @@ PsCreateWindow(WindowPtr pWin)
return status;
#endif
- pPriv = (PsWindowPrivPtr)pWin->devPrivates[PsWindowPrivateIndex].ptr;
+ pPriv = (PsWindowPrivPtr)
+ dixLookupPrivate(&pWin->devPrivates, PsWindowPrivateKey);
pPriv->validContext = 0;
return TRUE;
diff --git a/hw/xprint/raster/Raster.c b/hw/xprint/raster/Raster.c
index 0286a18fa..dccef613c 100644
--- a/hw/xprint/raster/Raster.c
+++ b/hw/xprint/raster/Raster.c
@@ -151,8 +151,8 @@ static int RasterReproducibleArea(XpContextPtr pCon,
#define DOC_PCL 1
#define DOC_RASTER 2
-static int RasterScreenPrivateIndex, RasterContextPrivateIndex;
-static int RasterGeneration = 0;
+static DevPrivateKey RasterScreenPrivateKey = &RasterScreenPrivateKey;
+static DevPrivateKey RasterContextPrivateKey = &RasterContextPrivateKey;
static char RASTER_DRIV_NAME[] = "XP-RASTER";
static int doc_type = DOC_RASTER;
@@ -205,7 +205,7 @@ InitializeRasterDriver(
AllocateRasterPrivates(pScreen);
pPriv = (RasterScreenPrivPtr)
- pScreen->devPrivates[RasterScreenPrivateIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, RasterScreenPrivateKey);
maxDim = MAX( pScreen->height, pScreen->width );
numBytes = maxDim + BITMAP_SCANLINE_PAD - 1; /* pixels per row */
@@ -252,7 +252,7 @@ GetPropString(
char *propName)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
char *type;
XrmValue val;
struct stat status;
@@ -371,7 +371,7 @@ StartJob(
ClientPtr client)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
SetDocumentType( pCon );
@@ -488,7 +488,7 @@ EndJob(
Bool cancel)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
if( cancel == True )
{
@@ -549,7 +549,7 @@ StartPage(
WindowPtr pWin)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
if(pConPriv->pPageFile != (FILE *)NULL)
{
@@ -830,7 +830,7 @@ SendPage( XpContextPtr pCon )
{
struct stat statBuf;
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
if(stat(pConPriv->pageFileName, &statBuf) < 0)
return BadAlloc;
@@ -872,7 +872,7 @@ EndPage(
WindowPtr pWin)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
struct stat statBuf;
char *rasterFileName = (char *)NULL, *pCommand = (char *)NULL;
FILE *pRasterFile = (FILE *)NULL;
@@ -1068,7 +1068,7 @@ DocumentData(
ClientPtr client)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
char *preRasterStr = PRE_RASTER, *postRasterStr = POST_RASTER,
*noRasterStr = NO_RASTER;
@@ -1135,7 +1135,7 @@ GetDocumentData(
int maxBufferSize)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pContext->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pContext->devPrivates, RasterContextPrivateKey);
pConPriv->getDocClient = client;
pConPriv->getDocBufSize = maxBufferSize;
@@ -1146,17 +1146,9 @@ static void
AllocateRasterPrivates(
ScreenPtr pScreen)
{
- if(RasterGeneration != serverGeneration)
- {
- RasterScreenPrivateIndex = AllocateScreenPrivateIndex();
- RasterContextPrivateIndex = XpAllocateContextPrivateIndex();
- XpAllocateContextPrivate( RasterContextPrivateIndex,
- sizeof( RasterContextPrivRec ) );
-
- RasterGeneration = serverGeneration;
- }
- pScreen->devPrivates[RasterScreenPrivateIndex].ptr = (pointer)Xalloc(
- sizeof(RasterScreenPrivRec));
+ dixRequestPrivate(RasterContextPrivateKey, sizeof( RasterContextPrivRec ) );
+ dixSetPrivate(&pScreen->devPrivates, RasterScreenPrivateKey,
+ Xalloc(sizeof(RasterScreenPrivRec)));
}
/*
@@ -1171,7 +1163,7 @@ RasterChangeWindowAttributes(
Bool status = Success;
ScreenPtr pScreen = pWin->drawable.pScreen;
RasterScreenPrivPtr pScreenPriv = (RasterScreenPrivPtr)
- pScreen->devPrivates[RasterScreenPrivateIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, RasterScreenPrivateKey);
if(pWin->backingStore == NotUseful)
{
@@ -1270,7 +1262,7 @@ RasterInitContext(
* Set up the context privates
*/
pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
pConPriv->jobFileName = (char *)NULL;
pConPriv->pageFileName = (char *)NULL;
@@ -1355,7 +1347,7 @@ RasterDestroyContext(
XpContextPtr pCon)
{
RasterContextPrivPtr pConPriv = (RasterContextPrivPtr)
- pCon->devPrivates[RasterContextPrivateIndex].ptr;
+ dixLookupPrivate(&pCon->devPrivates, RasterContextPrivateKey);
/*
* Clean up the temporary files
@@ -1477,7 +1469,7 @@ RasterCloseScreen(
{
Bool status = Success;
RasterScreenPrivPtr pScreenPriv = (RasterScreenPrivPtr)
- pScreen->devPrivates[RasterScreenPrivateIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, RasterScreenPrivateKey);
/*
* Call any wrapped CloseScreen proc.
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 09a9fb295..fad5e2b2e 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -631,11 +631,11 @@ extern DWORD g_dwEvents;
#ifdef HAS_DEVWINDOWS
extern int g_fdMessageQueue;
#endif
-extern int g_iScreenPrivateIndex;
-extern int g_iCmapPrivateIndex;
-extern int g_iGCPrivateIndex;
-extern int g_iPixmapPrivateIndex;
-extern int g_iWindowPrivateIndex;
+extern DevPrivateKey g_iScreenPrivateKey;
+extern DevPrivateKey g_iCmapPrivateKey;
+extern DevPrivateKey g_iGCPrivateKey;
+extern DevPrivateKey g_iPixmapPrivateKey;
+extern DevPrivateKey g_iWindowPrivateKey;
extern unsigned long g_ulServerGeneration;
extern CARD32 g_c32LastInputEventTime;
extern DWORD g_dwEnginesSupported;
@@ -661,11 +661,11 @@ extern FARPROC g_fpTrackMouseEvent;
* Screen privates macros
*/
-#define winGetScreenPriv(pScreen) \
- ((winPrivScreenPtr) (pScreen)->devPrivates[g_iScreenPrivateIndex].ptr)
+#define winGetScreenPriv(pScreen) ((winPrivScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, g_iScreenPrivateKey))
#define winSetScreenPriv(pScreen,v) \
- ((pScreen)->devPrivates[g_iScreenPrivateIndex].ptr = (pointer) v)
+ dixSetPrivate(&(pScreen)->devPrivates, g_iScreenPrivateKey, v)
#define winScreenPriv(pScreen) \
winPrivScreenPtr pScreenPriv = winGetScreenPriv(pScreen)
@@ -675,11 +675,11 @@ extern FARPROC g_fpTrackMouseEvent;
* Colormap privates macros
*/
-#define winGetCmapPriv(pCmap) \
- ((winPrivCmapPtr) (pCmap)->devPrivates[g_iCmapPrivateIndex].ptr)
+#define winGetCmapPriv(pCmap) ((winPrivCmapPtr) \
+ dixLookupPrivate(&(pCmap)->devPrivates, g_iCmapPrivateKey))
#define winSetCmapPriv(pCmap,v) \
- ((pCmap)->devPrivates[g_iCmapPrivateIndex].ptr = (pointer) v)
+ dixSetPrivate(&(pCmap)->devPrivates, g_iCmapPrivateKey, v)
#define winCmapPriv(pCmap) \
winPrivCmapPtr pCmapPriv = winGetCmapPriv(pCmap)
@@ -689,11 +689,11 @@ extern FARPROC g_fpTrackMouseEvent;
* GC privates macros
*/
-#define winGetGCPriv(pGC) \
- ((winPrivGCPtr) (pGC)->devPrivates[g_iGCPrivateIndex].ptr)
+#define winGetGCPriv(pGC) ((winPrivGCPtr) \
+ dixLookupPrivate(&(pGC)->devPrivates, g_iGCPrivateKey))
#define winSetGCPriv(pGC,v) \
- ((pGC)->devPrivates[g_iGCPrivateIndex].ptr = (pointer) v)
+ dixSetPrivate(&(pGC)->devPrivates, g_iGCPrivateKey, v)
#define winGCPriv(pGC) \
winPrivGCPtr pGCPriv = winGetGCPriv(pGC)
@@ -703,11 +703,11 @@ extern FARPROC g_fpTrackMouseEvent;
* Pixmap privates macros
*/
-#define winGetPixmapPriv(pPixmap) \
- ((winPrivPixmapPtr) (pPixmap)->devPrivates[g_iPixmapPrivateIndex].ptr)
+#define winGetPixmapPriv(pPixmap) ((winPrivPixmapPtr) \
+ dixLookupPrivate(&(pPixmap)->devPrivates, g_iPixmapPrivateKey))
#define winSetPixmapPriv(pPixmap,v) \
- ((pPixmap)->devPrivates[g_iPixmapPrivateIndex].ptr = (pointer) v)
+ dixLookupPrivate(&(pPixmap)->devPrivates, g_iPixmapPrivateKey, v)
#define winPixmapPriv(pPixmap) \
winPrivPixmapPtr pPixmapPriv = winGetPixmapPriv(pPixmap)
@@ -717,11 +717,11 @@ extern FARPROC g_fpTrackMouseEvent;
* Window privates macros
*/
-#define winGetWindowPriv(pWin) \
- ((winPrivWinPtr) (pWin)->devPrivates[g_iWindowPrivateIndex].ptr)
+#define winGetWindowPriv(pWin) ((winPrivWinPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, g_iWindowPrivateKey))
#define winSetWindowPriv(pWin,v) \
- ((pWin)->devPrivates[g_iWindowPrivateIndex].ptr = (pointer) v)
+ dixLookupPrivate(&(pWin)->devPrivates, g_iWindowPrivateKey, v)
#define winWindowPriv(pWin) \
winPrivWinPtr pWinPriv = winGetWindowPriv(pWin)
diff --git a/hw/xwin/winallpriv.c b/hw/xwin/winallpriv.c
index f4decfb59..21ccd9b3b 100644
--- a/hw/xwin/winallpriv.c
+++ b/hw/xwin/winallpriv.c
@@ -57,12 +57,6 @@ winAllocatePrivates (ScreenPtr pScreen)
/* We need a new slot for our privates if the screen gen has changed */
if (g_ulServerGeneration != serverGeneration)
{
- /* Get an index that we can store our privates at */
- g_iScreenPrivateIndex = AllocateScreenPrivateIndex ();
- g_iGCPrivateIndex = AllocateGCPrivateIndex ();
- g_iPixmapPrivateIndex = AllocatePixmapPrivateIndex ();
- g_iWindowPrivateIndex = AllocateWindowPrivateIndex ();
-
g_ulServerGeneration = serverGeneration;
}
@@ -84,24 +78,21 @@ winAllocatePrivates (ScreenPtr pScreen)
winSetScreenPriv (pScreen, pScreenPriv);
/* Reserve GC memory for our privates */
- if (!AllocateGCPrivate (pScreen, g_iGCPrivateIndex,
- sizeof (winPrivGCRec)))
+ if (!dixRequestPrivate(g_iGCPrivateKey, sizeof (winPrivGCRec)))
{
ErrorF ("winAllocatePrivates - AllocateGCPrivate () failed\n");
return FALSE;
}
/* Reserve Pixmap memory for our privates */
- if (!AllocatePixmapPrivate (pScreen, g_iPixmapPrivateIndex,
- sizeof (winPrivPixmapRec)))
+ if (!dixRequestPrivate(g_iPixmapPrivateKey, sizeof (winPrivPixmapRec)))
{
ErrorF ("winAllocatePrivates - AllocatePixmapPrivates () failed\n");
return FALSE;
}
/* Reserve Window memory for our privates */
- if (!AllocateWindowPrivate (pScreen, g_iWindowPrivateIndex,
- sizeof (winPrivWinRec)))
+ if (!dixRequestPrivate(g_iWindowPrivateKey, sizeof (winPrivWinRec)))
{
ErrorF ("winAllocatePrivates () - AllocateWindowPrivates () failed\n");
return FALSE;
@@ -155,9 +146,6 @@ winAllocateCmapPrivates (ColormapPtr pCmap)
/* Get a new privates index when the server generation changes */
if (s_ulPrivateGeneration != serverGeneration)
{
- /* Get an index that we can store our privates at */
- g_iCmapPrivateIndex = AllocateColormapPrivateIndex (winInitCmapPrivates);
-
/* Save the new server generation */
s_ulPrivateGeneration = serverGeneration;
}
diff --git a/hw/xwin/wincursor.c b/hw/xwin/wincursor.c
index c1e619bf8..021b8b82c 100644
--- a/hw/xwin/wincursor.c
+++ b/hw/xwin/wincursor.c
@@ -598,7 +598,8 @@ winInitCursor (ScreenPtr pScreen)
pScreenPriv->cursor.QueryBestSize = pScreen->QueryBestSize;
pScreen->QueryBestSize = winCursorQueryBestSize;
- pPointPriv = (miPointerScreenPtr) pScreen->devPrivates[miPointerScreenIndex].ptr;
+ pPointPriv = (miPointerScreenPtr)
+ dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
pScreenPriv->cursor.spriteFuncs = pPointPriv->spriteFuncs;
pPointPriv->spriteFuncs = &winSpriteFuncsRec;
diff --git a/hw/xwin/winfillsp.c b/hw/xwin/winfillsp.c
index 7e3966965..702f34f96 100644
--- a/hw/xwin/winfillsp.c
+++ b/hw/xwin/winfillsp.c
@@ -35,15 +35,6 @@
#include "win.h"
-/*
- * References to external symbols
- */
-
-extern int g_iPixmapPrivateIndex;
-extern int g_iGCPrivateIndex;
-extern int g_copyROP[];
-
-
extern void ROP16(HDC hdc, int rop);
#define TRANSLATE_COLOR(color) \
diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c
index af8190d3f..fddada39e 100644
--- a/hw/xwin/winglobals.c
+++ b/hw/xwin/winglobals.c
@@ -44,11 +44,11 @@ int g_iLastScreen = -1;
#ifdef HAS_DEVWINDOWS
int g_fdMessageQueue = WIN_FD_INVALID;
#endif
-int g_iScreenPrivateIndex = -1;
-int g_iCmapPrivateIndex = -1;
-int g_iGCPrivateIndex = -1;
-int g_iPixmapPrivateIndex = -1;
-int g_iWindowPrivateIndex = -1;
+DevPrivateKey g_iScreenPrivateKey = &g_iScreenPrivateKey;
+DevPrivateKey g_iCmapPrivateKey = &g_iCmapPrivateKey;
+DevPrivateKey g_iGCPrivateKey = &g_iGCPrivateKey;
+DevPrivateKey g_iPixmapPrivateKey = &g_iPixmapPrivateKey;
+DevPrivateKey g_iWindowPrivateKey = &g_iWindowPrivateKey;
unsigned long g_ulServerGeneration = 0;
Bool g_fInitializedDefaultScreens = FALSE;
DWORD g_dwEnginesSupported = 0;
diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c
index 0a7579b61..20ff9f7db 100644
--- a/hw/xwin/winmultiwindowwndproc.c
+++ b/hw/xwin/winmultiwindowwndproc.c
@@ -365,7 +365,7 @@ winTopLevelWindowProc (HWND hwnd, UINT message,
ErrorF ("\thenght %08X\n", pWin->drawable.height);
ErrorF ("\tpScreen %08X\n", pWin->drawable.pScreen);
ErrorF ("\tserialNumber %08X\n", pWin->drawable.serialNumber);
- ErrorF ("g_iWindowPrivateIndex %d\n", g_iWindowPrivateIndex);
+ ErrorF ("g_iWindowPrivateKey %p\n", g_iWindowPrivateKey);
ErrorF ("pWinPriv %08X\n", pWinPriv);
ErrorF ("s_pScreenPriv %08X\n", s_pScreenPriv);
ErrorF ("s_pScreenInfo %08X\n", s_pScreenInfo);
diff --git a/hw/xwin/winpixmap.c b/hw/xwin/winpixmap.c
index baff60c92..ffe72079a 100644
--- a/hw/xwin/winpixmap.c
+++ b/hw/xwin/winpixmap.c
@@ -36,13 +36,6 @@
/*
- * References to external symbols
- */
-
-extern int g_iPixmapPrivateIndex;
-
-
-/*
* Local prototypes
*/
diff --git a/hw/xwin/winscrinit.c b/hw/xwin/winscrinit.c
index 52adba819..2038e6fe5 100644
--- a/hw/xwin/winscrinit.c
+++ b/hw/xwin/winscrinit.c
@@ -73,9 +73,6 @@ winMWExtWMProcs = {
* References to external symbols
*/
-extern winScreenInfo g_ScreenInfo[];
-extern miPointerScreenFuncRec g_winPointerCursorFuncs;
-extern int g_iScreenPrivateIndex;
extern Bool g_fSoftwareCursor;
diff --git a/hw/xwin/winsetsp.c b/hw/xwin/winsetsp.c
index 8a3faee93..f894d6cda 100644
--- a/hw/xwin/winsetsp.c
+++ b/hw/xwin/winsetsp.c
@@ -35,15 +35,6 @@
#include "win.h"
-/*
- * References to external symbols
- */
-
-extern int g_iPixmapPrivateIndex;
-extern int g_iGCPrivateIndex;
-extern int g_copyROP[];
-
-
/* See Porting Layer Definition - p. 55 */
void
winSetSpansNativeGDI (DrawablePtr pDrawable,
diff --git a/include/colormapst.h b/include/colormapst.h
index c9d9514ad..f1fc8ebef 100644
--- a/include/colormapst.h
+++ b/include/colormapst.h
@@ -52,6 +52,7 @@ SOFTWARE.
#include "colormap.h"
#include "screenint.h"
+#include "privates.h"
/* Shared color -- the color is used by AllocColorPlanes */
typedef struct
@@ -126,7 +127,7 @@ typedef struct _ColormapRec
Entry *green;
Entry *blue;
pointer devPriv;
- DevUnion *devPrivates; /* dynamic devPrivates added after devPriv
+ PrivateRec *devPrivates; /* dynamic devPrivates added after devPriv
already existed - must keep devPriv */
} ColormapRec;
diff --git a/include/dix-config.h.in b/include/dix-config.h.in
index 01142a59d..8d4d7318e 100644
--- a/include/dix-config.h.in
+++ b/include/dix-config.h.in
@@ -261,9 +261,6 @@
/* Internal define for Xinerama */
#undef PANORAMIX
-/* Support pixmap privates */
-#undef PIXPRIV
-
/* Overall prefix */
#undef PROJECTROOT
diff --git a/include/dix.h b/include/dix.h
index 05366ecd0..54629cd14 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -496,12 +496,6 @@ void
ScreenRestructured (ScreenPtr pScreen);
#endif
-extern int AllocateClientPrivateIndex(void);
-
-extern Bool AllocateClientPrivate(
- int /*index*/,
- unsigned /*amount*/);
-
extern int ffs(int i);
/*
diff --git a/include/dixstruct.h b/include/dixstruct.h
index 2a3e696fd..7f14abab4 100644
--- a/include/dixstruct.h
+++ b/include/dixstruct.h
@@ -29,6 +29,7 @@ SOFTWARE.
#include "cursor.h"
#include "gc.h"
#include "pixmap.h"
+#include "privates.h"
#include <X11/Xmd.h>
/*
@@ -110,7 +111,7 @@ typedef struct _Client {
Bool big_requests; /* supports large requests */
int priority;
ClientState clientState;
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
#ifdef XKB
unsigned short xkbClientFlags;
unsigned short mapNotifyMask;
diff --git a/include/extension.h b/include/extension.h
index 27decc12c..6e6081740 100644
--- a/include/extension.h
+++ b/include/extension.h
@@ -58,12 +58,6 @@ extern Bool EnableDisableExtension(char *name, Bool enable);
extern void EnableDisableExtensionError(char *name, Bool enable);
-extern int AllocateExtensionPrivateIndex(void);
-
-extern Bool AllocateExtensionPrivate(
- int /*index*/,
- unsigned /*amount*/);
-
extern void InitExtensions(int argc, char **argv);
extern void InitVisualWrap(void);
diff --git a/include/extnsionst.h b/include/extnsionst.h
index 58bf0a206..59acd0ef4 100644
--- a/include/extnsionst.h
+++ b/include/extnsionst.h
@@ -53,6 +53,7 @@ SOFTWARE.
#include "screenint.h"
#include "extension.h"
#include "gc.h"
+#include "privates.h"
typedef struct _ExtensionEntry {
int index;
@@ -69,7 +70,7 @@ typedef struct _ExtensionEntry {
pointer extPrivate;
unsigned short (* MinorOpcode)( /* called for errors */
ClientPtr /* client */);
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
} ExtensionEntry;
/*
diff --git a/include/gcstruct.h b/include/gcstruct.h
index 14f747836..8d9b05575 100644
--- a/include/gcstruct.h
+++ b/include/gcstruct.h
@@ -56,6 +56,7 @@ SOFTWARE.
#include "region.h"
#include "pixmap.h"
#include "screenint.h"
+#include "privates.h"
#include <X11/Xprotostr.h>
/*
@@ -308,7 +309,7 @@ typedef struct _GC {
unsigned long serialNumber;
GCFuncs *funcs;
GCOps *ops;
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
/*
* The following were moved here from private storage to allow device-
* independent access to them from screen wrappers.
diff --git a/include/input.h b/include/input.h
index 97a78567f..4f9164a19 100644
--- a/include/input.h
+++ b/include/input.h
@@ -158,9 +158,6 @@ typedef struct {
unsigned char id;
} LedCtrl;
-extern int AllocateDevicePrivateIndex(void);
-extern Bool AllocateDevicePrivate(DeviceIntPtr device, int index);
-
extern KeybdCtrl defaultKeyboardControl;
extern PtrCtrl defaultPointerControl;
diff --git a/include/inputstr.h b/include/inputstr.h
index 3398949d4..bb7f35096 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -52,6 +52,7 @@ SOFTWARE.
#include "input.h"
#include "window.h"
#include "dixstruct.h"
+#include "privates.h"
#define BitIsOn(ptr, bit) (((BYTE *) (ptr))[(bit)>>3] & (1 << ((bit) & 7)))
@@ -62,7 +63,7 @@ SOFTWARE.
#define EMASKSIZE MAX_DEVICES
-extern int CoreDevicePrivatesIndex;
+extern DevPrivateKey CoreDevicePrivateKey;
/* Kludge: OtherClients and InputClients must be compatible, see code */
@@ -327,7 +328,7 @@ typedef struct _DeviceIntRec {
void *pad0;
#endif
char *config_info; /* used by the hotplug layer */
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
int nPrivates;
DeviceUnwrapProc unwrapProc;
} DeviceIntRec;
diff --git a/include/pixmapstr.h b/include/pixmapstr.h
index 459488226..4162c667e 100644
--- a/include/pixmapstr.h
+++ b/include/pixmapstr.h
@@ -47,27 +47,17 @@ SOFTWARE.
#ifndef PIXMAPSTRUCT_H
#define PIXMAPSTRUCT_H
-#include <X11/Xarch.h>
#include "pixmap.h"
#include "screenint.h"
#include "regionstr.h"
-
-/*
- * The padN members are unfortunate ABI BC. See fdo bug #6924.
- */
+#include "privates.h"
typedef struct _Drawable {
unsigned char type; /* DRAWABLE_<type> */
unsigned char class; /* specific to type */
unsigned char depth;
unsigned char bitsPerPixel;
-#if defined(_XSERVER64)
- XID pad0;
-#endif
XID id; /* resource id */
-#if defined(_XSERVER64)
- XID pad1;
-#endif
short x; /* window: screen absolute, pixmap: 0 */
short y; /* window: screen absolute, pixmap: 0 */
unsigned short width;
@@ -85,7 +75,7 @@ typedef struct _Pixmap {
int refcnt;
int devKind;
DevUnion devPrivate;
- DevUnion *devPrivates; /* real devPrivates like gcs & windows */
+ PrivateRec *devPrivates;
#ifdef COMPOSITE
short screen_x;
short screen_y;
diff --git a/include/privates.h b/include/privates.h
index e377b3068..9539a2912 100644
--- a/include/privates.h
+++ b/include/privates.h
@@ -28,13 +28,6 @@ typedef struct _Private {
} PrivateRec;
/*
- * Backwards compatibility macro. Use to get the proper PrivateRec
- * reference from any of the structure types that supported the old
- * devPrivates mechanism.
- */
-#define DEVPRIV_PTR(foo) ((PrivateRec **)(&(foo)->devPrivates[0].ptr))
-
-/*
* Request pre-allocated private space for your driver/module.
* Calling this is not necessary if only a pointer by itself is needed.
*/
@@ -154,7 +147,4 @@ dixLookupPrivateOffset(RESTYPE type);
extern int
dixRegisterPrivateOffset(RESTYPE type, unsigned offset);
-/* Used by the legacy support, don't rely on this being here */
-#define PadToLong(w) ((((w) + sizeof(long)-1) / sizeof(long)) * sizeof(long))
-
#endif /* PRIVATES_H */
diff --git a/include/screenint.h b/include/screenint.h
index bf8da4432..6d074a375 100644
--- a/include/screenint.h
+++ b/include/screenint.h
@@ -55,22 +55,6 @@ typedef struct _Visual *VisualPtr;
typedef struct _Depth *DepthPtr;
typedef struct _Screen *ScreenPtr;
-extern int AllocateScreenPrivateIndex(void);
-
-extern int AllocateWindowPrivateIndex(void);
-
-extern Bool AllocateWindowPrivate(
- ScreenPtr /* pScreen */,
- int /* index */,
- unsigned /* amount */);
-
-extern int AllocateGCPrivateIndex(void);
-
-extern Bool AllocateGCPrivate(
- ScreenPtr /* pScreen */,
- int /* index */,
- unsigned /* amount */);
-
extern int AddScreen(
Bool (* /*pfnInit*/)(
int /*index*/,
@@ -80,18 +64,6 @@ extern int AddScreen(
int /*argc*/,
char** /*argv*/);
-extern int AllocatePixmapPrivateIndex(void);
-
-extern Bool AllocatePixmapPrivate(
- ScreenPtr /* pScreen */,
- int /* index */,
- unsigned /* amount */);
-
-
typedef struct _ColormapRec *ColormapPtr;
-typedef int (*InitCmapPrivFunc)(ColormapPtr, int);
-
-extern int AllocateColormapPrivateIndex(
- InitCmapPrivFunc /* initPrivFunc */);
#endif /* SCREENINT_H */
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 110f4dce9..a24c5f528 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -56,6 +56,7 @@ SOFTWARE.
#include "validate.h"
#include <X11/Xproto.h>
#include "dix.h"
+#include "privates.h"
typedef struct _PixmapFormat {
unsigned char depth;
@@ -449,12 +450,6 @@ typedef struct _Screen {
pointer devPrivate;
short numVisuals;
VisualPtr visuals;
- int WindowPrivateLen;
- unsigned *WindowPrivateSizes;
- unsigned totalWindowSize;
- int GCPrivateLen;
- unsigned *GCPrivateSizes;
- unsigned totalGCSize;
/* Random screen procedures */
@@ -546,7 +541,7 @@ typedef struct _Screen {
pointer wakeupData;
/* anybody can get a piece of this array */
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
CreateScreenResourcesProcPtr CreateScreenResources;
ModifyPixmapHeaderProcPtr ModifyPixmapHeader;
@@ -558,8 +553,6 @@ typedef struct _Screen {
PixmapPtr pScratchPixmap; /* scratch pixmap "pool" */
- int PixmapPrivateLen;
- unsigned int *PixmapPrivateSizes;
unsigned int totalPixmapSize;
MarkWindowProcPtr MarkWindow;
diff --git a/include/window.h b/include/window.h
index d5437a759..f85eceb2d 100644
--- a/include/window.h
+++ b/include/window.h
@@ -83,9 +83,6 @@ extern int WalkTree(
VisitWindowProcPtr /*func*/,
pointer /*data*/);
-extern WindowPtr AllocateWindow(
- ScreenPtr /*pScreen*/);
-
extern Bool CreateRootWindow(
ScreenPtr /*pScreen*/);
diff --git a/include/windowstr.h b/include/windowstr.h
index 6d874ae9e..ca212ad99 100644
--- a/include/windowstr.h
+++ b/include/windowstr.h
@@ -55,6 +55,7 @@ SOFTWARE.
#include "property.h"
#include "resource.h" /* for ROOT_WINDOW_ID_BASE */
#include "dix.h"
+#include "privates.h"
#include "miscstruct.h"
#include <X11/Xprotostr.h>
#include "opaque.h"
@@ -159,7 +160,7 @@ typedef struct _Window {
#ifdef COMPOSITE
unsigned redirectDraw:2; /* rendering is redirected from here */
#endif
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
} WindowRec;
/*
diff --git a/include/xkbsrv.h b/include/xkbsrv.h
index 5edee539b..71ea115e6 100644
--- a/include/xkbsrv.h
+++ b/include/xkbsrv.h
@@ -246,7 +246,7 @@ typedef struct
device->public.realInputProc = oldprocs->realInputProc; \
device->unwrapProc = oldprocs->unwrapProc;
-#define XKBDEVICEINFO(dev) ((xkbDeviceInfoPtr) (dev)->devPrivates[xkbDevicePrivateIndex].ptr)
+#define XKBDEVICEINFO(dev) ((xkbDeviceInfoPtr)dixLookupPrivate(&(dev)->devPrivates, xkbDevicePrivateKey))
/***====================================================================***/
diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
index b9643a2a4..97d53a2ee 100644
--- a/include/xorg-config.h.in
+++ b/include/xorg-config.h.in
@@ -57,9 +57,6 @@
/* Solaris 8 or later? */
#undef __SOL8__
-/* Whether to use pixmap privates */
-#undef PIXPRIV
-
/* Define to 1 if you have the `walkcontext' function (used on Solaris for
xorg_backtrace in hw/xfree86/common/xf86Events.c */
#undef HAVE_WALKCONTEXT
diff --git a/include/xorg-server.h.in b/include/xorg-server.h.in
index c117dfa33..4b9104d9f 100644
--- a/include/xorg-server.h.in
+++ b/include/xorg-server.h.in
@@ -70,9 +70,6 @@
/* Internal define for Xinerama */
#undef PANORAMIX
-/* Support pixmap privates */
-#undef PIXPRIV
-
/* Support RANDR extension */
#undef RANDR
diff --git a/mfb/mfb.h b/mfb/mfb.h
index 001f43e53..42f3002f2 100644
--- a/mfb/mfb.h
+++ b/mfb/mfb.h
@@ -705,8 +705,8 @@ extern Bool mfbCloseScreen(
extern Bool mfbAllocatePrivates(
ScreenPtr /*pScreen*/,
- int * /*pWinIndex*/,
- int * /*pGCIndex*/
+ DevPrivateKey *pWinKey,
+ DevPrivateKey *pGCIndex
);
extern Bool mfbScreenInit(
@@ -891,14 +891,10 @@ typedef struct {
typedef mfbPrivGC *mfbPrivGCPtr;
#endif
-/* XXX these should be static, but it breaks the ABI */
-extern int mfbGCPrivateIndex; /* index into GC private array */
-extern int mfbGetGCPrivateIndex(void);
-extern int mfbWindowPrivateIndex; /* index into Window private array */
-extern int mfbGetWindowPrivateIndex(void);
+extern DevPrivateKey mfbGetGCPrivateKey(void);
+extern DevPrivateKey mfbGetWindowPrivateKey(void);
#ifdef PIXMAP_PER_WINDOW
-extern int frameWindowPrivateIndex; /* index into Window private array */
-extern int frameGetWindowPrivateIndex(void);
+extern DevPrivateKey frameGetWindowPrivateKey(void);
#endif
#ifndef MFB_PROTOTYPES_ONLY
diff --git a/mfb/mfbbitblt.c b/mfb/mfbbitblt.c
index 270fd96a7..3efee45b1 100644
--- a/mfb/mfbbitblt.c
+++ b/mfb/mfbbitblt.c
@@ -397,8 +397,7 @@ int dstx, dsty;
* must register a function for n-to-1 copy operations
*/
-static unsigned long copyPlaneGeneration;
-static int copyPlaneScreenIndex = -1;
+static DevPrivateKey copyPlaneScreenKey = &copyPlaneScreenKey;
typedef RegionPtr (*CopyPlaneFuncPtr)(
DrawablePtr /* pSrcDrawable */,
@@ -417,14 +416,7 @@ mfbRegisterCopyPlaneProc (pScreen, proc)
ScreenPtr pScreen;
CopyPlaneFuncPtr proc;
{
- if (copyPlaneGeneration != serverGeneration)
- {
- copyPlaneScreenIndex = AllocateScreenPrivateIndex();
- if (copyPlaneScreenIndex < 0)
- return FALSE;
- copyPlaneGeneration = serverGeneration;
- }
- pScreen->devPrivates[copyPlaneScreenIndex].fptr = (CopyPlaneFuncPtr)proc;
+ dixSetPrivate(&pScreen->devPrivates, copyPlaneScreenKey, proc);
return TRUE;
}
@@ -469,9 +461,9 @@ unsigned long plane;
if (pSrcDrawable->depth != 1)
{
- if (copyPlaneScreenIndex >= 0 &&
- (copyPlane = (CopyPlaneFuncPtr)
- pSrcDrawable->pScreen->devPrivates[copyPlaneScreenIndex].fptr)
+ if ((copyPlane = (CopyPlaneFuncPtr)
+ dixLookupPrivate(&pSrcDrawable->pScreen->devPrivates,
+ copyPlaneScreenKey))
)
{
return (*copyPlane) (pSrcDrawable, pDstDrawable,
diff --git a/mfb/mfbfillarc.c b/mfb/mfbfillarc.c
index 30ec00dc3..cbf47a0eb 100644
--- a/mfb/mfbfillarc.c
+++ b/mfb/mfbfillarc.c
@@ -289,7 +289,8 @@ mfbPolyFillArcSolid(pDraw, pGC, narcs, parcs)
RegionPtr cclip;
int rop;
- priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ priv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
rop = priv->rop;
if ((rop == RROP_NOP) || !(pGC->planemask & 1))
return;
diff --git a/mfb/mfbfillrct.c b/mfb/mfbfillrct.c
index f9209d096..506776b3f 100644
--- a/mfb/mfbfillrct.c
+++ b/mfb/mfbfillrct.c
@@ -96,7 +96,8 @@ mfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
if (!(pGC->planemask & 1))
return;
- priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ priv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
alu = priv->ropFillArea;
pfn = priv->FillArea;
ppix = pGC->pRotatedPixmap;
diff --git a/mfb/mfbfillsp.c b/mfb/mfbfillsp.c
index 112f5327c..e9be737da 100644
--- a/mfb/mfbfillsp.c
+++ b/mfb/mfbfillsp.c
@@ -624,7 +624,8 @@ mfbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
if (pGC->fillStyle == FillTiled)
rop = pGC->alu;
else
- rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->ropOpStip;
+ rop = ((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->ropOpStip;
flip = 0;
switch(rop)
@@ -769,7 +770,8 @@ mfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
{
pTile = pGC->stipple;
tlwidth = pTile->devKind / PGSZB;
- rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->ropOpStip;
+ rop = ((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->ropOpStip;
}
xSrc = pDrawable->x;
@@ -926,7 +928,8 @@ mfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
ppt, pwidth, fSorted);
pTile = pGC->stipple;
- rop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop;
+ rop = ((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->rop;
tlwidth = pTile->devKind / PGSZB;
xSrc = pDrawable->x;
ySrc = pDrawable->y;
diff --git a/mfb/mfbgc.c b/mfb/mfbgc.c
index c60e97676..7492d7c04 100644
--- a/mfb/mfbgc.c
+++ b/mfb/mfbgc.c
@@ -381,7 +381,8 @@ matchCommon (
FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
FONTMINBOUNDS(pGC->font,characterWidth) < 0)
return 0;
- priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ priv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
for (i = 0; i < numberCommonOps; i++) {
cop = &mfbCommonOps[i];
if ((pGC->fgPixel & 1) != cop->fg)
@@ -420,7 +421,8 @@ mfbCreateGC(pGC)
/* mfb wants to translate before scan convesion */
pGC->miTranslate = 1;
- pPriv = (mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr);
+ pPriv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
pPriv->rop = mfbReduceRop(pGC->alu, pGC->fgPixel);
pGC->fExpose = TRUE;
pGC->pRotatedPixmap = NullPixmap;
@@ -508,8 +510,8 @@ mfbValidateGC(pGC, changes, pDrawable)
new_rotate = (oldOrg.x != pGC->lastWinOrg.x) ||
(oldOrg.y != pGC->lastWinOrg.y);
- devPriv = ((mfbPrivGCPtr) (pGC->devPrivates[mfbGCPrivateIndex].ptr));
-
+ devPriv = (mfbPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
/*
if the client clip is different or moved OR
the subwindowMode has changed OR
diff --git a/mfb/mfbimggblt.c b/mfb/mfbimggblt.c
index e5c186b89..2778b625c 100644
--- a/mfb/mfbimggblt.c
+++ b/mfb/mfbimggblt.c
@@ -184,7 +184,8 @@ MFBIMAGEGLYPHBLT(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
but that is usually not a cheap thing to do.
*/
- pPrivGC = pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ pPrivGC = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
oldFillArea = pPrivGC->FillArea;
if (pGC->bgPixel & 1)
diff --git a/mfb/mfbline.c b/mfb/mfbline.c
index 863a6187b..65baa5efd 100644
--- a/mfb/mfbline.c
+++ b/mfb/mfbline.c
@@ -146,7 +146,8 @@ mfbLineSS (pDrawable, pGC, mode, npt, pptInit)
return;
cclip = pGC->pCompositeClip;
- alu = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop;
+ alu = ((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->rop;
pboxInit = REGION_RECTS(cclip);
nboxInit = REGION_NUM_RECTS(cclip);
@@ -525,7 +526,8 @@ mfbLineSD( pDrawable, pGC, mode, npt, pptInit)
return;
cclip = pGC->pCompositeClip;
- fgrop = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop;
+ fgrop = ((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->rop;
pboxInit = REGION_RECTS(cclip);
nboxInit = REGION_NUM_RECTS(cclip);
diff --git a/mfb/mfbpixmap.c b/mfb/mfbpixmap.c
index b13e3af0f..1f3f011fb 100644
--- a/mfb/mfbpixmap.c
+++ b/mfb/mfbpixmap.c
@@ -113,7 +113,7 @@ mfbDestroyPixmap(pPixmap)
{
if(--pPixmap->refcnt)
return TRUE;
- dixFreePrivates(*DEVPRIV_PTR(pPixmap));
+ dixFreePrivates(pPixmap->devPrivates);
xfree(pPixmap);
return TRUE;
}
diff --git a/mfb/mfbpntwin.c b/mfb/mfbpntwin.c
index b18797a40..725d6beb8 100644
--- a/mfb/mfbpntwin.c
+++ b/mfb/mfbpntwin.c
@@ -56,6 +56,7 @@ SOFTWARE.
#include "regionstr.h"
#include "pixmapstr.h"
#include "scrnintstr.h"
+#include "privates.h"
#include "mfb.h"
#include "maskbits.h"
@@ -69,8 +70,8 @@ mfbPaintWindow(pWin, pRegion, what)
{
register mfbPrivWin *pPrivWin;
- pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
-
+ pPrivWin = (mfbPrivWin *)dixLookupPrivate(&pWin->devPrivates,
+ mfbGetWindowPrivateKey());
switch (what) {
case PW_BACKGROUND:
switch (pWin->backgroundState) {
diff --git a/mfb/mfbpolypnt.c b/mfb/mfbpolypnt.c
index 1c4045126..146cfdce0 100644
--- a/mfb/mfbpolypnt.c
+++ b/mfb/mfbpolypnt.c
@@ -88,7 +88,8 @@ mfbPolyPoint(pDrawable, pGC, mode, npt, pptInit)
if (!(pGC->planemask & 1))
return;
- pGCPriv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+ pGCPriv = (mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey());
rop = pGCPriv->rop;
mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrl);
diff --git a/mfb/mfbscrinit.c b/mfb/mfbscrinit.c
index 13ea5d365..515e9e3ce 100644
--- a/mfb/mfbscrinit.c
+++ b/mfb/mfbscrinit.c
@@ -68,13 +68,13 @@ SOFTWARE.
#include "servermd.h"
#ifdef PIXMAP_PER_WINDOW
-int frameWindowPrivateIndex;
-int frameGetWindowPrivateIndex(void) { return frameWindowPrivateIndex; }
+static DevPrivateKey frameWindowPrivateKey = &frameWindowPrivateKey;
+DevPrivateKey frameGetWindowPrivateKey(void) { return frameWindowPrivateKey; }
#endif
-int mfbWindowPrivateIndex;
-int mfbGetWindowPrivateIndex(void) { return mfbWindowPrivateIndex; }
-int mfbGCPrivateIndex;
-int mfbGetGCPrivateIndex(void) { return mfbGCPrivateIndex; }
+static DevPrivateKey mfbWindowPrivateKey = &mfbWindowPrivateKey;
+DevPrivateKey mfbGetWindowPrivateKey(void) { return mfbWindowPrivateKey; }
+static DevPrivateKey mfbGCPrivateKey = &mfbGCPrivateKey;
+DevPrivateKey mfbGetGCPrivateKey(void) { return mfbGCPrivateKey; }
static unsigned long mfbGeneration = 0;
static VisualRec visual = {
@@ -90,30 +90,23 @@ static DepthRec depth = {
};
Bool
-mfbAllocatePrivates(pScreen, pWinIndex, pGCIndex)
- ScreenPtr pScreen;
- int *pWinIndex, *pGCIndex;
+mfbAllocatePrivates(ScreenPtr pScreen,
+ DevPrivateKey *pWinIndex, DevPrivateKey *pGCIndex)
{
if (mfbGeneration != serverGeneration)
{
-#ifdef PIXMAP_PER_WINDOW
- frameWindowPrivateIndex = AllocateWindowPrivateIndex();
-#endif
- mfbWindowPrivateIndex = AllocateWindowPrivateIndex();
- mfbGCPrivateIndex = miAllocateGCPrivateIndex();
visual.vid = FakeClientID(0);
VID = visual.vid;
mfbGeneration = serverGeneration;
}
if (pWinIndex)
- *pWinIndex = mfbWindowPrivateIndex;
+ *pWinIndex = mfbWindowPrivateKey;
if (pGCIndex)
- *pGCIndex = mfbGCPrivateIndex;
+ *pGCIndex = mfbGCPrivateKey;
pScreen->GetWindowPixmap = mfbGetWindowPixmap;
pScreen->SetWindowPixmap = mfbSetWindowPixmap;
- return (AllocateWindowPrivate(pScreen, mfbWindowPrivateIndex,
- sizeof(mfbPrivWin)) &&
- AllocateGCPrivate(pScreen, mfbGCPrivateIndex, sizeof(mfbPrivGC)));
+ return (dixRequestPrivate(mfbWindowPrivateKey, sizeof(mfbPrivWin)) &&
+ dixRequestPrivate(mfbGCPrivateKey, sizeof(mfbPrivGC)));
}
@@ -126,7 +119,7 @@ mfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width)
int dpix, dpiy; /* dots per inch */
int width; /* pixel width of frame buffer */
{
- if (!mfbAllocatePrivates(pScreen, (int *)NULL, (int *)NULL))
+ if (!mfbAllocatePrivates(pScreen, NULL, NULL))
return FALSE;
pScreen->defColormap = (Colormap) FakeClientID(0);
/* whitePixel, blackPixel */
@@ -167,7 +160,8 @@ mfbGetWindowPixmap(pWin)
WindowPtr pWin;
{
#ifdef PIXMAP_PER_WINDOW
- return (PixmapPtr)(pWin->devPrivates[frameWindowPrivateIndex].ptr);
+ return (PixmapPtr)dixLookupPrivate(&pWin->devPrivates,
+ frameWindowPrivateKey);
#else
ScreenPtr pScreen = pWin->drawable.pScreen;
@@ -181,7 +175,7 @@ mfbSetWindowPixmap(pWin, pPix)
PixmapPtr pPix;
{
#ifdef PIXMAP_PER_WINDOW
- pWin->devPrivates[frameWindowPrivateIndex].ptr = (pointer)pPix;
+ dixSetPrivate(&pWin->devPrivates, frameWindowPrivateKey, pPix);
#else
(* pWin->drawable.pScreen->SetScreenPixmap)(pPix);
#endif
diff --git a/mfb/mfbwindow.c b/mfb/mfbwindow.c
index b138d5805..c522b07a3 100644
--- a/mfb/mfbwindow.c
+++ b/mfb/mfbwindow.c
@@ -55,6 +55,7 @@ SOFTWARE.
#include <X11/X.h>
#include "scrnintstr.h"
#include "windowstr.h"
+#include "privates.h"
#include "mfb.h"
#include "mistruct.h"
#include "regionstr.h"
@@ -66,7 +67,8 @@ mfbCreateWindow(pWin)
{
register mfbPrivWin *pPrivWin;
- pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
+ pPrivWin = (mfbPrivWin *)dixLookupPrivate(&pWin->devPrivates,
+ mfbGetWindowPrivateKey());
pPrivWin->pRotatedBorder = NullPixmap;
pPrivWin->pRotatedBackground = NullPixmap;
pPrivWin->fastBackground = FALSE;
@@ -83,8 +85,8 @@ mfbDestroyWindow(pWin)
{
register mfbPrivWin *pPrivWin;
- pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
-
+ pPrivWin = (mfbPrivWin *)dixLookupPrivate(&pWin->devPrivates,
+ mfbGetWindowPrivateKey());
if (pPrivWin->pRotatedBorder)
(*pWin->drawable.pScreen->DestroyPixmap)(pPrivWin->pRotatedBorder);
if (pPrivWin->pRotatedBackground)
@@ -116,7 +118,8 @@ mfbPositionWindow(pWin, x, y)
register mfbPrivWin *pPrivWin;
int reset = 0;
- pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
+ pPrivWin = (mfbPrivWin *)dixLookupPrivate(&pWin->devPrivates,
+ mfbGetWindowPrivateKey());
if (pWin->backgroundState == BackgroundPixmap && pPrivWin->fastBackground)
{
mfbXRotatePixmap(pPrivWin->pRotatedBackground,
@@ -227,7 +230,8 @@ mfbChangeWindowAttributes(pWin, mask)
register mfbPrivWin *pPrivWin;
WindowPtr pBgWin;
- pPrivWin = (mfbPrivWin *)(pWin->devPrivates[mfbWindowPrivateIndex].ptr);
+ pPrivWin = (mfbPrivWin *)dixLookupPrivate(&pWin->devPrivates,
+ mfbGetWindowPrivateKey());
/*
* When background state changes from ParentRelative and
* we had previously rotated the fast border pixmap to match
diff --git a/mfb/mfbzerarc.c b/mfb/mfbzerarc.c
index 964e2f100..624e45fee 100644
--- a/mfb/mfbzerarc.c
+++ b/mfb/mfbzerarc.c
@@ -92,7 +92,8 @@ mfbZeroArcSS(
PixelType pmask;
register PixelType *paddr;
- if (((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop ==
+ if (((mfbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
+ mfbGetGCPrivateKey()))->rop ==
RROP_BLACK)
pixel = 0;
else
diff --git a/mi/mi.h b/mi/mi.h
index c71c9b7c0..8d8f488a0 100644
--- a/mi/mi.h
+++ b/mi/mi.h
@@ -55,6 +55,7 @@ SOFTWARE.
#include <X11/fonts/font.h>
#include "input.h"
#include "cursor.h"
+#include "privates.h"
#define MiBits CARD32
@@ -412,7 +413,7 @@ extern Bool miScreenInit(
VisualPtr /*visuals*/
);
-extern int miAllocateGCPrivateIndex(
+extern DevPrivateKey miAllocateGCPrivateIndex(
void
);
diff --git a/mi/mibank.c b/mi/mibank.c
index 00638a4c2..b52399cfe 100644
--- a/mi/mibank.c
+++ b/mi/mibank.c
@@ -177,15 +177,15 @@ typedef struct _miBankQueue
#define ALLOCATE_LOCAL_ARRAY(atype, ntype) \
(atype *)ALLOCATE_LOCAL((ntype) * sizeof(atype))
-static int miBankScreenIndex;
-static int miBankGCIndex;
+static DevPrivateKey miBankScreenKey = &miBankScreenKey;
+static DevPrivateKey miBankGCKey = &miBankGCKey;
static unsigned long miBankGeneration = 0;
-#define BANK_SCRPRIVLVAL pScreen->devPrivates[miBankScreenIndex].ptr
+#define BANK_SCRPRIVLVAL dixLookupPrivate(&pScreen->devPrivates, miBankScreenKey)
#define BANK_SCRPRIVATE ((miBankScreenPtr)(BANK_SCRPRIVLVAL))
-#define BANK_GCPRIVLVAL(pGC) (pGC)->devPrivates[miBankGCIndex].ptr
+#define BANK_GCPRIVLVAL(pGC) dixLookupPrivate(&(pGC)->devPrivates, miBankGCKey)
#define BANK_GCPRIVATE(pGC) ((miBankGCPtr)(BANK_GCPRIVLVAL(pGC)))
@@ -2116,15 +2116,9 @@ miInitializeBanking(
/* Private areas */
if (miBankGeneration != serverGeneration)
- {
- if (((miBankScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((miBankGCIndex = AllocateGCPrivateIndex()) < 0))
- return FALSE;
-
miBankGeneration = serverGeneration;
- }
- if (!AllocateGCPrivate(pScreen, miBankGCIndex,
+ if (!dixRequestPrivate(miBankGCKey,
(nBanks * sizeof(RegionPtr)) +
(sizeof(miBankGCRec) - sizeof(RegionPtr))))
return FALSE;
@@ -2273,7 +2267,7 @@ miInitializeBanking(
SCREEN_WRAP(PaintWindowBorder, miBankPaintWindow);
SCREEN_WRAP(CopyWindow, miBankCopyWindow);
- BANK_SCRPRIVLVAL = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, miBankScreenKey, pScreenPriv);
return TRUE;
}
diff --git a/mi/midispcur.c b/mi/midispcur.c
index feb6c2f98..8b782925a 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -54,8 +54,7 @@ in this Software without prior written authorization from The Open Group.
/* per-screen private data */
-static int miDCScreenIndex;
-static unsigned long miDCGeneration = 0;
+static DevPrivateKey miDCScreenKey = &miDCScreenKey;
static Bool miDCCloseScreen(int index, ScreenPtr pScreen);
@@ -117,13 +116,6 @@ miDCInitialize (pScreen, screenFuncs)
{
miDCScreenPtr pScreenPriv;
- if (miDCGeneration != serverGeneration)
- {
- miDCScreenIndex = AllocateScreenPrivateIndex ();
- if (miDCScreenIndex < 0)
- return FALSE;
- miDCGeneration = serverGeneration;
- }
pScreenPriv = (miDCScreenPtr) xalloc (sizeof (miDCScreenRec));
if (!pScreenPriv)
return FALSE;
@@ -149,7 +141,7 @@ miDCInitialize (pScreen, screenFuncs)
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = miDCCloseScreen;
- pScreen->devPrivates[miDCScreenIndex].ptr = (pointer) pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, miDCScreenKey, pScreenPriv);
if (!miSpriteInitialize (pScreen, &miDCFuncs, screenFuncs))
{
@@ -170,7 +162,8 @@ miDCCloseScreen (index, pScreen)
{
miDCScreenPtr pScreenPriv;
- pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miDCScreenKey);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
tossGC (pScreenPriv->pSourceGC);
tossGC (pScreenPriv->pMaskGC);
@@ -475,7 +468,8 @@ miDCPutUpCursor (pScreen, pCursor, x, y, source, mask)
if (!pPriv)
return FALSE;
}
- pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miDCScreenKey);
pWin = WindowTable[pScreen->myNum];
#ifdef ARGB_CURSOR
if (pPriv->pPicture)
@@ -520,7 +514,8 @@ miDCSaveUnderCursor (pScreen, x, y, w, h)
WindowPtr pWin;
GCPtr pGC;
- pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miDCScreenKey);
pSave = pScreenPriv->pSave;
pWin = WindowTable[pScreen->myNum];
if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h)
@@ -552,7 +547,8 @@ miDCRestoreUnderCursor (pScreen, x, y, w, h)
WindowPtr pWin;
GCPtr pGC;
- pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miDCScreenKey);
pSave = pScreenPriv->pSave;
pWin = WindowTable[pScreen->myNum];
if (!pSave)
@@ -578,7 +574,8 @@ miDCChangeSave (pScreen, x, y, w, h, dx, dy)
GCPtr pGC;
int sourcex, sourcey, destx, desty, copyw, copyh;
- pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miDCScreenKey);
pSave = pScreenPriv->pSave;
pWin = WindowTable[pScreen->myNum];
/*
@@ -721,7 +718,8 @@ miDCMoveCursor (pScreen, pCursor, x, y, w, h, dx, dy, source, mask)
if (!pPriv)
return FALSE;
}
- pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr;
+ pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miDCScreenKey);
pWin = WindowTable[pScreen->myNum];
pTemp = pScreenPriv->pTemp;
if (!pTemp ||
diff --git a/mi/miline.h b/mi/miline.h
index b97b8cf9d..ffa4b2743 100644
--- a/mi/miline.h
+++ b/mi/miline.h
@@ -119,9 +119,8 @@ extern void miSetZeroLineBias(
t = y1; y1 = y2; y2 = t;\
}
-#define miGetZeroLineBias(_pScreen) \
- ((miZeroLineScreenIndex < 0) ? \
- 0 : ((_pScreen)->devPrivates[miZeroLineScreenIndex].uval))
+#define miGetZeroLineBias(_pScreen) ((unsigned long) \
+ dixLookupPrivate(&(_pScreen)->devPrivates, miZeroLineScreenKey))
#define CalcLineDeltas(_x1,_y1,_x2,_y2,_adx,_ady,_sx,_sy,_SX,_SY,_octant) \
(_octant) = 0; \
@@ -148,7 +147,7 @@ extern void miSetZeroLineBias(
#define IsXDecreasingOctant(_octant) ((_octant) & XDECREASING)
#define IsYDecreasingOctant(_octant) ((_octant) & YDECREASING)
-extern int miZeroLineScreenIndex;
+extern DevPrivateKey miZeroLineScreenKey;
extern int miZeroClipLine(
int /*xmin*/,
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index 1dbb85da5..a1f32ad60 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -10,6 +10,7 @@
#include "mi.h"
#include "gcstruct.h"
#include "regionstr.h"
+#include "privates.h"
#include "mivalidate.h"
#include "mioverlay.h"
#include "migc.h"
@@ -53,9 +54,8 @@ typedef struct {
Bool copyUnderlay;
} miOverlayScreenRec, *miOverlayScreenPtr;
-static unsigned long miOverlayGeneration = 0;
-static int miOverlayWindowIndex = -1;
-static int miOverlayScreenIndex = -1;
+static DevPrivateKey miOverlayWindowKey = &miOverlayWindowKey;
+static DevPrivateKey miOverlayScreenKey = &miOverlayScreenKey;
static void RebuildTree(WindowPtr);
static Bool HasUnderlayChildren(WindowPtr);
@@ -85,10 +85,10 @@ static void miOverlaySetShape(WindowPtr);
#endif
static void miOverlayChangeBorderWidth(WindowPtr, unsigned int);
-#define MIOVERLAY_GET_SCREEN_PRIVATE(pScreen) \
- ((miOverlayScreenPtr)((pScreen)->devPrivates[miOverlayScreenIndex].ptr))
-#define MIOVERLAY_GET_WINDOW_PRIVATE(pWin) \
- ((miOverlayWindowPtr)((pWin)->devPrivates[miOverlayWindowIndex].ptr))
+#define MIOVERLAY_GET_SCREEN_PRIVATE(pScreen) ((miOverlayScreenPtr) \
+ dixLookupPrivate(&(pScreen)->devPrivates, miOverlayScreenKey))
+#define MIOVERLAY_GET_WINDOW_PRIVATE(pWin) ((miOverlayWindowPtr) \
+ dixLookupPrivate(&(pWin)->devPrivates, miOverlayWindowKey))
#define MIOVERLAY_GET_WINDOW_TREE(pWin) \
(MIOVERLAY_GET_WINDOW_PRIVATE(pWin)->tree)
@@ -112,22 +112,13 @@ miInitOverlay(
if(!inOverlayFunc || !transFunc) return FALSE;
- if(miOverlayGeneration != serverGeneration) {
- if(((miOverlayScreenIndex = AllocateScreenPrivateIndex()) < 0) ||
- ((miOverlayWindowIndex = AllocateWindowPrivateIndex()) < 0))
- return FALSE;
-
- miOverlayGeneration = serverGeneration;
- }
-
- if(!AllocateWindowPrivate(pScreen, miOverlayWindowIndex,
- sizeof(miOverlayWindowRec)))
+ if(!dixRequestPrivate(miOverlayWindowKey, sizeof(miOverlayWindowRec)))
return FALSE;
if(!(pScreenPriv = xalloc(sizeof(miOverlayScreenRec))))
return FALSE;
- pScreen->devPrivates[miOverlayScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, miOverlayScreenKey, pScreenPriv);
pScreenPriv->InOverlay = inOverlayFunc;
pScreenPriv->MakeTransparent = transFunc;
diff --git a/mi/mipointer.c b/mi/mipointer.c
index b86a26a97..4d1db4fca 100644
--- a/mi/mipointer.c
+++ b/mi/mipointer.c
@@ -41,10 +41,10 @@ in this Software without prior written authorization from The Open Group.
# include "dixstruct.h"
# include "inputstr.h"
-_X_EXPORT int miPointerScreenIndex;
-static unsigned long miPointerGeneration = 0;
+_X_EXPORT DevPrivateKey miPointerScreenKey = &miPointerScreenKey;
-#define GetScreenPrivate(s) ((miPointerScreenPtr) ((s)->devPrivates[miPointerScreenIndex].ptr))
+#define GetScreenPrivate(s) ((miPointerScreenPtr) \
+ dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey))
#define SetupScreen(s) miPointerScreenPtr pScreenPriv = GetScreenPrivate(s)
/*
@@ -76,13 +76,6 @@ miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate)
{
miPointerScreenPtr pScreenPriv;
- if (miPointerGeneration != serverGeneration)
- {
- miPointerScreenIndex = AllocateScreenPrivateIndex();
- if (miPointerScreenIndex < 0)
- return FALSE;
- miPointerGeneration = serverGeneration;
- }
pScreenPriv = (miPointerScreenPtr) xalloc (sizeof (miPointerScreenRec));
if (!pScreenPriv)
return FALSE;
@@ -99,7 +92,7 @@ miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate)
pScreenPriv->showTransparent = FALSE;
pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = miPointerCloseScreen;
- pScreen->devPrivates[miPointerScreenIndex].ptr = (pointer) pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, miPointerScreenKey, pScreenPriv);
/*
* set up screen cursor method table
*/
diff --git a/mi/mipointer.h b/mi/mipointer.h
index 1bce42c26..e864fddf4 100644
--- a/mi/mipointer.h
+++ b/mi/mipointer.h
@@ -28,6 +28,7 @@ in this Software without prior written authorization from The Open Group.
#include "cursor.h"
#include "input.h"
+#include "privates.h"
typedef struct _miPointerSpriteFuncRec {
Bool (*RealizeCursor)(
@@ -166,6 +167,6 @@ extern void miPointerSetPosition(
extern void miPointerUpdateSprite(
DeviceIntPtr pDev);
-extern int miPointerScreenIndex;
+extern DevPrivateKey miPointerScreenKey;
#endif /* MIPOINTER_H */
diff --git a/mi/miscrinit.c b/mi/miscrinit.c
index cc40cbede..2dd8cd955 100644
--- a/mi/miscrinit.c
+++ b/mi/miscrinit.c
@@ -293,35 +293,22 @@ miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
return miScreenDevPrivateInit(pScreen, width, pbits);
}
-_X_EXPORT int
+static DevPrivateKey privateKey = &privateKey;
+
+_X_EXPORT DevPrivateKey
miAllocateGCPrivateIndex()
{
- static int privateIndex = -1;
- static unsigned long miGeneration = 0;
-
- if (miGeneration != serverGeneration)
- {
- privateIndex = AllocateGCPrivateIndex();
- miGeneration = serverGeneration;
- }
- return privateIndex;
+ return privateKey;
}
-_X_EXPORT int miZeroLineScreenIndex;
-static unsigned int miZeroLineGeneration = 0;
+_X_EXPORT DevPrivateKey miZeroLineScreenKey;
_X_EXPORT void
miSetZeroLineBias(pScreen, bias)
ScreenPtr pScreen;
unsigned int bias;
{
- if (miZeroLineGeneration != serverGeneration)
- {
- miZeroLineScreenIndex = AllocateScreenPrivateIndex();
- miZeroLineGeneration = serverGeneration;
- }
- if (miZeroLineScreenIndex >= 0)
- pScreen->devPrivates[miZeroLineScreenIndex].uval = bias;
+ dixSetPrivate(&pScreen->devPrivates, miZeroLineScreenKey, (pointer)bias);
}
_X_EXPORT PixmapPtr
diff --git a/mi/misprite.c b/mi/misprite.c
index 0b402fa59..0af3368b6 100644
--- a/mi/misprite.c
+++ b/mi/misprite.c
@@ -67,8 +67,7 @@ in this Software without prior written authorization from The Open Group.
* screen wrappers
*/
-static int miSpriteScreenIndex;
-static unsigned long miSpriteGeneration = 0;
+static DevPrivateKey miSpriteScreenKey = &miSpriteScreenKey;
static Bool miSpriteCloseScreen(int i, ScreenPtr pScreen);
static void miSpriteGetImage(DrawablePtr pDrawable, int sx, int sy,
@@ -91,10 +90,9 @@ static void miSpriteStoreColors(ColormapPtr pMap, int ndef,
static void miSpriteComputeSaved(ScreenPtr pScreen);
-#define SCREEN_PROLOGUE(pScreen, field)\
- ((pScreen)->field = \
- ((miSpriteScreenPtr) (pScreen)->devPrivates[miSpriteScreenIndex].ptr)->field)
-
+#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \
+ ((miSpriteScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
+ miSpriteScreenKey))->field)
#define SCREEN_EPILOGUE(pScreen, field)\
((pScreen)->field = miSprite##field)
@@ -128,8 +126,8 @@ miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure)
ScreenPtr pScreen = closure;
miSpriteScreenPtr pScreenPriv;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
if (pScreenPriv->isUp &&
RECT_IN_REGION (pScreen, pRegion, &pScreenPriv->saved) != rgnOUT)
{
@@ -156,14 +154,6 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs)
if (!DamageSetup (pScreen))
return FALSE;
- if (miSpriteGeneration != serverGeneration)
- {
- miSpriteScreenIndex = AllocateScreenPrivateIndex ();
- if (miSpriteScreenIndex < 0)
- return FALSE;
- miSpriteGeneration = serverGeneration;
- }
-
pScreenPriv = (miSpriteScreenPtr) xalloc (sizeof (miSpriteScreenRec));
if (!pScreenPriv)
return FALSE;
@@ -214,7 +204,7 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs)
pScreenPriv->colors[MASK_COLOR].red = 0;
pScreenPriv->colors[MASK_COLOR].green = 0;
pScreenPriv->colors[MASK_COLOR].blue = 0;
- pScreen->devPrivates[miSpriteScreenIndex].ptr = (pointer) pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, miSpriteScreenKey, pScreenPriv);
pScreen->CloseScreen = miSpriteCloseScreen;
pScreen->GetImage = miSpriteGetImage;
@@ -247,8 +237,8 @@ miSpriteCloseScreen (i, pScreen)
{
miSpriteScreenPtr pScreenPriv;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
pScreen->GetImage = pScreenPriv->GetImage;
pScreen->GetSpans = pScreenPriv->GetSpans;
@@ -278,8 +268,8 @@ miSpriteGetImage (pDrawable, sx, sy, w, h, format, planemask, pdstLine)
SCREEN_PROLOGUE (pScreen, GetImage);
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
if (pDrawable->type == DRAWABLE_WINDOW &&
pScreenPriv->isUp &&
ORG_OVERLAP(&pScreenPriv->saved,pDrawable->x,pDrawable->y, sx, sy, w, h))
@@ -308,8 +298,8 @@ miSpriteGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart)
SCREEN_PROLOGUE (pScreen, GetSpans);
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp)
{
DDXPointPtr pts;
@@ -350,8 +340,8 @@ miSpriteSourceValidate (pDrawable, x, y, width, height)
SCREEN_PROLOGUE (pScreen, SourceValidate);
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp &&
ORG_OVERLAP(&pScreenPriv->saved, pDrawable->x, pDrawable->y,
x, y, width, height))
@@ -374,7 +364,8 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
SCREEN_PROLOGUE (pScreen, CopyWindow);
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
/*
* Damage will take care of destination check
*/
@@ -399,8 +390,8 @@ miSpriteBlockHandler (i, blockData, pTimeout, pReadmask)
ScreenPtr pScreen = screenInfo.screens[i];
miSpriteScreenPtr pPriv;
- pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
SCREEN_PROLOGUE(pScreen, BlockHandler);
(*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
@@ -421,8 +412,8 @@ miSpriteInstallColormap (pMap)
ScreenPtr pScreen = pMap->pScreen;
miSpriteScreenPtr pPriv;
- pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
SCREEN_PROLOGUE(pScreen, InstallColormap);
(*pScreen->InstallColormap) (pMap);
@@ -450,8 +441,8 @@ miSpriteStoreColors (pMap, ndef, pdef)
int updated;
VisualPtr pVisual;
- pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
-
+ pPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
SCREEN_PROLOGUE(pScreen, StoreColors);
(*pScreen->StoreColors) (pMap, ndef, pdef);
@@ -518,7 +509,7 @@ static void
miSpriteFindColors (ScreenPtr pScreen)
{
miSpriteScreenPtr pScreenPriv = (miSpriteScreenPtr)
- pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ dixLookupPrivate(&pScreen->devPrivates, miSpriteScreenKey);
CursorPtr pCursor;
xColorItem *sourceColor, *maskColor;
@@ -562,7 +553,8 @@ miSpriteRealizeCursor (pScreen, pCursor)
{
miSpriteScreenPtr pScreenPriv;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
if (pCursor == pScreenPriv->pCursor)
pScreenPriv->checkPixels = TRUE;
return (*pScreenPriv->funcs->RealizeCursor) (pScreen, pCursor);
@@ -575,7 +567,8 @@ miSpriteUnrealizeCursor (pScreen, pCursor)
{
miSpriteScreenPtr pScreenPriv;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
return (*pScreenPriv->funcs->UnrealizeCursor) (pScreen, pCursor);
}
@@ -588,7 +581,8 @@ miSpriteSetCursor (pScreen, pCursor, x, y)
{
miSpriteScreenPtr pScreenPriv;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
if (!pCursor)
{
pScreenPriv->shouldBeUp = FALSE;
@@ -688,7 +682,8 @@ miSpriteMoveCursor (pScreen, x, y)
{
miSpriteScreenPtr pScreenPriv;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
miSpriteSetCursor (pScreen, pScreenPriv->pCursor, x, y);
}
@@ -703,7 +698,8 @@ miSpriteRemoveCursor (pScreen)
miSpriteScreenPtr pScreenPriv;
DamageDrawInternal (pScreen, TRUE);
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
miSpriteIsUpFALSE (pScreen, pScreenPriv);
pScreenPriv->pCacheWin = NullWindow;
if (!(*pScreenPriv->funcs->RestoreUnderCursor) (pScreen,
@@ -732,7 +728,8 @@ miSpriteRestoreCursor (pScreen)
DamageDrawInternal (pScreen, TRUE);
miSpriteComputeSaved (pScreen);
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
pCursor = pScreenPriv->pCursor;
x = pScreenPriv->x - (int)pCursor->bits->xhot;
y = pScreenPriv->y - (int)pCursor->bits->yhot;
@@ -767,7 +764,8 @@ miSpriteComputeSaved (pScreen)
int wpad, hpad;
CursorPtr pCursor;
- pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr;
+ pScreenPriv = (miSpriteScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ miSpriteScreenKey);
pCursor = pScreenPriv->pCursor;
x = pScreenPriv->x - (int)pCursor->bits->xhot;
y = pScreenPriv->y - (int)pCursor->bits->yhot;
diff --git a/miext/cw/cw.c b/miext/cw/cw.c
index b03f5e3a8..df4b121d8 100644
--- a/miext/cw/cw.c
+++ b/miext/cw/cw.c
@@ -43,13 +43,12 @@
#define CW_ASSERT(x) do {} while (0)
#endif
-int cwGCIndex;
-int cwScreenIndex;
-int cwWindowIndex;
+DevPrivateKey cwGCKey = &cwGCKey;
+DevPrivateKey cwScreenKey = &cwScreenKey;
+DevPrivateKey cwWindowKey = &cwWindowKey;
#ifdef RENDER
-int cwPictureIndex;
+DevPrivateKey cwPictureKey = &cwPictureKey;
#endif
-static unsigned long cwGeneration = 0;
extern GCOps cwGCOps;
static Bool
@@ -237,7 +236,7 @@ cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable)
static void
cwChangeGC(GCPtr pGC, unsigned long mask)
{
- cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGC->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGC, pPriv);
@@ -249,7 +248,7 @@ cwChangeGC(GCPtr pGC, unsigned long mask)
static void
cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
{
- cwGCPtr pPriv = (cwGCPtr)(pGCDst)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGCDst->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGCDst, pPriv);
@@ -261,7 +260,7 @@ cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
static void
cwDestroyGC(GCPtr pGC)
{
- cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGC->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGC, pPriv);
@@ -275,7 +274,7 @@ cwDestroyGC(GCPtr pGC)
static void
cwChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
{
- cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGC->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGC, pPriv);
@@ -287,7 +286,7 @@ cwChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
static void
cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
{
- cwGCPtr pPriv = (cwGCPtr)(pgcDst)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pgcDst->devPrivates, cwGCKey);
FUNC_PROLOGUE(pgcDst, pPriv);
@@ -299,7 +298,7 @@ cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
static void
cwDestroyClip(GCPtr pGC)
{
- cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGC->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGC, pPriv);
@@ -621,34 +620,14 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
Bool has_render = GetPictureScreenIfSet(pScreen) != NULL;
#endif
- if (cwGeneration != serverGeneration)
- {
- cwScreenIndex = AllocateScreenPrivateIndex();
- if (cwScreenIndex < 0)
- return;
- cwGCIndex = AllocateGCPrivateIndex();
- cwWindowIndex = AllocateWindowPrivateIndex();
-#ifdef RENDER
- if (has_render)
- cwPictureIndex = AllocatePicturePrivateIndex();
-#endif
- cwGeneration = serverGeneration;
- }
- if (!AllocateGCPrivate(pScreen, cwGCIndex, sizeof(cwGCRec)))
- return;
- if (!AllocateWindowPrivate(pScreen, cwWindowIndex, 0))
+ if (!dixRequestPrivate(cwGCKey, sizeof(cwGCRec)))
return;
-#ifdef RENDER
- if (has_render) {
- if (!AllocatePicturePrivate(pScreen, cwPictureIndex, 0))
- return;
- }
-#endif
+
pScreenPriv = (cwScreenPtr)xalloc(sizeof(cwScreenRec));
if (!pScreenPriv)
return;
- pScreen->devPrivates[cwScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, cwScreenKey, pScreenPriv);
SCREEN_EPILOGUE(pScreen, CloseScreen, cwCloseScreen);
SCREEN_EPILOGUE(pScreen, GetImage, cwGetImage);
@@ -675,8 +654,8 @@ cwCloseScreen (int i, ScreenPtr pScreen)
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
- pScreenPriv = (cwScreenPtr)pScreen->devPrivates[cwScreenIndex].ptr;
-
+ pScreenPriv = (cwScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ cwScreenKey);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
pScreen->GetImage = pScreenPriv->GetImage;
pScreen->GetSpans = pScreenPriv->GetSpans;
diff --git a/miext/cw/cw.h b/miext/cw/cw.h
index 0d57b9b9d..45247d670 100644
--- a/miext/cw/cw.h
+++ b/miext/cw/cw.h
@@ -26,6 +26,7 @@
#include "gcstruct.h"
#include "picturestr.h"
+#include "privates.h"
/*
* One of these structures is allocated per GC that gets used with a window with
@@ -43,10 +44,10 @@ typedef struct {
GCFuncs *wrapFuncs; /* wrapped funcs */
} cwGCRec, *cwGCPtr;
-extern int cwGCIndex;
+extern DevPrivateKey cwGCKey;
-#define getCwGC(pGC) ((cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr)
-#define setCwGC(pGC,p) ((pGC)->devPrivates[cwGCIndex].ptr = (pointer) (p))
+#define getCwGC(pGC) ((cwGCPtr)dixLookupPrivate(&(pGC)->devPrivates, cwGCKey))
+#define setCwGC(pGC,p) dixSetPrivate(&(pGC)->devPrivates, cwGCKey, p)
/*
* One of these structures is allocated per Picture that gets used with a
@@ -59,17 +60,17 @@ typedef struct {
unsigned long stateChanges;
} cwPictureRec, *cwPicturePtr;
-#define getCwPicture(pPicture) \
- (pPicture->pDrawable ? (cwPicturePtr)(pPicture)->devPrivates[cwPictureIndex].ptr : 0)
-#define setCwPicture(pPicture,p) ((pPicture)->devPrivates[cwPictureIndex].ptr = (pointer) (p))
+#define getCwPicture(pPicture) (pPicture->pDrawable ? \
+ (cwPicturePtr)dixLookupPrivate(&(pPicture)->devPrivates, cwPictureKey) : 0)
+#define setCwPicture(pPicture,p) dixSetPrivate(&(pPicture)->devPrivates, cwPictureKey, p)
-extern int cwPictureIndex;
+extern DevPrivateKey cwPictureKey;
+extern DevPrivateKey cwWindowKey;
-extern int cwWindowIndex;
-
-#define cwWindowPrivate(pWindow) ((pWindow)->devPrivates[cwWindowIndex].ptr)
+#define cwWindowPrivate(pWin) dixLookupPrivate(&(pWin)->devPrivates, cwWindowKey)
#define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow))
-#define setCwPixmap(pWindow,pPixmap) (cwWindowPrivate(pWindow) = (pointer) (pPixmap))
+#define setCwPixmap(pWindow,pPixmap) \
+ dixSetPrivate(&(pWindow)->devPrivates, cwWindowKey, pPixmap)
#define cwDrawableIsRedirWindow(pDraw) \
((pDraw)->type == DRAWABLE_WINDOW && \
@@ -112,10 +113,10 @@ typedef struct {
#endif
} cwScreenRec, *cwScreenPtr;
-extern int cwScreenIndex;
+extern DevPrivateKey cwScreenKey;
-#define getCwScreen(pScreen) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr)
-#define setCwScreen(pScreen,p) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr = (p))
+#define getCwScreen(pScreen) ((cwScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, cwScreenKey))
+#define setCwScreen(pScreen,p) dixSetPrivate(&(pScreen)->devPrivates, cwScreenKey, p)
#define CW_OFFSET_XYPOINTS(ppt, npt) do { \
DDXPointPtr _ppt = (DDXPointPtr)(ppt); \
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 65314d8a9..b7f6fb550 100755
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -65,16 +65,15 @@
#define DAMAGE_DEBUG(x)
#endif
-#define getPixmapDamageRef(pPixmap) \
- ((DamagePtr *) &(pPixmap->devPrivates[damagePixPrivateIndex].ptr))
+#define getPixmapDamageRef(pPixmap) ((DamagePtr *) \
+ dixLookupPrivateAddr(&(pPixmap)->devPrivates, damagePixPrivateKey))
#define pixmapDamage(pPixmap) damagePixPriv(pPixmap)
-static int damageScrPrivateIndex;
-static int damagePixPrivateIndex;
-static int damageGCPrivateIndex;
-static int damageWinPrivateIndex;
-static int damageGeneration;
+static DevPrivateKey damageScrPrivateKey = &damageScrPrivateKey;
+static DevPrivateKey damagePixPrivateKey = &damagePixPrivateKey;
+static DevPrivateKey damageGCPrivateKey = &damageGCPrivateKey;
+static DevPrivateKey damageWinPrivateKey = &damageWinPrivateKey;
static DamagePtr *
getDrawableDamageRef (DrawablePtr pDrawable)
@@ -115,7 +114,7 @@ getDrawableDamageRef (DrawablePtr pDrawable)
#define winDamageRef(pWindow) \
DamagePtr *pPrev = (DamagePtr *) \
- &(pWindow->devPrivates[damageWinPrivateIndex].ptr)
+ dixLookupPrivateAddr(&(pWindow)->devPrivates, damageWinPrivateKey)
static void
DamageReportDamage (DamagePtr pDamage, RegionPtr pDamageRegion)
@@ -1779,30 +1778,10 @@ DamageSetup (ScreenPtr pScreen)
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
- if (damageGeneration != serverGeneration)
- {
- damageScrPrivateIndex = AllocateScreenPrivateIndex ();
- if (damageScrPrivateIndex == -1)
- return FALSE;
- damageGCPrivateIndex = AllocateGCPrivateIndex ();
- if (damageGCPrivateIndex == -1)
- return FALSE;
- damagePixPrivateIndex = AllocatePixmapPrivateIndex ();
- if (damagePixPrivateIndex == -1)
- return FALSE;
- damageWinPrivateIndex = AllocateWindowPrivateIndex ();
- if (damageWinPrivateIndex == -1)
- return FALSE;
- damageGeneration = serverGeneration;
- }
- if (pScreen->devPrivates[damageScrPrivateIndex].ptr)
+ if (dixLookupPrivate(&pScreen->devPrivates, damageScrPrivateKey))
return TRUE;
- if (!AllocateGCPrivate (pScreen, damageGCPrivateIndex, sizeof (DamageGCPrivRec)))
- return FALSE;
- if (!AllocatePixmapPrivate (pScreen, damagePixPrivateIndex, 0))
- return FALSE;
- if (!AllocateWindowPrivate (pScreen, damageWinPrivateIndex, 0))
+ if (!dixRequestPrivate(damageGCPrivateKey, sizeof(DamageGCPrivRec)))
return FALSE;
pScrPriv = (DamageScrPrivPtr) xalloc (sizeof (DamageScrPrivRec));
@@ -1827,7 +1806,7 @@ DamageSetup (ScreenPtr pScreen)
}
#endif
- pScreen->devPrivates[damageScrPrivateIndex].ptr = (pointer) pScrPriv;
+ dixSetPrivate(&pScreen->devPrivates, damageScrPrivateKey, pScrPriv);
return TRUE;
}
diff --git a/miext/damage/damagestr.h b/miext/damage/damagestr.h
index 1e0efad4f..9f3dd6684 100755
--- a/miext/damage/damagestr.h
+++ b/miext/damage/damagestr.h
@@ -29,6 +29,7 @@
#include "damage.h"
#include "gcstruct.h"
+#include "privates.h"
#ifdef RENDER
# include "picturestr.h"
#endif
@@ -80,31 +81,31 @@ typedef struct _damageGCPriv {
} DamageGCPrivRec, *DamageGCPrivPtr;
/* XXX should move these into damage.c, damageScrPrivateIndex is static */
-#define damageGetScrPriv(pScr) \
- ((DamageScrPrivPtr) (pScr)->devPrivates[damageScrPrivateIndex].ptr)
+#define damageGetScrPriv(pScr) ((DamageScrPrivPtr) \
+ dixLookupPrivate(&(pScr)->devPrivates, damageScrPrivateKey))
#define damageScrPriv(pScr) \
DamageScrPrivPtr pScrPriv = damageGetScrPriv(pScr)
#define damageGetPixPriv(pPix) \
- ((DamagePtr) (pPix)->devPrivates[damagePixPrivateIndex].ptr)
+ dixLookupPrivate(&(pPix)->devPrivates, damagePixPrivateKey)
#define damgeSetPixPriv(pPix,v) \
- ((pPix)->devPrivates[damagePixPrivateIndex].ptr = (pointer ) (v))
+ dixSetPrivate(&(pPix)->devPrivates, damagePixPrivateKey, v)
#define damagePixPriv(pPix) \
DamagePtr pDamage = damageGetPixPriv(pPix)
#define damageGetGCPriv(pGC) \
- ((DamageGCPrivPtr) (pGC)->devPrivates[damageGCPrivateIndex].ptr)
+ dixLookupPrivate(&(pGC)->devPrivates, damageGCPrivateKey)
#define damageGCPriv(pGC) \
DamageGCPrivPtr pGCPriv = damageGetGCPriv(pGC)
#define damageGetWinPriv(pWin) \
- ((DamagePtr) (pWin)->devPrivates[damageWinPrivateIndex].ptr)
+ ((DamagePtr)dixLookupPrivate(&(pWin)->devPrivates, damageWinPrivateKey))
#define damageSetWinPriv(pWin,d) \
- ((pWin)->devPrivates[damageWinPrivateIndex].ptr = (d))
+ dixSetPrivate(&(pWin)->devPrivates, damageWinPrivateKey, d)
#endif /* _DAMAGESTR_H_ */
diff --git a/miext/rootless/accel/rlAccel.c b/miext/rootless/accel/rlAccel.c
index d62bee740..a14412416 100644
--- a/miext/rootless/accel/rlAccel.c
+++ b/miext/rootless/accel/rlAccel.c
@@ -46,10 +46,10 @@ typedef struct _rlAccelScreenRec {
CloseScreenProcPtr CloseScreen;
} rlAccelScreenRec, *rlAccelScreenPtr;
-static int rlAccelScreenPrivateIndex = -1;
+static DevPrivateKey rlAccelScreenPrivateKey = &rlAccelScreenPrivateKey;
-#define RLACCELREC(pScreen) \
- ((rlAccelScreenRec *)(pScreen)->devPrivates[rlAccelScreenPrivateIndex].ptr)
+#define RLACCELREC(pScreen) ((rlAccelScreenRec *) \
+ dixLookupPrivate(&(pScreen)->devPrivates, rlAccelScreenPrivateKey))
/* This is mostly identical to fbGCOps. */
static GCOps rlAccelOps = {
@@ -128,15 +128,8 @@ rlCloseScreen (int iScreen, ScreenPtr pScreen)
Bool
RootlessAccelInit(ScreenPtr pScreen)
{
- static unsigned long rlAccelGeneration = 0;
rlAccelScreenRec *s;
- if (rlAccelGeneration != serverGeneration) {
- rlAccelScreenPrivateIndex = AllocateScreenPrivateIndex();
- if (rlAccelScreenPrivateIndex == -1) return FALSE;
- rlAccelGeneration = serverGeneration;
- }
-
s = xalloc(sizeof(rlAccelScreenRec));
if (!s) return FALSE;
RLACCELREC(pScreen) = s;
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index 3bf6af02f..5ebe35e63 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -52,9 +52,9 @@
// Global variables
-extern int rootlessGCPrivateIndex;
-extern int rootlessScreenPrivateIndex;
-extern int rootlessWindowPrivateIndex;
+extern DevPrivateKey rootlessGCPrivateKey;
+extern DevPrivateKey rootlessScreenPrivateKey;
+extern DevPrivateKey rootlessWindowPrivateKey;
// RootlessGCRec: private per-gc data
@@ -133,12 +133,17 @@ typedef struct _RootlessScreenRec {
// Accessors for screen and window privates
-#define SCREENREC(pScreen) \
- ((RootlessScreenRec *)(pScreen)->devPrivates[rootlessScreenPrivateIndex].ptr)
+#define SCREENREC(pScreen) ((RootlessScreenRec *) \
+ dixLookupPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey))
-#define WINREC(pWin) \
- ((RootlessWindowRec *)(pWin)->devPrivates[rootlessWindowPrivateIndex].ptr)
+#define SETSCREENREC(pScreen, v) \
+ dixSetPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey, v)
+#define WINREC(pWin) ((RootlessWindowRec *) \
+ dixLookupPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey))
+
+#define SETWINREC(pWin, v) \
+ dixSetPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey, v)
// Call a rootless implementation function.
// Many rootless implementation functions are allowed to be NULL.
diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c
index b26f52c54..bf129eadc 100644
--- a/miext/rootless/rootlessGC.c
+++ b/miext/rootless/rootlessGC.c
@@ -276,11 +276,11 @@ RootlessCreateGC(GCPtr pGC)
Bool result;
SCREEN_UNWRAP(pGC->pScreen, CreateGC);
- s = (RootlessScreenRec *) pGC->pScreen->
- devPrivates[rootlessScreenPrivateIndex].ptr;
+ s = SCREENREC(pGC->pScreen);
result = s->CreateGC(pGC);
- gcrec = (RootlessGCRec *) pGC->devPrivates[rootlessGCPrivateIndex].ptr;
+ gcrec = (RootlessGCRec *)
+ dixLookupPrivate(&pGC->devPrivates, rootlessGCPrivateKey);
gcrec->originalOps = NULL; // don't wrap ops yet
gcrec->originalFuncs = pGC->funcs;
pGC->funcs = &rootlessGCFuncs;
@@ -302,7 +302,7 @@ RootlessCreateGC(GCPtr pGC)
// does not assume ops have been wrapped
#define GCFUNC_UNWRAP(pGC) \
RootlessGCRec *gcrec = (RootlessGCRec *) \
- (pGC)->devPrivates[rootlessGCPrivateIndex].ptr; \
+ dixLookupPrivate(&(pGC)->devPrivates, rootlessGCPrivateKey); \
(pGC)->funcs = gcrec->originalFuncs; \
if (gcrec->originalOps) { \
(pGC)->ops = gcrec->originalOps; \
@@ -399,7 +399,7 @@ static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
// assumes both funcs and ops are wrapped
#define GCOP_UNWRAP(pGC) \
RootlessGCRec *gcrec = (RootlessGCRec *) \
- (pGC)->devPrivates[rootlessGCPrivateIndex].ptr; \
+ dixLookupPrivate(&(pGC)->devPrivates, rootlessGCPrivateKey); \
GCFuncs *saveFuncs = pGC->funcs; \
(pGC)->funcs = gcrec->originalFuncs; \
(pGC)->ops = gcrec->originalOps;
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 700de6edc..f647893de 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -61,9 +61,9 @@ extern int RootlessMiValidateTree(WindowPtr pRoot, WindowPtr pChild,
extern Bool RootlessCreateGC(GCPtr pGC);
// Initialize globals
-int rootlessGCPrivateIndex = -1;
-int rootlessScreenPrivateIndex = -1;
-int rootlessWindowPrivateIndex = -1;
+DevPrivateKey rootlessGCPrivateKey = &rootlessGCPrivateKey;
+DevPrivateKey rootlessScreenPrivateKey = &rootlessScreenPrivateKey;
+DevPrivateKey rootlessWindowPrivateKey = &rootlessWindowPrivateKey;
/*
@@ -547,28 +547,14 @@ static Bool
RootlessAllocatePrivates(ScreenPtr pScreen)
{
RootlessScreenRec *s;
- static unsigned long rootlessGeneration = 0;
-
- if (rootlessGeneration != serverGeneration) {
- rootlessScreenPrivateIndex = AllocateScreenPrivateIndex();
- if (rootlessScreenPrivateIndex == -1) return FALSE;
- rootlessGCPrivateIndex = AllocateGCPrivateIndex();
- if (rootlessGCPrivateIndex == -1) return FALSE;
- rootlessWindowPrivateIndex = AllocateWindowPrivateIndex();
- if (rootlessWindowPrivateIndex == -1) return FALSE;
- rootlessGeneration = serverGeneration;
- }
// no allocation needed for screen privates
- if (!AllocateGCPrivate(pScreen, rootlessGCPrivateIndex,
- sizeof(RootlessGCRec)))
- return FALSE;
- if (!AllocateWindowPrivate(pScreen, rootlessWindowPrivateIndex, 0))
+ if (!dixRequestPrivate(rootlessGCPrivateKey, sizeof(RootlessGCRec)))
return FALSE;
s = xalloc(sizeof(RootlessScreenRec));
if (! s) return FALSE;
- SCREENREC(pScreen) = s;
+ SETSCREENREC(pScreen, s);
s->pixmap_data = NULL;
s->pixmap_data_size = 0;
@@ -583,8 +569,7 @@ RootlessAllocatePrivates(ScreenPtr pScreen)
static void
RootlessWrap(ScreenPtr pScreen)
{
- RootlessScreenRec *s = (RootlessScreenRec*)
- pScreen->devPrivates[rootlessScreenPrivateIndex].ptr;
+ RootlessScreenRec *s = SCREENREC(pScreen);
#define WRAP(a) \
if (pScreen->a) { \
@@ -650,8 +635,7 @@ Bool RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs)
if (!RootlessAllocatePrivates(pScreen))
return FALSE;
- s = (RootlessScreenRec*)
- pScreen->devPrivates[rootlessScreenPrivateIndex].ptr;
+ s = SCREENREC(pScreen);
s->imp = procs;
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 30b7daaab..687748c2d 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -66,7 +66,7 @@ RootlessCreateWindow(WindowPtr pWin)
Bool result;
RegionRec saveRoot;
- WINREC(pWin) = NULL;
+ SETWINREC(pWin, NULL);
SCREEN_UNWRAP(pWin->drawable.pScreen, CreateWindow);
@@ -107,7 +107,7 @@ RootlessDestroyFrame(WindowPtr pWin, RootlessWindowPtr winRec)
#endif
xfree(winRec);
- WINREC(pWin) = NULL;
+ SETWINREC(pWin, NULL);
}
@@ -353,7 +353,7 @@ RootlessEnsureFrame(WindowPtr pWin)
winRec->pixmap = NULL;
winRec->wid = NULL;
- WINREC(pWin) = winRec;
+ SETWINREC(pWin, winRec);
#ifdef SHAPE
// Set the frame's shape if the window is shaped
@@ -370,7 +370,7 @@ RootlessEnsureFrame(WindowPtr pWin)
{
RL_DEBUG_MSG("implementation failed to create frame!\n");
xfree(winRec);
- WINREC(pWin) = NULL;
+ SETWINREC(pWin, NULL);
return NULL;
}
@@ -1298,8 +1298,8 @@ RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent)
/* Switch the frame record from one to the other. */
- WINREC(pWin) = NULL;
- WINREC(pTopWin) = winRec;
+ SETWINREC(pWin, NULL);
+ SETWINREC(pTopWin, winRec);
RootlessInitializeFrame(pTopWin, winRec);
RootlessReshapeFrame(pTopWin);
diff --git a/miext/shadow/shadow.c b/miext/shadow/shadow.c
index f624216db..74544b1a0 100644
--- a/miext/shadow/shadow.c
+++ b/miext/shadow/shadow.c
@@ -36,8 +36,7 @@
#include "gcstruct.h"
#include "shadow.h"
-int shadowScrPrivateIndex;
-int shadowGeneration;
+DevPrivateKey shadowScrPrivateKey = &shadowScrPrivateKey;
#define wrap(priv, real, mem) {\
priv->mem = real->mem; \
@@ -116,7 +115,8 @@ static void
shadowReportFunc(DamagePtr pDamage, RegionPtr pRegion, void *closure)
{
ScreenPtr pScreen = closure;
- shadowBufPtr pBuf = pScreen->devPrivates[shadowScrPrivateIndex].ptr;
+ shadowBufPtr pBuf = (shadowBufPtr)
+ dixLookupPrivate(&pScreen->devPrivates, shadowScrPrivateKey);
/* Register the damaged region, use DamageReportNone below when we
* want to break BC below... */
@@ -138,13 +138,6 @@ shadowSetup(ScreenPtr pScreen)
if (!DamageSetup(pScreen))
return FALSE;
- if (shadowGeneration != serverGeneration) {
- shadowScrPrivateIndex = AllocateScreenPrivateIndex();
- if (shadowScrPrivateIndex == -1)
- return FALSE;
- shadowGeneration = serverGeneration;
- }
-
pBuf = (shadowBufPtr) xalloc(sizeof(shadowBufRec));
if (!pBuf)
return FALSE;
@@ -175,7 +168,7 @@ shadowSetup(ScreenPtr pScreen)
REGION_NULL(pScreen, &pBuf->damage); /* bc */
#endif
- pScreen->devPrivates[shadowScrPrivateIndex].ptr = (pointer) pBuf;
+ dixSetPrivate(&pScreen->devPrivates, shadowScrPrivateKey, pBuf);
return TRUE;
}
diff --git a/miext/shadow/shadow.h b/miext/shadow/shadow.h
index 8986809f4..2e45df2b5 100644
--- a/miext/shadow/shadow.h
+++ b/miext/shadow/shadow.h
@@ -74,9 +74,10 @@ typedef struct _shadowBuf {
#define SHADOW_REFLECT_Y 32
#define SHADOW_REFLECT_ALL (SHADOW_REFLECT_X|SHADOW_REFLECT_Y)
-extern int shadowScrPrivateIndex;
+extern DevPrivateKey shadowScrPrivateKey;
-#define shadowGetBuf(pScr) ((shadowBufPtr) (pScr)->devPrivates[shadowScrPrivateIndex].ptr)
+#define shadowGetBuf(pScr) ((shadowBufPtr) \
+ dixLookupPrivate(&(pScr)->devPrivates, shadowScrPrivateKey))
#define shadowBuf(pScr) shadowBufPtr pBuf = shadowGetBuf(pScr)
#define shadowDamage(pBuf) DamageRegion(pBuf->pDamage)
diff --git a/randr/randr.c b/randr/randr.c
index 958f9c192..bc2b995d2 100644
--- a/randr/randr.c
+++ b/randr/randr.c
@@ -56,9 +56,9 @@ static int SProcRRDispatch (ClientPtr pClient);
int RREventBase;
int RRErrorBase;
RESTYPE RRClientType, RREventType; /* resource types for event masks */
-int RRClientPrivateIndex;
+DevPrivateKey RRClientPrivateKey = &RRClientPrivateKey;
-int rrPrivIndex = -1;
+DevPrivateKey rrPrivKey = &rrPrivKey;
static void
RRClientCallback (CallbackListPtr *list,
@@ -214,8 +214,6 @@ Bool RRInit (void)
return TRUE;
}
-static int RRScreenGeneration;
-
Bool RRScreenInit(ScreenPtr pScreen)
{
rrScrPrivPtr pScrPriv;
@@ -223,13 +221,6 @@ Bool RRScreenInit(ScreenPtr pScreen)
if (!RRInit ())
return FALSE;
- if (RRScreenGeneration != serverGeneration)
- {
- if ((rrPrivIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- RRScreenGeneration = serverGeneration;
- }
-
pScrPriv = (rrScrPrivPtr) xcalloc (1, sizeof (rrScrPrivRec));
if (!pScrPriv)
return FALSE;
@@ -333,8 +324,7 @@ RRExtensionInit (void)
if (RRNScreens == 0) return;
- RRClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (RRClientPrivateIndex,
+ if (!dixRequestPrivate(RRClientPrivateKey,
sizeof (RRClientRec) +
screenInfo.numScreens * sizeof (RRTimesRec)))
return;
diff --git a/randr/randrstr.h b/randr/randrstr.h
index bd19fe9d0..e8358bc0c 100644
--- a/randr/randrstr.h
+++ b/randr/randrstr.h
@@ -262,11 +262,11 @@ typedef struct _rrScrPriv {
#endif
} rrScrPrivRec, *rrScrPrivPtr;
-extern int rrPrivIndex;
+extern DevPrivateKey rrPrivKey;
-#define rrGetScrPriv(pScr) ((rrScrPrivPtr) (pScr)->devPrivates[rrPrivIndex].ptr)
+#define rrGetScrPriv(pScr) ((rrScrPrivPtr)dixLookupPrivate(&(pScr)->devPrivates, rrPrivKey))
#define rrScrPriv(pScr) rrScrPrivPtr pScrPriv = rrGetScrPriv(pScr)
-#define SetRRScreen(s,p) ((s)->devPrivates[rrPrivIndex].ptr = (pointer) (p))
+#define SetRRScreen(s,p) dixSetPrivate(&(s)->devPrivates, rrPrivKey, p)
/*
* each window has a list of clients requesting
@@ -298,7 +298,7 @@ typedef struct _RRClient {
} RRClientRec, *RRClientPtr;
extern RESTYPE RRClientType, RREventType; /* resource types for event masks */
-extern int RRClientPrivateIndex;
+extern DevPrivateKey RRClientPrivateKey;
extern RESTYPE RRCrtcType, RRModeType, RROutputType;
#define LookupOutput(client,id,a) ((RROutputPtr) \
@@ -311,7 +311,7 @@ extern RESTYPE RRCrtcType, RRModeType, RROutputType;
(SecurityLookupIDByType (client, id, \
RRModeType, a)))
-#define GetRRClient(pClient) ((RRClientPtr) (pClient)->devPrivates[RRClientPrivateIndex].ptr)
+#define GetRRClient(pClient) ((RRClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RRClientPrivateKey))
#define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient)
/* Initialize the extension */
diff --git a/record/record.c b/record/record.c
index 0ed8f84c2..2e65e677b 100644
--- a/record/record.c
+++ b/record/record.c
@@ -164,13 +164,13 @@ typedef struct {
ProcFunctionPtr recordVector[256];
} RecordClientPrivateRec, *RecordClientPrivatePtr;
-static int RecordClientPrivateIndex;
+static DevPrivateKey RecordClientPrivateKey = &RecordClientPrivateKey;
/* RecordClientPrivatePtr RecordClientPrivate(ClientPtr)
* gets the client private of the given client. Syntactic sugar.
*/
#define RecordClientPrivate(_pClient) (RecordClientPrivatePtr) \
- ((_pClient)->devPrivates[RecordClientPrivateIndex].ptr)
+ dixLookupPrivate(&(_pClient)->devPrivates, RecordClientPrivateKey)
/***************************************************************************/
@@ -982,8 +982,8 @@ RecordInstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
memcpy(pClientPriv->recordVector, pClient->requestVector,
sizeof (pClientPriv->recordVector));
pClientPriv->originalVector = pClient->requestVector;
- pClient->devPrivates[RecordClientPrivateIndex].ptr =
- (pointer)pClientPriv;
+ dixSetPrivate(&pClient->devPrivates,
+ RecordClientPrivateKey, pClientPriv);
pClient->requestVector = pClientPriv->recordVector;
}
while ((pIter = RecordIterateSet(pRCAP->pRequestMajorOpSet,
@@ -1096,7 +1096,8 @@ RecordUninstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient)
if (!otherRCAPwantsProcVector)
{ /* nobody needs it, so free it */
pClient->requestVector = pClientPriv->originalVector;
- pClient->devPrivates[RecordClientPrivateIndex].ptr = NULL;
+ dixSetPrivate(&pClient->devPrivates,
+ RecordClientPrivateKey, NULL);
xfree(pClientPriv);
}
} /* end if this RCAP specifies any requests */
@@ -2948,10 +2949,6 @@ RecordExtensionInit(void)
if (!RTContext)
return;
- RecordClientPrivateIndex = AllocateClientPrivateIndex();
- if (!AllocateClientPrivate(RecordClientPrivateIndex, 0))
- return;
-
ppAllContexts = NULL;
numContexts = numEnabledContexts = numEnabledRCAPs = 0;
diff --git a/render/animcur.c b/render/animcur.c
index 1f25e79d0..444d70645 100644
--- a/render/animcur.c
+++ b/render/animcur.c
@@ -87,14 +87,14 @@ static CursorBits animCursorBits = {
empty, empty, 2, 1, 1, 0, 0, 1
};
-static int AnimCurScreenPrivateIndex = -1;
static int AnimCurGeneration;
+static DevPrivateKey AnimCurScreenPrivateKey = &AnimCurScreenPrivateKey;
#define IsAnimCur(c) ((c)->bits == &animCursorBits)
#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1))
-#define GetAnimCurScreen(s) ((AnimCurScreenPtr) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr))
-#define GetAnimCurScreenIfSet(s) ((AnimCurScreenPrivateIndex != -1) ? GetAnimCurScreen(s) : NULL)
-#define SetAnimCurScreen(s,p) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr = (pointer) (p))
+#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey))
+#define GetAnimCurScreenIfSet(s) GetAnimCurScreen(s)
+#define SetAnimCurScreen(s,p) dixSetPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey, p)
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
@@ -128,8 +128,6 @@ AnimCurCloseScreen (int index, ScreenPtr pScreen)
SetAnimCurScreen(pScreen,0);
ret = (*pScreen->CloseScreen) (index, pScreen);
xfree (as);
- if (index == 0)
- AnimCurScreenPrivateIndex = -1;
return ret;
}
@@ -324,9 +322,6 @@ AnimCurInit (ScreenPtr pScreen)
if (AnimCurGeneration != serverGeneration)
{
- AnimCurScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (AnimCurScreenPrivateIndex < 0)
- return FALSE;
AnimCurGeneration = serverGeneration;
animCurState.pCursor = 0;
animCurState.pScreen = 0;
diff --git a/render/glyph.c b/render/glyph.c
index 583a52ba3..cb1534d6e 100644
--- a/render/glyph.c
+++ b/render/glyph.c
@@ -81,220 +81,18 @@ static const CARD8 glyphDepths[GlyphFormatNum] = { 1, 4, 8, 16, 32 };
static GlyphHashRec globalGlyphs[GlyphFormatNum];
-static int globalTotalGlyphPrivateSize = 0;
-
-static int glyphPrivateCount = 0;
-
-void
-ResetGlyphPrivates (void)
-{
- glyphPrivateCount = 0;
-}
-
-int
-AllocateGlyphPrivateIndex (void)
-{
- return glyphPrivateCount++;
-}
-
-Bool
-AllocateGlyphPrivate (ScreenPtr pScreen,
- int index2,
- unsigned amount)
-{
- PictureScreenPtr ps;
- unsigned oldamount;
-
- ps = GetPictureScreenIfSet (pScreen);
- if (!ps)
- return FALSE;
-
- /* Round up sizes for proper alignment */
- amount = ((amount + (sizeof (DevUnion) - 1)) / sizeof (DevUnion)) *
- sizeof (DevUnion);
-
- if (index2 >= ps->glyphPrivateLen)
- {
- unsigned *nsizes;
- nsizes = (unsigned *) xrealloc (ps->glyphPrivateSizes,
- (index2 + 1) * sizeof (unsigned));
- if (!nsizes)
- return FALSE;
-
- while (ps->glyphPrivateLen <= index2)
- {
- nsizes[ps->glyphPrivateLen++] = 0;
- ps->totalGlyphPrivateSize += sizeof (DevUnion);
- }
- ps->glyphPrivateSizes = nsizes;
- }
- oldamount = ps->glyphPrivateSizes[index2];
- if (amount > oldamount)
- {
- ps->glyphPrivateSizes[index2] = amount;
- ps->totalGlyphPrivateSize += (amount - oldamount);
- }
- ps->totalGlyphPrivateSize = BitmapBytePad (ps->totalGlyphPrivateSize * 8);
-
- return TRUE;
-}
-
static void
-SetGlyphScreenPrivateOffsets (void)
+FreeGlyphPrivates (GlyphPtr glyph)
{
- PictureScreenPtr ps;
- int offset = 0;
- int i;
+ ScreenPtr pScreen;
+ int i;
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- ps = GetPictureScreenIfSet (screenInfo.screens[i]);
- if (ps && ps->totalGlyphPrivateSize)
- {
- ps->glyphPrivateOffset = offset;
- offset += ps->totalGlyphPrivateSize / sizeof (DevUnion);
- }
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ pScreen = screenInfo.screens[i];
+ dixFreePrivates(*GetGlyphPrivatesForScreen(glyph, pScreen));
}
-}
-static void
-SetGlyphPrivatePointers (GlyphPtr glyph)
-{
- PictureScreenPtr ps;
- int i;
- char *ptr;
- DevUnion *ppriv;
- unsigned *sizes;
- unsigned size;
- int len;
-
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- ps = GetPictureScreenIfSet (screenInfo.screens[i]);
- if (ps && ps->totalGlyphPrivateSize)
- {
- ppriv = glyph->devPrivates + ps->glyphPrivateOffset;
- sizes = ps->glyphPrivateSizes;
- ptr = (char *) (ppriv + ps->glyphPrivateLen);
- for (len = ps->glyphPrivateLen; --len >= 0; ppriv++, sizes++)
- {
- if ((size = *sizes) != 0)
- {
- ppriv->ptr = (pointer) ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer) 0;
- }
- }
- }
-}
-
-static Bool
-ReallocGlobalGlyphPrivate (GlyphPtr glyph)
-{
- PictureScreenPtr ps;
- DevUnion *devPrivates;
- char *ptr;
- int i;
-
- devPrivates = xalloc (globalTotalGlyphPrivateSize);
- if (!devPrivates)
- return FALSE;
-
- ptr = (char *) devPrivates;
- for (i = 0; i < screenInfo.numScreens; i++)
- {
- ps = GetPictureScreenIfSet (screenInfo.screens[i]);
- if (ps && ps->totalGlyphPrivateSize)
- {
- if (ps->glyphPrivateOffset != -1)
- {
- memcpy (ptr, glyph->devPrivates + ps->glyphPrivateOffset,
- ps->totalGlyphPrivateSize);
- }
- else if (ps->totalGlyphPrivateSize)
- {
- memset (ptr, 0, ps->totalGlyphPrivateSize);
- }
-
- ptr += ps->totalGlyphPrivateSize;
- }
- }
-
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
-
- glyph->devPrivates = devPrivates;
-
- return TRUE;
-}
-
-Bool
-GlyphInit (ScreenPtr pScreen)
-{
- PictureScreenPtr ps = GetPictureScreen (pScreen);
-
- ps->totalGlyphPrivateSize = 0;
- ps->glyphPrivateSizes = 0;
- ps->glyphPrivateLen = 0;
- ps->glyphPrivateOffset = -1;
-
- return TRUE;
-}
-
-Bool
-GlyphFinishInit (ScreenPtr pScreen)
-{
- PictureScreenPtr ps = GetPictureScreen (pScreen);
-
- if (ps->totalGlyphPrivateSize)
- {
- GlyphPtr glyph;
- int fdepth, i;
-
- globalTotalGlyphPrivateSize += ps->totalGlyphPrivateSize;
-
- for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
- {
- if (!globalGlyphs[fdepth].hashSet)
- continue;
-
- for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
- {
- glyph = globalGlyphs[fdepth].table[i].glyph;
- if (glyph && glyph != DeletedGlyph)
- {
- if (!ReallocGlobalGlyphPrivate (glyph))
- return FALSE;
- }
- }
- }
-
- SetGlyphScreenPrivateOffsets ();
-
- for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
- {
- if (!globalGlyphs[fdepth].hashSet)
- continue;
-
- for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
- {
- glyph = globalGlyphs[fdepth].table[i].glyph;
- if (glyph && glyph != DeletedGlyph)
- {
- SetGlyphPrivatePointers (glyph);
-
- if (!(*ps->RealizeGlyph) (pScreen, glyph))
- return FALSE;
- }
- }
- }
- }
- else
- ps->glyphPrivateOffset = 0;
-
- return TRUE;
+ dixFreePrivates(glyph->devPrivates);
}
void
@@ -304,8 +102,6 @@ GlyphUninit (ScreenPtr pScreen)
GlyphPtr glyph;
int fdepth, i;
- globalTotalGlyphPrivateSize -= ps->totalGlyphPrivateSize;
-
for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
{
if (!globalGlyphs[fdepth].hashSet)
@@ -317,43 +113,20 @@ GlyphUninit (ScreenPtr pScreen)
if (glyph && glyph != DeletedGlyph)
{
(*ps->UnrealizeGlyph) (pScreen, glyph);
-
- if (globalTotalGlyphPrivateSize)
- {
- if (!ReallocGlobalGlyphPrivate (glyph))
- return;
- }
- else
- {
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
- glyph->devPrivates = NULL;
- }
+ FreeGlyphPrivates(glyph);
+ glyph->devPrivates = NULL;
}
}
}
- if (globalTotalGlyphPrivateSize)
- SetGlyphScreenPrivateOffsets ();
-
for (fdepth = 0; fdepth < GlyphFormatNum; fdepth++)
{
if (!globalGlyphs[fdepth].hashSet)
continue;
for (i = 0; i < globalGlyphs[fdepth].hashSet->size; i++)
- {
glyph = globalGlyphs[fdepth].table[i].glyph;
- if (glyph && glyph != DeletedGlyph)
- {
- if (globalTotalGlyphPrivateSize)
- SetGlyphPrivatePointers (glyph);
- }
- }
}
-
- if (ps->glyphPrivateSizes)
- xfree (ps->glyphPrivateSizes);
}
GlyphHashSetPtr
@@ -367,50 +140,6 @@ FindGlyphHashSet (CARD32 filled)
return 0;
}
-static int _GlyphSetPrivateAllocateIndex = 0;
-
-int
-AllocateGlyphSetPrivateIndex (void)
-{
- return _GlyphSetPrivateAllocateIndex++;
-}
-
-void
-ResetGlyphSetPrivateIndex (void)
-{
- _GlyphSetPrivateAllocateIndex = 0;
-}
-
-Bool
-_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr)
-{
- pointer *new;
-
- if (n > glyphSet->maxPrivate) {
- if (glyphSet->devPrivates &&
- glyphSet->devPrivates != (pointer)(&glyphSet[1])) {
- new = (pointer *) xrealloc (glyphSet->devPrivates,
- (n + 1) * sizeof (pointer));
- if (!new)
- return FALSE;
- } else {
- new = (pointer *) xalloc ((n + 1) * sizeof (pointer));
- if (!new)
- return FALSE;
- if (glyphSet->devPrivates)
- memcpy (new,
- glyphSet->devPrivates,
- (glyphSet->maxPrivate + 1) * sizeof (pointer));
- }
- glyphSet->devPrivates = new;
- /* Zero out new, uninitialize privates */
- while (++glyphSet->maxPrivate < n)
- glyphSet->devPrivates[glyphSet->maxPrivate] = (pointer)0;
- }
- glyphSet->devPrivates[n] = ptr;
- return TRUE;
-}
-
GlyphRefPtr
FindGlyphRef (GlyphHashPtr hash, CARD32 signature, Bool match, GlyphPtr compare)
{
@@ -539,8 +268,7 @@ FreeGlyph (GlyphPtr glyph, int format)
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
}
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
+ FreeGlyphPrivates(glyph);
xfree (glyph);
}
}
@@ -566,8 +294,7 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id)
if (ps)
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
}
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
+ FreeGlyphPrivates(glyph);
xfree (glyph);
glyph = gr->glyph;
}
@@ -634,16 +361,7 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth)
glyph->refcnt = 0;
glyph->size = size + sizeof (xGlyphInfo);
glyph->info = *gi;
-
- if (globalTotalGlyphPrivateSize)
- {
- glyph->devPrivates = xalloc (globalTotalGlyphPrivateSize);
- if (!glyph->devPrivates)
- return 0;
-
- SetGlyphPrivatePointers (glyph);
- } else
- glyph->devPrivates = NULL;
+ glyph->devPrivates = NULL;
for (i = 0; i < screenInfo.numScreens; i++)
{
@@ -659,8 +377,7 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth)
(*ps->UnrealizeGlyph) (screenInfo.screens[i], glyph);
}
- if (glyph->devPrivates)
- xfree (glyph->devPrivates);
+ FreeGlyphPrivates(glyph);
xfree (glyph);
return 0;
}
@@ -744,15 +461,11 @@ AllocateGlyphSet (int fdepth, PictFormatPtr format)
return FALSE;
}
- size = (sizeof (GlyphSetRec) +
- (sizeof (pointer) * _GlyphSetPrivateAllocateIndex));
+ size = sizeof (GlyphSetRec);
glyphSet = xalloc (size);
if (!glyphSet)
return FALSE;
bzero((char *)glyphSet, size);
- glyphSet->maxPrivate = _GlyphSetPrivateAllocateIndex - 1;
- if (_GlyphSetPrivateAllocateIndex)
- glyphSet->devPrivates = (pointer)(&glyphSet[1]);
if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0]))
{
@@ -792,11 +505,7 @@ FreeGlyphSet (pointer value,
else
ResizeGlyphHash (&globalGlyphs[glyphSet->fdepth], 0, TRUE);
xfree (table);
-
- if (glyphSet->devPrivates &&
- glyphSet->devPrivates != (pointer)(&glyphSet[1]))
- xfree(glyphSet->devPrivates);
-
+ dixFreePrivates(glyphSet->devPrivates);
xfree (glyphSet);
}
return Success;
diff --git a/render/glyphstr.h b/render/glyphstr.h
index 22150deee..e89f34e59 100644
--- a/render/glyphstr.h
+++ b/render/glyphstr.h
@@ -30,6 +30,7 @@
#include "screenint.h"
#include "regionstr.h"
#include "miscstruct.h"
+#include "privates.h"
#define GlyphFormat1 0
#define GlyphFormat4 1
@@ -40,7 +41,7 @@
typedef struct _Glyph {
CARD32 refcnt;
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
CARD32 size; /* info + bitmap */
xGlyphInfo info;
/* bits follow */
@@ -71,18 +72,14 @@ typedef struct _GlyphSet {
int fdepth;
GlyphHashRec hash;
int maxPrivate;
- pointer *devPrivates;
+ PrivateRec *devPrivates;
} GlyphSetRec, *GlyphSetPtr;
-#define GlyphSetGetPrivate(pGlyphSet,n) \
- ((n) > (pGlyphSet)->maxPrivate ? \
- (pointer) 0 : \
- (pGlyphSet)->devPrivates[n])
+#define GlyphSetGetPrivate(pGlyphSet,k) \
+ dixLookupPrivate(&(pGlyphSet)->devPrivates, k)
-#define GlyphSetSetPrivate(pGlyphSet,n,ptr) \
- ((n) > (pGlyphSet)->maxPrivate ? \
- _GlyphSetSetNewPrivate(pGlyphSet, n, ptr) : \
- ((((pGlyphSet)->devPrivates[n] = (ptr)) != 0) || TRUE))
+#define GlyphSetSetPrivate(pGlyphSet,k,ptr) \
+ dixSetPrivate(&(pGlyphSet)->devPrivates, k, ptr)
typedef struct _GlyphList {
INT16 xOff;
@@ -94,32 +91,6 @@ typedef struct _GlyphList {
GlyphHashSetPtr
FindGlyphHashSet (CARD32 filled);
-int
-AllocateGlyphSetPrivateIndex (void);
-
-void
-ResetGlyphSetPrivateIndex (void);
-
-Bool
-_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, pointer ptr);
-
-void
-ResetGlyphPrivates (void);
-
-int
-AllocateGlyphPrivateIndex (void);
-
-Bool
-AllocateGlyphPrivate (ScreenPtr pScreen,
- int index2,
- unsigned amount);
-
-Bool
-GlyphInit (ScreenPtr pScreen);
-
-Bool
-GlyphFinishInit (ScreenPtr pScreen);
-
void
GlyphUninit (ScreenPtr pScreen);
diff --git a/render/picture.c b/render/picture.c
index ede865f28..bc2c3b526 100644
--- a/render/picture.c
+++ b/render/picture.c
@@ -41,65 +41,14 @@
#include "servermd.h"
#include "picturestr.h"
-_X_EXPORT int PictureScreenPrivateIndex = -1;
-int PictureWindowPrivateIndex;
+_X_EXPORT DevPrivateKey PictureScreenPrivateKey = &PictureScreenPrivateKey;
+DevPrivateKey PictureWindowPrivateKey = &PictureWindowPrivateKey;
static int PictureGeneration;
RESTYPE PictureType;
RESTYPE PictFormatType;
RESTYPE GlyphSetType;
int PictureCmapPolicy = PictureCmapPolicyDefault;
-/* Picture Private machinery */
-
-static int picturePrivateCount;
-
-void
-ResetPicturePrivateIndex (void)
-{
- picturePrivateCount = 0;
-}
-
-int
-AllocatePicturePrivateIndex (void)
-{
- return picturePrivateCount++;
-}
-
-Bool
-AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount)
-{
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- unsigned int oldamount;
-
- /* Round up sizes for proper alignment */
- amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long);
-
- if (index2 >= ps->PicturePrivateLen)
- {
- unsigned int *nsizes;
-
- nsizes = (unsigned int *)xrealloc(ps->PicturePrivateSizes,
- (index2 + 1) * sizeof(unsigned int));
- if (!nsizes)
- return FALSE;
- while (ps->PicturePrivateLen <= index2)
- {
- nsizes[ps->PicturePrivateLen++] = 0;
- ps->totalPictureSize += sizeof(DevUnion);
- }
- ps->PicturePrivateSizes = nsizes;
- }
- oldamount = ps->PicturePrivateSizes[index2];
- if (amount > oldamount)
- {
- ps->PicturePrivateSizes[index2] = amount;
- ps->totalPictureSize += (amount - oldamount);
- }
-
- return TRUE;
-}
-
-
Bool
PictureDestroyWindow (WindowPtr pWindow)
{
@@ -137,8 +86,6 @@ PictureCloseScreen (int index, ScreenPtr pScreen)
(*ps->CloseIndexed) (pScreen, &ps->formats[n]);
GlyphUninit (pScreen);
SetPictureScreen(pScreen, 0);
- if (ps->PicturePrivateSizes)
- xfree (ps->PicturePrivateSizes);
xfree (ps->formats);
xfree (ps);
return ret;
@@ -497,8 +444,6 @@ PictureFinishInit (void)
for (s = 0; s < screenInfo.numScreens; s++)
{
- if (!GlyphFinishInit (screenInfo.screens[s]))
- return FALSE;
if (!PictureInitIndexedFormats (screenInfo.screens[s]))
return FALSE;
(void) AnimCurInit (screenInfo.screens[s]);
@@ -637,10 +582,6 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
GlyphSetType = CreateNewResourceType (FreeGlyphSet);
if (!GlyphSetType)
return FALSE;
- PictureScreenPrivateIndex = AllocateScreenPrivateIndex();
- if (PictureScreenPrivateIndex < 0)
- return FALSE;
- PictureWindowPrivateIndex = AllocateWindowPrivateIndex();
PictureGeneration = serverGeneration;
#ifdef XResExtension
RegisterResourceName (PictureType, "PICTURE");
@@ -648,9 +589,6 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
RegisterResourceName (GlyphSetType, "GLYPHSET");
#endif
}
- if (!AllocateWindowPrivate (pScreen, PictureWindowPrivateIndex, 0))
- return FALSE;
-
if (!formats)
{
formats = PictureCreateDefaultFormats (pScreen, &nformats);
@@ -697,18 +635,7 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats)
return FALSE;
}
SetPictureScreen(pScreen, ps);
- if (!GlyphInit (pScreen))
- {
- SetPictureScreen(pScreen, 0);
- xfree (formats);
- xfree (ps);
- return FALSE;
- }
- ps->totalPictureSize = sizeof (PictureRec);
- ps->PicturePrivateSizes = 0;
- ps->PicturePrivateLen = 0;
-
ps->formats = formats;
ps->fallback = formats;
ps->nformats = nformats;
@@ -774,37 +701,6 @@ SetPictureToDefaults (PicturePtr pPicture)
}
PicturePtr
-AllocatePicture (ScreenPtr pScreen)
-{
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- PicturePtr pPicture;
- char *ptr;
- DevUnion *ppriv;
- unsigned int *sizes;
- unsigned int size;
- int i;
-
- pPicture = (PicturePtr) xalloc (ps->totalPictureSize);
- if (!pPicture)
- return 0;
- ppriv = (DevUnion *)(pPicture + 1);
- pPicture->devPrivates = ppriv;
- sizes = ps->PicturePrivateSizes;
- ptr = (char *)(ppriv + ps->PicturePrivateLen);
- for (i = ps->PicturePrivateLen; --i >= 0; ppriv++, sizes++)
- {
- if ( (size = *sizes) )
- {
- ppriv->ptr = (pointer)ptr;
- ptr += size;
- }
- else
- ppriv->ptr = (pointer)NULL;
- }
- return pPicture;
-}
-
-PicturePtr
CreatePicture (Picture pid,
DrawablePtr pDrawable,
PictFormatPtr pFormat,
@@ -816,7 +712,7 @@ CreatePicture (Picture pid,
PicturePtr pPicture;
PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen);
- pPicture = AllocatePicture (pDrawable->pScreen);
+ pPicture = (PicturePtr)xalloc(sizeof(PictureRec));
if (!pPicture)
{
*error = BadAlloc;
@@ -827,6 +723,7 @@ CreatePicture (Picture pid,
pPicture->pDrawable = pDrawable;
pPicture->pFormat = pFormat;
pPicture->format = pFormat->format | (pDrawable->bitsPerPixel << 24);
+ pPicture->devPrivates = NULL;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
++((PixmapPtr)pDrawable)->refcnt;
@@ -1607,7 +1504,8 @@ FreePicture (pointer value,
WindowPtr pWindow = (WindowPtr) pPicture->pDrawable;
PicturePtr *pPrev;
- for (pPrev = (PicturePtr *) &((pWindow)->devPrivates[PictureWindowPrivateIndex].ptr);
+ for (pPrev = (PicturePtr *)dixLookupPrivateAddr
+ (&pWindow->devPrivates, PictureWindowPrivateKey);
*pPrev;
pPrev = &(*pPrev)->pNext)
{
@@ -1623,6 +1521,7 @@ FreePicture (pointer value,
(*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable);
}
}
+ dixFreePrivates(pPicture->devPrivates);
xfree (pPicture);
}
return Success;
diff --git a/render/picturestr.h b/render/picturestr.h
index 005c58808..aafe4e80a 100644
--- a/render/picturestr.h
+++ b/render/picturestr.h
@@ -27,6 +27,7 @@
#include "glyphstr.h"
#include "scrnintstr.h"
#include "resource.h"
+#include "privates.h"
typedef struct _DirectFormat {
CARD16 red, redMask;
@@ -173,7 +174,7 @@ typedef struct _Picture {
RegionPtr pCompositeClip;
- DevUnion *devPrivates;
+ PrivateRec *devPrivates;
PictTransform *transform;
@@ -328,10 +329,6 @@ typedef void (*UnrealizeGlyphProcPtr) (ScreenPtr pScreen,
GlyphPtr glyph);
typedef struct _PictureScreen {
- int totalPictureSize;
- unsigned int *PicturePrivateSizes;
- int PicturePrivateLen;
-
PictFormatPtr formats;
PictFormatPtr fallback;
int nformats;
@@ -389,30 +386,25 @@ typedef struct _PictureScreen {
AddTrapsProcPtr AddTraps;
- int totalGlyphPrivateSize;
- unsigned int *glyphPrivateSizes;
- int glyphPrivateLen;
- int glyphPrivateOffset;
-
RealizeGlyphProcPtr RealizeGlyph;
UnrealizeGlyphProcPtr UnrealizeGlyph;
} PictureScreenRec, *PictureScreenPtr;
-extern int PictureScreenPrivateIndex;
-extern int PictureWindowPrivateIndex;
+extern DevPrivateKey PictureScreenPrivateKey;
+extern DevPrivateKey PictureWindowPrivateKey;
extern RESTYPE PictureType;
extern RESTYPE PictFormatType;
extern RESTYPE GlyphSetType;
-#define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr))
-#define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL)
-#define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (pointer) (p))
-#define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr))
-#define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (pointer) (p))
+#define GetPictureScreen(s) ((PictureScreenPtr)dixLookupPrivate(&(s)->devPrivates, PictureScreenPrivateKey))
+#define GetPictureScreenIfSet(s) GetPictureScreen(s)
+#define SetPictureScreen(s,p) dixSetPrivate(&(s)->devPrivates, PictureScreenPrivateKey, p)
+#define GetPictureWindow(w) ((PicturePtr)dixLookupPrivate(&(w)->devPrivates, PictureWindowPrivateKey))
+#define SetPictureWindow(w,p) dixSetPrivate(&(w)->devPrivates, PictureWindowPrivateKey, p)
-#define GetGlyphPrivatesForScreen(glyph, s) \
- ((glyph)->devPrivates + (GetPictureScreen (s))->glyphPrivateOffset)
+#define GetGlyphPrivatesForScreen(glyph, s) \
+ ((PrivateRec **)dixLookupPrivateAddr(&(glyph)->devPrivates, s))
#define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\
pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\
@@ -430,15 +422,6 @@ extern RESTYPE GlyphSetType;
} \
} \
-void
-ResetPicturePrivateIndex (void);
-
-int
-AllocatePicturePrivateIndex (void);
-
-Bool
-AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount);
-
Bool
PictureDestroyWindow (WindowPtr pWindow);
@@ -501,9 +484,6 @@ PictureFinishInit (void);
void
SetPictureToDefaults (PicturePtr pPicture);
-PicturePtr
-AllocatePicture (ScreenPtr pScreen);
-
#if 0
Bool
miPictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats);
diff --git a/render/render.c b/render/render.c
index e57ffb126..7b2745758 100644
--- a/render/render.c
+++ b/render/render.c
@@ -216,14 +216,14 @@ RenderResetProc (ExtensionEntry *extEntry);
static CARD8 RenderReqCode;
#endif
int RenderErrBase;
-int RenderClientPrivateIndex;
+DevPrivateKey RenderClientPrivateKey;
typedef struct _RenderClient {
int major_version;
int minor_version;
} RenderClientRec, *RenderClientPtr;
-#define GetRenderClient(pClient) ((RenderClientPtr) (pClient)->devPrivates[RenderClientPrivateIndex].ptr)
+#define GetRenderClient(pClient) ((RenderClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RenderClientPrivateKey))
static void
RenderClientCallback (CallbackListPtr *list,
@@ -247,9 +247,7 @@ RenderExtensionInit (void)
return;
if (!PictureFinishInit ())
return;
- RenderClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (RenderClientPrivateIndex,
- sizeof (RenderClientRec)))
+ if (!dixRequestPrivate(RenderClientPrivateKey, sizeof(RenderClientRec)))
return;
if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0))
return;
@@ -268,8 +266,6 @@ RenderExtensionInit (void)
static void
RenderResetProc (ExtensionEntry *extEntry)
{
- ResetPicturePrivateIndex();
- ResetGlyphSetPrivateIndex();
}
static int
diff --git a/xfixes/cursor.c b/xfixes/cursor.c
index 450f366f2..975ebc36d 100755
--- a/xfixes/cursor.c
+++ b/xfixes/cursor.c
@@ -55,8 +55,7 @@
static RESTYPE CursorClientType;
static RESTYPE CursorHideCountType;
static RESTYPE CursorWindowType;
-static int CursorScreenPrivateIndex = -1;
-static int CursorGeneration;
+static DevPrivateKey CursorScreenPrivateKey = &CursorScreenPrivateKey;
static CursorPtr CursorCurrent;
static CursorPtr pInvisibleCursor = NULL;
@@ -113,9 +112,9 @@ typedef struct _CursorScreen {
CursorHideCountPtr pCursorHideCounts;
} CursorScreenRec, *CursorScreenPtr;
-#define GetCursorScreen(s) ((CursorScreenPtr) ((s)->devPrivates[CursorScreenPrivateIndex].ptr))
-#define GetCursorScreenIfSet(s) ((CursorScreenPrivateIndex != -1) ? GetCursorScreen(s) : NULL)
-#define SetCursorScreen(s,p) ((s)->devPrivates[CursorScreenPrivateIndex].ptr = (pointer) (p))
+#define GetCursorScreen(s) ((CursorScreenPtr)dixLookupPrivate(&(s)->devPrivates, CursorScreenPrivateKey))
+#define GetCursorScreenIfSet(s) GetCursorScreen(s)
+#define SetCursorScreen(s,p) dixSetPrivate(&(s)->devPrivates, CursorScreenPrivateKey, p)
#define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func)
#define Unwrap(as,s,elt) ((s)->elt = (as)->elt)
@@ -171,8 +170,6 @@ CursorCloseScreen (int index, ScreenPtr pScreen)
deleteCursorHideCountsForScreen(pScreen);
ret = (*pScreen->CloseScreen) (index, pScreen);
xfree (cs);
- if (index == 0)
- CursorScreenPrivateIndex = -1;
return ret;
}
@@ -1011,13 +1008,6 @@ XFixesCursorInit (void)
{
int i;
- if (CursorGeneration != serverGeneration)
- {
- CursorScreenPrivateIndex = AllocateScreenPrivateIndex ();
- if (CursorScreenPrivateIndex < 0)
- return FALSE;
- CursorGeneration = serverGeneration;
- }
for (i = 0; i < screenInfo.numScreens; i++)
{
ScreenPtr pScreen = screenInfo.screens[i];
diff --git a/xfixes/xfixes.c b/xfixes/xfixes.c
index 32dee8a18..0db49895e 100755
--- a/xfixes/xfixes.c
+++ b/xfixes/xfixes.c
@@ -56,7 +56,7 @@
static unsigned char XFixesReqCode;
int XFixesEventBase;
int XFixesErrorBase;
-static int XFixesClientPrivateIndex;
+static DevPrivateKey XFixesClientPrivateKey = &XFixesClientPrivateKey;
static int
ProcXFixesQueryVersion(ClientPtr client)
@@ -239,9 +239,7 @@ XFixesExtensionInit(void)
{
ExtensionEntry *extEntry;
- XFixesClientPrivateIndex = AllocateClientPrivateIndex ();
- if (!AllocateClientPrivate (XFixesClientPrivateIndex,
- sizeof (XFixesClientRec)))
+ if (!dixRequestPrivate(XFixesClientPrivateKey, sizeof (XFixesClientRec)))
return;
if (!AddCallback (&ClientStateCallback, XFixesClientCallback, 0))
return;
diff --git a/xfixes/xfixesint.h b/xfixes/xfixesint.h
index 48927ae0f..33a3205ed 100755
--- a/xfixes/xfixesint.h
+++ b/xfixes/xfixesint.h
@@ -66,7 +66,7 @@ typedef struct _XFixesClient {
CARD32 minor_version;
} XFixesClientRec, *XFixesClientPtr;
-#define GetXFixesClient(pClient) ((XFixesClientPtr) (pClient)->devPrivates[XFixesClientPrivateIndex].ptr)
+#define GetXFixesClient(pClient) ((XFixesClientPtr)dixLookupPrivate(&(pClient)->devPrivates, XFixesClientPrivateKey))
extern int (*ProcXFixesVector[XFixesNumberRequests])(ClientPtr);
diff --git a/xkb/ddxFakeMtn.c b/xkb/ddxFakeMtn.c
index 1060afe99..320e0ca33 100644
--- a/xkb/ddxFakeMtn.c
+++ b/xkb/ddxFakeMtn.c
@@ -107,7 +107,7 @@ ScreenPtr pScreen, oldScreen;
oldY= y;
else oldY+= y;
-#define GetScreenPrivate(s) ((miPointerScreenPtr) ((s)->devPrivates[miPointerScreenIndex].ptr))
+#define GetScreenPrivate(s) ((miPointerScreenPtr)dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey))
(*(GetScreenPrivate(oldScreen))->screenFuncs->CursorOffScreen)
(&pScreen, &oldX, &oldY);
}
diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
index 2e0c89fc2..7f0f74db1 100644
--- a/xkb/xkbActions.c
+++ b/xkb/xkbActions.c
@@ -40,8 +40,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "xkb.h"
#include <ctype.h>
-static unsigned int _xkbServerGeneration;
-static int xkbDevicePrivateIndex = -1;
+static DevPrivateKey xkbDevicePrivateKey = &xkbDevicePrivateKey;
static void
xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc,
@@ -64,20 +63,12 @@ XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc)
{
xkbDeviceInfoPtr xkbPrivPtr;
- if (serverGeneration != _xkbServerGeneration) {
- if ((xkbDevicePrivateIndex = AllocateDevicePrivateIndex()) == -1)
- return;
- _xkbServerGeneration = serverGeneration;
- }
- if (!AllocateDevicePrivate(device, xkbDevicePrivateIndex))
- return;
-
xkbPrivPtr = (xkbDeviceInfoPtr) xalloc(sizeof(xkbDeviceInfoRec));
if (!xkbPrivPtr)
return;
xkbPrivPtr->unwrapProc = NULL;
- device->devPrivates[xkbDevicePrivateIndex].ptr = xkbPrivPtr;
+ dixSetPrivate(&device->devPrivates, xkbDevicePrivateKey, xkbPrivPtr);
WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr,
proc,xkbUnwrapProc);
}