Change the devPrivates API to require dixRegisterPrivateKey

This patch only changes the API, not the implementation of the
devPrivates infrastructure. This will permit a new devPrivates
implementation to be layed into the server without requiring
simultaneous changes in every devPrivates user.

Signed-off-by: Keith Packard <keithp@keithp.com>
Tested-by: Tiago Vignatti <tiago.vignatti@nokia.com>
This commit is contained in:
Keith Packard 2010-04-26 17:22:21 -07:00
parent c865a24401
commit faeebead7b
139 changed files with 1108 additions and 714 deletions

View File

@ -36,12 +36,10 @@
#define rClient(obj) (clients[CLIENT_ID((obj)->resource)]) #define rClient(obj) (clients[CLIENT_ID((obj)->resource)])
static int GEClientPrivateKeyIndex; DevPrivateKeyRec GEClientPrivateKeyRec;
DevPrivateKey GEClientPrivateKey = &GEClientPrivateKeyIndex;
int RT_GECLIENT = 0; int RT_GECLIENT = 0;
GEExtension GEExtensions[MAXEXTENSIONS]; GEExtension GEExtensions[MAXEXTENSIONS];
/* Major available requests */ /* Major available requests */
@ -209,7 +207,7 @@ GEExtensionInit(void)
{ {
ExtensionEntry *extEntry; ExtensionEntry *extEntry;
if (!dixRequestPrivate(GEClientPrivateKey, sizeof(GEClientInfoRec))) if (!dixRegisterPrivateKey(&GEClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(GEClientInfoRec)))
FatalError("GEExtensionInit: GE private request failed.\n"); FatalError("GEExtensionInit: GE private request failed.\n");
if(!AddCallback(&ClientStateCallback, GEClientCallback, 0)) if(!AddCallback(&ClientStateCallback, GEClientCallback, 0))

View File

@ -37,7 +37,8 @@
#include "extnsionst.h" #include "extnsionst.h"
#include <X11/extensions/geproto.h> #include <X11/extensions/geproto.h>
extern _X_EXPORT DevPrivateKey GEClientPrivateKey; extern _X_EXPORT DevPrivateKeyRec GEClientPrivateKeyRec;
#define GEClientPrivateKey (&GEClientPrivateKeyRec)
typedef struct _GEClientInfo { typedef struct _GEClientInfo {
CARD32 major_version; CARD32 major_version;

View File

@ -103,10 +103,10 @@ static void PanoramiXResetProc(ExtensionEntry*);
int (* SavedProcVector[256]) (ClientPtr client) = { NULL, }; int (* SavedProcVector[256]) (ClientPtr client) = { NULL, };
static int PanoramiXGCKeyIndex; static DevPrivateKeyRec PanoramiXGCKeyRec;
static DevPrivateKey PanoramiXGCKey = &PanoramiXGCKeyIndex; #define PanoramiXGCKey (&PanoramiXGCKeyRec)
static int PanoramiXScreenKeyIndex; static DevPrivateKeyRec PanoramiXScreenKeyRec;
static DevPrivateKey PanoramiXScreenKey = &PanoramiXScreenKeyIndex; #define PanoramiXScreenKey (&PanoramiXScreenKeyRec)
typedef struct { typedef struct {
DDXPointRec clipOrg; DDXPointRec clipOrg;
@ -443,6 +443,16 @@ void PanoramiXExtensionInit(int argc, char *argv[])
if (noPanoramiXExtension) if (noPanoramiXExtension)
return; return;
if (!dixRegisterPrivateKey(&PanoramiXScreenKeyRec, PRIVATE_SCREEN, 0)) {
noPanoramiXExtension = TRUE;
return;
}
if (!dixRegisterPrivateKey(&PanoramiXGCKeyRec, PRIVATE_GC, sizeof(PanoramiXGCRec))) {
noPanoramiXExtension = TRUE;
return;
}
PanoramiXNumScreens = screenInfo.numScreens; PanoramiXNumScreens = screenInfo.numScreens;
if (PanoramiXNumScreens == 1) { /* Only 1 screen */ if (PanoramiXNumScreens == 1) { /* Only 1 screen */
noPanoramiXExtension = TRUE; noPanoramiXExtension = TRUE;
@ -462,11 +472,6 @@ void PanoramiXExtensionInit(int argc, char *argv[])
* run in non-PanoramiXeen mode. * run in non-PanoramiXeen mode.
*/ */
if (!dixRequestPrivate(PanoramiXGCKey, sizeof(PanoramiXGCRec))) {
noPanoramiXExtension = TRUE;
return;
}
for (i = 0; i < PanoramiXNumScreens; i++) { for (i = 0; i < PanoramiXNumScreens; i++) {
pScreen = screenInfo.screens[i]; pScreen = screenInfo.screens[i];
pScreenPriv = malloc(sizeof(PanoramiXScreenRec)); pScreenPriv = malloc(sizeof(PanoramiXScreenRec));

View File

@ -226,8 +226,8 @@ MakeScreenPrivate (
ScreenPtr /* pScreen */ ScreenPtr /* pScreen */
); );
static int ScreenPrivateKeyIndex; static DevPrivateKeyRec ScreenPrivateKeyRec;
static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKeyIndex; #define ScreenPrivateKey (&ScreenPrivateKeyRec)
#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \ #define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey)) dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
@ -252,6 +252,9 @@ ScreenSaverExtensionInit(INITARGS)
int i; int i;
ScreenPtr pScreen; ScreenPtr pScreen;
if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return;
AttrType = CreateNewResourceType(ScreenSaverFreeAttr, "SaverAttr"); AttrType = CreateNewResourceType(ScreenSaverFreeAttr, "SaverAttr");
SaverEventType = CreateNewResourceType(ScreenSaverFreeEvents, SaverEventType = CreateNewResourceType(ScreenSaverFreeEvents,
"SaverEvent"); "SaverEvent");

View File

@ -51,8 +51,8 @@ static RESTYPE RTEventClient;
static CallbackListPtr SecurityValidateGroupCallback = NULL; static CallbackListPtr SecurityValidateGroupCallback = NULL;
/* Private state record */ /* Private state record */
static int stateKeyIndex; static DevPrivateKeyRec stateKeyRec;
static DevPrivateKey stateKey = &stateKeyIndex; #define stateKey (&stateKeyRec)
/* This is what we store as client security state */ /* This is what we store as client security state */
typedef struct { typedef struct {
@ -1108,7 +1108,7 @@ SecurityExtensionInit(INITARGS)
RTEventClient |= RC_NEVERRETAIN; RTEventClient |= RC_NEVERRETAIN;
/* Allocate the private storage */ /* Allocate the private storage */
if (!dixRequestPrivate(stateKey, sizeof(SecurityStateRec))) if (!dixRegisterPrivateKey(stateKey, PRIVATE_CLIENT, sizeof(SecurityStateRec)))
FatalError("SecurityExtensionSetup: Can't allocate client private.\n"); FatalError("SecurityExtensionSetup: Can't allocate client private.\n");
/* Register callbacks */ /* Register callbacks */

View File

@ -141,10 +141,10 @@ int BadShmSegCode;
RESTYPE ShmSegType; RESTYPE ShmSegType;
static ShmDescPtr Shmsegs; static ShmDescPtr Shmsegs;
static Bool sharedPixmaps; static Bool sharedPixmaps;
static int shmScrPrivateKeyIndex; static DevPrivateKeyRec shmScrPrivateKeyRec;
static DevPrivateKey shmScrPrivateKey = &shmScrPrivateKeyIndex; #define shmScrPrivateKey (&shmScrPrivateKeyRec)
static int shmPixmapPrivateIndex; static DevPrivateKeyRec shmPixmapPrivateKeyRec;
static DevPrivateKey shmPixmapPrivate = &shmPixmapPrivateIndex; #define shmPixmapPrivateKey (&shmPixmapPrivateKeyRec)
static ShmFuncs miFuncs = {NULL, NULL}; static ShmFuncs miFuncs = {NULL, NULL};
static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL}; static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL};
@ -244,6 +244,16 @@ ShmInitScreenPriv(ScreenPtr pScreen)
return screen_priv; return screen_priv;
} }
static Bool
ShmRegisterPrivates(void)
{
if (!dixRegisterPrivateKey(&shmScrPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&shmPixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
return FALSE;
return TRUE;
}
void void
ShmExtensionInit(INITARGS) ShmExtensionInit(INITARGS)
{ {
@ -258,6 +268,9 @@ ShmExtensionInit(INITARGS)
} }
#endif #endif
if (!ShmRegisterPrivates())
return;
sharedPixmaps = xFalse; sharedPixmaps = xFalse;
{ {
sharedPixmaps = xTrue; sharedPixmaps = xTrue;
@ -303,6 +316,8 @@ ShmResetProc(ExtensionEntry *extEntry)
void void
ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs) ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs)
{ {
if (!ShmRegisterPrivates())
return;
ShmInitScreenPriv(pScreen)->shmFuncs = funcs; ShmInitScreenPriv(pScreen)->shmFuncs = funcs;
} }
@ -316,7 +331,7 @@ ShmDestroyPixmap (PixmapPtr pPixmap)
{ {
ShmDescPtr shmdesc; ShmDescPtr shmdesc;
shmdesc = (ShmDescPtr)dixLookupPrivate(&pPixmap->devPrivates, shmdesc = (ShmDescPtr)dixLookupPrivate(&pPixmap->devPrivates,
shmPixmapPrivate); shmPixmapPrivateKey);
if (shmdesc) if (shmdesc)
ShmDetachSegment ((pointer) shmdesc, pPixmap->drawable.id); ShmDetachSegment ((pointer) shmdesc, pPixmap->drawable.id);
} }
@ -817,7 +832,7 @@ CreatePmap:
shmdesc->addr + stuff->offset); shmdesc->addr + stuff->offset);
if (pMap) { if (pMap) {
dixSetPrivate(&pMap->devPrivates, shmPixmapPrivate, shmdesc); dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc);
shmdesc->refcnt++; shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = newPix->info[j].id; pMap->drawable.id = newPix->info[j].id;
@ -1156,7 +1171,7 @@ CreatePmap:
pDraw->pScreen->DestroyPixmap(pMap); pDraw->pScreen->DestroyPixmap(pMap);
return rc; return rc;
} }
dixSetPrivate(&pMap->devPrivates, shmPixmapPrivate, shmdesc); dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc);
shmdesc->refcnt++; shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
pMap->drawable.id = stuff->pid; pMap->drawable.id = stuff->pid;

View File

@ -59,12 +59,9 @@ typedef struct {
} SELinuxAuditRec; } SELinuxAuditRec;
/* private state keys */ /* private state keys */
static int subjectKeyIndex; DevPrivateKeyRec subjectKeyRec;
DevPrivateKey subjectKey = &subjectKeyIndex; DevPrivateKeyRec objectKeyRec;
static int objectKeyIndex; DevPrivateKeyRec dataKeyRec;
DevPrivateKey objectKey = &objectKeyIndex;
static int dataKeyIndex;
DevPrivateKey dataKey = &dataKeyIndex;
/* audit file descriptor */ /* audit file descriptor */
static int audit_fd; static int audit_fd;
@ -896,9 +893,9 @@ SELinuxFlaskInit(void)
FatalError("SELinux: Failed to open the system audit log\n"); FatalError("SELinux: Failed to open the system audit log\n");
/* Allocate private storage */ /* Allocate private storage */
if (!dixRequestPrivate(subjectKey, sizeof(SELinuxSubjectRec)) || if (!dixRegisterPrivateKey(subjectKey, PRIVATE_XSELINUX, sizeof(SELinuxSubjectRec)) ||
!dixRequestPrivate(objectKey, sizeof(SELinuxObjectRec)) || !dixRegisterPrivateKey(objectKey, PRIVATE_XSELINUX, sizeof(SELinuxObjectRec)) ||
!dixRequestPrivate(dataKey, sizeof(SELinuxObjectRec))) !dixRegisterPrivateKey(dataKey, PRIVATE_XSELINUX, sizeof(SELinuxObjectRec)))
FatalError("SELinux: Failed to allocate private storage.\n"); FatalError("SELinux: Failed to allocate private storage.\n");
/* Create atoms for doing window labeling */ /* Create atoms for doing window labeling */

View File

@ -62,9 +62,12 @@ typedef struct {
* Globals * Globals
*/ */
extern DevPrivateKey subjectKey; extern DevPrivateKeyRec subjectKeyRec;
extern DevPrivateKey objectKey; #define subjectKey (&subjectKeyRec)
extern DevPrivateKey dataKey; extern DevPrivateKeyRec objectKeyRec;
#define objectKey (&objectKeyRec)
extern DevPrivateKeyRec dataKeyRec;
#define dataKey (&dataKeyRec)
/* /*
* Label functions * Label functions

View File

@ -63,8 +63,8 @@ extern int DeviceValuator;
static EventListPtr xtest_evlist; static EventListPtr xtest_evlist;
/* Used to store if a device is an XTest Virtual device */ /* Used to store if a device is an XTest Virtual device */
static int XTestDevicePrivateKeyIndex; static DevPrivateKeyRec XTestDevicePrivateKeyRec;
DevPrivateKey XTestDevicePrivateKey = &XTestDevicePrivateKeyIndex; #define XTestDevicePrivateKey (&XTestDevicePrivateKeyRec)
/** /**
* xtestpointer * xtestpointer
@ -102,6 +102,9 @@ static DISPATCH_PROC(SProcXTestGrabControl);
void void
XTestExtensionInit(INITARGS) XTestExtensionInit(INITARGS)
{ {
if (!dixRegisterPrivateKey(&XTestDevicePrivateKeyRec, PRIVATE_DEVICE, 0))
return;
AddExtension(XTestExtensionName, 0, 0, AddExtension(XTestExtensionName, 0, 0,
ProcXTestDispatch, SProcXTestDispatch, ProcXTestDispatch, SProcXTestDispatch,
NULL, StandardMinorOpcode); NULL, StandardMinorOpcode);

View File

@ -105,8 +105,8 @@ SOFTWARE.
#endif #endif
#include "xvdisp.h" #include "xvdisp.h"
static int XvScreenKeyIndex; static DevPrivateKeyRec XvScreenKeyRec;
static DevPrivateKey XvScreenKey = &XvScreenKeyIndex; #define XvScreenKey (&XvScreenKeyRec)
unsigned long XvExtensionGeneration = 0; unsigned long XvExtensionGeneration = 0;
unsigned long XvScreenGeneration = 0; unsigned long XvScreenGeneration = 0;
unsigned long XvResourceGeneration = 0; unsigned long XvResourceGeneration = 0;
@ -156,6 +156,9 @@ XvExtensionInit(void)
{ {
ExtensionEntry *extEntry; ExtensionEntry *extEntry;
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
return;
/* LOOK TO SEE IF ANY SCREENS WERE INITIALIZED; IF NOT THEN /* LOOK TO SEE IF ANY SCREENS WERE INITIALIZED; IF NOT THEN
INIT GLOBAL VARIABLES SO THE EXTENSION CAN FUNCTION */ INIT GLOBAL VARIABLES SO THE EXTENSION CAN FUNCTION */
if (XvScreenGeneration != serverGeneration) if (XvScreenGeneration != serverGeneration)
@ -269,6 +272,9 @@ XvScreenInit(ScreenPtr pScreen)
XvScreenGeneration = serverGeneration; XvScreenGeneration = serverGeneration;
} }
if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0))
return BadAlloc;
if (dixLookupPrivate(&pScreen->devPrivates, XvScreenKey)) if (dixLookupPrivate(&pScreen->devPrivates, XvScreenKey))
{ {
ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n"); ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n");
@ -284,7 +290,6 @@ XvScreenInit(ScreenPtr pScreen)
} }
dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs); dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs);
pxvs->DestroyPixmap = pScreen->DestroyPixmap; pxvs->DestroyPixmap = pScreen->DestroyPixmap;
pxvs->DestroyWindow = pScreen->DestroyWindow; pxvs->DestroyWindow = pScreen->DestroyWindow;

View File

