diff options
author | Eamon Walsh <ewalsh@tycho.nsa.gov> | 2007-08-28 09:28:25 -0400 |
---|---|---|
committer | Eamon Walsh <ewalsh@moss-charon.epoch.ncsc.mil> | 2007-08-28 09:28:25 -0400 |
commit | 4017d3190234e189a0bbd33193a148d4d3c7556b (patch) | |
tree | 2ab228113d410386afde50c893f137d95974b8f3 /miext/rootless | |
parent | 85547073265ae9bc4ae3af920a6d3214fd1ca0c5 (diff) |
devPrivates rework: since API is already broken, switch everything
over to new system.
Need to update documentation and address some remaining vestiges of
old system such as CursorRec structure, fb "offman" structure, and
FontRec privates.
Diffstat (limited to 'miext/rootless')
-rw-r--r-- | miext/rootless/accel/rlAccel.c | 13 | ||||
-rw-r--r-- | miext/rootless/rootlessCommon.h | 19 | ||||
-rw-r--r-- | miext/rootless/rootlessGC.c | 10 | ||||
-rw-r--r-- | miext/rootless/rootlessScreen.c | 30 | ||||
-rw-r--r-- | miext/rootless/rootlessWindow.c | 12 |
5 files changed, 33 insertions, 51 deletions
diff --git a/miext/rootless/accel/rlAccel.c b/miext/rootless/accel/rlAccel.c index d62bee740..a14412416 100644 --- a/miext/rootless/accel/rlAccel.c +++ b/miext/rootless/accel/rlAccel.c @@ -46,10 +46,10 @@ typedef struct _rlAccelScreenRec { CloseScreenProcPtr CloseScreen; } rlAccelScreenRec, *rlAccelScreenPtr; -static int rlAccelScreenPrivateIndex = -1; +static DevPrivateKey rlAccelScreenPrivateKey = &rlAccelScreenPrivateKey; -#define RLACCELREC(pScreen) \ - ((rlAccelScreenRec *)(pScreen)->devPrivates[rlAccelScreenPrivateIndex].ptr) +#define RLACCELREC(pScreen) ((rlAccelScreenRec *) \ + dixLookupPrivate(&(pScreen)->devPrivates, rlAccelScreenPrivateKey)) /* This is mostly identical to fbGCOps. */ static GCOps rlAccelOps = { @@ -128,15 +128,8 @@ rlCloseScreen (int iScreen, ScreenPtr pScreen) Bool RootlessAccelInit(ScreenPtr pScreen) { - static unsigned long rlAccelGeneration = 0; rlAccelScreenRec *s; - if (rlAccelGeneration != serverGeneration) { - rlAccelScreenPrivateIndex = AllocateScreenPrivateIndex(); - if (rlAccelScreenPrivateIndex == -1) return FALSE; - rlAccelGeneration = serverGeneration; - } - s = xalloc(sizeof(rlAccelScreenRec)); if (!s) return FALSE; RLACCELREC(pScreen) = s; diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h index 3bf6af02f..5ebe35e63 100644 --- a/miext/rootless/rootlessCommon.h +++ b/miext/rootless/rootlessCommon.h @@ -52,9 +52,9 @@ // Global variables -extern int rootlessGCPrivateIndex; -extern int rootlessScreenPrivateIndex; -extern int rootlessWindowPrivateIndex; +extern DevPrivateKey rootlessGCPrivateKey; +extern DevPrivateKey rootlessScreenPrivateKey; +extern DevPrivateKey rootlessWindowPrivateKey; // RootlessGCRec: private per-gc data @@ -133,12 +133,17 @@ typedef struct _RootlessScreenRec { // Accessors for screen and window privates -#define SCREENREC(pScreen) \ - ((RootlessScreenRec *)(pScreen)->devPrivates[rootlessScreenPrivateIndex].ptr) +#define SCREENREC(pScreen) ((RootlessScreenRec *) \ + dixLookupPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey)) -#define WINREC(pWin) \ - ((RootlessWindowRec *)(pWin)->devPrivates[rootlessWindowPrivateIndex].ptr) +#define SETSCREENREC(pScreen, v) \ + dixSetPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey, v) +#define WINREC(pWin) ((RootlessWindowRec *) \ + dixLookupPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey)) + +#define SETWINREC(pWin, v) \ + dixSetPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey, v) // Call a rootless implementation function. // Many rootless implementation functions are allowed to be NULL. diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c index b26f52c54..bf129eadc 100644 --- a/miext/rootless/rootlessGC.c +++ b/miext/rootless/rootlessGC.c @@ -276,11 +276,11 @@ RootlessCreateGC(GCPtr pGC) Bool result; SCREEN_UNWRAP(pGC->pScreen, CreateGC); - s = (RootlessScreenRec *) pGC->pScreen-> - devPrivates[rootlessScreenPrivateIndex].ptr; + s = SCREENREC(pGC->pScreen); result = s->CreateGC(pGC); - gcrec = (RootlessGCRec *) pGC->devPrivates[rootlessGCPrivateIndex].ptr; + gcrec = (RootlessGCRec *) + dixLookupPrivate(&pGC->devPrivates, rootlessGCPrivateKey); gcrec->originalOps = NULL; // don't wrap ops yet gcrec->originalFuncs = pGC->funcs; pGC->funcs = &rootlessGCFuncs; @@ -302,7 +302,7 @@ RootlessCreateGC(GCPtr pGC) // does not assume ops have been wrapped #define GCFUNC_UNWRAP(pGC) \ RootlessGCRec *gcrec = (RootlessGCRec *) \ - (pGC)->devPrivates[rootlessGCPrivateIndex].ptr; \ + dixLookupPrivate(&(pGC)->devPrivates, rootlessGCPrivateKey); \ (pGC)->funcs = gcrec->originalFuncs; \ if (gcrec->originalOps) { \ (pGC)->ops = gcrec->originalOps; \ @@ -399,7 +399,7 @@ static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc) // assumes both funcs and ops are wrapped #define GCOP_UNWRAP(pGC) \ RootlessGCRec *gcrec = (RootlessGCRec *) \ - (pGC)->devPrivates[rootlessGCPrivateIndex].ptr; \ + dixLookupPrivate(&(pGC)->devPrivates, rootlessGCPrivateKey); \ GCFuncs *saveFuncs = pGC->funcs; \ (pGC)->funcs = gcrec->originalFuncs; \ (pGC)->ops = gcrec->originalOps; diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c index 700de6edc..f647893de 100644 --- a/miext/rootless/rootlessScreen.c +++ b/miext/rootless/rootlessScreen.c @@ -61,9 +61,9 @@ extern int RootlessMiValidateTree(WindowPtr pRoot, WindowPtr pChild, extern Bool RootlessCreateGC(GCPtr pGC); // Initialize globals -int rootlessGCPrivateIndex = -1; -int rootlessScreenPrivateIndex = -1; -int rootlessWindowPrivateIndex = -1; +DevPrivateKey rootlessGCPrivateKey = &rootlessGCPrivateKey; +DevPrivateKey rootlessScreenPrivateKey = &rootlessScreenPrivateKey; +DevPrivateKey rootlessWindowPrivateKey = &rootlessWindowPrivateKey; /* @@ -547,28 +547,14 @@ static Bool RootlessAllocatePrivates(ScreenPtr pScreen) { RootlessScreenRec *s; - static unsigned long rootlessGeneration = 0; - - if (rootlessGeneration != serverGeneration) { - rootlessScreenPrivateIndex = AllocateScreenPrivateIndex(); - if (rootlessScreenPrivateIndex == -1) return FALSE; - rootlessGCPrivateIndex = AllocateGCPrivateIndex(); - if (rootlessGCPrivateIndex == -1) return FALSE; - rootlessWindowPrivateIndex = AllocateWindowPrivateIndex(); - if (rootlessWindowPrivateIndex == -1) return FALSE; - rootlessGeneration = serverGeneration; - } // no allocation needed for screen privates - if (!AllocateGCPrivate(pScreen, rootlessGCPrivateIndex, - sizeof(RootlessGCRec))) - return FALSE; - if (!AllocateWindowPrivate(pScreen, rootlessWindowPrivateIndex, 0)) + if (!dixRequestPrivate(rootlessGCPrivateKey, sizeof(RootlessGCRec))) return FALSE; s = xalloc(sizeof(RootlessScreenRec)); if (! s) return FALSE; - SCREENREC(pScreen) = s; + SETSCREENREC(pScreen, s); s->pixmap_data = NULL; s->pixmap_data_size = 0; @@ -583,8 +569,7 @@ RootlessAllocatePrivates(ScreenPtr pScreen) static void RootlessWrap(ScreenPtr pScreen) { - RootlessScreenRec *s = (RootlessScreenRec*) - pScreen->devPrivates[rootlessScreenPrivateIndex].ptr; + RootlessScreenRec *s = SCREENREC(pScreen); #define WRAP(a) \ if (pScreen->a) { \ @@ -650,8 +635,7 @@ Bool RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs) if (!RootlessAllocatePrivates(pScreen)) return FALSE; - s = (RootlessScreenRec*) - pScreen->devPrivates[rootlessScreenPrivateIndex].ptr; + s = SCREENREC(pScreen); s->imp = procs; diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c index 30b7daaab..687748c2d 100644 --- a/miext/rootless/rootlessWindow.c +++ b/miext/rootless/rootlessWindow.c @@ -66,7 +66,7 @@ RootlessCreateWindow(WindowPtr pWin) Bool result; RegionRec saveRoot; - WINREC(pWin) = NULL; + SETWINREC(pWin, NULL); SCREEN_UNWRAP(pWin->drawable.pScreen, CreateWindow); @@ -107,7 +107,7 @@ RootlessDestroyFrame(WindowPtr pWin, RootlessWindowPtr winRec) #endif xfree(winRec); - WINREC(pWin) = NULL; + SETWINREC(pWin, NULL); } @@ -353,7 +353,7 @@ RootlessEnsureFrame(WindowPtr pWin) winRec->pixmap = NULL; winRec->wid = NULL; - WINREC(pWin) = winRec; + SETWINREC(pWin, winRec); #ifdef SHAPE // Set the frame's shape if the window is shaped @@ -370,7 +370,7 @@ RootlessEnsureFrame(WindowPtr pWin) { RL_DEBUG_MSG("implementation failed to create frame!\n"); xfree(winRec); - WINREC(pWin) = NULL; + SETWINREC(pWin, NULL); return NULL; } @@ -1298,8 +1298,8 @@ RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent) /* Switch the frame record from one to the other. */ - WINREC(pWin) = NULL; - WINREC(pTopWin) = winRec; + SETWINREC(pWin, NULL); + SETWINREC(pTopWin, winRec); RootlessInitializeFrame(pTopWin, winRec); RootlessReshapeFrame(pTopWin); |