@ -33,8 +33,9 @@
#define DR_CLIENT_DRIVER_NAME_SIZE 48 #define DR_CLIENT_DRIVER_NAME_SIZE 48
#define DR_BUSID_SIZE 48 #define DR_BUSID_SIZE 48
static int XvMCScreenKeyIndex; static DevPrivateKeyRec XvMCScreenKeyRec;
static DevPrivateKey XvMCScreenKey; #define XvMCScreenKey (&XvMCScreenKeyRec)
static Bool XvMCInUse;
unsigned long XvMCGeneration = 0; unsigned long XvMCGeneration = 0;
@ -138,7 +139,7 @@ ProcXvMCListSurfaceTypes(ClientPtr client)
VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess); VALIDATE_XV_PORT(stuff->port, pPort, DixReadAccess);
if(XvMCScreenKey) { /* any adaptors at all */ if(XvMCInUse) { /* any adaptors at all */
ScreenPtr pScreen = pPort->pAdaptor->pScreen; ScreenPtr pScreen = pPort->pAdaptor->pScreen;
if((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */ if((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */
for(i = 0; i < pScreenPriv->num_adaptors; i++) { for(i = 0; i < pScreenPriv->num_adaptors; i++) {
@ -193,7 +194,7 @@ ProcXvMCCreateContext(ClientPtr client)
pScreen = pPort->pAdaptor->pScreen; pScreen = pPort->pAdaptor->pScreen;
if(XvMCScreenKey == NULL) /* no XvMC adaptors */ if(!XvMCInUse) /* no XvMC adaptors */
return BadMatch; return BadMatch;
if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) /* none this screen */ if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) /* none this screen */
@ -716,7 +717,8 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
{ {
XvMCScreenPtr pScreenPriv; XvMCScreenPtr pScreenPriv;
XvMCScreenKey = &XvMCScreenKeyIndex; if (!dixRegisterPrivateKey(&XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
return BadAlloc;
if(!(pScreenPriv = malloc(sizeof(XvMCScreenRec)))) if(!(pScreenPriv = malloc(sizeof(XvMCScreenRec))))
return BadAlloc; return BadAlloc;
@ -734,6 +736,8 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt)
pScreenPriv->minor = 0; pScreenPriv->minor = 0;
pScreenPriv->patchLevel = 0; pScreenPriv->patchLevel = 0;
XvMCInUse = TRUE;
return Success; return Success;
} }

View File

@ -78,5 +78,7 @@ extern int DevicePropertyNotify;
extern int RT_INPUTCLIENT; extern int RT_INPUTCLIENT;
extern DevPrivateKey XIClientPrivateKey; extern DevPrivateKeyRec XIClientPrivateKeyRec;
#define XIClientPrivateKey (&XIClientPrivateKeyRec)
#endif /* EXGLOBALS_H */ #endif /* EXGLOBALS_H */

View File

@ -377,9 +377,7 @@ Mask PropagateMask[MAXDEVICES];
* *
*/ */
static int XIClientPrivateKeyIndex; DevPrivateKeyRec XIClientPrivateKeyRec;
DevPrivateKey XIClientPrivateKey = &XIClientPrivateKeyIndex;
/***************************************************************** /*****************************************************************
* *
@ -1256,7 +1254,7 @@ XInputExtensionInit(void)
SERVER_XI_MINOR_VERSION, SERVER_XI_MINOR_VERSION,
}; };
if (!dixRequestPrivate(XIClientPrivateKey, sizeof(XIClientRec))) if (!dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec)))
FatalError("Cannot request private for XI.\n"); FatalError("Cannot request private for XI.\n");
if (!AddCallback(&ClientStateCallback, XIClientCallback, 0)) if (!AddCallback(&ClientStateCallback, XIClientCallback, 0))

View File

@ -50,8 +50,8 @@
#include "protocol-versions.h" #include "protocol-versions.h"
static CARD8 CompositeReqCode; static CARD8 CompositeReqCode;
static int CompositeClientPrivateKeyIndex; static DevPrivateKeyRec CompositeClientPrivateKeyRec;
static DevPrivateKey CompositeClientPrivateKey = &CompositeClientPrivateKeyIndex; #define CompositeClientPrivateKey (&CompositeClientPrivateKeyRec)
RESTYPE CompositeClientWindowType; RESTYPE CompositeClientWindowType;
RESTYPE CompositeClientSubwindowsType; RESTYPE CompositeClientSubwindowsType;
RESTYPE CompositeClientOverlayType; RESTYPE CompositeClientOverlayType;
@ -558,8 +558,8 @@ CompositeExtensionInit (void)
if (!CompositeClientOverlayType) if (!CompositeClientOverlayType)
return; return;
if (!dixRequestPrivate(CompositeClientPrivateKey, if (!dixRegisterPrivateKey(&CompositeClientPrivateKeyRec, PRIVATE_CLIENT,
sizeof(CompositeClientRec))) sizeof(CompositeClientRec)))
return; return;
if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0)) if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0))

View File

@ -48,13 +48,9 @@
#include "compint.h" #include "compint.h"
#include "compositeext.h" #include "compositeext.h"
static int CompScreenPrivateKeyIndex; DevPrivateKeyRec CompScreenPrivateKeyRec;
DevPrivateKey CompScreenPrivateKey = &CompScreenPrivateKeyIndex; DevPrivateKeyRec CompWindowPrivateKeyRec;
static int CompWindowPrivateKeyIndex; DevPrivateKeyRec CompSubwindowsPrivateKeyRec;
DevPrivateKey CompWindowPrivateKey = &CompWindowPrivateKeyIndex;
static int CompSubwindowsPrivateKeyIndex;
DevPrivateKey CompSubwindowsPrivateKey = &CompSubwindowsPrivateKeyIndex;
static Bool static Bool
compCloseScreen (int index, ScreenPtr pScreen) compCloseScreen (int index, ScreenPtr pScreen)
@ -319,6 +315,13 @@ compScreenInit (ScreenPtr pScreen)
{ {
CompScreenPtr cs; CompScreenPtr cs;
if (!dixRegisterPrivateKey(&CompScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&CompWindowPrivateKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
if (!dixRegisterPrivateKey(&CompSubwindowsPrivateKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
if (GetCompScreen (pScreen)) if (GetCompScreen (pScreen))
return TRUE; return TRUE;
cs = (CompScreenPtr) malloc(sizeof (CompScreenRec)); cs = (CompScreenPtr) malloc(sizeof (CompScreenRec));

View File

@ -157,9 +157,14 @@ typedef struct _CompScreen {
} CompScreenRec, *CompScreenPtr; } CompScreenRec, *CompScreenPtr;
extern DevPrivateKey CompScreenPrivateKey; extern DevPrivateKeyRec CompScreenPrivateKeyRec;
extern DevPrivateKey CompWindowPrivateKey; #define CompScreenPrivateKey (&CompScreenPrivateKeyRec)
extern DevPrivateKey CompSubwindowsPrivateKey;
extern DevPrivateKeyRec CompWindowPrivateKeyRec;
#define CompWindowPrivateKey (&CompWindowPrivateKeyRec)
extern DevPrivateKeyRec CompSubwindowsPrivateKeyRec;
#define CompSubwindowsPrivateKey (&CompSubwindowsPrivateKeyRec)
#define GetCompScreen(s) ((CompScreenPtr) \ #define GetCompScreen(s) ((CompScreenPtr) \
dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey)) dixLookupPrivate(&(s)->devPrivates, CompScreenPrivateKey))

View File

@ -32,8 +32,8 @@ static int DamageEventBase;
static RESTYPE DamageExtType; static RESTYPE DamageExtType;
static RESTYPE DamageExtWinType; static RESTYPE DamageExtWinType;
static int DamageClientPrivateKeyIndex; static DevPrivateKeyRec DamageClientPrivateKeyRec;
static DevPrivateKey DamageClientPrivateKey = &DamageClientPrivateKeyIndex; #define DamageClientPrivateKey (&DamageClientPrivateKeyRec)
#define prScreen screenInfo.screens[0] #define prScreen screenInfo.screens[0]
@ -502,8 +502,9 @@ DamageExtensionInit(void)
if (!DamageExtWinType) if (!DamageExtWinType)
return; return;
if (!dixRequestPrivate(DamageClientPrivateKey, sizeof (DamageClientRec))) if (!dixRegisterPrivateKey(&DamageClientPrivateKeyRec, PRIVATE_CLIENT, sizeof (DamageClientRec)))
return; return;
if (!AddCallback (&ClientStateCallback, DamageClientCallback, 0)) if (!AddCallback (&ClientStateCallback, DamageClientCallback, 0))
return; return;

View File

@ -57,15 +57,13 @@
/* GLOBALS */ /* GLOBALS */
/* These are static globals copied to DBE's screen private for use by DDX */ /* These are globals for use by DDX */
static int dbeScreenPrivKeyIndex; DevPrivateKeyRec dbeScreenPrivKeyRec;
static DevPrivateKey dbeScreenPrivKey = &dbeScreenPrivKeyIndex; DevPrivateKeyRec dbeWindowPrivKeyRec;
static int dbeWindowPrivKeyIndex;
static DevPrivateKey dbeWindowPrivKey = &dbeWindowPrivKeyIndex;
/* These are static globals copied to DBE's screen private for use by DDX */ /* These are globals for use by DDX */
static RESTYPE dbeDrawableResType; RESTYPE dbeDrawableResType;
static RESTYPE dbeWindowPrivResType; RESTYPE dbeWindowPrivResType;
/* Used to generate DBE's BadBuffer error. */ /* Used to generate DBE's BadBuffer error. */
static int dbeErrorBase; static int dbeErrorBase;
@ -254,7 +252,7 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
* Allocate a window priv. * Allocate a window priv.
*/ */
pDbeWindowPriv = calloc(1, sizeof(DbeWindowPrivRec)); pDbeWindowPriv = dixAllocateObjectWithPrivates(DbeWindowPrivRec, PRIVATE_DBE_WINDOW);
if (!pDbeWindowPriv) if (!pDbeWindowPriv)
return(BadAlloc); return(BadAlloc);
@ -1410,8 +1408,7 @@ DbeWindowPrivDelete(pointer pDbeWinPriv, XID id)
NULL); NULL);
/* We are done with the window priv. */ /* We are done with the window priv. */
dixFreePrivates(pDbeWindowPriv->devPrivates); dixFreeObjectWithPrivates(pDbeWindowPriv, PRIVATE_DBE_WINDOW);
free(pDbeWindowPriv);
} }
return(Success); return(Success);
@ -1576,6 +1573,12 @@ DbeExtensionInit(void)
if (!dbeWindowPrivResType) if (!dbeWindowPrivResType)
return; return;
if (!dixRegisterPrivateKey(&dbeScreenPrivKeyRec, PRIVATE_SCREEN, 0))
return;
if (!dixRegisterPrivateKey(&dbeWindowPrivKeyRec, PRIVATE_WINDOW, 0))
return;
for (i = 0; i < screenInfo.numScreens; i++) for (i = 0; i < screenInfo.numScreens; i++)
{ {
/* For each screen, set up DBE screen privates and init DIX and DDX /* For each screen, set up DBE screen privates and init DIX and DDX
@ -1602,14 +1605,6 @@ DbeExtensionInit(void)
dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, pDbeScreenPriv); dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, pDbeScreenPriv);
/* Copy the resource types */
pDbeScreenPriv->dbeDrawableResType = dbeDrawableResType;
pDbeScreenPriv->dbeWindowPrivResType = dbeWindowPrivResType;
/* Copy the private indices */
pDbeScreenPriv->dbeScreenPrivKey = dbeScreenPrivKey;
pDbeScreenPriv->dbeWindowPrivKey = dbeWindowPrivKey;
{ {
/* We don't have DDX support for DBE anymore */ /* We don't have DDX support for DBE anymore */

View File

@ -167,14 +167,6 @@ typedef struct _DbeWindowPrivRec
typedef struct _DbeScreenPrivRec typedef struct _DbeScreenPrivRec
{ {
/* Resources created by DIX to be used by DDX */
RESTYPE dbeDrawableResType;
RESTYPE dbeWindowPrivResType;
/* Private indices created by DIX to be used by DDX */
DevPrivateKey dbeScreenPrivKey;
DevPrivateKey dbeWindowPrivKey;
/* Wrapped functions /* Wrapped functions
* It is the responsibilty of the DDX layer to wrap PositionWindow(). * It is the responsibilty of the DDX layer to wrap PositionWindow().
* DbeExtensionInit wraps DestroyWindow(). * DbeExtensionInit wraps DestroyWindow().

View File

@ -58,14 +58,8 @@
#include <stdio.h> #include <stdio.h>
static int miDbeWindowPrivPrivKeyIndex; static DevPrivateKeyRec miDbeWindowPrivPrivKeyRec;
static DevPrivateKey miDbeWindowPrivPrivKey = &miDbeWindowPrivPrivKeyIndex; #define miDbeWindowPrivPrivKey (&miDbeWindowPrivPrivKeyRec)
static RESTYPE dbeDrawableResType;
static RESTYPE dbeWindowPrivResType;
static int dbeScreenPrivKeyIndex;
static DevPrivateKey dbeScreenPrivKey = &dbeScreenPrivKeyIndex;
static int dbeWindowPrivKeyIndex;
static DevPrivateKey dbeWindowPrivKey = &dbeWindowPrivKeyIndex;
/****************************************************************************** /******************************************************************************
@ -787,16 +781,8 @@ miDbeResetProc(ScreenPtr pScreen)
Bool Bool
miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv) miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
{ {
/* Copy resource types created by DIX */ if (!dixRegisterPrivateKey(&miDbeWindowPrivPrivKeyRec, PRIVATE_DBE_WINDOW,
dbeDrawableResType = pDbeScreenPriv->dbeDrawableResType; sizeof(MiDbeWindowPrivPrivRec)))
dbeWindowPrivResType = pDbeScreenPriv->dbeWindowPrivResType;
/* Copy private indices created by DIX */
dbeScreenPrivKey = pDbeScreenPriv->dbeScreenPrivKey;
dbeWindowPrivKey = pDbeScreenPriv->dbeWindowPrivKey;
if (!dixRequestPrivate(miDbeWindowPrivPrivKey,
sizeof(MiDbeWindowPrivPrivRec)))
return(FALSE); return(FALSE);
/* Wrap functions. */ /* Wrap functions. */

View File

@ -36,6 +36,8 @@
#ifndef MIDBE_H #ifndef MIDBE_H
#define MIDBE_H #define MIDBE_H
#include "privates.h"
/* EXTERNS */ /* EXTERNS */
extern Bool miDbeInit( extern Bool miDbeInit(
@ -43,5 +45,14 @@ extern Bool miDbeInit(
DbeScreenPrivPtr pDbeScreenPriv DbeScreenPrivPtr pDbeScreenPriv
); );
extern DevPrivateKeyRec dbeScreenPrivKeyRec;
#define dbeScreenPrivKey (&dbeScreenPrivKeyRec)
extern DevPrivateKeyRec dbeWindowPrivKeyRec;
#define dbeWindowPrivKey (&dbeWindowPrivKeyRec)
extern RESTYPE dbeDrawableResType;
extern RESTYPE dbeWindowPrivResType;
#endif /* MIDBE_H */ #endif /* MIDBE_H */

View File

@ -273,9 +273,20 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
if ((class | DynamicClass) == DirectColor) if ((class | DynamicClass) == DirectColor)
sizebytes *= 3; sizebytes *= 3;
sizebytes += sizeof(ColormapRec); sizebytes += sizeof(ColormapRec);
pmap = malloc(sizebytes); if (mid == pScreen->defColormap) {
if (!pmap) pmap = malloc(sizebytes);
return (BadAlloc); if (!pmap)
return (BadAlloc);
if (!dixAllocatePrivates(&pmap->devPrivates, PRIVATE_COLORMAP)) {
free (pmap);
return (BadAlloc);
}
} else {
pmap = _dixAllocateObjectWithPrivates(sizebytes, sizebytes,
offsetof(ColormapRec, devPrivates), PRIVATE_COLORMAP);
if (!pmap)
return (BadAlloc);
}
#if defined(_XSERVER64) #if defined(_XSERVER64)
pmap->pad0 = 0; pmap->pad0 = 0;
pmap->pad1 = 0; pmap->pad1 = 0;
@ -385,7 +396,6 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
pmap->numPixelsBlue[client] = size; pmap->numPixelsBlue[client] = size;
} }
} }
pmap->devPrivates = NULL;
pmap->flags |= BeingCreated; pmap->flags |= BeingCreated;
if (!AddResource(mid, RT_COLORMAP, (pointer)pmap)) if (!AddResource(mid, RT_COLORMAP, (pointer)pmap))
@ -467,8 +477,11 @@ FreeColormap (pointer value, XID mid)
} }
} }
dixFreePrivates(pmap->devPrivates); if (pmap->flags & IsDefault) {
free(pmap); dixFreePrivates(pmap->devPrivates, PRIVATE_COLORMAP);
free(pmap);
} else
dixFreeObjectWithPrivates(pmap, PRIVATE_COLORMAP);
return(Success); return(Success);
} }

View File

@ -72,6 +72,8 @@ typedef struct _GlyphShare {
static GlyphSharePtr sharedGlyphs = (GlyphSharePtr)NULL; static GlyphSharePtr sharedGlyphs = (GlyphSharePtr)NULL;
DevPrivateKeyRec cursorScreenDevPriv[MAXSCREENS];
#ifdef XFIXES #ifdef XFIXES
static CARD32 cursorSerial; static CARD32 cursorSerial;
#endif #endif
@ -86,8 +88,7 @@ FreeCursorBits(CursorBitsPtr bits)
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
free(bits->argb); free(bits->argb);
#endif #endif
dixFreePrivates(bits->devPrivates); dixFiniPrivates(bits, PRIVATE_CURSOR_BITS);
bits->devPrivates = NULL;
if (bits->refcnt == 0) if (bits->refcnt == 0)
{ {
GlyphSharePtr *prev, this; GlyphSharePtr *prev, this;
@ -128,8 +129,8 @@ FreeCursor(pointer value, XID cid)
pscr = screenInfo.screens[nscr]; pscr = screenInfo.screens[nscr];
(void)( *pscr->UnrealizeCursor)(pDev, pscr, pCurs); (void)( *pscr->UnrealizeCursor)(pDev, pscr, pCurs);
} }
dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(pCurs->bits); FreeCursorBits(pCurs->bits);
dixFiniPrivates(pCurs, PRIVATE_CURSOR);
free( pCurs); free( pCurs);
return(Success); return(Success);
} }
@ -217,6 +218,7 @@ RealizeCursorAllScreens(CursorPtr pCurs)
return Success; return Success;
} }
/** /**
* does nothing about the resource table, just creates the data structure. * does nothing about the resource table, just creates the data structure.
* does not copy the src and mask bits * does not copy the src and mask bits
@ -237,14 +239,16 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
int rc; int rc;
*ppCurs = NULL; *ppCurs = NULL;
pCurs = (CursorPtr)calloc(sizeof(CursorRec) + sizeof(CursorBits), 1); pCurs = (CursorPtr)calloc(CURSOR_REC_SIZE + CURSOR_BITS_SIZE, 1);
if (!pCurs) if (!pCurs)
{ {
free(psrcbits); free(psrcbits);
free(pmaskbits); free(pmaskbits);
return BadAlloc; return BadAlloc;
} }
bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec)); bits = (CursorBitsPtr)((char *)pCurs + CURSOR_REC_SIZE);
dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR);
dixInitPrivates(bits, bits + 1, PRIVATE_CURSOR_BITS)
bits->source = psrcbits; bits->source = psrcbits;
bits->mask = pmaskbits; bits->mask = pmaskbits;
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
@ -255,7 +259,6 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
bits->xhot = cm->xhot; bits->xhot = cm->xhot;
bits->yhot = cm->yhot; bits->yhot = cm->yhot;
pCurs->refcnt = 1; pCurs->refcnt = 1;
bits->devPrivates = NULL;
bits->refcnt = -1; bits->refcnt = -1;
CheckForEmptyMask(bits); CheckForEmptyMask(bits);
pCurs->bits = bits; pCurs->bits = bits;
@ -273,7 +276,6 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
pCurs->backBlue = backBlue; pCurs->backBlue = backBlue;
pCurs->id = cid; pCurs->id = cid;
pCurs->devPrivates = NULL;
/* security creation/labeling check */ /* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
@ -289,8 +291,8 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits,
return Success; return Success;
error: error:
dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(bits); FreeCursorBits(bits);
dixFiniPrivates(pCurs, PRIVATE_CURSOR);
free(pCurs); free(pCurs);
return rc; return rc;
@ -339,9 +341,10 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
} }
if (pShare) if (pShare)
{ {
pCurs = (CursorPtr)calloc(sizeof(CursorRec), 1); pCurs = (CursorPtr)calloc(CURSOR_REC_SIZE, 1);
if (!pCurs) if (!pCurs)
return BadAlloc; return BadAlloc;
dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR);
bits = pShare->bits; bits = pShare->bits;
bits->refcnt++; bits->refcnt++;
} }
@ -382,17 +385,17 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
if (sourcefont != maskfont) if (sourcefont != maskfont)
{ {
pCurs = pCurs =
(CursorPtr)calloc(sizeof(CursorRec) + sizeof(CursorBits), 1); (CursorPtr)calloc(CURSOR_REC_SIZE + CURSOR_BITS_SIZE, 1);
if (pCurs) if (pCurs)
bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec)); bits = (CursorBitsPtr)((char *)pCurs + CURSOR_REC_SIZE);
else else
bits = (CursorBitsPtr)NULL; bits = (CursorBitsPtr)NULL;
} }
else else
{ {
pCurs = (CursorPtr)calloc(sizeof(CursorRec), 1); pCurs = (CursorPtr)calloc(CURSOR_REC_SIZE, 1);
if (pCurs) if (pCurs)
bits = (CursorBitsPtr)calloc(sizeof(CursorBits), 1); bits = (CursorBitsPtr)calloc(CURSOR_BITS_SIZE, 1);
else else
bits = (CursorBitsPtr)NULL; bits = (CursorBitsPtr)NULL;
} }
@ -403,6 +406,8 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
free(srcbits); free(srcbits);
return BadAlloc; return BadAlloc;
} }
dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR);
dixInitPrivates(bits, bits + 1, PRIVATE_CURSOR_BITS);
bits->source = srcbits; bits->source = srcbits;
bits->mask = mskbits; bits->mask = mskbits;
#ifdef ARGB_CURSOR #ifdef ARGB_CURSOR
@ -412,7 +417,6 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
bits->height = cm.height; bits->height = cm.height;
bits->xhot = cm.xhot; bits->xhot = cm.xhot;
bits->yhot = cm.yhot; bits->yhot = cm.yhot;
bits->devPrivates = NULL;
if (sourcefont != maskfont) if (sourcefont != maskfont)
bits->refcnt = -1; bits->refcnt = -1;
else else
@ -451,7 +455,6 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
pCurs->backBlue = backBlue; pCurs->backBlue = backBlue;
pCurs->id = cid; pCurs->id = cid;
pCurs->devPrivates = NULL;
/* security creation/labeling check */ /* security creation/labeling check */
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR,
@ -467,8 +470,8 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar,
return Success; return Success;
error: error:
dixFreePrivates(pCurs->devPrivates);
FreeCursorBits(bits); FreeCursorBits(bits);
dixFiniPrivates(pCurs, PRIVATE_CURSOR);
free(pCurs); free(pCurs);
return rc; return rc;

View File

@ -255,7 +255,9 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
if (devid >= MAXDEVICES) if (devid >= MAXDEVICES)
return (DeviceIntPtr)NULL; return (DeviceIntPtr)NULL;
dev = calloc(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec), 1); dev = _dixAllocateObjectWithPrivates(sizeof(DeviceIntRec) + sizeof(SpriteInfoRec),
sizeof(DeviceIntRec) + sizeof(SpriteInfoRec),
offsetof(DeviceIntRec, devPrivates), PRIVATE_DEVICE);
if (!dev) if (!dev)
return (DeviceIntPtr)NULL; return (DeviceIntPtr)NULL;
dev->id = devid; dev->id = devid;
@ -936,8 +938,7 @@ CloseDevice(DeviceIntPtr dev)
} }
free(dev->deviceGrab.sync.event); free(dev->deviceGrab.sync.event);
dixFreePrivates(dev->devPrivates); dixFreeObjectWithPrivates(dev, PRIVATE_DEVICE);
free(dev);
} }
/** /**

View File

@ -3498,8 +3498,7 @@ CloseDownClient(ClientPtr client)
nextFreeClientID = client->index; nextFreeClientID = client->index;
clients[client->index] = NullClient; clients[client->index] = NullClient;
SmartLastClient = NullClient; SmartLastClient = NullClient;
dixFreePrivates(client->devPrivates); dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
free(client);
while (!clients[currentMaxClients-1]) while (!clients[currentMaxClients-1])
currentMaxClients--; currentMaxClients--;
@ -3520,7 +3519,6 @@ KillAllClients(void)
void InitClient(ClientPtr client, int i, pointer ospriv) void InitClient(ClientPtr client, int i, pointer ospriv)
{ {
memset(client, 0, sizeof(*client));
client->index = i; client->index = i;
client->clientAsMask = ((Mask)i) << CLIENTOFFSET; client->clientAsMask = ((Mask)i) << CLIENTOFFSET;
client->closeDownMode = i ? DestroyAll : RetainPermanent; client->closeDownMode = i ? DestroyAll : RetainPermanent;
@ -3548,13 +3546,13 @@ ClientPtr NextAvailableClient(pointer ospriv)
i = nextFreeClientID; i = nextFreeClientID;
if (i == MAXCLIENTS) if (i == MAXCLIENTS)
return (ClientPtr)NULL; return (ClientPtr)NULL;
clients[i] = client = malloc(sizeof(ClientRec)); clients[i] = client = dixAllocateObjectWithPrivates(ClientRec, PRIVATE_CLIENT);
if (!client) if (!client)
return (ClientPtr)NULL; return (ClientPtr)NULL;
InitClient(client, i, ospriv); InitClient(client, i, ospriv);
if (!InitClientResources(client)) if (!InitClientResources(client))
{ {
free(client); dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
return (ClientPtr)NULL; return (ClientPtr)NULL;
} }
data.reqType = 1; data.reqType = 1;
@ -3562,7 +3560,7 @@ ClientPtr NextAvailableClient(pointer ospriv)
if (!InsertFakeRequest(client, (char *)&data, sz_xReq)) if (!InsertFakeRequest(client, (char *)&data, sz_xReq))
{ {
FreeClientResources(client); FreeClientResources(client);
free(client); dixFreeObjectWithPrivates(client, PRIVATE_CLIENT);
return (ClientPtr)NULL; return (ClientPtr)NULL;
} }
if (i == currentMaxClients) if (i == currentMaxClients)
@ -3868,9 +3866,12 @@ AddScreen(
if (!pScreen) if (!pScreen)
return -1; return -1;
pScreen->devPrivates = NULL; if (!dixAllocatePrivates(&pScreen->devPrivates, PRIVATE_SCREEN)) {
free (pScreen);
return -1;
}
pScreen->myNum = i; pScreen->myNum = i;
pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8); pScreen->totalPixmapSize = 0; /* computed in CreateScratchPixmapForScreen */
pScreen->ClipNotify = 0; /* for R4 ddx compatibility */ pScreen->ClipNotify = 0; /* for R4 ddx compatibility */
pScreen->CreateScreenResources = 0; pScreen->CreateScreenResources = 0;
@ -3920,10 +3921,13 @@ AddScreen(
screenInfo.numScreens++; screenInfo.numScreens++;
if (!(*pfnInit)(i, pScreen, argc, argv)) if (!(*pfnInit)(i, pScreen, argc, argv))
{ {
dixFreePrivates(pScreen->devPrivates); dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
free(pScreen); free(pScreen);
screenInfo.numScreens--; screenInfo.numScreens--;
return -1; return -1;
} }
dixRegisterPrivateKey(&cursorScreenDevPriv[i], PRIVATE_CURSOR, 0);
return i; return i;
} }

View File

@ -89,15 +89,19 @@ AddExtension(char *name, int NumEvents, int NumErrors,
return((ExtensionEntry *) NULL); return((ExtensionEntry *) NULL);
} }
ext = malloc(sizeof(ExtensionEntry)); ext = calloc(sizeof (ExtensionEntry), 1);
if (!ext) if (!ext)
return(NULL); return(NULL);
if (!dixAllocatePrivates(&ext->devPrivates, PRIVATE_EXTENSION)) {
free(ext);
return(NULL);
}
ext->name = malloc(strlen(name) + 1); ext->name = malloc(strlen(name) + 1);
ext->num_aliases = 0; ext->num_aliases = 0;
ext->aliases = (char **)NULL; ext->aliases = (char **)NULL;
ext->devPrivates = NULL;
if (!ext->name) if (!ext->name)
{ {
dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
free(ext); free(ext);
return((ExtensionEntry *) NULL); return((ExtensionEntry *) NULL);
} }
@ -108,6 +112,7 @@ AddExtension(char *name, int NumEvents, int NumErrors,
if (!newexts) if (!newexts)
{ {
free(ext->name); free(ext->name);
dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
free(ext); free(ext);
return((ExtensionEntry *) NULL); return((ExtensionEntry *) NULL);
} }
@ -253,7 +258,7 @@ CloseDownExtensions(void)
for (j = extensions[i]->num_aliases; --j >= 0;) for (j = extensions[i]->num_aliases; --j >= 0;)
free(extensions[i]->aliases[j]); free(extensions[i]->aliases[j]);
free(extensions[i]->aliases); free(extensions[i]->aliases);
dixFreePrivates(extensions[i]->devPrivates); dixFreePrivates(extensions[i]->devPrivates, PRIVATE_EXTENSION);
free(extensions[i]); free(extensions[i]);
} }
free(extensions); free(extensions);

View File

@ -479,7 +479,7 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus,
{ {
GCPtr pGC; GCPtr pGC;
pGC = malloc(sizeof(GC)); pGC = dixAllocateObjectWithPrivates(GC, PRIVATE_GC);
if (!pGC) if (!pGC)
{ {
*pStatus = BadAlloc; *pStatus = BadAlloc;
@ -492,7 +492,6 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus,
pGC->planemask = ~0; pGC->planemask = ~0;
pGC->serialNumber = GC_CHANGE_SERIAL_BIT; pGC->serialNumber = GC_CHANGE_SERIAL_BIT;
pGC->funcs = 0; pGC->funcs = 0;
pGC->devPrivates = NULL;
pGC->fgPixel = 0; pGC->fgPixel = 0;
pGC->bgPixel = 1; pGC->bgPixel = 1;
pGC->lineWidth = 0; pGC->lineWidth = 0;
@ -785,8 +784,7 @@ FreeGC(pointer value, XID gid)
(*pGC->funcs->DestroyGC) (pGC); (*pGC->funcs->DestroyGC) (pGC);
if (pGC->dash != DefaultDash) if (pGC->dash != DefaultDash)
free(pGC->dash); free(pGC->dash);
dixFreePrivates(pGC->devPrivates); dixFreeObjectWithPrivates(pGC, PRIVATE_GC);
free(pGC);
return(Success); return(Success);
} }
@ -808,7 +806,7 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth)
{ {
GCPtr pGC; GCPtr pGC;
pGC = malloc(sizeof(GC)); pGC = dixAllocateObjectWithPrivates(GC, PRIVATE_GC);
if (!pGC) if (!pGC)
return (GCPtr)NULL; return (GCPtr)NULL;
@ -817,7 +815,6 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth)
pGC->alu = GXcopy; /* dst <- src */ pGC->alu = GXcopy; /* dst <- src */
pGC->planemask = ~0; pGC->planemask = ~0;
pGC->serialNumber = 0; pGC->serialNumber = 0;
pGC->devPrivates = NULL;
pGC->fgPixel = 0; pGC->fgPixel = 0;
pGC->bgPixel = 1; pGC->bgPixel = 1;
pGC->lineWidth = 0; pGC->lineWidth = 0;

View File

@ -123,8 +123,6 @@ CursorPtr rootCursor;
Bool party_like_its_1989 = FALSE; Bool party_like_its_1989 = FALSE;
Bool whiteRoot = FALSE; Bool whiteRoot = FALSE;
int cursorScreenDevPriv[MAXSCREENS];
TimeStamp currentTime; TimeStamp currentTime;
TimeStamp lastDeviceEventTime; TimeStamp lastDeviceEventTime;

View File

@ -174,7 +174,7 @@ int main(int argc, char *argv[], char *envp[])
InitProcVectors(); InitProcVectors();
for (i=1; i<MAXCLIENTS; i++) for (i=1; i<MAXCLIENTS; i++)
clients[i] = NullClient; clients[i] = NullClient;
serverClient = malloc(sizeof(ClientRec)); serverClient = calloc(sizeof(ClientRec), 1);
if (!serverClient) if (!serverClient)
FatalError("couldn't create server client"); FatalError("couldn't create server client");
InitClient(serverClient, 0, (pointer)NULL); InitClient(serverClient, 0, (pointer)NULL);
@ -184,6 +184,12 @@ int main(int argc, char *argv[], char *envp[])
clients[0] = serverClient; clients[0] = serverClient;
currentMaxClients = 1; currentMaxClients = 1;
/* Initialize server client devPrivates, to be reallocated as
* more client privates are registered
*/
if (!dixAllocatePrivates(&serverClient->devPrivates, PRIVATE_CLIENT))
FatalError("failed to create server client privates");
if (!InitClientResources(serverClient)) /* for root resources */ if (!InitClientResources(serverClient)) /* for root resources */
FatalError("couldn't init server resources"); FatalError("couldn't init server resources");
@ -194,8 +200,7 @@ int main(int argc, char *argv[], char *envp[])
InitEvents(); InitEvents();
InitSelections(); InitSelections();
InitGlyphCaching(); InitGlyphCaching();
if (!dixResetPrivates()) dixResetPrivates();
FatalError("couldn't init private data storage");
dixResetRegistry(); dixResetRegistry();
ResetFontPrivateIndex(); ResetFontPrivateIndex();
InitCallbackManager(); InitCallbackManager();
@ -204,6 +209,7 @@ int main(int argc, char *argv[], char *envp[])
if (screenInfo.numScreens < 1) if (screenInfo.numScreens < 1)
FatalError("no screens found"); FatalError("no screens found");
InitExtensions(argc, argv); InitExtensions(argc, argv);
for (i = 0; i < screenInfo.numScreens; i++) for (i = 0; i < screenInfo.numScreens; i++)
{ {
ScreenPtr pScreen = screenInfo.screens[i]; ScreenPtr pScreen = screenInfo.screens[i];
@ -314,17 +320,18 @@ int main(int argc, char *argv[], char *envp[])
FreeGCperDepth(i); FreeGCperDepth(i);
FreeDefaultStipple(i); FreeDefaultStipple(i);
(* screenInfo.screens[i]->CloseScreen)(i, screenInfo.screens[i]); (* screenInfo.screens[i]->CloseScreen)(i, screenInfo.screens[i]);
dixFreePrivates(screenInfo.screens[i]->devPrivates); dixFreePrivates(screenInfo.screens[i]->devPrivates, PRIVATE_SCREEN);
free(screenInfo.screens[i]); free(screenInfo.screens[i]);
screenInfo.numScreens = i; screenInfo.numScreens = i;
} }
dixFreePrivates(serverClient->devPrivates, PRIVATE_CLIENT);
serverClient->devPrivates = NULL;
FreeFonts(); FreeFonts();
FreeAuditTimer(); FreeAuditTimer();
dixFreePrivates(serverClient->devPrivates);
serverClient->devPrivates = NULL;
if (dispatchException & DE_TERMINATE) if (dispatchException & DE_TERMINATE)
{ {
CloseWellKnownConnections(); CloseWellKnownConnections();

View File

@ -91,6 +91,11 @@ FreeScratchPixmapHeader(PixmapPtr pPixmap)
Bool Bool
CreateScratchPixmapsForScreen(int scrnum) CreateScratchPixmapsForScreen(int scrnum)
{ {
unsigned int pixmap_size;
pixmap_size = sizeof(PixmapRec) + dixPrivatesSize(PRIVATE_PIXMAP);
screenInfo.screens[scrnum]->totalPixmapSize = BitmapBytePad(pixmap_size * 8);
/* let it be created on first use */ /* let it be created on first use */
screenInfo.screens[scrnum]->pScratchPixmap = NULL; screenInfo.screens[scrnum]->pScratchPixmap = NULL;
return TRUE; return TRUE;
@ -110,6 +115,8 @@ AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
{ {
PixmapPtr pPixmap; PixmapPtr pPixmap;
assert(pScreen->totalPixmapSize > 0);
if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize) if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize)
return NullPixmap; return NullPixmap;
@ -117,6 +124,14 @@ AllocatePixmap(ScreenPtr pScreen, int pixDataSize)
if (!pPixmap) if (!pPixmap)
return NullPixmap; return NullPixmap;
pPixmap->devPrivates = NULL; dixInitPrivates(pPixmap, pPixmap + 1, PRIVATE_PIXMAP);
return pPixmap; return pPixmap;
} }
/* callable by ddx */
void
FreePixmap(PixmapPtr pPixmap)
{
dixFiniPrivates(pPixmap, PRIVATE_PIXMAP);
free(pPixmap);
}

View File

@ -52,6 +52,10 @@ typedef struct _PrivateDesc {
#define PRIV_MAX 256 #define PRIV_MAX 256
#define PRIV_STEP 16 #define PRIV_STEP 16
static int number_privates_allocated;
static int number_private_ptrs_allocated;
static int bytes_private_data_allocated;
/* list of all allocated privates */ /* list of all allocated privates */
static PrivateDescRec items[PRIV_MAX]; static PrivateDescRec items[PRIV_MAX];
static int nextPriv; static int nextPriv;
@ -59,31 +63,31 @@ static int nextPriv;
static PrivateDescRec * static PrivateDescRec *
findItem(const DevPrivateKey key) findItem(const DevPrivateKey key)
{ {
if (!*key) { if (!key->key) {
if (nextPriv >= PRIV_MAX) if (nextPriv >= PRIV_MAX)
return NULL; return NULL;
items[nextPriv].key = key; items[nextPriv].key = key;
*key = nextPriv; key->key = nextPriv;
nextPriv++; nextPriv++;
} }
return items + *key; return items + key->key;
} }
static _X_INLINE int static _X_INLINE int
privateExists(PrivateRec **privates, const DevPrivateKey key) privateExists(PrivateRec **privates, const DevPrivateKey key)
{ {
return *key && *privates && return key->key && *privates &&
(*privates)[0].state > *key && (*privates)[0].state > key->key &&
(*privates)[*key].state; (*privates)[key->key].state;
} }
/* /*
* Request pre-allocated space. * Request pre-allocated space.
*/ */
int int
dixRequestPrivate(const DevPrivateKey key, unsigned size) dixRegisterPrivateKey(const DevPrivateKey key, DevPrivateType type, unsigned size)
{ {
PrivateDescRec *item = findItem(key); PrivateDescRec *item = findItem(key);
if (!item) if (!item)
@ -96,7 +100,7 @@ dixRequestPrivate(const DevPrivateKey key, unsigned size)
/* /*
* Allocate a private and attach it to an existing object. * Allocate a private and attach it to an existing object.
*/ */
pointer * static pointer *
dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key) dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
{ {
PrivateDescRec *item = findItem(key); PrivateDescRec *item = findItem(key);
@ -104,7 +108,7 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
pointer value; pointer value;
int oldsize, newsize; int oldsize, newsize;
newsize = (*key / PRIV_STEP + 1) * PRIV_STEP; newsize = (key->key / PRIV_STEP + 1) * PRIV_STEP;
/* resize or init privates array */ /* resize or init privates array */
if (!item) if (!item)
@ -112,6 +116,8 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
/* initialize privates array if necessary */ /* initialize privates array if necessary */
if (!*privates) { if (!*privates) {
++number_privates_allocated;
number_private_ptrs_allocated += newsize;
ptr = calloc(newsize, sizeof(*ptr)); ptr = calloc(newsize, sizeof(*ptr));
if (!ptr) if (!ptr)
return NULL; return NULL;
@ -122,22 +128,25 @@ dixAllocatePrivate(PrivateRec **privates, const DevPrivateKey key)
oldsize = (*privates)[0].state; oldsize = (*privates)[0].state;
/* resize privates array if necessary */ /* resize privates array if necessary */
if (*key >= oldsize) { if (key->key >= oldsize) {
ptr = realloc(*privates, newsize * sizeof(*ptr)); ptr = realloc(*privates, newsize * sizeof(*ptr));
if (!ptr) if (!ptr)
return NULL; return NULL;
memset(ptr + oldsize, 0, (newsize - oldsize) * sizeof(*ptr)); memset(ptr + oldsize, 0, (newsize - oldsize) * sizeof(*ptr));
*privates = ptr; *privates = ptr;
(*privates)[0].state = newsize; (*privates)[0].state = newsize;
number_private_ptrs_allocated -= oldsize;
number_private_ptrs_allocated += newsize;
} }
/* initialize slot */ /* initialize slot */
ptr = *privates + *key; ptr = *privates + key->key;
ptr->state = 1; ptr->state = 1;
if (item->size) { if (item->size) {
value = calloc(item->size, 1); value = calloc(item->size, 1);
if (!value) if (!value)
return NULL; return NULL;
bytes_private_data_allocated += item->size;
ptr->value = value; ptr->value = value;
} }
@ -152,8 +161,9 @@ dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
{ {
pointer *ptr; pointer *ptr;
assert (key->key != 0);
if (privateExists(privates, key)) if (privateExists(privates, key))
return (*privates)[*key].value; return (*privates)[key->key].value;
ptr = dixAllocatePrivate(privates, key); ptr = dixAllocatePrivate(privates, key);
return ptr ? *ptr : NULL; return ptr ? *ptr : NULL;
@ -165,8 +175,10 @@ dixLookupPrivate(PrivateRec **privates, const DevPrivateKey key)
pointer * pointer *
dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key) dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
{ {
assert (key->key != 0);
if (privateExists(privates, key)) if (privateExists(privates, key))
return &(*privates)[*key].value; return &(*privates)[key->key].value;
return dixAllocatePrivate(privates, key); return dixAllocatePrivate(privates, key);
} }
@ -177,9 +189,10 @@ dixLookupPrivateAddr(PrivateRec **privates, const DevPrivateKey key)
int int
dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val) dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
{ {
assert (key->key != 0);
top: top:
if (privateExists(privates, key)) { if (privateExists(privates, key)) {
(*privates)[*key].value = val; (*privates)[key->key].value = val;
return TRUE; return TRUE;
} }
@ -192,17 +205,21 @@ dixSetPrivate(PrivateRec **privates, const DevPrivateKey key, pointer val)
* Called to free privates at object deletion time. * Called to free privates at object deletion time.
*/ */
void void
dixFreePrivates(PrivateRec *privates) dixFreePrivates(PrivateRec *privates, DevPrivateType type)
{ {
int i; int i;
if (privates) if (privates) {
number_private_ptrs_allocated -= privates->state;
number_privates_allocated--;
for (i = 1; i < privates->state; i++) for (i = 1; i < privates->state; i++)
if (privates[i].state) { if (privates[i].state) {
/* free pre-allocated memory */ /* free pre-allocated memory */
if (items[i].size) if (items[i].size)
free(privates[i].value); free(privates[i].value);
bytes_private_data_allocated -= items[i].size;
} }
}
free(privates); free(privates);
} }
@ -239,16 +256,32 @@ dixLookupPrivateOffset(RESTYPE type)
return -1; return -1;
} }
int void
dixPrivateUsage(void)
{
ErrorF("number of private structures: %d\n",
number_privates_allocated);
ErrorF("total number of private pointers: %d (%zd bytes)\n",
number_private_ptrs_allocated,
number_private_ptrs_allocated * sizeof (struct _Private));
ErrorF("bytes of extra private data: %d\n",
bytes_private_data_allocated);
ErrorF("Total privates memory usage: %zd\n",
bytes_private_data_allocated +
number_private_ptrs_allocated * sizeof (struct _Private));
}
void
dixResetPrivates(void) dixResetPrivates(void)
{ {
int i; int i;
/* reset private descriptors */ /* reset private descriptors */
for (i = 1; i < nextPriv; i++) { for (i = 1; i < nextPriv; i++) {
*items[i].key = 0; items[i].key->key = 0;
items[i].size = 0; items[i].size = 0;
} }
nextPriv = 1; nextPriv = 1;
return TRUE; if (number_privates_allocated)
dixPrivateUsage();
} }

View File

@ -269,13 +269,13 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
{ {
if (!pWin->optional && !MakeWindowOptional (pWin)) if (!pWin->optional && !MakeWindowOptional (pWin))
return(BadAlloc); return(BadAlloc);
pProp = malloc(sizeof(PropertyRec)); pProp = dixAllocateObjectWithPrivates(PropertyRec, PRIVATE_PROPERTY);
if (!pProp) if (!pProp)
return(BadAlloc); return(BadAlloc);
data = malloc(totalSize); data = malloc(totalSize);
if (!data && len) if (!data && len)
{ {
free(pProp); dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
return(BadAlloc); return(BadAlloc);
} }
memcpy(data, value, totalSize); memcpy(data, value, totalSize);
@ -289,7 +289,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
DixCreateAccess|DixWriteAccess); DixCreateAccess|DixWriteAccess);
if (rc != Success) { if (rc != Success) {
free(data); free(data);
free(pProp); dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
pClient->errorValue = property; pClient->errorValue = property;
return rc; return rc;
} }
@ -405,9 +405,8 @@ DeleteProperty(ClientPtr client, WindowPtr pWin, Atom propName)
} }
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName); deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName);
dixFreePrivates(pProp->devPrivates);
free(pProp->data); free(pProp->data);
free(pProp); dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
} }
return rc; return rc;
} }
@ -422,9 +421,8 @@ DeleteAllWindowProperties(WindowPtr pWin)
{ {
deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName); deliverPropertyNotifyEvent(pWin, PropertyDelete, pProp->propertyName);
pNextProp = pProp->next; pNextProp = pProp->next;
dixFreePrivates(pProp->devPrivates);
free(pProp->data); free(pProp->data);
free(pProp); dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
pProp = pNextProp; pProp = pNextProp;
} }
} }
@ -570,9 +568,8 @@ ProcGetProperty(ClientPtr client)
prevProp->next = pProp->next; prevProp->next = pProp->next;
} }
dixFreePrivates(pProp->devPrivates);
free(pProp->data); free(pProp->data);
free(pProp); dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY);
} }
return Success; return Success;
} }

View File

@ -94,8 +94,7 @@ InitSelections(void)
pSel = CurrentSelections; pSel = CurrentSelections;
while (pSel) { while (pSel) {
pNextSel = pSel->next; pNextSel = pSel->next;
dixFreePrivates(pSel->devPrivates); dixFreeObjectWithPrivates(pSel, PRIVATE_SELECTION);
free(pSel);
pSel = pNextSel; pSel = pNextSel;
} }

View File

@ -151,12 +151,8 @@ WindowSeekDeviceCursor(WindowPtr pWin,
int screenIsSaved = SCREEN_SAVER_OFF; int screenIsSaved = SCREEN_SAVER_OFF;
static int FocusPrivatesKeyIndex;
DevPrivateKey FocusPrivatesKey = &FocusPrivatesKeyIndex;
static Bool TileScreenSaver(ScreenPtr pScreen, int kind); static Bool TileScreenSaver(ScreenPtr pScreen, int kind);
#define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \ #define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
CWDontPropagate | CWOverrideRedirect | CWCursor ) CWDontPropagate | CWOverrideRedirect | CWCursor )
@ -357,7 +353,7 @@ CreateRootWindow(ScreenPtr pScreen)
BoxRec box; BoxRec box;
PixmapFormatRec *format; PixmapFormatRec *format;
pWin = malloc(sizeof(WindowRec)); pWin = dixAllocateObjectWithPrivates(WindowRec, PRIVATE_WINDOW);
if (!pWin) if (!pWin)
return FALSE; return FALSE;
@ -370,7 +366,6 @@ CreateRootWindow(ScreenPtr pScreen)
pWin->drawable.pScreen = pScreen; pWin->drawable.pScreen = pScreen;
pWin->drawable.type = DRAWABLE_WINDOW; pWin->drawable.type = DRAWABLE_WINDOW;
pWin->devPrivates = NULL;
pWin->drawable.depth = pScreen->rootDepth; pWin->drawable.depth = pScreen->rootDepth;
for (format = screenInfo.formats; for (format = screenInfo.formats;
@ -637,14 +632,13 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
return NullWindow; return NullWindow;
} }
pWin = malloc(sizeof(WindowRec)); pWin = dixAllocateObjectWithPrivates(WindowRec, PRIVATE_WINDOW);
if (!pWin) if (!pWin)
{ {
*error = BadAlloc; *error = BadAlloc;
return NullWindow; return NullWindow;
} }
pWin->drawable = pParent->drawable; pWin->drawable = pParent->drawable;
pWin->devPrivates = NULL;
pWin->drawable.depth = depth; pWin->drawable.depth = depth;
if (depth == pParent->drawable.depth) if (depth == pParent->drawable.depth)
pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel; pWin->drawable.bitsPerPixel = pParent->drawable.bitsPerPixel;
@ -668,7 +662,7 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
{ {
if (!MakeWindowOptional (pWin)) if (!MakeWindowOptional (pWin))
{ {
free(pWin); dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
*error = BadAlloc; *error = BadAlloc;
return NullWindow; return NullWindow;
} }
@ -683,7 +677,7 @@ CreateWindow(Window wid, WindowPtr pParent, int x, int y, unsigned w,
*error = XaceHook(XACE_RESOURCE_ACCESS, client, wid, RT_WINDOW, pWin, *error = XaceHook(XACE_RESOURCE_ACCESS, client, wid, RT_WINDOW, pWin,
RT_WINDOW, pWin->parent, DixCreateAccess|DixSetAttrAccess); RT_WINDOW, pWin->parent, DixCreateAccess|DixSetAttrAccess);
if (*error != Success) { if (*error != Success) {
free(pWin); dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
return NullWindow; return NullWindow;
} }
@ -881,8 +875,7 @@ CrushTree(WindowPtr pWin)
(*UnrealizeWindow)(pChild); (*UnrealizeWindow)(pChild);
} }
FreeWindowResources(pChild); FreeWindowResources(pChild);
dixFreePrivates(pChild->devPrivates); dixFreeObjectWithPrivates(pChild, PRIVATE_WINDOW);
free(pChild);
if ( (pChild = pSib) ) if ( (pChild = pSib) )
break; break;
pChild = pParent; pChild = pParent;
@ -932,9 +925,7 @@ DeleteWindow(pointer value, XID wid)
if (pWin->prevSib) if (pWin->prevSib)
pWin->prevSib->nextSib = pWin->nextSib; pWin->prevSib->nextSib = pWin->nextSib;
} }
free(dixLookupPrivate(&pWin->devPrivates, FocusPrivatesKey)); dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW);
dixFreePrivates(pWin->devPrivates);
free(pWin);
return Success; return Success;
} }

View File

@ -37,12 +37,12 @@
#include "exa_priv.h" #include "exa_priv.h"
#include "exa.h" #include "exa.h"
static int exaScreenPrivateKeyIndex; static DevPrivateKeyRec exaScreenPrivateKeyRec;
DevPrivateKey exaScreenPrivateKey = &exaScreenPrivateKeyIndex; #define exaScreenPrivateKey (&exaScreenPrivateKeyRec)
static int exaPixmapPrivateKeyIndex; static DevPrivateKeyRec exaPixmapPrivateKeyRec;
DevPrivateKey exaPixmapPrivateKey = &exaPixmapPrivateKeyIndex; #define exaPixmapPrivateKey (&exaPixmapPrivateKeyRec)
static int exaGCPrivateKeyIndex; static DevPrivateKeyRec exaGCPrivateKeyRec;
DevPrivateKey exaGCPrivateKey = &exaGCPrivateKeyIndex; #define exaGCPrivateKey (&exaGCPrivateKeyRec)
#ifdef MITSHM #ifdef MITSHM
static ShmFuncs exaShmFuncs = { NULL, NULL }; static ShmFuncs exaShmFuncs = { NULL, NULL };
@ -889,7 +889,13 @@ exaDriverInit (ScreenPtr pScreen,
ps = GetPictureScreenIfSet(pScreen); ps = GetPictureScreenIfSet(pScreen);
pExaScr = calloc(sizeof (ExaScreenPrivRec), 1); if (!dixRegisterPrivateKey(&exaScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) {
LogMessage(X_WARNING, "EXA(%d): Failed to register screen private\n",
pScreen->myNum);
return FALSE;
}
pExaScr = calloc (sizeof (ExaScreenPrivRec), 1);
if (!pExaScr) { if (!pExaScr) {
LogMessage(X_WARNING, "EXA(%d): Failed to allocate screen private\n", LogMessage(X_WARNING, "EXA(%d): Failed to allocate screen private\n",
pScreen->myNum); pScreen->myNum);
@ -904,7 +910,7 @@ exaDriverInit (ScreenPtr pScreen,
exaDDXDriverInit(pScreen); exaDDXDriverInit(pScreen);
if (!dixRequestPrivate(exaGCPrivateKey, sizeof(ExaGCPrivRec))) { if (!dixRegisterPrivateKey(&exaGCPrivateKeyRec, PRIVATE_GC, sizeof(ExaGCPrivRec))) {
LogMessage(X_WARNING, LogMessage(X_WARNING,
"EXA(%d): Failed to allocate GC private\n", "EXA(%d): Failed to allocate GC private\n",
pScreen->myNum); pScreen->myNum);
@ -953,7 +959,7 @@ exaDriverInit (ScreenPtr pScreen,
*/ */
if (pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS) if (pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS)
{ {
if (!dixRequestPrivate(exaPixmapPrivateKey, sizeof(ExaPixmapPrivRec))) { if (!dixRegisterPrivateKey(&exaPixmapPrivateKeyRec, PRIVATE_PIXMAP, sizeof(ExaPixmapPrivRec))) {
LogMessage(X_WARNING, LogMessage(X_WARNING,
"EXA(%d): Failed to allocate pixmap private\n", "EXA(%d): Failed to allocate pixmap private\n",
pScreen->myNum); pScreen->myNum);

19
fb/fb.h
View File

@ -603,8 +603,12 @@ extern _X_EXPORT void fbSetBits (FbStip *bits, int stride, FbStip data);
} \ } \
} }
extern _X_EXPORT DevPrivateKey fbGetGCPrivateKey(void); extern _X_EXPORT DevPrivateKey
extern _X_EXPORT DevPrivateKey fbGetWinPrivateKey(void); fbGetGCPrivateKey (void);
extern _X_EXPORT DevPrivateKey
fbGetWinPrivateKey (void);
extern _X_EXPORT const GCOps fbGCOps; extern _X_EXPORT const GCOps fbGCOps;
extern _X_EXPORT const GCFuncs fbGCFuncs; extern _X_EXPORT const GCFuncs fbGCFuncs;
@ -639,7 +643,8 @@ typedef void (*FinishWrapProcPtr)(DrawablePtr pDraw);
#ifdef FB_SCREEN_PRIVATE #ifdef FB_SCREEN_PRIVATE
extern _X_EXPORT DevPrivateKey fbGetScreenPrivateKey(void); extern _X_EXPORT DevPrivateKey
fbGetScreenPrivateKey(void);
/* private field of a screen */ /* private field of a screen */
typedef struct { typedef struct {
@ -652,7 +657,7 @@ typedef struct {
} FbScreenPrivRec, *FbScreenPrivPtr; } FbScreenPrivRec, *FbScreenPrivPtr;
#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \ #define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey())) dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey()))
#endif #endif
/* private field of GC */ /* private field of GC */
@ -667,7 +672,7 @@ typedef struct {
} FbGCPrivRec, *FbGCPrivPtr; } FbGCPrivRec, *FbGCPrivPtr;
#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\ #define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey())) dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey()))
#define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip) #define fbGetCompositeClip(pGC) ((pGC)->pCompositeClip)
#define fbGetExpose(pGC) ((pGC)->fExpose) #define fbGetExpose(pGC) ((pGC)->fExpose)
@ -676,7 +681,7 @@ typedef struct {
#define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate) #define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate)
#define fbGetWindowPixmap(pWin) ((PixmapPtr)\ #define fbGetWindowPixmap(pWin) ((PixmapPtr)\
dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey())) dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey()))
#ifdef ROOTLESS #ifdef ROOTLESS
#define __fbPixDrawableX(pPix) ((pPix)->drawable.x) #define __fbPixDrawableX(pPix) ((pPix)->drawable.x)
@ -830,8 +835,6 @@ fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
/* /*
* fballpriv.c * fballpriv.c
*/ */
extern _X_EXPORT DevPrivateKey fbGetWinPrivateKey(void);
extern _X_EXPORT Bool extern _X_EXPORT Bool
fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCIndex); fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCIndex);

View File

@ -27,46 +27,34 @@
#include "fb.h" #include "fb.h"
#ifdef FB_SCREEN_PRIVATE #ifdef FB_SCREEN_PRIVATE
static int fbScreenPrivateKeyIndex; static DevPrivateKeyRec fbScreenPrivateKeyRec;
static DevPrivateKey fbScreenPrivateKey = &fbScreenPrivateKeyIndex; DevPrivateKey
DevPrivateKey fbGetScreenPrivateKey(void) fbGetScreenPrivateKey(void) { return &fbScreenPrivateKeyRec; }
{
return fbScreenPrivateKey;
}
#endif #endif
static int fbGCPrivateKeyIndex; static DevPrivateKeyRec fbGCPrivateKeyRec;
static DevPrivateKey fbGCPrivateKey = &fbGCPrivateKeyIndex; DevPrivateKey
DevPrivateKey fbGetGCPrivateKey(void) fbGetGCPrivateKey (void) { return &fbGCPrivateKeyRec; }
{
return fbGCPrivateKey;
}
static int fbWinPrivateKeyIndex; static DevPrivateKeyRec fbWinPrivateKeyRec;
static DevPrivateKey fbWinPrivateKey = &fbWinPrivateKeyIndex; DevPrivateKey
DevPrivateKey fbGetWinPrivateKey(void) fbGetWinPrivateKey (void) { return &fbWinPrivateKeyRec; }
{
return fbWinPrivateKey;
}
Bool Bool
fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey) fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
{ {
if (pGCKey) if (pGCKey)
*pGCKey = fbGCPrivateKey; *pGCKey = &fbGCPrivateKeyRec;
if (!dixRequestPrivate(fbGCPrivateKey, sizeof(FbGCPrivRec))) if (!dixRegisterPrivateKey(&fbGCPrivateKeyRec, PRIVATE_GC, sizeof(FbGCPrivRec)))
return FALSE; return FALSE;
#ifdef FB_SCREEN_PRIVATE #ifdef FB_SCREEN_PRIVATE
{ if (!dixRegisterPrivateKey(&fbScreenPrivateKeyRec, PRIVATE_SCREEN, sizeof (FbScreenPrivRec)))
FbScreenPrivPtr pScreenPriv; return FALSE;
pScreenPriv = (FbScreenPrivPtr) malloc(sizeof (FbScreenPrivRec));
if (!pScreenPriv)
return FALSE;
dixSetPrivate(&pScreen->devPrivates, fbScreenPrivateKey, pScreenPriv);
}
#endif #endif
if (!dixRegisterPrivateKey(&fbWinPrivateKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
return TRUE; return TRUE;
} }

View File

@ -36,8 +36,8 @@
#error "You should be compiling fbcmap_mi.c instead of fbcmap.c!" #error "You should be compiling fbcmap_mi.c instead of fbcmap.c!"
#endif #endif
static int cmapScrPrivateKeyIndex; static DevPrivateKeyRec cmapScrPrivateKeyRec;
static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex; #define cmapScrPrivateKey (&cmapScrPrivateKeyRec)
#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey)) #define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c)) #define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))

View File

@ -33,8 +33,8 @@
#include "fboverlay.h" #include "fboverlay.h"
#include "shmint.h" #include "shmint.h"
static int fbOverlayScreenPrivateKeyIndex; static DevPrivateKeyRec fbOverlayScreenPrivateKeyRec;
static DevPrivateKey fbOverlayScreenPrivateKey = &fbOverlayScreenPrivateKeyIndex; #define fbOverlayScreenPrivateKey (&fbOverlayScreenPrivateKeyRec)
DevPrivateKey fbOverlayGetScreenPrivateKey(void) DevPrivateKey fbOverlayGetScreenPrivateKey(void)
{ {
@ -348,6 +348,9 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
VisualID defaultVisual; VisualID defaultVisual;
FbOverlayScrPrivPtr pScrPriv; FbOverlayScrPrivPtr pScrPriv;
if (!dixRegisterPrivateKey(&fbOverlayScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
pScrPriv = malloc(sizeof (FbOverlayScrPrivRec)); pScrPriv = malloc(sizeof (FbOverlayScrPrivRec));
if (!pScrPriv) if (!pScrPriv)
return FALSE; return FALSE;
@ -416,7 +419,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
pScrPriv->layer[1].u.init.pbits = pbits2; pScrPriv->layer[1].u.init.pbits = pbits2;
pScrPriv->layer[1].u.init.width = width2; pScrPriv->layer[1].u.init.width = width2;
pScrPriv->layer[1].u.init.depth = depth2; pScrPriv->layer[1].u.init.depth = depth2;
dixSetPrivate(&pScreen->devPrivates, fbOverlayScreenPrivateKey, pScrPriv); dixSetPrivate(&pScreen->devPrivates, fbOverlayScreenPrivateKey, pScrPriv);
/* overwrite miCloseScreen with our own */ /* overwrite miCloseScreen with our own */

View File

@ -67,6 +67,7 @@ fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp,
pPixmap->devKind = paddedWidth; pPixmap->devKind = paddedWidth;
pPixmap->refcnt = 1; pPixmap->refcnt = 1;
pPixmap->devPrivate.ptr = (pointer) ((char *)pPixmap + base + adjust); pPixmap->devPrivate.ptr = (pointer) ((char *)pPixmap + base + adjust);
#ifdef FB_DEBUG #ifdef FB_DEBUG
pPixmap->devPrivate.ptr = (void *) ((char *) pPixmap->devPrivate.ptr + paddedWidth); pPixmap->devPrivate.ptr = (void *) ((char *) pPixmap->devPrivate.ptr + paddedWidth);
fbInitializeDrawable (&pPixmap->drawable); fbInitializeDrawable (&pPixmap->drawable);
@ -100,8 +101,7 @@ fbDestroyPixmap (PixmapPtr pPixmap)
{ {
if(--pPixmap->refcnt) if(--pPixmap->refcnt)
return TRUE; return TRUE;
dixFreePrivates(pPixmap->devPrivates); FreePixmap(pPixmap);
free(pPixmap);
return TRUE; return TRUE;
} }

View File

@ -37,9 +37,6 @@ fbCloseScreen (int index, ScreenPtr pScreen)
free(depths); free(depths);
free(pScreen->visuals); free(pScreen->visuals);
free(pScreen->devPrivate); free(pScreen->devPrivate);
#ifdef FB_SCREEN_PRIVATE
free(dixLookupPrivate(&pScreen->devPrivates, fbGetScreenPrivateKey()));
#endif
return TRUE; return TRUE;
} }

View File

@ -83,13 +83,14 @@
#define fbFixCoordModePrevious wfbFixCoordModePrevious #define fbFixCoordModePrevious wfbFixCoordModePrevious
#define fbGCFuncs wfbGCFuncs #define fbGCFuncs wfbGCFuncs
#define fbGCOps wfbGCOps #define fbGCOps wfbGCOps
#define fbGCPrivateKey wfbGCPrivateKey #define fbGCPrivateKeyRec wfbGCPrivateKeyRec
#define fbGeneration wfbGeneration #define fbGeneration wfbGeneration
#define fbGetGCPrivateKey wfbGetGCPrivateKey #define fbGetGCPrivateKey wfbGetGCPrivateKey
#define fbGetImage wfbGetImage #define fbGetImage wfbGetImage
#define fbGetScreenPrivateKey wfbGetScreenPrivateKey #define fbGetScreenPrivateKey wfbGetScreenPrivateKey
#define fbGetSpans wfbGetSpans #define fbGetSpans wfbGetSpans
#define _fbGetWindowPixmap _wfbGetWindowPixmap #define _fbGetWindowPixmap _wfbGetWindowPixmap
#define fbWinPrivateKeyRec wfbWinPrivateKeyRec
#define fbGetWinPrivateKey wfbGetWinPrivateKey #define fbGetWinPrivateKey wfbGetWinPrivateKey
#define fbGlyph16 wfbGlyph16 #define fbGlyph16 wfbGlyph16
#define fbGlyph24 wfbGlyph24 #define fbGlyph24 wfbGlyph24
@ -118,7 +119,6 @@
#define fbOverlayGeneration wfbOverlayGeneration #define fbOverlayGeneration wfbOverlayGeneration
#define fbOverlayGetScreenPrivateKey wfbOverlayGetScreenPrivateKey #define fbOverlayGetScreenPrivateKey wfbOverlayGetScreenPrivateKey
#define fbOverlayPaintKey wfbOverlayPaintKey #define fbOverlayPaintKey wfbOverlayPaintKey
#define fbOverlayScreenPrivateKey wfbOverlayScreenPrivateKey
#define fbOverlaySetupScreen wfbOverlaySetupScreen #define fbOverlaySetupScreen wfbOverlaySetupScreen
#define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion #define fbOverlayUpdateLayerRegion wfbOverlayUpdateLayerRegion
#define fbOverlayWindowExposures wfbOverlayWindowExposures #define fbOverlayWindowExposures wfbOverlayWindowExposures
@ -157,7 +157,7 @@
#define fbResolveColor wfbResolveColor #define fbResolveColor wfbResolveColor
#define fbRestoreAreas wfbRestoreAreas #define fbRestoreAreas wfbRestoreAreas
#define fbSaveAreas wfbSaveAreas #define fbSaveAreas wfbSaveAreas
#define fbScreenPrivateKey wfbScreenPrivateKey #define fbScreenPrivateKeyRec wfbScreenPrivateKeyRec
#define fbSegment wfbSegment #define fbSegment wfbSegment
#define fbSelectBres wfbSelectBres #define fbSelectBres wfbSelectBres
#define fbSetSpans wfbSetSpans #define fbSetSpans wfbSetSpans
@ -182,7 +182,7 @@
#define fbUnrealizeFont wfbUnrealizeFont #define fbUnrealizeFont wfbUnrealizeFont
#define fbValidateGC wfbValidateGC #define fbValidateGC wfbValidateGC
#define fbWalkCompositeRegion wfbWalkCompositeRegion #define fbWalkCompositeRegion wfbWalkCompositeRegion
#define fbWinPrivateKey wfbWinPrivateKey #define fbWinPrivateKeyRec wfbWinPrivateKeyRec
#define fbZeroLine wfbZeroLine #define fbZeroLine wfbZeroLine
#define fbZeroSegment wfbZeroSegment #define fbZeroSegment wfbZeroSegment
#define free_pixman_pict wfb_free_pixman_pict #define free_pixman_pict wfb_free_pixman_pict

View File

@ -65,8 +65,8 @@ RESTYPE __glXSwapBarrierRes;
*/ */
xGLXSingleReply __glXReply; xGLXSingleReply __glXReply;
static int glxClientPrivateKeyIndex; static DevPrivateKeyRec glxClientPrivateKeyRec;
static DevPrivateKey glxClientPrivateKey = &glxClientPrivateKeyIndex; #define glxClientPrivateKey (&glxClientPrivateKeyRec)
/* /*
** Client that called into GLX dispatch. ** Client that called into GLX dispatch.
@ -364,7 +364,7 @@ void GlxExtensionInit(void)
if (!__glXContextRes || !__glXDrawableRes || !__glXSwapBarrierRes) if (!__glXContextRes || !__glXDrawableRes || !__glXSwapBarrierRes)
return; return;
if (!dixRequestPrivate(glxClientPrivateKey, sizeof (__GLXclientState))) if (!dixRegisterPrivateKey(&glxClientPrivateKeyRec, PRIVATE_CLIENT, sizeof (__GLXclientState)))
return; return;
if (!AddCallback (&ClientStateCallback, glxClientCallback, 0)) if (!AddCallback (&ClientStateCallback, glxClientCallback, 0))
return; return;

View File

@ -44,8 +44,8 @@
#include "glxext.h" #include "glxext.h"
#include "protocol-versions.h" #include "protocol-versions.h"
static int glxScreenPrivateKeyIndex; static DevPrivateKeyRec glxScreenPrivateKeyRec;
static DevPrivateKey glxScreenPrivateKey = &glxScreenPrivateKeyIndex; #define glxScreenPrivateKey (&glxScreenPrivateKeyRec)
const char GLServerVersion[] = "1.4"; const char GLServerVersion[] = "1.4";
static const char GLServerExtensions[] = static const char GLServerExtensions[] =
@ -352,6 +352,9 @@ void __glXScreenInit(__GLXscreen *pGlxScreen, ScreenPtr pScreen)
__GLXconfig *config; __GLXconfig *config;
int i; int i;
if (!dixRegisterPrivateKey(&glxScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return;
pGlxScreen->pScreen = pScreen; pGlxScreen->pScreen = pScreen;
pGlxScreen->GLextensions = xstrdup(GLServerExtensions); pGlxScreen->GLextensions = xstrdup(GLServerExtensions);
pGlxScreen->GLXvendor = xstrdup(GLXServerVendorName); pGlxScreen->GLXvendor = xstrdup(GLXServerVendorName);

View File

@ -364,4 +364,27 @@ do { \
#define MAXSCREENSCALLOC_FATAL(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),1) #define MAXSCREENSCALLOC_FATAL(o,m) _MAXSCREENSALLOCF(o,MAXSCREENS*(m),1)
#endif #endif
extern DevPrivateKeyRec dmxGCPrivateKeyRec;
#define dmxGCPrivateKey (&dmxGCPrivateKeyRec) /**< Private index for GCs */
extern DevPrivateKeyRec dmxWinPrivateKeyRec;
#define dmxWinPrivateKey (&dmxWinPrivateKeyRec) /**< Private index for Windows */
extern DevPrivateKeyRec dmxPixPrivateKeyRec;
#define dmxPixPrivateKey (&dmxPixPrivateKeyRec) /**< Private index for Pixmaps */
extern int dmxFontPrivateIndex; /**< Private index for Fonts */
extern DevPrivateKeyRec dmxScreenPrivateKeyRec;
#define dmxScreenPrivateKey (&dmxScreenPrivateKeyRec) /**< Private index for Screens */
extern DevPrivateKeyRec dmxColormapPrivateKeyRec;
#define dmxColormapPrivateKey (&dmxColormapPrivateKeyRec) /**< Private index for Colormaps */
extern DevPrivateKeyRec dmxPictPrivateKeyRec;
#define dmxPictPrivateKey (&dmxPictPrivateKeyRec) /**< Private index for Picts */
extern DevPrivateKeyRec dmxGlyphSetPrivateKeyRec;
#define dmxGlyphSetPrivateKey (&dmxGlyphSetPrivateKeyRec) /**< Private index for GlyphSets */
#endif /* DMX_H */ #endif /* DMX_H */

View File

@ -55,9 +55,6 @@ extern Bool dmxCreateDefColormap(ScreenPtr pScreen);
extern Bool dmxBECreateColormap(ColormapPtr pColormap); extern Bool dmxBECreateColormap(ColormapPtr pColormap);
extern Bool dmxBEFreeColormap(ColormapPtr pColormap); extern Bool dmxBEFreeColormap(ColormapPtr pColormap);
/** Private index. \see dmxcmap.c \see dmxscrinit.c \see dmxwindow.c */
extern DevPrivateKey dmxColormapPrivateKey;
/** Set colormap private structure. */ /** Set colormap private structure. */
#define DMX_SET_COLORMAP_PRIV(_pCMap, _pCMapPriv) \ #define DMX_SET_COLORMAP_PRIV(_pCMap, _pCMapPriv) \
dixSetPrivate(&(_pCMap)->devPrivates, dmxColormapPrivateKey, _pCMapPriv) dixSetPrivate(&(_pCMap)->devPrivates, dmxColormapPrivateKey, _pCMapPriv)

View File

@ -85,7 +85,7 @@ static GCOps dmxGCOps = {
/** Initialize the GC on \a pScreen */ /** Initialize the GC on \a pScreen */
Bool dmxInitGC(ScreenPtr pScreen) Bool dmxInitGC(ScreenPtr pScreen)
{ {
if (!dixRequestPrivate(dmxGCPrivateKey, sizeof(dmxGCPrivRec))) if (!dixRegisterPrivateKey(&dmxGCPrivateKeyRec, PRIVATE_GC, sizeof(dmxGCPrivRec)))
return FALSE; return FALSE;
return TRUE; return TRUE;
} }

View File

@ -63,9 +63,6 @@ extern void dmxCopyClip(GCPtr pGCDst, GCPtr pGCSrc);
extern void dmxBECreateGC(ScreenPtr pScreen, GCPtr pGC); extern void dmxBECreateGC(ScreenPtr pScreen, GCPtr pGC);
extern Bool dmxBEFreeGC(GCPtr pGC); extern Bool dmxBEFreeGC(GCPtr pGC);
/** Private index. \see dmxgc.c \see dmxscrinit.c */
extern DevPrivateKey dmxGCPrivateKey;
/** Get private. */ /** Get private. */
#define DMX_GET_GC_PRIV(_pGC) \ #define DMX_GET_GC_PRIV(_pGC) \
(dmxGCPrivPtr)dixLookupPrivate(&(_pGC)->devPrivates, dmxGCPrivateKey) (dmxGCPrivPtr)dixLookupPrivate(&(_pGC)->devPrivates, dmxGCPrivateKey)

View File

@ -145,7 +145,7 @@ Bool dmxPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats)
if (!miPictureInit(pScreen, formats, nformats)) if (!miPictureInit(pScreen, formats, nformats))
return FALSE; return FALSE;
if (!dixRequestPrivate(dmxPictPrivateKey, sizeof(dmxPictPrivRec))) if (!dixRegisterPrivateKey(&dmxPictPrivateKeyRec, PRIVATE_PICTURE, sizeof(dmxPictPrivRec)))
return FALSE; return FALSE;
ps = GetPictureScreen(pScreen); ps = GetPictureScreen(pScreen);

View File

@ -116,10 +116,6 @@ extern Bool dmxBEFreeGlyphSet(ScreenPtr pScreen, GlyphSetPtr glyphSet);
extern int dmxBECreatePicture(PicturePtr pPicture); extern int dmxBECreatePicture(PicturePtr pPicture);
extern Bool dmxBEFreePicture(PicturePtr pPicture); extern Bool dmxBEFreePicture(PicturePtr pPicture);
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 */ /** Get the picture private data given a picture pointer */
#define DMX_GET_PICT_PRIV(_pPict) \ #define DMX_GET_PICT_PRIV(_pPict) \
(dmxPictPrivPtr)dixLookupPrivate(&(_pPict)->devPrivates, dmxPictPrivateKey) (dmxPictPrivPtr)dixLookupPrivate(&(_pPict)->devPrivates, dmxPictPrivateKey)

View File

@ -49,7 +49,7 @@
/** Initialize a private area in \a pScreen for pixmap information. */ /** Initialize a private area in \a pScreen for pixmap information. */
Bool dmxInitPixmap(ScreenPtr pScreen) Bool dmxInitPixmap(ScreenPtr pScreen)
{ {
if (!dixRequestPrivate(dmxPixPrivateKey, sizeof(dmxPixPrivRec))) if (!dixRegisterPrivateKey(&dmxPixPrivateKeyRec, PRIVATE_PIXMAP, sizeof(dmxPixPrivRec)))
return FALSE; return FALSE;
return TRUE; return TRUE;
@ -174,8 +174,7 @@ Bool dmxDestroyPixmap(PixmapPtr pPixmap)
dmxSync(dmxScreen, FALSE); dmxSync(dmxScreen, FALSE);
} }
} }
dixFreePrivates(pPixmap->devPrivates); FreePixmap(pPixmap);
free(pPixmap);
#if 0 #if 0
if (pScreen->DestroyPixmap) if (pScreen->DestroyPixmap)

View File

@ -57,9 +57,6 @@ extern RegionPtr dmxBitmapToRegion(PixmapPtr pPixmap);
extern void dmxBECreatePixmap(PixmapPtr pPixmap); extern void dmxBECreatePixmap(PixmapPtr pPixmap);
extern Bool dmxBEFreePixmap(PixmapPtr pPixmap); extern Bool dmxBEFreePixmap(PixmapPtr pPixmap);
/** Private index. \see dmxpicmap.h \see dmxscrinit.c */
extern DevPrivateKey dmxPixPrivateKey;
/** Get pixmap private pointer. */ /** Get pixmap private pointer. */
#define DMX_GET_PIXMAP_PRIV(_pPix) \ #define DMX_GET_PIXMAP_PRIV(_pPix) \
(dmxPixPrivPtr)dixLookupPrivate(&(_pPix)->devPrivates, dmxPixPrivateKey) (dmxPixPrivPtr)dixLookupPrivate(&(_pPix)->devPrivates, dmxPixPrivateKey)

View File

@ -65,21 +65,14 @@ static Bool dmxSaveScreen(ScreenPtr pScreen, int what);
static unsigned long dmxGeneration; static unsigned long dmxGeneration;
static unsigned long *dmxCursorGeneration; static unsigned long *dmxCursorGeneration;
static int dmxGCPrivateKeyIndex; DevPrivateKeyRec dmxGCPrivateKeyRec;
DevPrivateKey dmxGCPrivateKey = &dmxGCPrivateKeyIndex; /**< Private index for GCs */ DevPrivateKeyRec dmxWinPrivateKeyRec;
static int dmxWinPrivateKeyIndex; DevPrivateKeyRec dmxPixPrivateKeyRec;
DevPrivateKey dmxWinPrivateKey = &dmxWinPrivateKeyIndex; /**< Private index for Windows */
static int dmxPixPrivateKeyIndex;
DevPrivateKey dmxPixPrivateKey = &dmxPixPrivateKeyIndex; /**< Private index for Pixmaps */
int dmxFontPrivateIndex; /**< Private index for Fonts */ int dmxFontPrivateIndex; /**< Private index for Fonts */
static int dmxScreenPrivateKeyIndex; DevPrivateKeyRec dmxScreenPrivateKeyRec;
DevPrivateKey dmxScreenPrivateKey = &dmxScreenPrivateKeyIndex; /**< Private index for Screens */ DevPrivateKeyRec dmxColormapPrivateKeyRec;
static int dmxColormapPrivateKeyIndex; DevPrivateKeyRec dmxPictPrivateKeyRec;
DevPrivateKey dmxColormapPrivateKey = &dmxColormapPrivateKeyIndex; /**< Private index for Colormaps */ DevPrivateKeyRec dmxGlyphSetPrivateKeyRec;
static int dmxPictPrivateKeyIndex;
DevPrivateKey dmxPictPrivateKey = &dmxPictPrivateKeyIndex; /**< Private index for Picts */
static int dmxGlyphSetPrivateKeyIndex;
DevPrivateKey dmxGlyphSetPrivateKey = &dmxGlyphSetPrivateKeyIndex; /**< Private index for GlyphSets */
/** Initialize the parts of screen \a idx that require access to the /** Initialize the parts of screen \a idx that require access to the
* back-end server. */ * back-end server. */
@ -210,6 +203,13 @@ Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[])
DMXScreenInfo *dmxScreen = &dmxScreens[idx]; DMXScreenInfo *dmxScreen = &dmxScreens[idx];
int i, j; int i, j;
if (!dixRegisterPrivateKey(&dmxScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&dmxColormapPrivateKeyRec, PRIVATE_COLORMAP, 0))
return FALSE;
if (!dixRegisterPrivateKey(&dmxGlyphSetPrivateKeyRec, PRIVATE_GLYPHSET, 0))
return FALSE;
if (dmxGeneration != serverGeneration) { if (dmxGeneration != serverGeneration) {
/* Allocate font private index */ /* Allocate font private index */
dmxFontPrivateIndex = AllocateFontPrivateIndex(); dmxFontPrivateIndex = AllocateFontPrivateIndex();

View File

@ -40,9 +40,6 @@
#include "scrnintstr.h" #include "scrnintstr.h"
/** Private index. \see dmxscrrinit.c \see input/dmxconcole.c */
extern DevPrivateKey dmxScreenPrivateKey;
extern Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[]); extern Bool dmxScreenInit(int idx, ScreenPtr pScreen, int argc, char *argv[]);
extern void dmxBEScreenInit(int idx, ScreenPtr pScreen); extern void dmxBEScreenInit(int idx, ScreenPtr pScreen);

View File

@ -60,7 +60,7 @@ static void dmxDoSetShape(WindowPtr pWindow);
/** Initialize the private area for the window functions. */ /** Initialize the private area for the window functions. */
Bool dmxInitWindow(ScreenPtr pScreen) Bool dmxInitWindow(ScreenPtr pScreen)
{ {
if (!dixRequestPrivate(dmxWinPrivateKey, sizeof(dmxWinPrivRec))) if (!dixRegisterPrivateKey(&dmxWinPrivateKeyRec, PRIVATE_WINDOW, sizeof(dmxWinPrivRec)))
return FALSE; return FALSE;
return TRUE; return TRUE;

View File

@ -96,9 +96,6 @@ extern Bool dmxBEDestroyWindow(WindowPtr pWindow);
/* Support for shape extension */ /* Support for shape extension */
extern void dmxSetShape(WindowPtr pWindow, int kind); extern void dmxSetShape(WindowPtr pWindow, int kind);
/** Private index. \see dmxwindow.c \see dmxscrinit.c */
extern DevPrivateKey dmxWinPrivateKey;
/** Get window private pointer. */ /** Get window private pointer. */
#define DMX_GET_WINDOW_PRIV(_pWin) ((dmxWinPrivPtr) \ #define DMX_GET_WINDOW_PRIV(_pWin) ((dmxWinPrivPtr) \
dixLookupPrivate(&(_pWin)->devPrivates, dmxWinPrivateKey)) dixLookupPrivate(&(_pWin)->devPrivates, dmxWinPrivateKey))

View File

@ -109,10 +109,10 @@ static Bool findWindowPairFromLocal (WindowPtr a_local,
static unsigned char DRIReqCode = 0; static unsigned char DRIReqCode = 0;
static int ephyrDRIWindowKeyIndex; static DevPrivateKeyRec ephyrDRIWindowKeyRec;
static DevPrivateKey ephyrDRIWindowKey = &ephyrDRIWindowKeyIndex; #define ephyrDRIWindowKey (&ephyrDRIWindowKeyRec)
static int ephyrDRIScreenKeyIndex; static DevPrivateKeyRec ephyrDRIScreenKeyRec;
static DevPrivateKey ephyrDRIScreenKey = &ephyrDRIScreenKeyIndex; #define ephyrDRIScreenKey (&ephyrDRIScreenKeyRec)
#define GET_EPHYR_DRI_WINDOW_PRIV(win) ((EphyrDRIWindowPrivPtr) \ #define GET_EPHYR_DRI_WINDOW_PRIV(win) ((EphyrDRIWindowPrivPtr) \
dixLookupPrivate(&(win)->devPrivates, ephyrDRIWindowKey)) dixLookupPrivate(&(win)->devPrivates, ephyrDRIWindowKey))

View File

@ -64,8 +64,7 @@ KdDepths kdDepths[] = {
#define KD_DEFAULT_BUTTONS 5 #define KD_DEFAULT_BUTTONS 5
static int kdScreenPrivateKeyIndex; DevPrivateKeyRec kdScreenPrivateKeyRec;
DevPrivateKey kdScreenPrivateKey = &kdScreenPrivateKeyIndex;
unsigned long kdGeneration; unsigned long kdGeneration;
Bool kdVideoTest; Bool kdVideoTest;
@ -699,6 +698,9 @@ KdAllocatePrivates (ScreenPtr pScreen)
if (kdGeneration != serverGeneration) if (kdGeneration != serverGeneration)
kdGeneration = serverGeneration; kdGeneration = serverGeneration;
if (!dixRegisterPrivateKey(&kdScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
pScreenPriv = calloc(1, sizeof (*pScreenPriv)); pScreenPriv = calloc(1, sizeof (*pScreenPriv));
if (!pScreenPriv) if (!pScreenPriv)
return FALSE; return FALSE;

View File

@ -342,7 +342,9 @@ typedef struct _KdPointerMatrix {
(PixmapWidthPaddingInfo[d].padRoundUp+1))) (PixmapWidthPaddingInfo[d].padRoundUp+1)))
#endif #endif
extern DevPrivateKey kdScreenPrivateKey; extern DevPrivateKeyRec kdScreenPrivateKeyRec;
#define kdScreenPrivateKey (&kdScreenPrivateKeyRec)
extern unsigned long kdGeneration; extern unsigned long kdGeneration;
extern Bool kdEnabled; extern Bool kdEnabled;
extern Bool kdSwitchPending; extern Bool kdSwitchPending;

View File

@ -103,10 +103,10 @@ static void KdXVClipNotify(WindowPtr pWin, int dx, int dy);
/* misc */ /* misc */
static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr*, int); static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr*, int);
static int KdXVWindowKeyIndex; static DevPrivateKeyRec KdXVWindowKeyRec;
DevPrivateKey KdXVWindowKey = &KdXVWindowKeyIndex; #define KdXVWindowKey (&KdXVWindowKeyRec)
static int KdXvScreenKeyIndex; static DevPrivateKeyRec KdXvScreenKeyRec;
DevPrivateKey KdXvScreenKey = &KdXvScreenKeyIndex; #define KdXvScreenKey (&KdXvScreenKeyRec)
static unsigned long KdXVGeneration = 0; static unsigned long KdXVGeneration = 0;
static unsigned long PortResource = 0; static unsigned long PortResource = 0;
@ -199,6 +199,12 @@ KdXVScreenInit(
if(!XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc) if(!XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc)
return FALSE; return FALSE;
if (!dixRegisterPrivateKey(&KdXVWindowKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
if (!dixRegisterPrivateKey(&KdXVScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if(Success != (*XvScreenInitProc)(pScreen)) return FALSE; if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
KdXvScreenKey = (*XvGetScreenKeyProc)(); KdXvScreenKey = (*XvGetScreenKeyProc)();

View File

@ -389,8 +389,8 @@ ddxProcessArgument(int argc, char *argv[], int i)
return 0; return 0;
} }
static int cmapScrPrivateKeyIndex; static DevPrivateKeyRec cmapScrPrivateKeyRec;
static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex; #define cmapScrPrivateKey (&cmapScrPrivateKeyRec)
#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey)) #define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c)) #define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))
@ -811,6 +811,9 @@ vfbScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
int ret; int ret;
char *pbits; char *pbits;
if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (dpix == 0) if (dpix == 0)
dpix = 100; dpix = 100;

View File

@ -55,9 +55,16 @@
extern _X_EXPORT int xf86DoConfigure; extern _X_EXPORT int xf86DoConfigure;
extern _X_EXPORT int xf86DoShowOptions; extern _X_EXPORT int xf86DoShowOptions;
extern _X_EXPORT Bool xf86DoConfigurePass1; extern _X_EXPORT Bool xf86DoConfigurePass1;
extern _X_EXPORT DevPrivateKey xf86ScreenKey;
extern _X_EXPORT DevPrivateKey xf86CreateRootWindowKey; extern _X_EXPORT DevPrivateKeyRec xf86ScreenKeyRec;
extern _X_EXPORT DevPrivateKey xf86PixmapKey; #define xf86ScreenKey (&xf86ScreenKeyRec)
extern _X_EXPORT DevPrivateKeyRec xf86CreateRootWindowKeyRec;
#define xf86CreateRootWindowKey (&xf86CreateRootWindowKeyRec)
extern _X_EXPORT DevPrivateKeyRec xf86PixmapKeyRec;
#define xf86PixmapKey (&xf86PixmapKeyRec)
extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */ extern _X_EXPORT ScrnInfoPtr *xf86Screens; /* List of pointers to ScrnInfoRecs */
extern _X_EXPORT const unsigned char byte_reversed[256]; extern _X_EXPORT const unsigned char byte_reversed[256];
extern _X_EXPORT Bool fbSlotClaimed; extern _X_EXPORT Bool fbSlotClaimed;

View File

@ -51,8 +51,8 @@
#include "mi.h" #include "mi.h"
static int DGAScreenKeyIndex; static DevPrivateKeyRec DGAScreenKeyRec;
static DevPrivateKey DGAScreenKey; #define DGAScreenKeyRegistered dixPrivateKeyRegistered(&DGAScreenKeyRec)
static int mieq_installed = 0; static int mieq_installed = 0;
static Bool DGACloseScreen(int i, ScreenPtr pScreen); static Bool DGACloseScreen(int i, ScreenPtr pScreen);
@ -71,7 +71,7 @@ DGACopyModeInfo(
int *XDGAEventBase = NULL; int *XDGAEventBase = NULL;
#define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \ #define DGA_GET_SCREEN_PRIV(pScreen) ((DGAScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, DGAScreenKey)) dixLookupPrivate(&(pScreen)->devPrivates, &DGAScreenKeyRec))
typedef struct _FakedVisualList{ typedef struct _FakedVisualList{
@ -118,7 +118,8 @@ DGAInit(
if(!modes || num <= 0) if(!modes || num <= 0)
return FALSE; return FALSE;
DGAScreenKey = &DGAScreenKeyIndex; if (!dixRegisterPrivateKey(&DGAScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
@ -126,7 +127,7 @@ DGAInit(
{ {
if(!(pScreenPriv = (DGAScreenPtr)malloc(sizeof(DGAScreenRec)))) if(!(pScreenPriv = (DGAScreenPtr)malloc(sizeof(DGAScreenRec))))
return FALSE; return FALSE;
dixSetPrivate(&pScreen->devPrivates, DGAScreenKey, pScreenPriv); dixSetPrivate(&pScreen->devPrivates, &DGAScreenKeyRec, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = DGACloseScreen; pScreen->CloseScreen = DGACloseScreen;
pScreenPriv->DestroyColormap = pScreen->DestroyColormap; pScreenPriv->DestroyColormap = pScreen->DestroyColormap;
@ -177,7 +178,7 @@ DGAReInitModes(
int i; int i;
/* No DGA? Ignore call (but don't make it look like it failed) */ /* No DGA? Ignore call (but don't make it look like it failed) */
if(DGAScreenKey == NULL) if(!DGAScreenKeyRegistered)
return TRUE; return TRUE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
@ -347,7 +348,7 @@ xf86SetDGAMode(
DGAModePtr pMode = NULL; DGAModePtr pMode = NULL;
/* First check if DGAInit was successful on this screen */ /* First check if DGAInit was successful on this screen */
if (DGAScreenKey == NULL) if (!DGAScreenKeyRegistered)
return BadValue; return BadValue;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if (!pScreenPriv) if (!pScreenPriv)
@ -478,7 +479,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
DGAModePtr pMode; DGAModePtr pMode;
PixmapPtr pPix; PixmapPtr pPix;
if(DGAScreenKey == NULL) if(!DGAScreenKeyRegistered)
return FALSE; return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@ -528,7 +529,7 @@ DGAChangePixmapMode(int index, int *x, int *y, int mode)
Bool Bool
DGAAvailable(int index) DGAAvailable(int index)
{ {
if(DGAScreenKey == NULL) if(!DGAScreenKeyRegistered)
return FALSE; return FALSE;
if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index])) if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
@ -542,7 +543,7 @@ DGAActive(int index)
{ {
DGAScreenPtr pScreenPriv; DGAScreenPtr pScreenPriv;
if(DGAScreenKey == NULL) if(!DGAScreenKeyRegistered)
return FALSE; return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@ -563,7 +564,7 @@ DGAShutdown(void)
ScrnInfoPtr pScrn; ScrnInfoPtr pScrn;
int i; int i;
if(DGAScreenKey == NULL) if(!DGAScreenKeyRegistered)
return; return;
for(i = 0; i < screenInfo.numScreens; i++) { for(i = 0; i < screenInfo.numScreens; i++) {
@ -893,7 +894,7 @@ DGAVTSwitch(void)
/* Alternatively, this could send events to DGA clients */ /* Alternatively, this could send events to DGA clients */
if(DGAScreenKey) { if(DGAScreenKeyRegistered) {
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
if(pScreenPriv && pScreenPriv->current) if(pScreenPriv && pScreenPriv->current)
@ -910,7 +911,7 @@ DGAStealKeyEvent(DeviceIntPtr dev, int index, int key_code, int is_down)
DGAScreenPtr pScreenPriv; DGAScreenPtr pScreenPriv;
DGAEvent event; DGAEvent event;
if(DGAScreenKey == NULL) /* no DGA */ if(!DGAScreenKeyRegistered) /* no DGA */
return FALSE; return FALSE;
if (key_code < 8 || key_code > 255) if (key_code < 8 || key_code > 255)
@ -943,7 +944,7 @@ DGAStealMotionEvent(DeviceIntPtr dev, int index, int dx, int dy)
DGAScreenPtr pScreenPriv; DGAScreenPtr pScreenPriv;
DGAEvent event; DGAEvent event;
if(DGAScreenKey == NULL) /* no DGA */ if(!DGAScreenKeyRegistered) /* no DGA */
return FALSE; return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@ -981,7 +982,7 @@ DGAStealButtonEvent(DeviceIntPtr dev, int index, int button, int is_down)
DGAScreenPtr pScreenPriv; DGAScreenPtr pScreenPriv;
DGAEvent event; DGAEvent event;
if (DGAScreenKey == NULL) if(!DGAScreenKeyRegistered) /* no DGA */
return FALSE; return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]); pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
@ -1009,7 +1010,7 @@ Bool
DGAIsDgaEvent (xEvent *e) DGAIsDgaEvent (xEvent *e)
{ {
int coreEquiv; int coreEquiv;
if (DGAScreenKey == NULL || XDGAEventBase == 0) if (!DGAScreenKeyRegistered || XDGAEventBase == 0)
return FALSE; return FALSE;
coreEquiv = e->u.u.type - *XDGAEventBase; coreEquiv = e->u.u.type - *XDGAEventBase;
if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify) if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify)
@ -1203,7 +1204,7 @@ DGAHandleEvent(int screen_num, InternalEvent *ev, DeviceIntPtr device)
DGAScreenPtr pScreenPriv; DGAScreenPtr pScreenPriv;
/* no DGA */ /* no DGA */
if (DGAScreenKey == NULL || XDGAEventBase == 0) if (!DGAScreenKeyRegistered || XDGAEventBase == 0)
return; return;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen); pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);

View File

@ -46,7 +46,7 @@
#ifdef DPMSExtension #ifdef DPMSExtension
static int DPMSKeyIndex; static DevPrivateKeyRec DPMSKeyRec;
static DevPrivateKey DPMSKey; static DevPrivateKey DPMSKey;
static Bool DPMSClose(int i, ScreenPtr pScreen); static Bool DPMSClose(int i, ScreenPtr pScreen);
static int DPMSCount = 0; static int DPMSCount = 0;
@ -62,10 +62,9 @@ xf86DPMSInit(ScreenPtr pScreen, DPMSSetProcPtr set, int flags)
pointer DPMSOpt; pointer DPMSOpt;
MessageType enabled_from; MessageType enabled_from;
DPMSKey = &DPMSKeyIndex; DPMSKey = &DPMSKeyRec;
if (!dixSetPrivate(&pScreen->devPrivates, DPMSKey, if (!dixRegisterPrivateKey(&DPMSKeyRec, PRIVATE_SCREEN, sizeof (DPMSRec)))
calloc(sizeof(DPMSRec), 1)))
return FALSE; return FALSE;
pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey); pDPMS = dixLookupPrivate(&pScreen->devPrivates, DPMSKey);
@ -127,8 +126,6 @@ DPMSClose(int i, ScreenPtr pScreen)
xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0); xf86Screens[i]->DPMSSet(xf86Screens[i],DPMSModeOn,0);
} }
free(pDPMS);
dixSetPrivate(&pScreen->devPrivates, DPMSKey, NULL);
if (--DPMSCount == 0) if (--DPMSCount == 0)
DPMSKey = NULL; DPMSKey = NULL;
return pScreen->CloseScreen(i, pScreen); return pScreen->CloseScreen(i, pScreen);

View File

@ -47,14 +47,10 @@
/* Globals that video drivers may access */ /* Globals that video drivers may access */
/* Index into pScreen.devPrivates */ DevPrivateKeyRec xf86CreateRootWindowKeyRec;
static int xf86CreateRootWindowKeyIndex; DevPrivateKeyRec xf86ScreenKeyRec;
DevPrivateKey xf86CreateRootWindowKey = &xf86CreateRootWindowKeyIndex; DevPrivateKeyRec xf86PixmapKeyRec;
/* Index of ScrnInfo in pScreen.devPrivates */
static int xf86ScreenKeyIndex;
DevPrivateKey xf86ScreenKey = &xf86ScreenKeyIndex;
static int xf86PixmapKeyIndex;
DevPrivateKey xf86PixmapKey = &xf86PixmapKeyIndex;
ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */ ScrnInfoPtr *xf86Screens = NULL; /* List of ScrnInfos */
const unsigned char byte_reversed[256] = const unsigned char byte_reversed[256] =
{ {

View File

@ -66,6 +66,7 @@
#include "xf86Priv.h" #include "xf86Priv.h"
#include "xf86Config.h" #include "xf86Config.h"
#include "xf86_OSlib.h" #include "xf86_OSlib.h"
#include "xf86cmap.h"
#include "xorgVersion.h" #include "xorgVersion.h"
#include "xf86Build.h" #include "xf86Build.h"
#include "mipointer.h" #include "mipointer.h"
@ -734,6 +735,15 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
} }
#endif /* SCO325 */ #endif /* SCO325 */
for (i = 0; i < xf86NumScreens; i++)
if (!xf86ColormapAllocatePrivates(xf86Screens[i]))
FatalError("Cannot register DDX private keys");
if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) ||
!dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0) ||
!dixRegisterPrivateKey(&xf86PixmapKeyRec, PRIVATE_PIXMAP, 0))
FatalError("Cannot register DDX private keys");
for (i = 0; i < xf86NumScreens; i++) { for (i = 0; i < xf86NumScreens; i++) {
xf86VGAarbiterLock(xf86Screens[i]); xf86VGAarbiterLock(xf86Screens[i]);
/* /*

View File

@ -46,7 +46,7 @@ typedef struct _xf86RandRInfo {
Rotation rotation; Rotation rotation;
} XF86RandRInfoRec, *XF86RandRInfoPtr; } XF86RandRInfoRec, *XF86RandRInfoPtr;
static int xf86RandRKeyIndex; static DevPrivateKeyRec xf86RandRKeyRec;
static DevPrivateKey xf86RandRKey; static DevPrivateKey xf86RandRKey;
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey)) #define XF86RANDRINFO(p) ((XF86RandRInfoPtr)dixLookupPrivate(&(p)->devPrivates, xf86RandRKey))
@ -424,7 +424,10 @@ xf86RandRInit (ScreenPtr pScreen)
return TRUE; return TRUE;
#endif #endif
xf86RandRKey = &xf86RandRKeyIndex; xf86RandRKey = &xf86RandRKeyRec;
if (!dixRegisterPrivateKey(&xf86RandRKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
randrp = malloc(sizeof (XF86RandRInfoRec)); randrp = malloc(sizeof (XF86RandRInfoRec));
if (!randrp) if (!randrp)

View File

@ -62,10 +62,10 @@ static miPointerSpriteFuncRec VGAarbiterSpriteFuncs = {
VGAarbiterDeviceCursorInitialize, VGAarbiterDeviceCursorCleanup VGAarbiterDeviceCursorInitialize, VGAarbiterDeviceCursorCleanup
}; };
static int VGAarbiterKeyIndex; static DevPrivateKeyRec VGAarbiterScreenKeyRec;
static DevPrivateKey VGAarbiterScreenKey = &VGAarbiterKeyIndex; #define VGAarbiterScreenKey (&VGAarbiterScreenKeyRec)
static int VGAarbiterGCIndex; static DevPrivateKeyRec VGAarbiterGCKeyRec;
static DevPrivateKey VGAarbiterGCKey = &VGAarbiterGCIndex; #define VGAarbiterGCKey (&VGAarbiterGCKeyRec)
static int vga_no_arb = 0; static int vga_no_arb = 0;
void void
@ -175,9 +175,12 @@ xf86VGAarbiterWrapFunctions(void)
pScrn = xf86Screens[pScreen->myNum]; pScrn = xf86Screens[pScreen->myNum];
PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
if (!dixRequestPrivate(VGAarbiterGCKey, sizeof(VGAarbiterGCRec))) if (!dixRegisterPrivateKey(&VGAarbiterGCKeyRec, PRIVATE_GC, sizeof(VGAarbiterGCRec)))
return FALSE; return FALSE;
if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec)))) if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec))))
return FALSE; return FALSE;

View File

@ -47,7 +47,7 @@
#include "vidmodeproc.h" #include "vidmodeproc.h"
#include "xf86cmap.h" #include "xf86cmap.h"
static int VidModeKeyIndex; static DevPrivateKeyRec VidModeKeyRec;
static DevPrivateKey VidModeKey; static DevPrivateKey VidModeKey;
static int VidModeCount = 0; static int VidModeCount = 0;
static Bool VidModeClose(int i, ScreenPtr pScreen); static Bool VidModeClose(int i, ScreenPtr pScreen);
@ -67,15 +67,17 @@ VidModeExtensionInit(ScreenPtr pScreen)
return FALSE; return FALSE;
} }
VidModeKey = &VidModeKeyIndex; VidModeKey = &VidModeKeyRec;
if (!dixSetPrivate(&pScreen->devPrivates, VidModeKey, if (!dixRegisterPrivateKey(&VidModeKeyRec, PRIVATE_SCREEN, 0))
calloc(sizeof(VidModeRec), 1))) {
DebugF("xcalloc failed\n");
return FALSE; return FALSE;
}
pVidMode = VMPTR(pScreen); pVidMode = calloc(sizeof(VidModeRec), 1);
if (!pVidMode)
return FALSE;
dixSetPrivate(&pScreen->devPrivates, VidModeKey, pVidMode);
pVidMode->Flags = 0; pVidMode->Flags = 0;
pVidMode->Next = NULL; pVidMode->Next = NULL;
pVidMode->CloseScreen = pScreen->CloseScreen; pVidMode->CloseScreen = pScreen->CloseScreen;

View File

@ -102,10 +102,11 @@ typedef struct {
int overscan; int overscan;
} CMapColormapRec, *CMapColormapPtr; } CMapColormapRec, *CMapColormapPtr;
static int CMapScreenKeyIndex; static DevPrivateKeyRec CMapScreenKeyRec;
static DevPrivateKey CMapScreenKey; #define CMapScreenKeyRegistered dixPrivateKeyRegistered(&CMapScreenKeyRec)
static int CMapColormapKeyIndex; #define CMapScreenKey (&CMapScreenKeyRec)
static DevPrivateKey CMapColormapKey = &CMapColormapKeyIndex; static DevPrivateKeyRec CMapColormapKeyRec;
#define CMapColormapKey (&CMapColormapKeyRec)
static void CMapInstallColormap(ColormapPtr); static void CMapInstallColormap(ColormapPtr);
static void CMapStoreColors(ColormapPtr, int, xColorItem *); static void CMapStoreColors(ColormapPtr, int, xColorItem *);
@ -128,6 +129,18 @@ static void CMapReinstallMap(ColormapPtr);
static void CMapUnwrapScreen(ScreenPtr pScreen); static void CMapUnwrapScreen(ScreenPtr pScreen);
Bool xf86ColormapAllocatePrivates(ScrnInfoPtr pScrn)
{
/* If we support a better colormap system, then pretend we succeeded. */
if (xf86_crtc_supports_gamma(pScrn))
return TRUE;
if (!dixRegisterPrivateKey(&CMapScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&CMapColormapKeyRec, PRIVATE_COLORMAP, 0))
return FALSE;
return TRUE;
}
Bool xf86HandleColormaps( Bool xf86HandleColormaps(
ScreenPtr pScreen, ScreenPtr pScreen,
@ -151,8 +164,6 @@ Bool xf86HandleColormaps(
if(!maxColors || !sigRGBbits || !loadPalette) if(!maxColors || !sigRGBbits || !loadPalette)
return FALSE; return FALSE;
CMapScreenKey = &CMapScreenKeyIndex;
elements = 1 << sigRGBbits; elements = 1 << sigRGBbits;
if(!(gamma = malloc(elements * sizeof(LOCO)))) if(!(gamma = malloc(elements * sizeof(LOCO))))
@ -169,7 +180,7 @@ Bool xf86HandleColormaps(
return FALSE; return FALSE;
} }
dixSetPrivate(&pScreen->devPrivates, CMapScreenKey, pScreenPriv); dixSetPrivate(&pScreen->devPrivates, &CMapScreenKeyRec, pScreenPriv);
pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreenPriv->CloseScreen = pScreen->CloseScreen;
pScreenPriv->CreateColormap = pScreen->CreateColormap; pScreenPriv->CreateColormap = pScreen->CreateColormap;
@ -900,7 +911,7 @@ CMapChangeGamma(
CMapLinkPtr pLink; CMapLinkPtr pLink;
/* Is this sufficient checking ? */ /* Is this sufficient checking ? */
if(CMapScreenKey == NULL) if(!CMapScreenKeyRegistered)
return BadImplementation; return BadImplementation;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
@ -1012,7 +1023,7 @@ xf86ChangeGammaRamp(
} }
} }
if(CMapScreenKey == NULL) if(!CMapScreenKeyRegistered)
return BadImplementation; return BadImplementation;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
@ -1080,7 +1091,7 @@ xf86GetGammaRampSize(ScreenPtr pScreen)
return crtc->gammaSize; return crtc->gammaSize;
} }
if(CMapScreenKey == NULL) return 0; if(!CMapScreenKeyRegistered) return 0;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
CMapScreenKey); CMapScreenKey);
@ -1120,7 +1131,7 @@ xf86GetGammaRamp(
} }
} }
if(CMapScreenKey == NULL) if(!CMapScreenKeyRegistered)
return BadImplementation; return BadImplementation;
pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates, pScreenPriv = (CMapScreenPtr)dixLookupPrivate(&pScreen->devPrivates,

View File

@ -45,6 +45,10 @@ extern _X_EXPORT Bool xf86HandleColormaps(
unsigned int flags unsigned int flags
); );
extern _X_EXPORT Bool xf86ColormapAllocatePrivates(
ScrnInfoPtr pScrn
);
extern _X_EXPORT int extern _X_EXPORT int
xf86ChangeGamma( xf86ChangeGamma(
ScreenPtr pScreen, ScreenPtr pScreen,

View File

@ -42,7 +42,7 @@
#define DEBUG #define DEBUG
*/ */
static int xf86FBManagerKeyIndex; static DevPrivateKeyRec xf86FBManagerKeyRec;
static DevPrivateKey xf86FBManagerKey; static DevPrivateKey xf86FBManagerKey;
Bool xf86RegisterOffscreenManager( Bool xf86RegisterOffscreenManager(
@ -50,7 +50,11 @@ Bool xf86RegisterOffscreenManager(
FBManagerFuncsPtr funcs FBManagerFuncsPtr funcs
){ ){
xf86FBManagerKey = &xf86FBManagerKeyIndex; xf86FBManagerKey = &xf86FBManagerKeyRec;
if (!dixRegisterPrivateKey(&xf86FBManagerKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs); dixSetPrivate(&pScreen->devPrivates, xf86FBManagerKey, funcs);
return TRUE; return TRUE;
@ -60,8 +64,9 @@ Bool xf86RegisterOffscreenManager(
Bool Bool
xf86FBManagerRunning(ScreenPtr pScreen) xf86FBManagerRunning(ScreenPtr pScreen)
{ {
if(xf86FBManagerKey == NULL) if (xf86FBManagerKey == NULL)
return FALSE; return FALSE;
if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey)) if(!dixLookupPrivate(&pScreen->devPrivates, xf86FBManagerKey))
return FALSE; return FALSE;
@ -270,8 +275,8 @@ xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
\************************************************************/ \************************************************************/
static int xf86FBScreenKeyIndex; static DevPrivateKeyRec xf86FBScreenKeyRec;
static DevPrivateKey xf86FBScreenKey = &xf86FBScreenKeyIndex; #define xf86FBScreenKey (&xf86FBScreenKeyRec)
typedef struct _FBLink { typedef struct _FBLink {
FBArea area; FBArea area;
@ -1321,6 +1326,9 @@ xf86InitFBManagerRegion(
if(RegionNil(FullRegion)) if(RegionNil(FullRegion))
return FALSE; return FALSE;
if (!dixRegisterPrivateKey(&xf86FBScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs)) if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
return FALSE; return FALSE;

View File

@ -110,10 +110,11 @@ static void xf86XVAdjustFrame(int index, int x, int y, int flags);
static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int); static Bool xf86XVInitAdaptors(ScreenPtr, XF86VideoAdaptorPtr*, int);
static int XF86XVWindowKeyIndex; static DevPrivateKeyRec XF86XVWindowKeyRec;
static DevPrivateKey XF86XVWindowKey = &XF86XVWindowKeyIndex; #define XF86XVWindowKey (&XF86XVWindowKeyRec)
static int XF86XvScreenKeyIndex;
DevPrivateKey XF86XvScreenKey = &XF86XvScreenKeyIndex; DevPrivateKey XF86XvScreenKey;
static unsigned long PortResource = 0; static unsigned long PortResource = 0;
DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL; DevPrivateKey (*XvGetScreenKeyProc)(void) = NULL;
@ -186,8 +187,8 @@ typedef struct {
int num; int num;
} OffscreenImageRec; } OffscreenImageRec;
static int OffscreenPrivateKeyIndex; static DevPrivateKeyRec OffscreenPrivateKeyRec;
static DevPrivateKey OffscreenPrivateKey = &OffscreenPrivateKeyIndex; #define OffscreenPrivateKey (&OffscreenPrivateKeyRec)
#define GetOffscreenImage(pScreen) ((OffscreenImageRec *) dixLookupPrivate(&(pScreen)->devPrivates, OffscreenPrivateKey)) #define GetOffscreenImage(pScreen) ((OffscreenImageRec *) dixLookupPrivate(&(pScreen)->devPrivates, OffscreenPrivateKey))
Bool Bool
@ -198,9 +199,9 @@ xf86XVRegisterOffscreenImages(
){ ){
OffscreenImageRec *OffscreenImage; OffscreenImageRec *OffscreenImage;
/* This function may be called before xf86XVScreenInit, so there's /* This function may be called before xf86XVScreenInit, so there's
* no better place than this to call dixRequestPrivate to ensure we * no better place than this to call dixRegisterPrivateKey to ensure we
* have space reserved. After the first call it is a no-op. */ * have space reserved. After the first call it is a no-op. */
if(!dixRequestPrivate(OffscreenPrivateKey, sizeof(OffscreenImageRec)) || if(!dixRegisterPrivateKey(OffscreenPrivateKey, PRIVATE_SCREEN, sizeof(OffscreenImageRec)) ||
!(OffscreenImage = GetOffscreenImage(pScreen))) !(OffscreenImage = GetOffscreenImage(pScreen)))
/* Every X.org driver assumes this function always succeeds, so /* Every X.org driver assumes this function always succeeds, so
* just die on allocation failure. */ * just die on allocation failure. */
@ -251,7 +252,11 @@ xf86XVScreenInit(
if(Success != (*XvScreenInitProc)(pScreen)) return FALSE; if(Success != (*XvScreenInitProc)(pScreen)) return FALSE;
if (!dixRegisterPrivateKey(&XF86XVWindowKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
XF86XvScreenKey = (*XvGetScreenKeyProc)(); XF86XvScreenKey = (*XvGetScreenKeyProc)();
PortResource = (*XvGetRTPortProc)(); PortResource = (*XvGetRTPortProc)();
pxvs = GET_XV_SCREEN(pScreen); pxvs = GET_XV_SCREEN(pScreen);

View File

@ -55,8 +55,8 @@ typedef struct {
XvMCAdaptorPtr dixinfo; XvMCAdaptorPtr dixinfo;
} xf86XvMCScreenRec, *xf86XvMCScreenPtr; } xf86XvMCScreenRec, *xf86XvMCScreenPtr;
static int XF86XvMCScreenKeyIndex; static DevPrivateKeyRec XF86XvMCScreenKeyRec;
static DevPrivateKey XF86XvMCScreenKey = &XF86XvMCScreenKeyIndex; #define XF86XvMCScreenKey (&XF86XvMCScreenKeyRec)
#define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \ #define XF86XVMC_GET_PRIVATE(pScreen) (xf86XvMCScreenPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey) dixLookupPrivate(&(pScreen)->devPrivates, XF86XvMCScreenKey)
@ -172,6 +172,9 @@ Bool xf86XvMCScreenInit(
if(!(pAdapt = malloc(sizeof(XvMCAdaptorRec) * num_adaptors))) if(!(pAdapt = malloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
return FALSE; return FALSE;
if (!dixRegisterPrivateKey(&XF86XvMCScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if(!(pScreenPriv = malloc(sizeof(xf86XvMCScreenRec)))) { if(!(pScreenPriv = malloc(sizeof(xf86XvMCScreenRec)))) {
free(pAdapt); free(pAdapt);
return FALSE; return FALSE;

View File

@ -61,10 +61,11 @@ unsigned char DGAReqCode = 0;
int DGAErrorBase; int DGAErrorBase;
int DGAEventBase; int DGAEventBase;
static int DGAScreenPrivateKeyIndex; static DevPrivateKeyRec DGAScreenPrivateKeyRec;
static DevPrivateKey DGAScreenPrivateKey = &DGAScreenPrivateKeyIndex; #define DGAScreenPrivateKey (&DGAScreenPrivateKeyRec)
static int DGAClientPrivateKeyIndex; #define DGAScreenPrivateKeyRegistered (DGAScreenPrivateKeyRec.initialized)
static DevPrivateKey DGAClientPrivateKey = &DGAClientPrivateKeyIndex; static DevPrivateKeyRec DGAClientPrivateKeyRec;
#define DGAClientPrivateKey (&DGAClientPrivateKeyRec)
static int DGACallbackRefCount = 0; static int DGACallbackRefCount = 0;
/* This holds the client's version information */ /* This holds the client's version information */
@ -89,6 +90,12 @@ XFree86DGAExtensionInit(INITARGS)
{ {
ExtensionEntry* extEntry; ExtensionEntry* extEntry;
if (!dixRegisterPrivateKey(&DGAClientPrivateKeyRec, PRIVATE_CLIENT, 0))
return;
if (!dixRegisterPrivateKey(&DGAScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return;
if ((extEntry = AddExtension(XF86DGANAME, if ((extEntry = AddExtension(XF86DGANAME,
XF86DGANumberEvents, XF86DGANumberEvents,
XF86DGANumberErrors, XF86DGANumberErrors,
@ -717,13 +724,13 @@ ProcXF86DGADirectVideo(ClientPtr client)
if (stuff->screen > screenInfo.numScreens) if (stuff->screen > screenInfo.numScreens)
return BadValue; return BadValue;
owner = DGA_GETCLIENT(stuff->screen);
REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq); REQUEST_SIZE_MATCH(xXF86DGADirectVideoReq);
if (!DGAAvailable(stuff->screen)) if (!DGAAvailable(stuff->screen))
return DGAErrorBase + XF86DGANoDirectVideoMode; return DGAErrorBase + XF86DGANoDirectVideoMode;
owner = DGA_GETCLIENT(stuff->screen);
if (owner && owner != client) if (owner && owner != client)
return DGAErrorBase + XF86DGANoDirectVideoMode; return DGAErrorBase + XF86DGANoDirectVideoMode;

View File

@ -51,8 +51,8 @@ from Kaleb S. KEITHLEY
#define DEFAULT_XF86VIDMODE_VERBOSITY 3 #define DEFAULT_XF86VIDMODE_VERBOSITY 3
static int VidModeErrorBase; static int VidModeErrorBase;
static int VidModeClientPrivateKeyIndex; static DevPrivateKeyRec VidModeClientPrivateKeyRec;
static DevPrivateKey VidModeClientPrivateKey = &VidModeClientPrivateKeyIndex; #define VidModeClientPrivateKey (&VidModeClientPrivateKeyRec)
/* This holds the client's version information */ /* This holds the client's version information */
typedef struct { typedef struct {
@ -141,8 +141,8 @@ typedef struct _XF86VidModeScreenPrivate {
Bool hasWindow; Bool hasWindow;
} XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr; } XF86VidModeScreenPrivateRec, *XF86VidModeScreenPrivatePtr;
static int ScreenPrivateKeyIndex; static DevPrivateKeyRec ScreenPrivateKeyRec;
static DevPrivateKey ScreenPrivateKey = &ScreenPrivateKeyIndex; #define ScreenPrivateKey (&ScreenPrivateKeyRec)
#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \ #define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \
dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey)) dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey))
@ -169,6 +169,13 @@ XFree86VidModeExtensionInit(void)
DEBUG_P("XFree86VidModeExtensionInit"); DEBUG_P("XFree86VidModeExtensionInit");
if (!dixRegisterPrivateKey(&VidModeClientPrivateKeyRec, PRIVATE_CLIENT, 0))
return;
#ifdef XF86VIDMODE_EVENTS
if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return;
#endif
#ifdef XF86VIDMODE_EVENTS #ifdef XF86VIDMODE_EVENTS
EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent"); EventType = CreateNewResourceType(XF86VidModeFreeEvents, "VidModeEvent");
#endif #endif
@ -177,9 +184,6 @@ XFree86VidModeExtensionInit(void)
pScreen = screenInfo.screens[i]; pScreen = screenInfo.screens[i];
if (VidModeExtensionInit(pScreen)) if (VidModeExtensionInit(pScreen))
enabled = TRUE; enabled = TRUE;
#ifdef XF86VIDMODE_EVENTS
SetScreenPrivate (pScreen, NULL);
#endif
} }
/* This means that the DDX doesn't want the vidmode extension enabled */ /* This means that the DDX doesn't want the vidmode extension enabled */
if (!enabled) if (!enabled)

View File

@ -74,10 +74,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu) #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
static int DRIEntPrivIndex = -1; static int DRIEntPrivIndex = -1;
static int DRIScreenPrivKeyIndex; static DevPrivateKeyRec DRIScreenPrivKeyRec;
static DevPrivateKey DRIScreenPrivKey = &DRIScreenPrivKeyIndex; #define DRIScreenPrivKey (&DRIScreenPrivKeyRec)
static int DRIWindowPrivKeyIndex; static DevPrivateKeyRec DRIWindowPrivKeyRec;
static DevPrivateKey DRIWindowPrivKey = &DRIWindowPrivKeyIndex; #define DRIWindowPrivKey (&DRIWindowPrivKeyRec)
static unsigned long DRIGeneration = 0; static unsigned long DRIGeneration = 0;
static unsigned int DRIDrawableValidationStamp = 0; static unsigned int DRIDrawableValidationStamp = 0;
@ -357,6 +357,11 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
if (DRIGeneration != serverGeneration) if (DRIGeneration != serverGeneration)
DRIGeneration = serverGeneration; DRIGeneration = serverGeneration;
if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec)); pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec));
if (!pDRIPriv) { if (!pDRIPriv) {
dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL);
@ -785,7 +790,7 @@ drmServerInfo DRIDRMServerInfo = {
Bool Bool
DRIExtensionInit(void) DRIExtensionInit(void)
{ {
if (!DRIScreenPrivKey || DRIGeneration != serverGeneration) { if (DRIGeneration != serverGeneration) {
return FALSE; return FALSE;
} }

View File

@ -51,12 +51,15 @@
CARD8 dri2_major; /* version of DRI2 supported by DDX */ CARD8 dri2_major; /* version of DRI2 supported by DDX */
CARD8 dri2_minor; CARD8 dri2_minor;
static int dri2ScreenPrivateKeyIndex; static DevPrivateKeyRec dri2ScreenPrivateKeyRec;
static DevPrivateKey dri2ScreenPrivateKey = &dri2ScreenPrivateKeyIndex; #define dri2ScreenPrivateKey (&dri2ScreenPrivateKeyRec)
static int dri2WindowPrivateKeyIndex;
static DevPrivateKey dri2WindowPrivateKey = &dri2WindowPrivateKeyIndex; static DevPrivateKeyRec dri2WindowPrivateKeyRec;
static int dri2PixmapPrivateKeyIndex; #define dri2WindowPrivateKey (&dri2WindowPrivateKeyRec)
static DevPrivateKey dri2PixmapPrivateKey = &dri2PixmapPrivateKeyIndex;
static DevPrivateKeyRec dri2PixmapPrivateKeyRec;
#define dri2PixmapPrivateKey (&dri2PixmapPrivateKeyRec)
static RESTYPE dri2DrawableRes; static RESTYPE dri2DrawableRes;
typedef struct _DRI2Screen *DRI2ScreenPtr; typedef struct _DRI2Screen *DRI2ScreenPtr;
@ -1025,6 +1028,15 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
return FALSE; return FALSE;
} }
if (!dixRegisterPrivateKey(&dri2ScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if (!dixRegisterPrivateKey(&dri2WindowPrivateKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
if (!dixRegisterPrivateKey(&dri2PixmapPrivateKeyRec, PRIVATE_PIXMAP, 0))
return FALSE;
ds = calloc(1, sizeof *ds); ds = calloc(1, sizeof *ds);
if (!ds) if (!ds)
return FALSE; return FALSE;

View File

@ -42,8 +42,8 @@ typedef struct _ExaXorgScreenPrivRec {
OptionInfoPtr options; OptionInfoPtr options;
} ExaXorgScreenPrivRec, *ExaXorgScreenPrivPtr; } ExaXorgScreenPrivRec, *ExaXorgScreenPrivPtr;
static int exaXorgScreenPrivateKeyIndex; static DevPrivateKeyRec exaXorgScreenPrivateKeyRec;
static DevPrivateKey exaXorgScreenPrivateKey = &exaXorgScreenPrivateKeyIndex; #define exaXorgScreenPrivateKey (&exaXorgScreenPrivateKeyRec)
typedef enum { typedef enum {
EXAOPT_MIGRATION_HEURISTIC, EXAOPT_MIGRATION_HEURISTIC,
@ -114,6 +114,9 @@ exaDDXDriverInit(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
ExaXorgScreenPrivPtr pScreenPriv; ExaXorgScreenPrivPtr pScreenPriv;
if (!dixRegisterPrivateKey(&exaXorgScreenPrivateKeyRec, PRIVATE_SCREEN, 0))
return;
pScreenPriv = calloc(1, sizeof(ExaXorgScreenPrivRec)); pScreenPriv = calloc(1, sizeof(ExaXorgScreenPrivRec));
if (pScreenPriv == NULL) if (pScreenPriv == NULL)
return; return;

View File

@ -71,7 +71,7 @@ static Bool xf86RandR12CreateScreenResources12 (ScreenPtr pScreen);
static int xf86RandR12Generation; static int xf86RandR12Generation;
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
static int xf86RandR12KeyIndex; static DevPrivateKeyRec xf86RandR12KeyRec;
static DevPrivateKey xf86RandR12Key; static DevPrivateKey xf86RandR12Key;
#define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \ #define XF86RANDRINFO(p) ((XF86RandRInfoPtr) \
dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key)) dixLookupPrivate(&(p)->devPrivates, xf86RandR12Key))
@ -883,7 +883,9 @@ xf86RandR12Init (ScreenPtr pScreen)
xf86RandR12Generation = serverGeneration; xf86RandR12Generation = serverGeneration;
#if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0) #if XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(7,0,0,0,0)
xf86RandR12Key = &xf86RandR12KeyIndex; xf86RandR12Key = &xf86RandR12KeyRec;
if (!dixRegisterPrivateKey(&xf86RandR12KeyRec, PRIVATE_SCREEN, 0))
return FALSE;
#else #else
xf86RandR12Index = AllocateScreenPrivateIndex(); xf86RandR12Index = AllocateScreenPrivateIndex();
#endif #endif

View File

@ -18,8 +18,7 @@
#include "inputstr.h" #include "inputstr.h"
extern InputInfo inputInfo; extern InputInfo inputInfo;
static int xf86CursorScreenKeyIndex; DevPrivateKeyRec xf86CursorScreenKeyRec;
DevPrivateKey xf86CursorScreenKey = &xf86CursorScreenKeyIndex;
/* sprite functions */ /* sprite functions */
@ -65,6 +64,9 @@ xf86InitCursor(
if (!xf86InitHardwareCursor(pScreen, infoPtr)) if (!xf86InitHardwareCursor(pScreen, infoPtr))
return FALSE; return FALSE;
if (!dixRegisterPrivateKey(&xf86CursorScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
ScreenPriv = calloc(1, sizeof(xf86CursorScreenRec)); ScreenPriv = calloc(1, sizeof(xf86CursorScreenRec));
if (!ScreenPriv) if (!ScreenPriv)
return FALSE; return FALSE;

View File

@ -45,6 +45,7 @@ Bool xf86InitHardwareCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr);
CARD32 xf86ReverseBitOrder(CARD32 data); CARD32 xf86ReverseBitOrder(CARD32 data);
extern _X_EXPORT DevPrivateKey xf86CursorScreenKey; extern _X_EXPORT DevPrivateKeyRec xf86CursorScreenKeyRec;
#define xf86CursorScreenKey (&xf86CursorScreenKeyRec)
#endif /* _XF86CURSORPRIV_H */ #endif /* _XF86CURSORPRIV_H */

View File

@ -84,11 +84,11 @@ typedef struct {
GCFuncs *funcs; GCFuncs *funcs;
} ShadowGCRec, *ShadowGCPtr; } ShadowGCRec, *ShadowGCPtr;
static DevPrivateKeyRec ShadowScreenKeyRec;
#define ShadowScreenKey (&ShadowScreenKeyRec)
static int ShadowScreenKeyIndex; static DevPrivateKeyRec ShadowGCKeyRec;
static DevPrivateKey ShadowScreenKey = &ShadowScreenKeyIndex; #define ShadowGCKey (&ShadowGCKeyRec)
static int ShadowGCKeyIndex;
static DevPrivateKey ShadowGCKey = &ShadowGCKeyIndex;
#define GET_SCREEN_PRIVATE(pScreen) \ #define GET_SCREEN_PRIVATE(pScreen) \
(ShadowScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, ShadowScreenKey) (ShadowScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, ShadowScreenKey)
@ -162,7 +162,10 @@ ShadowFBInit2 (
if(!preRefreshArea && !postRefreshArea) return FALSE; if(!preRefreshArea && !postRefreshArea) return FALSE;
if(!dixRequestPrivate(ShadowGCKey, sizeof(ShadowGCRec))) if (!dixRegisterPrivateKey(&ShadowScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if(!dixRegisterPrivateKey(&ShadowGCKeyRec, PRIVATE_GC, sizeof(ShadowGCRec)))
return FALSE; return FALSE;
if(!(pPriv = (ShadowScreenPtr)malloc(sizeof(ShadowScreenRec)))) if(!(pPriv = (ShadowScreenPtr)malloc(sizeof(ShadowScreenRec))))

View File

@ -42,12 +42,12 @@ static int XAASetDGAMode(int index, int num, DGADevicePtr devRet);
static void XAAEnableDisableFBAccess (int index, Bool enable); static void XAAEnableDisableFBAccess (int index, Bool enable);
static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask); static Bool XAAChangeWindowAttributes (WindowPtr pWin, unsigned long mask);
static int XAAScreenKeyIndex; static DevPrivateKeyRec XAAScreenKeyRec;
static DevPrivateKey XAAScreenKey = &XAAScreenKeyIndex; #define XAAScreenKey (&XAAScreenKeyRec)
static int XAAGCKeyIndex; static DevPrivateKeyRec XAAGCKeyRec;
static DevPrivateKey XAAGCKey = &XAAGCKeyIndex; #define XAAGCKey (&XAAGCKeyRec)
static int XAAPixmapKeyIndex; static DevPrivateKeyRec XAAPixmapKeyRec;
static DevPrivateKey XAAPixmapKey = &XAAPixmapKeyIndex; #define XAAPixmapKey (&XAAPixmapKeyRec)
DevPrivateKey XAAGetScreenKey(void) { DevPrivateKey XAAGetScreenKey(void) {
return XAAScreenKey; return XAAScreenKey;
@ -106,10 +106,13 @@ XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
if (!infoRec) if (!infoRec)
return TRUE; return TRUE;
if (!dixRequestPrivate(XAAGCKey, sizeof(XAAGCRec))) if (!dixRegisterPrivateKey(&XAAGCKeyRec, PRIVATE_GC, sizeof(XAAGCRec)))
return FALSE; return FALSE;
if (!dixRequestPrivate(XAAPixmapKey, sizeof(XAAPixmapRec))) if (!dixRegisterPrivateKey(&XAAPixmapKeyRec, PRIVATE_PIXMAP, sizeof(XAAPixmapRec)))
return FALSE;
if (!dixRegisterPrivateKey(&XAAScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE; return FALSE;
if (!(pScreenPriv = malloc(sizeof(XAAScreenRec)))) if (!(pScreenPriv = malloc(sizeof(XAAScreenRec))))

View File

@ -151,8 +151,8 @@ typedef struct {
int (*TiledFillChooser)(GCPtr); int (*TiledFillChooser)(GCPtr);
} XAAOverlayRec, *XAAOverlayPtr; } XAAOverlayRec, *XAAOverlayPtr;
static int XAAOverlayKeyIndex; static DevPrivateKeyRec XAAOverlayKeyRec;
static DevPrivateKey XAAOverlayKey = &XAAOverlayKeyIndex; #define XAAOverlayKey (&XAAOverlayKeyRec)
#define GET_OVERLAY_PRIV(pScreen) \ #define GET_OVERLAY_PRIV(pScreen) \
(XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey) (XAAOverlayPtr)dixLookupPrivate(&(pScreen)->devPrivates, XAAOverlayKey)
@ -173,6 +173,9 @@ XAAInitDualFramebufferOverlay(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen);
XAAOverlayPtr pOverPriv; XAAOverlayPtr pOverPriv;
if (!dixRegisterPrivateKey(&XAAOverlayKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
if(!(pOverPriv = malloc(sizeof(XAAOverlayRec)))) if(!(pOverPriv = malloc(sizeof(XAAOverlayRec))))
return FALSE; return FALSE;

View File

@ -272,8 +272,8 @@ typedef struct _XAAStateWrapRec {
int width, int height, int flags); int width, int height, int flags);
} XAAStateWrapRec, *XAAStateWrapPtr; } XAAStateWrapRec, *XAAStateWrapPtr;
static int XAAStateKeyIndex; static DevPrivateKeyRec XAAStateKeyRec;
static DevPrivateKey XAAStateKey = &XAAStateKeyIndex; #define XAAStateKey (&XAAStateKeyRec)
/* Wrap functions start here */ /* Wrap functions start here */
#define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\ #define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\
@ -1500,6 +1500,7 @@ XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
XAAStateWrapPtr pStatePriv; XAAStateWrapPtr pStatePriv;
int i = 0; int i = 0;
if (!dixRegisterPrivateKey(&XAAStateKeyRec, PRIVATE_SCREEN, 0)) return FALSE;
if(!(pStatePriv = malloc(sizeof(XAAStateWrapRec)))) return FALSE; if(!(pStatePriv = malloc(sizeof(XAAStateWrapRec)))) return FALSE;
dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv); dixSetPrivate(&pScreen->devPrivates, XAAStateKey, pStatePriv);
pStatePriv->RestoreAccelState = infoRec->RestoreAccelState; pStatePriv->RestoreAccelState = infoRec->RestoreAccelState;

View File

@ -125,10 +125,10 @@ typedef struct _xaaWrapperGCPriv {
#define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC) #define xaaWrapperGCPriv(pGC) xaaWrapperGCPrivPtr pGCPriv = xaaWrapperGetGCPriv(pGC)
static int xaaWrapperScrPrivateKeyIndex; static DevPrivateKeyRec xaaWrapperScrPrivateKeyRec;
static DevPrivateKey xaaWrapperScrPrivateKey = &xaaWrapperScrPrivateKeyIndex; #define xaaWrapperScrPrivateKey (&xaaWrapperScrPrivateKeyRec)
static int xaaWrapperGCPrivateKeyIndex; static DevPrivateKeyRec xaaWrapperGCPrivateKeyRec;
static DevPrivateKey xaaWrapperGCPrivateKey = &xaaWrapperGCPrivateKeyIndex; #define xaaWrapperGCPrivateKey (&xaaWrapperGCPrivateKeyRec)
static Bool static Bool
xaaWrapperCreateScreenResources(ScreenPtr pScreen) xaaWrapperCreateScreenResources(ScreenPtr pScreen)
@ -268,7 +268,10 @@ xaaSetupWrapper(ScreenPtr pScreen, XAAInfoRecPtr infoPtr, int depth, SyncFunc *f
xaaWrapperScrPrivPtr pScrPriv; xaaWrapperScrPrivPtr pScrPriv;
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
if (!dixRequestPrivate(xaaWrapperGCPrivateKey, sizeof(xaaWrapperGCPrivRec))) if (!dixRegisterPrivateKey(&xaaWrapperGCPrivateKeyRec, PRIVATE_GC, sizeof(xaaWrapperGCPrivRec)))
return FALSE;
if (!dixRegisterPrivateKey(&xaaWrapperScrPrivateKeyRec, PRIVATE_SCREEN, 0))
return FALSE; return FALSE;
pScrPriv = (xaaWrapperScrPrivPtr) malloc(sizeof (xaaWrapperScrPrivRec)); pScrPriv = (xaaWrapperScrPrivPtr) malloc(sizeof (xaaWrapperScrPrivRec));

View File

@ -34,8 +34,8 @@ is" without express or implied warranty.
#include "XNWindow.h" #include "XNWindow.h"
#include "Args.h" #include "Args.h"
static int cmapScrPrivateKeyIndex; static DevPrivateKeyRec cmapScrPrivateKeyRec;
static DevPrivateKey cmapScrPrivateKey = &cmapScrPrivateKeyIndex; #define cmapScrPrivateKey (&cmapScrPrivateKeyRec)
#define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey)) #define GetInstalledColormap(s) ((ColormapPtr) dixLookupPrivate(&(s)->devPrivates, cmapScrPrivateKey))
#define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c)) #define SetInstalledColormap(s,c) (dixSetPrivate(&(s)->devPrivates, cmapScrPrivateKey, c))

View File

@ -35,8 +35,7 @@ is" without express or implied warranty.
#include "XNFont.h" #include "XNFont.h"
#include "Color.h" #include "Color.h"
static int xnestGCPrivateKeyIndex; DevPrivateKeyRec xnestGCPrivateKeyRec;
DevPrivateKey xnestGCPrivateKey = &xnestGCPrivateKeyIndex;
static GCFuncs xnestFuncs = { static GCFuncs xnestFuncs = {
xnestValidateGC, xnestValidateGC,

View File

@ -33,8 +33,7 @@ is" without express or implied warranty.
#include "Screen.h" #include "Screen.h"
#include "XNPixmap.h" #include "XNPixmap.h"
static int xnestPixmapPrivateKeyIndex; DevPrivateKeyRec xnestPixmapPrivateKeyRec;
DevPrivateKey xnestPixmapPrivateKey = &xnestPixmapPrivateKeyIndex;
PixmapPtr PixmapPtr
xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
@ -42,7 +41,7 @@ xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
{ {
PixmapPtr pPixmap; PixmapPtr pPixmap;
pPixmap = AllocatePixmap(pScreen, sizeof(xnestPrivPixmap)); pPixmap = AllocatePixmap(pScreen, 0);
if (!pPixmap) if (!pPixmap)
return NullPixmap; return NullPixmap;
pPixmap->drawable.type = DRAWABLE_PIXMAP; pPixmap->drawable.type = DRAWABLE_PIXMAP;
@ -59,8 +58,6 @@ xnestCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
pPixmap->refcnt = 1; pPixmap->refcnt = 1;
pPixmap->devKind = PixmapBytePad(width, depth); pPixmap->devKind = PixmapBytePad(width, depth);
pPixmap->usage_hint = usage_hint; pPixmap->usage_hint = usage_hint;
dixSetPrivate(&pPixmap->devPrivates, xnestPixmapPrivateKey,
(char *)pPixmap + pScreen->totalPixmapSize);
if (width && height) if (width && height)
xnestPixmapPriv(pPixmap)->pixmap = xnestPixmapPriv(pPixmap)->pixmap =
XCreatePixmap(xnestDisplay, XCreatePixmap(xnestDisplay,
@ -78,8 +75,7 @@ xnestDestroyPixmap(PixmapPtr pPixmap)
if(--pPixmap->refcnt) if(--pPixmap->refcnt)
return TRUE; return TRUE;
XFreePixmap(xnestDisplay, xnestPixmap(pPixmap)); XFreePixmap(xnestDisplay, xnestPixmap(pPixmap));
dixFreePrivates(pPixmap->devPrivates); FreePixmap(pPixmap);
free(pPixmap);
return TRUE; return TRUE;
} }

View File

@ -45,8 +45,7 @@ is" without express or implied warranty.
Window xnestDefaultWindows[MAXSCREENS]; Window xnestDefaultWindows[MAXSCREENS];
Window xnestScreenSaverWindows[MAXSCREENS]; Window xnestScreenSaverWindows[MAXSCREENS];
static int xnestCursorScreenKeyIndex; DevPrivateKeyRec xnestCursorScreenKeyRec;
DevPrivateKey xnestCursorScreenKey = &xnestCursorScreenKeyIndex;
ScreenPtr ScreenPtr
xnestScreen(Window window) xnestScreen(Window window)
@ -146,10 +145,14 @@ xnestOpenScreen(int index, ScreenPtr pScreen, int argc, char *argv[])
int rootDepth; int rootDepth;
miPointerScreenPtr PointPriv; miPointerScreenPtr PointPriv;
if (!dixRequestPrivate(xnestWindowPrivateKey, sizeof(xnestPrivWin))) if (!dixRegisterPrivateKey(&xnestWindowPrivateKeyRec, PRIVATE_WINDOW, sizeof(xnestPrivWin)))
return False; return FALSE;
if (!dixRequestPrivate(xnestGCPrivateKey, sizeof(xnestPrivGC))) if (!dixRegisterPrivateKey(&xnestGCPrivateKeyRec, PRIVATE_GC, sizeof(xnestPrivGC)))
return False; return FALSE;
if (!dixRegisterPrivateKey(&xnestPixmapPrivateKeyRec, PRIVATE_PIXMAP, sizeof (xnestPrivPixmap)))
return FALSE;
if (!dixRegisterPrivateKey(&xnestCursorScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
visuals = (VisualPtr)malloc(xnestNumVisuals * sizeof(VisualRec)); visuals = (VisualPtr)malloc(xnestNumVisuals * sizeof(VisualRec));
numVisuals = 0; numVisuals = 0;

View File

@ -39,8 +39,7 @@ is" without express or implied warranty.
#include "Events.h" #include "Events.h"
#include "Args.h" #include "Args.h"
static int xnestWindowPrivateKeyIndex; DevPrivateKeyRec xnestWindowPrivateKeyRec;
DevPrivateKey xnestWindowPrivateKey = &xnestWindowPrivateKeyIndex;
static int static int
xnestFindWindowMatch(WindowPtr pWin, pointer ptr) xnestFindWindowMatch(WindowPtr pWin, pointer ptr)

View File

@ -21,7 +21,8 @@ typedef struct {
miPointerSpriteFuncPtr spriteFuncs; miPointerSpriteFuncPtr spriteFuncs;
} xnestCursorFuncRec, *xnestCursorFuncPtr; } xnestCursorFuncRec, *xnestCursorFuncPtr;
extern DevPrivateKey xnestCursorScreenKey; extern DevPrivateKeyRec xnestCursorScreenKeyRec;
#define xnestCursorScreenKey (&xnestCursorScreenKeyRec)
extern xnestCursorFuncRec xnestCursorFuncs; extern xnestCursorFuncRec xnestCursorFuncs;
typedef struct { typedef struct {

View File

@ -22,7 +22,8 @@ typedef struct {
int nClipRects; int nClipRects;
} xnestPrivGC; } xnestPrivGC;
extern DevPrivateKey xnestGCPrivateKey; extern DevPrivateKeyRec xnestGCPrivateKeyRec;
#define xnestGCPrivateKey (&xnestGCPrivateKeyRec)
#define xnestGCPriv(pGC) ((xnestPrivGC *) \ #define xnestGCPriv(pGC) ((xnestPrivGC *) \
dixLookupPrivate(&(pGC)->devPrivates, xnestGCPrivateKey)) dixLookupPrivate(&(pGC)->devPrivates, xnestGCPrivateKey))

View File

@ -15,7 +15,8 @@ is" without express or implied warranty.
#ifndef XNESTPIXMAP_H #ifndef XNESTPIXMAP_H
#define XNESTPIXMAP_H #define XNESTPIXMAP_H
extern DevPrivateKey xnestPixmapPrivateKey; extern DevPrivateKeyRec xnestPixmapPrivateKeyRec;
#define xnestPixmapPrivateKey (&xnestPixmapPrivateKeyRec)
typedef struct { typedef struct {
Pixmap pixmap; Pixmap pixmap;

View File

@ -33,7 +33,8 @@ typedef struct {
Window window; Window window;
} xnestWindowMatch; } xnestWindowMatch;
extern DevPrivateKey xnestWindowPrivateKey; extern DevPrivateKeyRec xnestWindowPrivateKeyRec;
#define xnestWindowPrivateKey (&xnestWindowPrivateKeyRec)
#define xnestWindowPriv(pWin) ((xnestPrivWin *) \ #define xnestWindowPriv(pWin) ((xnestPrivWin *) \
dixLookupPrivate(&(pWin)->devPrivates, xnestWindowPrivateKey)) dixLookupPrivate(&(pWin)->devPrivates, xnestWindowPrivateKey))

View File

@ -84,8 +84,7 @@ FILE *debug_log_fp = NULL;
* X server shared global variables * X server shared global variables
*/ */
int darwinScreensFound = 0; int darwinScreensFound = 0;
static int darwinScreenKeyIndex; DevPrivateKeyRec darwinScreenKeyRec;
DevPrivateKey darwinScreenKey = &darwinScreenKeyIndex;
io_connect_t darwinParamConnect = 0; io_connect_t darwinParamConnect = 0;
int darwinEventReadFD = -1; int darwinEventReadFD = -1;
int darwinEventWriteFD = -1; int darwinEventWriteFD = -1;
@ -185,6 +184,9 @@ static Bool DarwinScreenInit(int index, ScreenPtr pScreen, int argc, char **argv
Bool ret; Bool ret;
DarwinFramebufferPtr dfb; DarwinFramebufferPtr dfb;
if (!dixRegisterPrivateKey(&darwinScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
// reset index of found screens for each server generation // reset index of found screens for each server generation
if (index == 0) { if (index == 0) {
foundIndex = 0; foundIndex = 0;

View File

@ -50,7 +50,8 @@ void xf86SetRootClip (ScreenPtr pScreen, int enable);
/* /*
* Global variables from darwin.c * Global variables from darwin.c
*/ */
extern DevPrivateKey darwinScreenKey; // index into pScreen.devPrivates extern DevPrivateKeyRec darwinScreenKeyRec;
#define darwinScreenKey (&darwinScreenKeyRec)
extern int darwinScreensFound; extern int darwinScreensFound;
extern io_connect_t darwinParamConnect; extern io_connect_t darwinParamConnect;
extern int darwinEventReadFD; extern int darwinEventReadFD;

View File

@ -73,8 +73,7 @@ int quartzUseAGL = 1;
int quartzEnableKeyEquivalents = 1; int quartzEnableKeyEquivalents = 1;
int quartzServerVisible = FALSE; int quartzServerVisible = FALSE;
int quartzServerQuitting = FALSE; int quartzServerQuitting = FALSE;
static int quartzScreenKeyIndex; DevPrivateKeyRec quartzScreenKeyRec;
DevPrivateKey quartzScreenKey = &quartzScreenKeyIndex;
int aquaMenuBarHeight = 0; int aquaMenuBarHeight = 0;
QuartzModeProcsPtr quartzProcs = NULL; QuartzModeProcsPtr quartzProcs = NULL;
const char *quartzOpenGLBundle = NULL; const char *quartzOpenGLBundle = NULL;
@ -167,6 +166,9 @@ void QuartzInitOutput(
FatalError("Could not register block and wakeup handlers."); FatalError("Could not register block and wakeup handlers.");
} }
if (!dixRegisterPrivateKey(&quartzScreenKeyRec, PRIVATE_SCREEN, 0))
FatalError("Failed to alloc quartz screen private.\n");
#if defined(RANDR) && !defined(FAKE_RANDR) #if defined(RANDR) && !defined(FAKE_RANDR)
if(!QuartzRandRInit(pScreen)) if(!QuartzRandRInit(pScreen))
FatalError("Failed to init RandR extension.\n"); FatalError("Failed to init RandR extension.\n");

View File

@ -65,7 +65,8 @@ extern int quartzOptionSendsAlt;
// Other shared data // Other shared data
extern int quartzServerVisible; extern int quartzServerVisible;
extern int quartzServerQuitting; extern int quartzServerQuitting;
extern DevPrivateKey quartzScreenKey; extern DevPrivateKeyRec quartzScreenKeyRec;
#define quartzScreenKey (&quartzScreenKeyRec)
extern int aquaMenuBarHeight; extern int aquaMenuBarHeight;
// Name of GLX bundle for native OpenGL // Name of GLX bundle for native OpenGL

Some files were not shown because too many files have changed in this diff Show More