diff --git a/nx-X11/programs/Xserver/Xext/panoramiX.c b/nx-X11/programs/Xserver/Xext/panoramiX.c index e36d04d9ec..b332f4dd7f 100644 --- a/nx-X11/programs/Xserver/Xext/panoramiX.c +++ b/nx-X11/programs/Xserver/Xext/panoramiX.c @@ -109,8 +109,12 @@ static void PanoramiXResetProc(ExtensionEntry*); int (* SavedProcVector[256]) (ClientPtr client) = { NULL, }; ScreenInfo *GlobalScrInfo = NULL; -static int PanoramiXGCIndex = -1; -static int PanoramiXScreenIndex = -1; +static DevPrivateKeyRec PanoramiXGCKeyRec; + +#define PanoramiXGCKey (&PanoramiXGCKeyRec) +static DevPrivateKeyRec PanoramiXScreenKeyRec; + +#define PanoramiXScreenKey (&PanoramiXScreenKeyRec) typedef struct { DDXPointRec clipOrg; @@ -139,20 +143,19 @@ GCFuncs XineramaGCFuncs = { }; #define Xinerama_GC_FUNC_PROLOGUE(pGC)\ - PanoramiXGCPtr pGCPriv = \ - (PanoramiXGCPtr) (pGC)->devPrivates[PanoramiXGCIndex].ptr;\ + PanoramiXGCPtr pGCPriv = (PanoramiXGCPtr) \ + dixLookupPrivate(&(pGC)->devPrivates, PanoramiXGCKey); \ (pGC)->funcs = pGCPriv->wrapFuncs; #define Xinerama_GC_FUNC_EPILOGUE(pGC)\ pGCPriv->wrapFuncs = (pGC)->funcs;\ (pGC)->funcs = &XineramaGCFuncs; - static Bool XineramaCloseScreen (ScreenPtr pScreen) { - PanoramiXScreenPtr pScreenPriv = - (PanoramiXScreenPtr) pScreen->devPrivates[PanoramiXScreenIndex].ptr; + PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr) + dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey); pScreen->CloseScreen = pScreenPriv->CloseScreen; pScreen->CreateGC = pScreenPriv->CreateGC; @@ -161,7 +164,7 @@ XineramaCloseScreen (ScreenPtr pScreen) if (pScreen->myNum == 0) RegionUninit(&PanoramiXScreenRegion); - free ((void *) pScreenPriv); + free (pScreenPriv); return (*pScreen->CloseScreen) (pScreen); } @@ -170,14 +173,14 @@ Bool XineramaCreateGC(GCPtr pGC) { ScreenPtr pScreen = pGC->pScreen; - PanoramiXScreenPtr pScreenPriv = - (PanoramiXScreenPtr) pScreen->devPrivates[PanoramiXScreenIndex].ptr; + PanoramiXScreenPtr pScreenPriv = (PanoramiXScreenPtr) + dixLookupPrivate(&pScreen->devPrivates, PanoramiXScreenKey); Bool ret; pScreen->CreateGC = pScreenPriv->CreateGC; if((ret = (*pScreen->CreateGC)(pGC))) { - PanoramiXGCPtr pGCPriv = - (PanoramiXGCPtr) pGC->devPrivates[PanoramiXGCIndex].ptr; + PanoramiXGCPtr pGCPriv = (PanoramiXGCPtr) + dixLookupPrivate(&pGC->devPrivates, PanoramiXGCKey); pGCPriv->wrapFuncs = pGC->funcs; pGC->funcs = &XineramaGCFuncs; @@ -283,8 +286,8 @@ XineramaCopyGC ( unsigned long mask, GCPtr pGCDst ){ - PanoramiXGCPtr pSrcPriv = - (PanoramiXGCPtr) pGCSrc->devPrivates[PanoramiXGCIndex].ptr; + PanoramiXGCPtr pSrcPriv = (PanoramiXGCPtr) + dixLookupPrivate(&pGCSrc->devPrivates, PanoramiXGCKey); Xinerama_GC_FUNC_PROLOGUE (pGCDst); if(mask & GCTileStipXOrigin) @@ -494,6 +497,17 @@ void PanoramiXExtensionInit(int argc, char *argv[]) if (noPanoramiXExtension) return; + if (!dixRegisterPrivateKey(&PanoramiXScreenKeyRec, PRIVATE_SCREEN, 0)) { + noPanoramiXExtension = TRUE; + return; + } + + if (!dixRegisterPrivateKey + (&PanoramiXGCKeyRec, PRIVATE_GC, sizeof(PanoramiXGCRec))) { + noPanoramiXExtension = TRUE; + return; + } + GlobalScrInfo = &screenInfo; /* For debug visibility */ PanoramiXNumScreens = screenInfo.numScreens; if (PanoramiXNumScreens == 1) { /* Only 1 screen */ @@ -524,20 +538,13 @@ void PanoramiXExtensionInit(int argc, char *argv[]) calloc(PanoramiXNumScreens, sizeof(PanoramiXData)); BREAK_IF(!panoramiXdataPtr); - BREAK_IF((PanoramiXGCIndex = AllocateGCPrivateIndex()) < 0); - BREAK_IF((PanoramiXScreenIndex = AllocateScreenPrivateIndex()) < 0); for (i = 0; i < PanoramiXNumScreens; i++) { pScreen = screenInfo.screens[i]; - if(!AllocateGCPrivate(pScreen, PanoramiXGCIndex, - sizeof(PanoramiXGCRec))) { - noPanoramiXExtension = TRUE; - return; - } pScreenPriv = malloc(sizeof(PanoramiXScreenRec)); - pScreen->devPrivates[PanoramiXScreenIndex].ptr = - (void *)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, PanoramiXScreenKey, + pScreenPriv); if(!pScreenPriv) { noPanoramiXExtension = TRUE; return; @@ -640,7 +647,6 @@ Bool PanoramiXCreateConnectionBlock(void) { int i, j, length; Bool disableBackingStore = FALSE; - Bool disableSaveUnders = FALSE; int old_width, old_height; float width_mult, height_mult; xWindowRoot *root; @@ -666,17 +672,12 @@ Bool PanoramiXCreateConnectionBlock(void) } if(pScreen->backingStoreSupport != screenInfo.screens[0]->backingStoreSupport) disableBackingStore = TRUE; - if(pScreen->saveUnderSupport != screenInfo.screens[0]->saveUnderSupport) - disableSaveUnders = TRUE; } - if(disableBackingStore || disableSaveUnders) { + if(disableBackingStore) { for(i = 0; i < screenInfo.numScreens; i++) { pScreen = screenInfo.screens[i]; - if(disableBackingStore) - pScreen->backingStoreSupport = NotUseful; - if(disableSaveUnders) - pScreen->saveUnderSupport = NotUseful; + pScreen->backingStoreSupport = NotUseful; } } diff --git a/nx-X11/programs/Xserver/Xext/saver.c b/nx-X11/programs/Xserver/Xext/saver.c index 89eebd7b19..ab5e1aecf6 100644 --- a/nx-X11/programs/Xserver/Xext/saver.c +++ b/nx-X11/programs/Xserver/Xext/saver.c @@ -233,11 +233,15 @@ MakeScreenPrivate ( ScreenPtr /* pScreen */ ); -static int ScreenPrivateIndex; +static DevPrivateKeyRec ScreenPrivateKeyRec; -#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr)(s)->devPrivates[ScreenPrivateIndex].ptr) -#define SetScreenPrivate(s,v) ((s)->devPrivates[ScreenPrivateIndex].ptr = (void *) v); -#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL) +#define ScreenPrivateKey (&ScreenPrivateKeyRec) + +#define GetScreenPrivate(s) ((ScreenSaverScreenPrivatePtr) \ + dixLookupPrivate(&(s)->devPrivates, ScreenPrivateKey)) +#define SetScreenPrivate(s,v) \ + dixSetPrivate(&(s)->devPrivates, ScreenPrivateKey, v); +#define SetupScreen(s) ScreenSaverScreenPrivatePtr pPriv = (s ? GetScreenPrivate(s) : NULL) #define New(t) ((t *) malloc (sizeof (t))) @@ -256,17 +260,19 @@ ScreenSaverExtensionInit(void) int i; ScreenPtr pScreen; + if (!dixRegisterPrivateKey(&ScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) + return; + AttrType = CreateNewResourceType(ScreenSaverFreeAttr); EventType = CreateNewResourceType(ScreenSaverFreeEvents); SuspendType = CreateNewResourceType(ScreenSaverFreeSuspend); - ScreenPrivateIndex = AllocateScreenPrivateIndex (); for (i = 0; i < screenInfo.numScreens; i++) { pScreen = screenInfo.screens[i]; SetScreenPrivate (pScreen, NULL); } - if (AttrType && EventType && SuspendType && ScreenPrivateIndex != -1 && + if (AttrType && EventType && SuspendType && (extEntry = AddExtension(ScreenSaverName, ScreenSaverNumberEvents, 0, ProcScreenSaverDispatch, SProcScreenSaverDispatch, ScreenSaverResetProc, StandardMinorOpcode))) diff --git a/nx-X11/programs/Xserver/Xext/shm.c b/nx-X11/programs/Xserver/Xext/shm.c index ca1ff9a7f3..6f3e28e0db 100644 --- a/nx-X11/programs/Xserver/Xext/shm.c +++ b/nx-X11/programs/Xserver/Xext/shm.c @@ -50,8 +50,8 @@ in this Software without prior written authorization from The Open Group. #include "gcstruct.h" #include "extnsionst.h" #include "servermd.h" +#include "shmint.h" #define _XSHM_SERVER_ -#include #include #include "protocol-versions.h" @@ -61,14 +61,11 @@ in this Software without prior written authorization from The Open Group. #include "panoramiXsrv.h" #endif -typedef struct _ShmDesc { - struct _ShmDesc *next; - int shmid; - int refcnt; - char *addr; - Bool writable; - unsigned long size; -} ShmDescRec, *ShmDescPtr; +typedef struct _ShmScrPrivateRec { + CloseScreenProcPtr CloseScreen; + ShmFuncsPtr shmFuncs; + DestroyPixmapProcPtr destroyPixmap; +} ShmScrPrivateRec; static void miShmPutImage(XSHM_PUT_IMAGE_ARGS); static void fbShmPutImage(XSHM_PUT_IMAGE_ARGS); @@ -108,15 +105,16 @@ int BadShmSegCode; RESTYPE ShmSegType; static ShmDescPtr Shmsegs; static Bool sharedPixmaps; -static int pixmapFormat; -static int shmPixFormat[MAXSCREENS]; -static ShmFuncsPtr shmFuncs[MAXSCREENS]; -static DestroyPixmapProcPtr destroyPixmap[MAXSCREENS]; -#ifdef PIXPRIV -static int shmPixmapPrivate; -#endif -static ShmFuncs miFuncs = {NULL, miShmPutImage}; -static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage}; +static DevPrivateKeyRec shmScrPrivateKeyRec; + +#define shmScrPrivateKey (&shmScrPrivateKeyRec) +static DevPrivateKeyRec shmPixmapPrivateKeyRec; + +#define shmPixmapPrivateKey (&shmPixmapPrivateKeyRec) +static ShmFuncs miFuncs = { NULL, miShmPutImage }; +static ShmFuncs fbFuncs = { fbShmCreatePixmap, fbShmPutImage }; + +#define ShmGetScreenPriv(s) ((ShmScrPrivateRec *)dixLookupPrivate(&(s)->devPrivates, shmScrPrivateKey)) #define VERIFY_SHMSEG(shmseg,shmdesc,client) \ { \ @@ -204,42 +202,28 @@ ShmExtensionInit(void) } #endif + if (!ShmRegisterPrivates()) + return; + sharedPixmaps = xFalse; - pixmapFormat = 0; { - sharedPixmaps = xTrue; - pixmapFormat = shmPixFormat[0]; - for (i = 0; i < screenInfo.numScreens; i++) - { - if (!shmFuncs[i]) - shmFuncs[i] = &miFuncs; - if (!shmFuncs[i]->CreatePixmap) - sharedPixmaps = xFalse; - if (shmPixFormat[i] && (shmPixFormat[i] != pixmapFormat)) - { - sharedPixmaps = xFalse; - pixmapFormat = 0; + sharedPixmaps = xTrue; + for (i = 0; i < screenInfo.numScreens; i++) { + ShmScrPrivateRec *screen_priv = + ShmInitScreenPriv(screenInfo.screens[i]); + if (!screen_priv->shmFuncs) + screen_priv->shmFuncs = &miFuncs; + if (!screen_priv->shmFuncs->CreatePixmap) + sharedPixmaps = xFalse; } - } - if (!pixmapFormat) - pixmapFormat = ZPixmap; - if (sharedPixmaps) - { - for (i = 0; i < screenInfo.numScreens; i++) - { - destroyPixmap[i] = screenInfo.screens[i]->DestroyPixmap; - screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap; - } -#ifdef PIXPRIV - shmPixmapPrivate = AllocatePixmapPrivateIndex(); - for (i = 0; i < screenInfo.numScreens; i++) - { - if (!AllocatePixmapPrivate(screenInfo.screens[i], - shmPixmapPrivate, 0)) - return; - } -#endif - } + if (sharedPixmaps) + for (i = 0; i < screenInfo.numScreens; i++) { + ShmScrPrivateRec *screen_priv = + ShmGetScreenPriv(screenInfo.screens[i]); + screen_priv->destroyPixmap = + screenInfo.screens[i]->DestroyPixmap; + screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap; + } } ShmSegType = CreateNewResourceType(ShmDetachSegment); if (ShmSegType && @@ -255,68 +239,79 @@ ShmExtensionInit(void) } #endif /* NXAGENT_SERVER */ -/*ARGSUSED*/ -static void -ShmResetProc (extEntry) -ExtensionEntry *extEntry; +static Bool +ShmCloseScreen(ScreenPtr pScreen) { - int i; + ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen); - for (i = 0; i < MAXSCREENS; i++) - { - shmFuncs[i] = (ShmFuncsPtr)NULL; - shmPixFormat[i] = 0; + pScreen->CloseScreen = screen_priv->CloseScreen; + dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, NULL); + free(screen_priv); + return (*pScreen->CloseScreen) (pScreen); +} + +static ShmScrPrivateRec * +ShmInitScreenPriv(ScreenPtr pScreen) +{ + ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen); + + if (!screen_priv) { + screen_priv = calloc(1, sizeof(ShmScrPrivateRec)); + screen_priv->CloseScreen = pScreen->CloseScreen; + dixSetPrivate(&pScreen->devPrivates, shmScrPrivateKey, screen_priv); + pScreen->CloseScreen = ShmCloseScreen; } + return screen_priv; } -void -ShmRegisterFuncs( - ScreenPtr pScreen, - ShmFuncsPtr funcs) +static Bool +ShmRegisterPrivates(void) { - shmFuncs[pScreen->myNum] = funcs; + if (!dixRegisterPrivateKey(&shmScrPrivateKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + if (!dixRegisterPrivateKey(&shmPixmapPrivateKeyRec, PRIVATE_PIXMAP, 0)) + return FALSE; + return TRUE; +} + +/*ARGSUSED*/ static void +ShmResetProc(ExtensionEntry * extEntry) +{ + int i; + + for (i = 0; i < screenInfo.numScreens; i++) + ShmRegisterFuncs(screenInfo.screens[i], NULL); } void -ShmSetPixmapFormat( +ShmRegisterFuncs( ScreenPtr pScreen, - int format) + ShmFuncsPtr funcs) { - shmPixFormat[pScreen->myNum] = format; + if (!ShmRegisterPrivates()) + return; + ShmInitScreenPriv(pScreen)->shmFuncs = funcs; } static Bool ShmDestroyPixmap (PixmapPtr pPixmap) { ScreenPtr pScreen = pPixmap->drawable.pScreen; + ShmScrPrivateRec *screen_priv = ShmGetScreenPriv(pScreen); + void *shmdesc = NULL; Bool ret; + if (pPixmap->refcnt == 1) - { - ShmDescPtr shmdesc; -#ifdef PIXPRIV - shmdesc = (ShmDescPtr) pPixmap->devPrivates[shmPixmapPrivate].ptr; -#else - char *base = (char *) pPixmap->devPrivate.ptr; - - if (base != (void *) (pPixmap + 1)) - { - for (shmdesc = Shmsegs; shmdesc; shmdesc = shmdesc->next) - { - if (shmdesc->addr <= base && base <= shmdesc->addr + shmdesc->size) - break; - } - } - else - shmdesc = 0; -#endif - if (shmdesc) - ShmDetachSegment ((void *) shmdesc, pPixmap->drawable.id); - } - - pScreen->DestroyPixmap = destroyPixmap[pScreen->myNum]; + shmdesc = dixLookupPrivate(&pPixmap->devPrivates, shmPixmapPrivateKey); + + pScreen->DestroyPixmap = screen_priv->destroyPixmap; ret = (*pScreen->DestroyPixmap) (pPixmap); - destroyPixmap[pScreen->myNum] = pScreen->DestroyPixmap; + screen_priv->destroyPixmap = pScreen->DestroyPixmap; pScreen->DestroyPixmap = ShmDestroyPixmap; + + if (shmdesc) + ShmDetachSegment ((void *) shmdesc, pPixmap->drawable.id); + return ret; } @@ -324,7 +319,7 @@ void ShmRegisterFbFuncs(pScreen) ScreenPtr pScreen; { - shmFuncs[pScreen->myNum] = &fbFuncs; + ShmRegisterFuncs(pScreen, &fbFuncs); } static int @@ -339,7 +334,6 @@ ProcShmQueryVersion(client) rep.length = 0; rep.sequenceNumber = client->sequence; rep.sharedPixmaps = sharedPixmaps; - rep.pixmapFormat = pixmapFormat; rep.majorVersion = SERVER_SHM_MAJOR_VERSION; rep.minorVersion = SERVER_SHM_MINOR_VERSION; rep.uid = geteuid(); @@ -777,16 +771,17 @@ ProcPanoramiXShmCreatePixmap( result = (client->noClientException); FOR_NSCREENS(j) { + ShmScrPrivateRec *screen_priv; + pScreen = screenInfo.screens[j]; - pMap = (*shmFuncs[j]->CreatePixmap)(pScreen, + screen_priv = ShmGetScreenPriv(pScreen); + pMap = (*screen_priv->shmFuncs->CreatePixmap)(pScreen, stuff->width, stuff->height, stuff->depth, shmdesc->addr + stuff->offset); if (pMap) { -#ifdef PIXPRIV - pMap->devPrivates[shmPixmapPrivate].ptr = (void *) shmdesc; -#endif + dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc); shmdesc->refcnt++; pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.id = newPix->info[j].id; @@ -824,8 +819,9 @@ ProcShmPutImage(client) register DrawablePtr pDraw; long length; ShmDescPtr shmdesc; - REQUEST(xShmPutImageReq); + ShmScrPrivateRec *screen_priv; + REQUEST(xShmPutImageReq); REQUEST_SIZE_MATCH(xShmPutImageReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client); @@ -902,7 +898,8 @@ ProcShmPutImage(client) shmdesc->addr + stuff->offset + (stuff->srcY * length)); else - (*shmFuncs[pDraw->pScreen->myNum]->PutImage)( + screen_priv = ShmGetScreenPriv(pDraw->pScreen); + (*screen_priv->shmFuncs->PutImage)( pDraw, pGC, stuff->depth, stuff->format, stuff->totalWidth, stuff->totalHeight, stuff->srcX, stuff->srcY, @@ -1074,6 +1071,8 @@ ProcShmCreatePixmap(client) DepthPtr pDepth; register int i; ShmDescPtr shmdesc; + ShmScrPrivateRec *screen_priv; + REQUEST(xShmCreatePixmapReq); unsigned int width, height, depth; unsigned long size; @@ -1118,15 +1117,14 @@ ProcShmCreatePixmap(client) } VERIFY_SHMSIZE(shmdesc, stuff->offset, size, client); - pMap = (*shmFuncs[pDraw->pScreen->myNum]->CreatePixmap)( + screen_priv = ShmGetScreenPriv(pDraw->pScreen); + pMap = (*screen_priv->shmFuncs->CreatePixmap)( pDraw->pScreen, stuff->width, stuff->height, stuff->depth, shmdesc->addr + stuff->offset); if (pMap) { -#ifdef PIXPRIV - pMap->devPrivates[shmPixmapPrivate].ptr = (void *) shmdesc; -#endif + dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc); shmdesc->refcnt++; pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pMap->drawable.id = stuff->pid; diff --git a/nx-X11/programs/Xserver/Xext/shmint.h b/nx-X11/programs/Xserver/Xext/shmint.h index 5135d17293..8960860b4e 100644 --- a/nx-X11/programs/Xserver/Xext/shmint.h +++ b/nx-X11/programs/Xserver/Xext/shmint.h @@ -25,20 +25,54 @@ #ifndef _SHMINT_H_ #define _SHMINT_H_ -#define _XSHM_SERVER_ -#include +#include #include "screenint.h" #include "pixmap.h" #include "gc.h" -void -ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs); +#define XSHM_PUT_IMAGE_ARGS \ + DrawablePtr /* dst */, \ + GCPtr /* pGC */, \ + int /* depth */, \ + unsigned int /* format */, \ + int /* w */, \ + int /* h */, \ + int /* sx */, \ + int /* sy */, \ + int /* sw */, \ + int /* sh */, \ + int /* dx */, \ + int /* dy */, \ + char * /* data */ + +#define XSHM_CREATE_PIXMAP_ARGS \ + ScreenPtr /* pScreen */, \ + int /* width */, \ + int /* height */, \ + int /* depth */, \ + char * /* addr */ + +typedef struct _ShmFuncs { + PixmapPtr (*CreatePixmap) (XSHM_CREATE_PIXMAP_ARGS); + void (*PutImage) (XSHM_PUT_IMAGE_ARGS); +} ShmFuncs, *ShmFuncsPtr; + +typedef struct _ShmDesc { + struct _ShmDesc *next; + int shmid; + int refcnt; + char *addr; + Bool writable; + unsigned long size; +} ShmDescRec, *ShmDescPtr; void -ShmSetPixmapFormat(ScreenPtr pScreen, int format); +ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs); void ShmRegisterFbFuncs(ScreenPtr pScreen); + + #endif /* _SHMINT_H_ */ diff --git a/nx-X11/programs/Xserver/Xext/xf86bigfont.c b/nx-X11/programs/Xserver/Xext/xf86bigfont.c index d8cae74ef0..95f335e0c9 100644 --- a/nx-X11/programs/Xserver/Xext/xf86bigfont.c +++ b/nx-X11/programs/Xserver/Xext/xf86bigfont.c @@ -193,7 +193,6 @@ XFree86BigfontExtensionInit() #ifdef HAS_XFONT2 FontShmdescIndex = xfont2_allocate_font_private_index(); #else - FontShmdescIndex = AllocateFontPrivateIndex(); #endif /* HAS_XFONT2 */ #if !defined(CSRG_BASED) && !defined(__CYGWIN__) diff --git a/nx-X11/programs/Xserver/Xext/xtest.c b/nx-X11/programs/Xserver/Xext/xtest.c index a392599ea8..68076cc86b 100644 --- a/nx-X11/programs/Xserver/Xext/xtest.c +++ b/nx-X11/programs/Xserver/Xext/xtest.c @@ -47,7 +47,6 @@ from The Open Group. #ifdef XINPUT #include #include -#define EXTENSION_EVENT_BASE 64 #include "extinit.h" /* LookupDeviceIntRec */ #endif /* XINPUT */ diff --git a/nx-X11/programs/Xserver/Xext/xvdisp.c b/nx-X11/programs/Xserver/Xext/xvdisp.c index 5f65c3fcd8..370a006056 100644 --- a/nx-X11/programs/Xserver/Xext/xvdisp.c +++ b/nx-X11/programs/Xserver/Xext/xvdisp.c @@ -400,7 +400,8 @@ ProcXvQueryAdaptors(ClientPtr client) } pScreen = pWin->drawable.pScreen; - pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr; + pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, + XvGetScreenKey()); if (!pxvs) { @@ -2086,8 +2087,9 @@ XineramaXvPutStill(ClientPtr client) void XineramifyXv(void) { - ScreenPtr pScreen, screen0 = screenInfo.screens[0]; - XvScreenPtr xvsp0 = (XvScreenPtr)screen0->devPrivates[XvScreenIndex].ptr; + ScreenPtr pScreen; + XvScreenPtr xvsp0 = + dixLookupPrivate(&screenInfo.screens[0]->devPrivates, XvGetScreenKey()); XvAdaptorPtr refAdapt, pAdapt; XvAttributePtr pAttr; XvScreenPtr xvsp; @@ -2120,8 +2122,8 @@ void XineramifyXv(void) for(j = 1; j < PanoramiXNumScreens; j++) { pScreen = screenInfo.screens[j]; - xvsp = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr; - + xvsp = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, + XvGetScreenKey()); /* Do not try to go on if xv is not supported on this screen */ if (xvsp==NULL) continue ; diff --git a/nx-X11/programs/Xserver/Xext/xvdix.h b/nx-X11/programs/Xserver/Xext/xvdix.h index 973c39b761..e17f531ab1 100644 --- a/nx-X11/programs/Xserver/Xext/xvdix.h +++ b/nx-X11/programs/Xserver/Xext/xvdix.h @@ -224,10 +224,8 @@ typedef struct { DevUnion devPriv; } XvScreenRec, *XvScreenPtr; -#define SCREEN_PROLOGUE(pScreen, field)\ - ((pScreen)->field = \ - ((XvScreenPtr) \ - (pScreen)->devPrivates[XvScreenIndex].ptr)->field) +#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = ((XvScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, XvScreenKey))->field) #define SCREEN_EPILOGUE(pScreen, field, wrapper)\ ((pScreen)->field = wrapper) @@ -242,7 +240,7 @@ extern int SProcXvDispatch(ClientPtr); extern void XvExtensionInit(void); extern int XvScreenInit(ScreenPtr); -extern int XvGetScreenIndex(void); +extern DevPrivateKey XvGetScreenKey(void); extern unsigned long XvGetRTPort(void); extern int XvdiSendPortNotify(XvPortPtr, Atom, INT32); extern int XvdiVideoStopped(XvPortPtr, int); diff --git a/nx-X11/programs/Xserver/Xext/xvmain.c b/nx-X11/programs/Xserver/Xext/xvmain.c index c1492fdc64..3a32eba11c 100644 --- a/nx-X11/programs/Xserver/Xext/xvmain.c +++ b/nx-X11/programs/Xserver/Xext/xvmain.c @@ -105,7 +105,9 @@ SOFTWARE. #include "xvdisp.h" #endif -int XvScreenIndex = -1; +static DevPrivateKeyRec XvScreenKeyRec; + +#define XvScreenKey (&XvScreenKeyRec) unsigned long XvExtensionGeneration = 0; unsigned long XvScreenGeneration = 0; unsigned long XvResourceGeneration = 0; @@ -157,6 +159,9 @@ XvExtensionInit() { ExtensionEntry *extEntry; + if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0)) + return; + /* LOOK TO SEE IF ANY SCREENS WERE INITIALIZED; IF NOT THEN INIT GLOBAL VARIABLES SO THE EXTENSION CAN FUNCTION */ if (XvScreenGeneration != serverGeneration) @@ -166,12 +171,6 @@ XvExtensionInit() ErrorF("XvExtensionInit: Unable to allocate resource types\n"); return; } - XvScreenIndex = AllocateScreenPrivateIndex (); - if (XvScreenIndex < 0) - { - ErrorF("XvExtensionInit: Unable to allocate screen private index\n"); - return; - } #ifdef PANORAMIX XineramaRegisterConnectionBlockCallback(XineramifyXv); #endif @@ -265,19 +264,16 @@ XvScreenInit(ScreenPtr pScreen) ErrorF("XvScreenInit: Unable to allocate resource types\n"); return BadAlloc; } - XvScreenIndex = AllocateScreenPrivateIndex (); - if (XvScreenIndex < 0) - { - ErrorF("XvScreenInit: Unable to allocate screen private index\n"); - return BadAlloc; - } #ifdef PANORAMIX XineramaRegisterConnectionBlockCallback(XineramifyXv); #endif XvScreenGeneration = serverGeneration; } - if (pScreen->devPrivates[XvScreenIndex].ptr) + if (!dixRegisterPrivateKey(&XvScreenKeyRec, PRIVATE_SCREEN, 0)) + return BadAlloc; + + if (dixLookupPrivate(&pScreen->devPrivates, XvScreenKey)) { ErrorF("XvScreenInit: screen devPrivates ptr non-NULL before init\n"); } @@ -291,8 +287,7 @@ XvScreenInit(ScreenPtr pScreen) return BadAlloc; } - pScreen->devPrivates[XvScreenIndex].ptr = (void *)pxvs; - + dixSetPrivate(&pScreen->devPrivates, XvScreenKey, pxvs); pxvs->DestroyPixmap = pScreen->DestroyPixmap; pxvs->DestroyWindow = pScreen->DestroyWindow; @@ -312,17 +307,18 @@ XvCloseScreen( XvScreenPtr pxvs; - pxvs = (XvScreenPtr) pScreen->devPrivates[XvScreenIndex].ptr; + pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XvScreenKey); pScreen->DestroyPixmap = pxvs->DestroyPixmap; pScreen->DestroyWindow = pxvs->DestroyWindow; pScreen->CloseScreen = pxvs->CloseScreen; + // FIXME: Backport X.org commit b01cfe5f23766b9c13ed6bd889263d5d7a8a351d (* pxvs->ddCloseScreen)(pScreen); free(pxvs); - pScreen->devPrivates[XvScreenIndex].ptr = (void *)NULL; + dixSetPrivate(&pScreen->devPrivates, XvScreenKey, NULL); return (*pScreen->CloseScreen)(pScreen); @@ -333,10 +329,10 @@ XvResetProc(ExtensionEntry* extEntry) { } -_X_EXPORT int -XvGetScreenIndex() +DevPrivateKey +XvGetScreenKey(void) { - return XvScreenIndex; + return XvScreenKey; } _X_EXPORT unsigned long @@ -360,7 +356,7 @@ XvDestroyPixmap(PixmapPtr pPix) SCREEN_PROLOGUE(pScreen, DestroyPixmap); - pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr; + pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XvScreenKey); /* CHECK TO SEE IF THIS PORT IS IN USE */ @@ -412,7 +408,7 @@ XvDestroyWindow(WindowPtr pWin) SCREEN_PROLOGUE(pScreen, DestroyWindow); - pxvs = (XvScreenPtr)pScreen->devPrivates[XvScreenIndex].ptr; + pxvs = (XvScreenPtr) dixLookupPrivate(&pScreen->devPrivates, XvScreenKey); /* CHECK TO SEE IF THIS PORT IS IN USE */ diff --git a/nx-X11/programs/Xserver/Xext/xvmc.c b/nx-X11/programs/Xserver/Xext/xvmc.c index fcd170efd5..ed3dbee467 100644 --- a/nx-X11/programs/Xserver/Xext/xvmc.c +++ b/nx-X11/programs/Xserver/Xext/xvmc.c @@ -32,9 +32,9 @@ #define DR_CLIENT_DRIVER_NAME_SIZE 48 #define DR_BUSID_SIZE 48 -int XvMCScreenIndex = -1; +static DevPrivateKeyRec XvMCScreenKeyRec; -unsigned long XvMCGeneration = 0; +#define XvMCScreenKey (&XvMCScreenKeyRec) int XvMCReqCode; int XvMCEventBase; @@ -56,8 +56,7 @@ typedef struct { } XvMCScreenRec, *XvMCScreenPtr; #define XVMC_GET_PRIVATE(pScreen) \ - (XvMCScreenPtr)((pScreen)->devPrivates[XvMCScreenIndex].ptr) - + (XvMCScreenPtr)(dixLookupPrivate(&(pScreen)->devPrivates, XvMCScreenKey)) static int XvMCDestroyContextRes(void * data, XID id) @@ -146,16 +145,19 @@ ProcXvMCListSurfaceTypes(ClientPtr client) return _XvBadPort; } - if(XvMCScreenIndex >= 0) { /* any adaptors at all */ - ScreenPtr pScreen = pPort->pAdaptor->pScreen; - if((pScreenPriv = XVMC_GET_PRIVATE(pScreen))) { /* any this screen */ - for(i = 0; i < pScreenPriv->num_adaptors; i++) { - if(pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) { - adaptor = &(pScreenPriv->adaptors[i]); + ScreenPtr pScreen = pPort->pAdaptor->pScreen; + + if (!dixPrivateKeyRegistered(XvMCScreenKey)) + return BadMatch; /* No XvMC adaptors */ + + if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) + return BadMatch; /* None this screen */ + + for(i = 0; i < pScreenPriv->num_adaptors; i++) { + if(pPort->pAdaptor == pScreenPriv->adaptors[i].xv_adaptor) { + adaptor = &(pScreenPriv->adaptors[i]); break; - } - } - } + } } rep.type = X_Reply; @@ -204,9 +206,6 @@ ProcXvMCCreateContext(ClientPtr client) pScreen = pPort->pAdaptor->pScreen; - if(XvMCScreenIndex < 0) /* no XvMC adaptors */ - return BadMatch; - if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) /* none this screen */ return BadMatch; @@ -487,8 +486,8 @@ ProcXvMCListSubpictureTypes(ClientPtr client) pScreen = pPort->pAdaptor->pScreen; - if(XvMCScreenIndex < 0) /* No XvMC adaptors */ - return BadMatch; + if (!dixPrivateKeyRegistered(XvMCScreenKey)) + return BadMatch; /* No XvMC adaptors */ if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) return BadMatch; /* None this screen */ @@ -672,8 +671,8 @@ XvMCExtensionInit() { ExtensionEntry *extEntry; - if(XvMCScreenIndex < 0) /* nobody supports it */ - return; + if (!dixPrivateKeyRegistered(XvMCScreenKey)) + return; if(!(XvMCRTContext = CreateNewResourceType(XvMCDestroyContextRes))) return; @@ -713,17 +712,13 @@ XvMCScreenInit(ScreenPtr pScreen, int num, XvMCAdaptorPtr pAdapt) { XvMCScreenPtr pScreenPriv; - if(XvMCGeneration != serverGeneration) { - if((XvMCScreenIndex = AllocateScreenPrivateIndex()) < 0) - return BadAlloc; - - XvMCGeneration = serverGeneration; - } + if (!dixRegisterPrivateKey(&XvMCScreenKeyRec, PRIVATE_SCREEN, 0)) + return BadAlloc; if(!(pScreenPriv = (XvMCScreenPtr)malloc(sizeof(XvMCScreenRec)))) return BadAlloc; - pScreen->devPrivates[XvMCScreenIndex].ptr = (void *)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, XvMCScreenKey, pScreenPriv); pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = XvMCCloseScreen; @@ -747,7 +742,8 @@ XvImagePtr XvMCFindXvImage(XvPortPtr pPort, CARD32 id) XvMCAdaptorPtr adaptor = NULL; int i; - if(XvMCScreenIndex < 0) return NULL; + if (!dixPrivateKeyRegistered(XvMCScreenKey)) + return NULL; if(!(pScreenPriv = XVMC_GET_PRIVATE(pScreen))) return NULL; diff --git a/nx-X11/programs/Xserver/Xi/sendexev.c b/nx-X11/programs/Xserver/Xi/sendexev.c index ef7b9c4e96..1e2888376c 100644 --- a/nx-X11/programs/Xserver/Xi/sendexev.c +++ b/nx-X11/programs/Xserver/Xi/sendexev.c @@ -51,7 +51,6 @@ SOFTWARE. * */ -#define EXTENSION_EVENT_BASE 64 #ifdef HAVE_DIX_CONFIG_H #include #endif diff --git a/nx-X11/programs/Xserver/composite/compalloc.c b/nx-X11/programs/Xserver/composite/compalloc.c index 22b0362657..88fc027f5b 100644 --- a/nx-X11/programs/Xserver/composite/compalloc.c +++ b/nx-X11/programs/Xserver/composite/compalloc.c @@ -572,8 +572,8 @@ compNewPixmap (WindowPtr pWin, int x, int y, int w, int h) } } else { - PictFormatPtr pSrcFormat = compWindowFormat (pParent); - PictFormatPtr pDstFormat = compWindowFormat (pWin); + PictFormatPtr pSrcFormat = PictureWindowFormat(pParent); + PictFormatPtr pDstFormat = PictureWindowFormat(pWin); XID inferiors = IncludeInferiors; int error; diff --git a/nx-X11/programs/Xserver/composite/compext.c b/nx-X11/programs/Xserver/composite/compext.c index 8513c6d739..ea6e06a5be 100644 --- a/nx-X11/programs/Xserver/composite/compext.c +++ b/nx-X11/programs/Xserver/composite/compext.c @@ -34,13 +34,9 @@ static CARD8 CompositeReqCode; -#ifndef NXAGENT_SERVER static DevPrivateKeyRec CompositeClientPrivateKeyRec; #define CompositeClientPrivateKey (&CompositeClientPrivateKeyRec) -#else /* !defined(NXAGENT_SERVER) */ -static int CompositeClientPrivIndex = -1; -#endif /* !defined(NXAGENT_SERVER) */ RESTYPE CompositeClientWindowType; RESTYPE CompositeClientSubwindowsType; @@ -51,13 +47,8 @@ typedef struct _CompositeClient { int minor_version; } CompositeClientRec, *CompositeClientPtr; -#ifndef NXAGENT_SERVER #define GetCompositeClient(pClient) ((CompositeClientPtr) \ dixLookupPrivate(&(pClient)->devPrivates, CompositeClientPrivateKey)) -#else /* !defined(NXAGENT_SERVER) */ -#define GetCompositeClient(pClient) ((CompositeClientPtr) \ - (pClient)->devPrivates[CompositeClientPrivIndex].ptr) -#endif /* !edefined(NXAGENT_SERVER) */ static void CompositeClientCallback (CallbackListPtr *list, @@ -667,16 +658,9 @@ CompositeExtensionInit (void) if (!CompositeClientOverlayType) return; -#ifndef NXAGENT_SERVER if (!dixRegisterPrivateKey(&CompositeClientPrivateKeyRec, PRIVATE_CLIENT, sizeof (CompositeClientRec))) return; -#else /* !defined(NXAGENT_SERVER) */ - if ((CompositeClientPrivIndex = AllocateClientPrivateIndex()) < 0) - return; - if (!AllocateClientPrivate(CompositeClientPrivIndex, sizeof (CompositeClientRec))) - return; -#endif /* !defined(NXAGENT_SERVER) */ if (!AddCallback (&ClientStateCallback, CompositeClientCallback, 0)) return; diff --git a/nx-X11/programs/Xserver/composite/compinit.c b/nx-X11/programs/Xserver/composite/compinit.c index ff21378873..882a424320 100644 --- a/nx-X11/programs/Xserver/composite/compinit.c +++ b/nx-X11/programs/Xserver/composite/compinit.c @@ -29,15 +29,9 @@ #include "compint.h" #include "compositeext.h" -#ifndef NXAGENT_SERVER DevPrivateKeyRec CompScreenPrivateKeyRec; DevPrivateKeyRec CompWindowPrivateKeyRec; DevPrivateKeyRec CompSubwindowsPrivateKeyRec; -#else /* !defined(NXAGENT_SERVER) */ -int CompScreenPrivIndex = -1; -int CompWindowPrivIndex = -1; -int CompSubwindowsPrivIndex = -1; -#endif static Bool compCloseScreen (ScreenPtr pScreen) @@ -99,8 +93,6 @@ compInstallColormap (ColormapPtr pColormap) pScreen->InstallColormap = compInstallColormap; } -/* Unsupported by current architecture, drop for now. */ -#if 0 static void compCheckBackingStore(WindowPtr pWin) { @@ -134,7 +126,6 @@ compChangeWindowAttributes(WindowPtr pWin, unsigned long mask) return ret; } -#endif /* 0 */ static void compGetImage(DrawablePtr pDrawable, @@ -371,27 +362,12 @@ compScreenInit (ScreenPtr pScreen) { CompScreenPtr cs; -#ifndef NXAGENT_SERVER if (!dixRegisterPrivateKey(&CompScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) return FALSE; if (!dixRegisterPrivateKey(&CompWindowPrivateKeyRec, PRIVATE_WINDOW, 0)) return FALSE; if (!dixRegisterPrivateKey(&CompSubwindowsPrivateKeyRec, PRIVATE_WINDOW, 0)) return FALSE; -#else /* !defined(NXAGENT_SERVER) */ - if ((CompScreenPrivIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - if ((CompWindowPrivIndex = AllocateWindowPrivateIndex()) < 0) - return FALSE; - if ((CompSubwindowsPrivIndex = AllocateWindowPrivateIndex()) < 0) - return FALSE; - - if (!AllocateWindowPrivate (pScreen, CompWindowPrivIndex, 0)) - return FALSE; - - if (!AllocateWindowPrivate (pScreen, CompSubwindowsPrivIndex, 0)) - return FALSE; -#endif if (GetCompScreen (pScreen)) return TRUE; @@ -464,11 +440,8 @@ compScreenInit (ScreenPtr pScreen) cs->InstallColormap = pScreen->InstallColormap; pScreen->InstallColormap = compInstallColormap; - /* Unsupported by our current architecture, drop for now. */ - /* cs->ChangeWindowAttributes = pScreen->ChangeWindowAttributes; pScreen->ChangeWindowAttributes = compChangeWindowAttributes; - */ cs->BlockHandler = NULL; diff --git a/nx-X11/programs/Xserver/composite/compint.h b/nx-X11/programs/Xserver/composite/compint.h index 62d5fd8689..d7eedb69d6 100644 --- a/nx-X11/programs/Xserver/composite/compint.h +++ b/nx-X11/programs/Xserver/composite/compint.h @@ -160,7 +160,6 @@ typedef struct _CompScreen { SourceValidateProcPtr SourceValidate; } CompScreenRec, *CompScreenPtr; -#ifndef NXAGENT_SERVER extern DevPrivateKeyRec CompScreenPrivateKeyRec; #define CompScreenPrivateKey (&CompScreenPrivateKeyRec) @@ -179,33 +178,16 @@ extern DevPrivateKeyRec CompSubwindowsPrivateKeyRec; dixLookupPrivate(&(w)->devPrivates, CompWindowPrivateKey)) #define GetCompSubwindows(w) ((CompSubwindowsPtr) \ dixLookupPrivate(&(w)->devPrivates, CompSubwindowsPrivateKey)) -#else /* !defined(NXAGENT_SERVER) */ -extern int CompScreenPrivIndex; -extern int CompWindowPrivIndex; -extern int CompSubwindowsPrivIndex; - -#define GetCompScreen(s) ((CompScreenPtr) (s)->devPrivates[CompScreenPrivIndex].ptr) -#define GetCompWindow(w) ((CompWindowPtr) (w)->devPrivates[CompWindowPrivIndex].ptr) -#define GetCompSubwindows(w) ((CompSubwindowsPtr) (w)->devPrivates[CompSubwindowsPrivIndex].ptr) -#endif /* !defined(NXAGENT_SERVER) */ extern RESTYPE CompositeClientSubwindowsType; extern RESTYPE CompositeClientOverlayType; /* Shim for less ifdefs within the actual code. */ -#ifndef NXAGENT_SERVER #define FAKE_DIX_SET_PRIVATE_IMPL(obj, privateKey, ptr_val) do { dixSetPrivate(&(obj)->devPrivates, privateKey, ptr_val); } while (0) #define FAKE_DIX_SET_SCREEN_PRIVATE(pScreen, ptr_val) FAKE_DIX_SET_PRIVATE_IMPL(pScreen, CompScreenPrivateKey, ptr_val) #define FAKE_DIX_SET_WINDOW_PRIVATE(pWin, ptr_val) FAKE_DIX_SET_PRIVATE_IMPL(pWin, CompWindowPrivateKey, ptr_val) #define FAKE_DIX_SET_SUBWINDOWS_PRIVATE(pWin, ptr_val) FAKE_DIX_SET_PRIVATE_IMPL(pWin, CompSubwindowsPrivateKey, ptr_val) -#else /* !defined(NXAGENT_SERVER) */ -#define FAKE_DIX_SET_PRIVATE_IMPL(obj, privIndex, ptr_val) do { (obj)->devPrivates[privIndex].ptr = (void *) (ptr_val); } while (0) - -#define FAKE_DIX_SET_SCREEN_PRIVATE(pScreen, ptr_val) FAKE_DIX_SET_PRIVATE_IMPL(pScreen, CompScreenPrivIndex, ptr_val) -#define FAKE_DIX_SET_WINDOW_PRIVATE(pWin, ptr_val) FAKE_DIX_SET_PRIVATE_IMPL(pWin, CompWindowPrivIndex, ptr_val) -#define FAKE_DIX_SET_SUBWINDOWS_PRIVATE(pWin, ptr_val) FAKE_DIX_SET_PRIVATE_IMPL(pWin, CompSubwindowsPrivIndex, ptr_val) -#endif /* !defined(NXAGENT_SERVER) */ /* * compalloc.c @@ -285,9 +267,6 @@ compCheckTree (ScreenPtr pScreen); #define compCheckTree(s) #endif -PictFormatPtr -compWindowFormat (WindowPtr pWin); - void compSetPixmap (WindowPtr pWin, PixmapPtr pPixmap); diff --git a/nx-X11/programs/Xserver/composite/compwindow.c b/nx-X11/programs/Xserver/composite/compwindow.c index e9bb39827a..b265d0d420 100644 --- a/nx-X11/programs/Xserver/composite/compwindow.c +++ b/nx-X11/programs/Xserver/composite/compwindow.c @@ -717,28 +717,6 @@ compGetRedirectBorderClip (WindowPtr pWin) return &cw->borderClip; } -static VisualPtr -compGetWindowVisual (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - VisualID vid = wVisual (pWin); - int i; - - for (i = 0; i < pScreen->numVisuals; i++) - if (pScreen->visuals[i].vid == vid) - return &pScreen->visuals[i]; - return 0; -} - -PictFormatPtr -compWindowFormat (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - - return PictureMatchVisual (pScreen, pWin->drawable.depth, - compGetWindowVisual (pWin)); -} - static void compWindowUpdateAutomatic (WindowPtr pWin) { @@ -746,8 +724,8 @@ compWindowUpdateAutomatic (WindowPtr pWin) ScreenPtr pScreen = pWin->drawable.pScreen; WindowPtr pParent = pWin->parent; PixmapPtr pSrcPixmap = (*pScreen->GetWindowPixmap) (pWin); - PictFormatPtr pSrcFormat = compWindowFormat (pWin); - PictFormatPtr pDstFormat = compWindowFormat (pWin->parent); + PictFormatPtr pSrcFormat = PictureWindowFormat (pWin); + PictFormatPtr pDstFormat = PictureWindowFormat (pWin->parent); int error; RegionPtr pRegion = DamageRegion (cw->damage); PicturePtr pSrcPicture = CreatePicture (0, &pSrcPixmap->drawable, diff --git a/nx-X11/programs/Xserver/damageext/damageext.c b/nx-X11/programs/Xserver/damageext/damageext.c index b9d99a53cd..6af97ddc29 100644 --- a/nx-X11/programs/Xserver/damageext/damageext.c +++ b/nx-X11/programs/Xserver/damageext/damageext.c @@ -32,12 +32,15 @@ unsigned char DamageReqCode; int DamageEventBase; int DamageErrorBase; -int DamageClientPrivateIndex; RESTYPE DamageExtType; RESTYPE DamageExtWinType; #define prScreen screenInfo.screens[0] +DevPrivateKeyRec DamageClientPrivateKeyRec; + +#define DamageClientPrivateKey (&DamageClientPrivateKeyRec) + static void DamageExtNotify (DamageExtPtr pDamageExt, BoxPtr pBoxes, int nBoxes) { @@ -454,10 +457,10 @@ DamageExtensionInit(void) if (!DamageExtWinType) return; - DamageClientPrivateIndex = AllocateClientPrivateIndex (); - if (!AllocateClientPrivate (DamageClientPrivateIndex, - sizeof (DamageClientRec))) + if (!dixRegisterPrivateKey + (&DamageClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(DamageClientRec))) return; + if (!AddCallback (&ClientStateCallback, DamageClientCallback, 0)) return; diff --git a/nx-X11/programs/Xserver/damageext/damageextint.h b/nx-X11/programs/Xserver/damageext/damageextint.h index ba9212ebaf..5f45179216 100644 --- a/nx-X11/programs/Xserver/damageext/damageextint.h +++ b/nx-X11/programs/Xserver/damageext/damageextint.h @@ -46,7 +46,7 @@ extern unsigned char DamageReqCode; extern int DamageEventBase; extern int DamageErrorBase; -extern int DamageClientPrivateIndex; +extern DevPrivateKeyRec DamageClientPrivateKeyRec; extern RESTYPE DamageExtType; extern RESTYPE DamageExtWinType; @@ -56,7 +56,7 @@ typedef struct _DamageClient { int critical; } DamageClientRec, *DamageClientPtr; -#define GetDamageClient(pClient) ((DamageClientPtr) (pClient)->devPrivates[DamageClientPrivateIndex].ptr) +#define GetDamageClient(pClient) ((DamageClientPtr)dixLookupPrivate(&(pClient)->devPrivates, DamageClientPrivateKey)) typedef struct _DamageExt { DamagePtr pDamage; diff --git a/nx-X11/programs/Xserver/dbe/dbe.c b/nx-X11/programs/Xserver/dbe/dbe.c index 588dd05829..7d80709e68 100644 --- a/nx-X11/programs/Xserver/dbe/dbe.c +++ b/nx-X11/programs/Xserver/dbe/dbe.c @@ -58,16 +58,13 @@ /* Per-screen initialization functions [init'ed by DbeRegisterFunction()] */ static Bool (* DbeInitFunct[MAXSCREENS])(); /* pScreen, pDbeScreenPriv */ -/* These are static globals copied to DBE's screen private for use by DDX */ -static int dbeScreenPrivIndex; -static int dbeWindowPrivIndex; +/* These are globals for use by DDX */ +DevPrivateKeyRec dbeScreenPrivKeyRec; +DevPrivateKeyRec dbeWindowPrivKeyRec; -/* These are static globals copied to DBE's screen private for use by DDX */ -static RESTYPE dbeDrawableResType; -static RESTYPE dbeWindowPrivResType; - -/* This global is used by DbeAllocWinPrivPrivIndex() */ -static int winPrivPrivCount = 0; +/* These are globals for use by DDX */ +RESTYPE dbeDrawableResType; +RESTYPE dbeWindowPrivResType; /* Used to generate DBE's BadBuffer error. */ static int dbeErrorBase; @@ -110,146 +107,6 @@ DbeRegisterFunction(ScreenPtr pScreen, Bool (*funct) (/* ??? */)) } /* DbeRegisterFunction() */ - -/****************************************************************************** - * - * DBE DIX Procedure: DbeAllocWinPriv - * - * Description: - * - * This function was cloned from AllocateWindow() in window.c. - * This function allocates a window priv structure to be associated - * with a double-buffered window. - * - *****************************************************************************/ -static DbeWindowPrivPtr -DbeAllocWinPriv(ScreenPtr pScreen) -{ - DbeWindowPrivPtr pDbeWindowPriv; - DbeScreenPrivPtr pDbeScreenPriv; - register char *ptr; - register DevUnion *ppriv; - register unsigned int *sizes; - register unsigned int size; - register int i; - - pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen); - pDbeWindowPriv = (DbeWindowPrivPtr)malloc(pDbeScreenPriv->totalWinPrivSize); - - if (pDbeWindowPriv) - { - ppriv = (DevUnion *)(pDbeWindowPriv + 1); - pDbeWindowPriv->devPrivates = ppriv; - sizes = pDbeScreenPriv->winPrivPrivSizes; - ptr = (char *)(ppriv + pDbeScreenPriv->winPrivPrivLen); - for (i = pDbeScreenPriv->winPrivPrivLen; --i >= 0; ppriv++, sizes++) - { - if ((size = *sizes)) - { - ppriv->ptr = (void *)ptr; - ptr += size; - } - else - ppriv->ptr = (void *)NULL; - } - } - - return(pDbeWindowPriv); - -} /* DbeAllocWinPriv() */ - - -/****************************************************************************** - * - * DBE DIX Procedure: DbeFallbackAllocWinPriv - * - * Description: - * - * This is a fallback function for AllocWinPriv(). - * - *****************************************************************************/ - -#if 0 /* NOT USED */ -static DbeWindowPrivPtr -DbeFallbackAllocWinPriv(pScreen) - ScreenPtr pScreen; -{ - return (NULL); -} /* DbeFallbackAllocWinPriv() */ -#endif - - -/****************************************************************************** - * - * DBE DIX Procedure: DbeAllocWinPrivPrivIndex - * - * Description: - * - * This function was cloned from AllocateWindowPrivateIndex() in window.c. - * This function allocates a new window priv priv index by simply returning - * an incremented private counter. - * - *****************************************************************************/ - -static int -DbeAllocWinPrivPrivIndex(void) -{ - return winPrivPrivCount++; - -} /* DbeAllocWinPrivPrivIndex() */ - - -/****************************************************************************** - * - * DBE DIX Procedure: DbeAllocWinPrivPriv - * - * Description: - * - * This function was cloned from AllocateWindowPrivate() in privates.c. - * This function allocates a private structure to be hung off - * a window private. - * - *****************************************************************************/ - -static Bool -DbeAllocWinPrivPriv(register ScreenPtr pScreen, int index, unsigned int amount) -{ - DbeScreenPrivPtr pDbeScreenPriv; - unsigned int oldamount; - - - pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen); - - if (index >= pDbeScreenPriv->winPrivPrivLen) - { - unsigned *nsizes; - nsizes = (unsigned *)realloc(pDbeScreenPriv->winPrivPrivSizes, - (index + 1) * sizeof(unsigned)); - if (!nsizes) - { - return(FALSE); - } - - while (pDbeScreenPriv->winPrivPrivLen <= index) - { - nsizes[pDbeScreenPriv->winPrivPrivLen++] = 0; - pDbeScreenPriv->totalWinPrivSize += sizeof(DevUnion); - } - - pDbeScreenPriv->winPrivPrivSizes = nsizes; - } - - oldamount = pDbeScreenPriv->winPrivPrivSizes[index]; - - if (amount > oldamount) - { - pDbeScreenPriv->winPrivPrivSizes[index] = amount; - pDbeScreenPriv->totalWinPrivSize += (amount - oldamount); - } - return(TRUE); - -} /* DbeAllocWinPrivPriv() */ - /****************************************************************************** * @@ -267,9 +124,6 @@ DbeStubScreen(DbeScreenPrivPtr pDbeScreenPriv, int *nStubbedScreens) { /* Stub DIX. */ pDbeScreenPriv->SetupBackgroundPainter = NULL; - pDbeScreenPriv->AllocWinPriv = NULL; - pDbeScreenPriv->AllocWinPrivPrivIndex = NULL; - pDbeScreenPriv->AllocWinPrivPriv = NULL; /* Do not unwrap PositionWindow nor DestroyWindow. If the DDX * initialization function failed, we assume that it did not wrap @@ -443,19 +297,9 @@ ProcDbeAllocateBackBufferName(ClientPtr client) * Allocate a window priv. */ - if (!(pDbeWindowPriv = - (*pDbeScreenPriv->AllocWinPriv)(pWin->drawable.pScreen))) - { - return(BadAlloc); - } - - /* Make the window priv a DBE window priv resource. */ - if (!AddResource(stuff->buffer, dbeWindowPrivResType, - (void *)pDbeWindowPriv)) - { - free(pDbeWindowPriv); - return(BadAlloc); - } + pDbeWindowPriv = calloc(1, sizeof(DbeWindowPrivRec)); + if (!pDbeWindowPriv) + return BadAlloc; /* Fill out window priv information. */ pDbeWindowPriv->pWindow = pWin; @@ -476,9 +320,8 @@ ProcDbeAllocateBackBufferName(ClientPtr client) pDbeWindowPriv->IDs[i] = DBE_FREE_ID_ELEMENT; } - /* Actually connect the window priv to the window. */ - pWin->devPrivates[dbeWindowPrivIndex].ptr = (void *)pDbeWindowPriv; + dixSetPrivate(&pWin->devPrivates, dbeWindowPrivKey, pDbeWindowPriv); } /* if -- There is no buffer associated with the window. */ @@ -574,7 +417,6 @@ ProcDbeAllocateBackBufferName(ClientPtr client) /* Set swap action on all calls. */ pDbeWindowPriv->swapAction = stuff->swapAction; - return(status); } /* ProcDbeAllocateBackBufferName() */ @@ -1609,8 +1451,8 @@ DbeWindowPrivDelete(void * pDbeWinPriv, XID id) if (pDbeWindowPriv->nBufferIDs == 0) { /* Reset the DBE window priv pointer. */ - pDbeWindowPriv->pWindow->devPrivates[dbeWindowPrivIndex].ptr = - (void *)NULL; + dixSetPrivate(&pDbeWindowPriv->pWindow->devPrivates, dbeWindowPrivKey, + NULL); /* We are done with the window priv. */ free(pDbeWindowPriv); @@ -1639,12 +1481,6 @@ DbeResetProc(ExtensionEntry *extEntry) ScreenPtr pScreen; DbeScreenPrivPtr pDbeScreenPriv; - - if (dbeScreenPrivIndex < 0) - { - return; - } - for (i = 0; i < screenInfo.numScreens; i++) { pScreen = screenInfo.screens[i]; @@ -1658,11 +1494,6 @@ DbeResetProc(ExtensionEntry *extEntry) if (pDbeScreenPriv->ResetProc) (*pDbeScreenPriv->ResetProc)(pScreen); - if (pDbeScreenPriv->winPrivPrivSizes) - { - free(pDbeScreenPriv->winPrivPrivSizes); - } - free(pDbeScreenPriv); } } @@ -1783,20 +1614,11 @@ DbeExtensionInit(void) if(!noPanoramiXExtension) return; #endif - /* Allocate private pointers in windows and screens. */ - - if ((dbeScreenPrivIndex = AllocateScreenPrivateIndex()) < 0) - { + if (!dixRegisterPrivateKey(&dbeScreenPrivKeyRec, PRIVATE_SCREEN, 0)) return; - } - if ((dbeWindowPrivIndex = AllocateWindowPrivateIndex()) < 0) - { + if (!dixRegisterPrivateKey(&dbeWindowPrivKeyRec, PRIVATE_WINDOW, 0)) return; - } - - /* Initialize the priv priv counts between server generations. */ - winPrivPrivCount = 0; /* Create the resource types. */ dbeDrawableResType = @@ -1812,38 +1634,21 @@ DbeExtensionInit(void) pScreen = screenInfo.screens[i]; - if (!AllocateWindowPrivate(pScreen, dbeWindowPrivIndex, 0) || - !(pDbeScreenPriv = - (DbeScreenPrivPtr)calloc(1, sizeof(DbeScreenPrivRec)))) - { + if (!(pDbeScreenPriv = malloc(sizeof(DbeScreenPrivRec)))) { /* If we can not alloc a window or screen private, * then free any privates that we already alloc'ed and return */ for (j = 0; j < i; j++) { - free(screenInfo.screens[j]->devPrivates[dbeScreenPrivIndex].ptr); - screenInfo.screens[j]->devPrivates[dbeScreenPrivIndex].ptr = NULL; + free(dixLookupPrivate(&screenInfo.screens[i]->devPrivates, + dbeScreenPrivKey)); + dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, NULL); } return; } - pScreen->devPrivates[dbeScreenPrivIndex].ptr = (void *)pDbeScreenPriv; - - /* Store the DBE priv priv size info for later use when allocating - * priv privs at the driver level. - */ - pDbeScreenPriv->winPrivPrivLen = 0; - pDbeScreenPriv->winPrivPrivSizes = (unsigned *)NULL; - pDbeScreenPriv->totalWinPrivSize = sizeof(DbeWindowPrivRec); - - /* Copy the resource types */ - pDbeScreenPriv->dbeDrawableResType = dbeDrawableResType; - pDbeScreenPriv->dbeWindowPrivResType = dbeWindowPrivResType; - - /* Copy the private indices */ - pDbeScreenPriv->dbeScreenPrivIndex = dbeScreenPrivIndex; - pDbeScreenPriv->dbeWindowPrivIndex = dbeWindowPrivIndex; + dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, pDbeScreenPriv); if(DbeInitFunct[i]) { @@ -1851,9 +1656,6 @@ DbeExtensionInit(void) /* Setup DIX. */ pDbeScreenPriv->SetupBackgroundPainter = DbeSetupBackgroundPainter; - pDbeScreenPriv->AllocWinPriv = DbeAllocWinPriv; - pDbeScreenPriv->AllocWinPrivPrivIndex = DbeAllocWinPrivPrivIndex; - pDbeScreenPriv->AllocWinPrivPriv = DbeAllocWinPrivPriv; /* Setup DDX. */ ddxInitSuccess = (*DbeInitFunct[i])(pScreen, pDbeScreenPriv); @@ -1885,9 +1687,6 @@ DbeExtensionInit(void) #ifndef DISABLE_MI_DBE_BY_DEFAULT /* Setup DIX. */ pDbeScreenPriv->SetupBackgroundPainter = DbeSetupBackgroundPainter; - pDbeScreenPriv->AllocWinPriv = DbeAllocWinPriv; - pDbeScreenPriv->AllocWinPrivPrivIndex = DbeAllocWinPrivPrivIndex; - pDbeScreenPriv->AllocWinPrivPriv = DbeAllocWinPrivPriv; /* Setup DDX. */ ddxInitSuccess = miDbeInit(pScreen, pDbeScreenPriv); @@ -1926,8 +1725,9 @@ DbeExtensionInit(void) for (i = 0; i < screenInfo.numScreens; i++) { - free(screenInfo.screens[i]->devPrivates[dbeScreenPrivIndex].ptr); - pScreen->devPrivates[dbeScreenPrivIndex].ptr = NULL; + free(dixLookupPrivate(&screenInfo.screens[i]->devPrivates, + dbeScreenPrivKey)); + dixSetPrivate(&pScreen->devPrivates, dbeScreenPrivKey, NULL); } return; } diff --git a/nx-X11/programs/Xserver/dbe/dbestruct.h b/nx-X11/programs/Xserver/dbe/dbestruct.h index 3e5945bdb8..0fa6439df4 100644 --- a/nx-X11/programs/Xserver/dbe/dbestruct.h +++ b/nx-X11/programs/Xserver/dbe/dbestruct.h @@ -38,14 +38,12 @@ #include #include "windowstr.h" - +#include "privates.h" /* DEFINES */ -#define DBE_SCREEN_PRIV(pScreen) \ - ((dbeScreenPrivIndex < 0) ? \ - NULL : \ - ((DbeScreenPrivPtr)((pScreen)->devPrivates[dbeScreenPrivIndex].ptr))) +#define DBE_SCREEN_PRIV(pScreen) ((DbeScreenPrivPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, dbeScreenPrivKey)) #define DBE_SCREEN_PRIV_FROM_DRAWABLE(pDrawable) \ DBE_SCREEN_PRIV((pDrawable)->pScreen) @@ -62,10 +60,8 @@ #define DBE_SCREEN_PRIV_FROM_GC(pGC)\ DBE_SCREEN_PRIV((pGC)->pScreen) -#define DBE_WINDOW_PRIV(pWindow)\ - ((dbeWindowPrivIndex < 0) ? \ - NULL : \ - ((DbeWindowPrivPtr)(pWindow->devPrivates[dbeWindowPrivIndex].ptr))) +#define DBE_WINDOW_PRIV(pWin) ((DbeWindowPrivPtr) \ + dixLookupPrivate(&(pWin)->devPrivates, dbeWindowPrivKey)) /* Initial size of the buffer ID array in the window priv. */ #define DBE_INIT_MAX_IDS 2 @@ -139,9 +135,23 @@ typedef struct _DbeWindowPrivRec */ XID initIDs[DBE_INIT_MAX_IDS]; + /* Pointer to a drawable that contains the contents of the back buffer. + */ + PixmapPtr pBackBuffer; + + /* Pointer to a drawable that contains the contents of the front buffer. + * This pointer is only used for the XdbeUntouched swap action. For that + * swap action, we need to copy the front buffer (window) contents into + * this drawable, copy the contents of current back buffer drawable (the + * back buffer) into the window, swap the front and back drawable pointers, + * and then swap the drawable/resource associations in the resource + * database. + */ + PixmapPtr pFrontBuffer; + /* Device-specific private information. */ - DevUnion *devPrivates; + PrivateRec *devPrivates; } DbeWindowPrivRec, *DbeWindowPrivPtr; @@ -164,8 +174,8 @@ typedef struct _DbeScreenPrivRec RESTYPE dbeWindowPrivResType; /* Private indices created by DIX to be used by DDX */ - int dbeScreenPrivIndex; - int dbeWindowPrivIndex; + DevPrivateKeyRec dbeScreenPrivKeyRec; + DevPrivateKeyRec dbeWindowPrivKeyRec; /* Wrapped functions * It is the responsibilty of the DDX layer to wrap PositionWindow(). @@ -182,7 +192,7 @@ typedef struct _DbeScreenPrivRec DbeWindowPrivPtr (*AllocWinPriv)( ScreenPtr /*pScreen*/ ); - int (*AllocWinPrivPrivIndex)( + DevPrivateKeyRec (*AllocWinPrivPrivKeyRec)( void ); Bool (*AllocWinPrivPriv)( @@ -222,7 +232,7 @@ typedef struct _DbeScreenPrivRec /* Device-specific private information. */ - DevUnion *devPrivates; + PrivateRec *devPrivates; } DbeScreenPrivRec, *DbeScreenPrivPtr; diff --git a/nx-X11/programs/Xserver/dbe/midbe.c b/nx-X11/programs/Xserver/dbe/midbe.c index 0cc838d808..4dd1bb2438 100644 --- a/nx-X11/programs/Xserver/dbe/midbe.c +++ b/nx-X11/programs/Xserver/dbe/midbe.c @@ -49,7 +49,6 @@ #include "resource.h" #include "opaque.h" #include "dbestruct.h" -#include "midbestr.h" #include "regionstr.h" #include "gcstruct.h" #include "inputstr.h" @@ -57,12 +56,18 @@ #include -static int miDbePrivPrivGeneration = 0; -static int miDbeWindowPrivPrivIndex = -1; -static RESTYPE dbeDrawableResType; -static RESTYPE dbeWindowPrivResType; -static int dbeScreenPrivIndex = -1; -static int dbeWindowPrivIndex = -1; +/* DEFINES */ + + +/* TYPEDEFS */ + + +/* GLOBALS */ + +RESTYPE dbeDrawableResType; +RESTYPE dbeWindowPrivResType; +DevPrivateKeyRec dbeScreenPrivKeyRec; +DevPrivateKeyRec dbeWindowPrivKeyRec; /****************************************************************************** @@ -148,7 +153,6 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction) { ScreenPtr pScreen; DbeWindowPrivPtr pDbeWindowPriv; - MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv; DbeScreenPrivPtr pDbeScreenPriv; GCPtr pGC; xRectangle clearRect; @@ -167,12 +171,8 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction) pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen); - /* Setup the window priv priv. */ - pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv); - pDbeWindowPrivPriv->pDbeWindowPriv = pDbeWindowPriv; - /* Get a front pixmap. */ - if (!(pDbeWindowPrivPriv->pFrontBuffer = + if (!(pDbeWindowPriv->pFrontBuffer = (*pScreen->CreatePixmap)(pScreen, pDbeWindowPriv->width, pDbeWindowPriv->height, pWin->drawable.depth, 0))) @@ -181,41 +181,35 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction) } /* Get a back pixmap. */ - if (!(pDbeWindowPrivPriv->pBackBuffer = + if (!(pDbeWindowPriv->pBackBuffer = (*pScreen->CreatePixmap)(pScreen, pDbeWindowPriv->width, pDbeWindowPriv->height, pWin->drawable.depth, 0))) { - (*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pFrontBuffer); + (*pScreen->DestroyPixmap)(pDbeWindowPriv->pFrontBuffer); return(BadAlloc); } /* Make the back pixmap a DBE drawable resource. */ if (!AddResource(bufId, dbeDrawableResType, - (void *)pDbeWindowPrivPriv->pBackBuffer)) + (void *)pDbeWindowPriv->pBackBuffer)) { /* free the buffer and the drawable resource */ FreeResource(bufId, RT_NONE); return(BadAlloc); } - - /* Attach the priv priv to the priv. */ - pDbeWindowPriv->devPrivates[miDbeWindowPrivPrivIndex].ptr = - (void *)pDbeWindowPrivPriv; - - /* Clear the back buffer. */ pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen); if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC)) { - ValidateGC((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, pGC); + ValidateGC((DrawablePtr)pDbeWindowPriv->pBackBuffer, pGC); clearRect.x = clearRect.y = 0; - clearRect.width = pDbeWindowPrivPriv->pBackBuffer->drawable.width; - clearRect.height = pDbeWindowPrivPriv->pBackBuffer->drawable.height; + clearRect.width = pDbeWindowPriv->pBackBuffer->drawable.width; + clearRect.height = pDbeWindowPriv->pBackBuffer->drawable.height; (*pGC->ops->PolyFillRect)( - (DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, pGC, 1, + (DrawablePtr)pDbeWindowPriv->pBackBuffer, pGC, 1, &clearRect); } FreeScratchGC(pGC); @@ -229,9 +223,8 @@ miDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction) */ /* Associate the new ID with an existing pixmap. */ - pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv); if (!AddResource(bufId, dbeDrawableResType, - (void *)pDbeWindowPrivPriv->pBackBuffer)) + (void *)pDbeWindowPriv->pBackBuffer)) { return(BadAlloc); } @@ -258,13 +251,11 @@ static void miDbeAliasBuffers(DbeWindowPrivPtr pDbeWindowPriv) { int i; - MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv = - MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv); for (i = 0; i < pDbeWindowPriv->nBufferIDs; i++) { ChangeResourceValue(pDbeWindowPriv->IDs[i], dbeDrawableResType, - (void *)pDbeWindowPrivPriv->pBackBuffer); + (void *)pDbeWindowPriv->pBackBuffer); } } /* miDbeAliasBuffers() */ @@ -284,16 +275,16 @@ static int miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo) { DbeScreenPrivPtr pDbeScreenPriv; + DbeWindowPrivPtr pDbeWindowPriv; GCPtr pGC; WindowPtr pWin; - MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv; PixmapPtr pTmpBuffer; xRectangle clearRect; pWin = swapInfo[0].pWindow; pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin); - pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin); + pDbeWindowPriv = DBE_WINDOW_PRIV(pWin); pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen); /* @@ -311,9 +302,9 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo) break; case XdbeUntouched: - ValidateGC((DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer, pGC); + ValidateGC((DrawablePtr)pDbeWindowPriv->pFrontBuffer, pGC); (*pGC->ops->CopyArea)((DrawablePtr)pWin, - (DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer, + (DrawablePtr)pDbeWindowPriv->pFrontBuffer, pGC, 0, 0, pWin->drawable.width, pWin->drawable.height, 0, 0); break; @@ -330,7 +321,7 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo) */ ValidateGC((DrawablePtr)pWin, pGC); - (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, + (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPriv->pBackBuffer, (DrawablePtr)pWin, pGC, 0, 0, pWin->drawable.width, pWin->drawable.height, 0, 0); @@ -349,27 +340,27 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo) case XdbeBackground: if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC)) { - ValidateGC((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, pGC); + ValidateGC((DrawablePtr)pDbeWindowPriv->pBackBuffer, pGC); clearRect.x = 0; clearRect.y = 0; clearRect.width = - pDbeWindowPrivPriv->pBackBuffer->drawable.width; + pDbeWindowPriv->pBackBuffer->drawable.width; clearRect.height = - pDbeWindowPrivPriv->pBackBuffer->drawable.height; + pDbeWindowPriv->pBackBuffer->drawable.height; (*pGC->ops->PolyFillRect)( - (DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, + (DrawablePtr)pDbeWindowPriv->pBackBuffer, pGC, 1, &clearRect); } break; case XdbeUntouched: /* Swap pixmap pointers. */ - pTmpBuffer = pDbeWindowPrivPriv->pBackBuffer; - pDbeWindowPrivPriv->pBackBuffer = - pDbeWindowPrivPriv->pFrontBuffer; - pDbeWindowPrivPriv->pFrontBuffer = pTmpBuffer; + pTmpBuffer = pDbeWindowPriv->pBackBuffer; + pDbeWindowPriv->pBackBuffer = + pDbeWindowPriv->pFrontBuffer; + pDbeWindowPriv->pFrontBuffer = pTmpBuffer; - miDbeAliasBuffers(pDbeWindowPrivPriv->pDbeWindowPriv); + miDbeAliasBuffers(pDbeWindowPriv); break; @@ -462,8 +453,6 @@ miDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo) static void miDbeWinPrivDelete(DbeWindowPrivPtr pDbeWindowPriv, XID bufId) { - MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv; - if (pDbeWindowPriv->nBufferIDs != 0) { @@ -478,18 +467,16 @@ miDbeWinPrivDelete(DbeWindowPrivPtr pDbeWindowPriv, XID bufId) * free some stuff. */ - pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv); - /* Destroy the front and back pixmaps. */ - if (pDbeWindowPrivPriv->pFrontBuffer) + if (pDbeWindowPriv->pFrontBuffer) { (*pDbeWindowPriv->pWindow->drawable.pScreen->DestroyPixmap)( - pDbeWindowPrivPriv->pFrontBuffer); + pDbeWindowPriv->pFrontBuffer); } - if (pDbeWindowPrivPriv->pBackBuffer) + if (pDbeWindowPriv->pBackBuffer) { (*pDbeWindowPriv->pWindow->drawable.pScreen->DestroyPixmap)( - pDbeWindowPrivPriv->pBackBuffer); + pDbeWindowPriv->pBackBuffer); } } /* miDbeWinPrivDelete() */ @@ -683,10 +670,6 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) { /* Clear out the new DBE buffer pixmaps. */ - MiDbeWindowPrivPrivPtr pDbeWindowPrivPriv; - - - pDbeWindowPrivPriv = MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv); ValidateGC((DrawablePtr)pFrontBuffer, pGC); /* I suppose this could avoid quite a bit of work if @@ -703,10 +686,10 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) /* Copy the contents of the old DBE pixmaps to the new pixmaps. */ if (pWin->bitGravity != ForgetGravity) { - (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer, + (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPriv->pFrontBuffer, (DrawablePtr)pFrontBuffer, pGC, sourcex, sourcey, savewidth, saveheight, destx, desty); - (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, + (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPriv->pBackBuffer, (DrawablePtr)pBackBuffer, pGC, sourcex, sourcey, savewidth, saveheight, destx, desty); } @@ -715,11 +698,11 @@ miDbePositionWindow(WindowPtr pWin, int x, int y) * pixmaps. */ - (*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pFrontBuffer); - (*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pBackBuffer); + (*pScreen->DestroyPixmap)(pDbeWindowPriv->pFrontBuffer); + (*pScreen->DestroyPixmap)(pDbeWindowPriv->pBackBuffer); - pDbeWindowPrivPriv->pFrontBuffer = pFrontBuffer; - pDbeWindowPrivPriv->pBackBuffer = pBackBuffer; + pDbeWindowPriv->pFrontBuffer = pFrontBuffer; + pDbeWindowPriv->pBackBuffer = pBackBuffer; /* Make sure all XID are associated with the new back pixmap. */ miDbeAliasBuffers(pDbeWindowPriv); @@ -771,36 +754,6 @@ miDbeResetProc(ScreenPtr pScreen) Bool miDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv) { - /* Copy resource types created by DIX */ - dbeDrawableResType = pDbeScreenPriv->dbeDrawableResType; - dbeWindowPrivResType = pDbeScreenPriv->dbeWindowPrivResType; - - /* Copy private indices created by DIX */ - dbeScreenPrivIndex = pDbeScreenPriv->dbeScreenPrivIndex; - dbeWindowPrivIndex = pDbeScreenPriv->dbeWindowPrivIndex; - - /* Reset the window priv privs if generations do not match. */ - if (miDbePrivPrivGeneration != serverGeneration) - { - /* - ********************************************************************** - ** Allocate the window priv priv. - ********************************************************************** - */ - - miDbeWindowPrivPrivIndex = (*pDbeScreenPriv->AllocWinPrivPrivIndex)(); - - /* Make sure we only do this code once. */ - miDbePrivPrivGeneration = serverGeneration; - - } /* if -- Reset priv privs. */ - - if (!(*pDbeScreenPriv->AllocWinPrivPriv)(pScreen, - miDbeWindowPrivPrivIndex, sizeof(MiDbeWindowPrivPrivRec))) - { - return(FALSE); - } - /* Wrap functions. */ pDbeScreenPriv->PositionWindow = pScreen->PositionWindow; pScreen->PositionWindow = miDbePositionWindow; diff --git a/nx-X11/programs/Xserver/dbe/midbe.h b/nx-X11/programs/Xserver/dbe/midbe.h index 007f2e37bf..c84453b3fa 100644 --- a/nx-X11/programs/Xserver/dbe/midbe.h +++ b/nx-X11/programs/Xserver/dbe/midbe.h @@ -43,5 +43,13 @@ extern Bool miDbeInit( DbeScreenPrivPtr pDbeScreenPriv ); +extern DevPrivateKeyRec dbeScreenPrivKeyRec; + +#define dbeScreenPrivKey (&dbeScreenPrivKeyRec) + +extern DevPrivateKeyRec dbeWindowPrivKeyRec; + +#define dbeWindowPrivKey (&dbeWindowPrivKeyRec) + #endif /* MIDBE_H */ diff --git a/nx-X11/programs/Xserver/dbe/midbestr.h b/nx-X11/programs/Xserver/dbe/midbestr.h deleted file mode 100644 index 1ad0104aa3..0000000000 --- a/nx-X11/programs/Xserver/dbe/midbestr.h +++ /dev/null @@ -1,99 +0,0 @@ -/****************************************************************************** - * - * Copyright (c) 1994, 1995 Hewlett-Packard Company - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL HEWLETT-PACKARD COMPANY BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of the Hewlett-Packard - * Company shall not be used in advertising or otherwise to promote the - * sale, use or other dealings in this Software without prior written - * authorization from the Hewlett-Packard Company. - * - * Header file for users of machine-independent DBE code - * - *****************************************************************************/ - - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#ifndef MIDBE_STRUCT_H -#define MIDBE_STRUCT_H - - -/* DEFINES */ - -#define MI_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv) \ - (((miDbeWindowPrivPrivIndex < 0) || (!pDbeWindowPriv)) ? \ - NULL : \ - ((MiDbeWindowPrivPrivPtr) \ - ((pDbeWindowPriv)->devPrivates[miDbeWindowPrivPrivIndex].ptr))) - -#define MI_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin)\ - MI_DBE_WINDOW_PRIV_PRIV(DBE_WINDOW_PRIV(pWin)) - -#define MI_DBE_SCREEN_PRIV_PRIV(pDbeScreenPriv) \ - (((miDbeScreenPrivPrivIndex < 0) || (!pDbeScreenPriv)) ? \ - NULL : \ - ((MiDbeScreenPrivPrivPtr) \ - ((pDbeScreenPriv)->devPrivates[miDbeScreenPrivPrivIndex].ptr))) - - -/* TYPEDEFS */ - -typedef struct _MiDbeWindowPrivPrivRec -{ - /* Place machine-specific fields in here. - * Since this is mi code, we do not really have machine-specific fields. - */ - - /* Pointer to a drawable that contains the contents of the back buffer. - */ - PixmapPtr pBackBuffer; - - /* Pointer to a drawable that contains the contents of the front buffer. - * This pointer is only used for the XdbeUntouched swap action. For that - * swap action, we need to copy the front buffer (window) contents into - * this drawable, copy the contents of current back buffer drawable (the - * back buffer) into the window, swap the front and back drawable pointers, - * and then swap the drawable/resource associations in the resource - * database. - */ - PixmapPtr pFrontBuffer; - - /* Pointer back to our window private with which we are associated. */ - DbeWindowPrivPtr pDbeWindowPriv; - -} MiDbeWindowPrivPrivRec, *MiDbeWindowPrivPrivPtr; - -typedef struct _MiDbeScreenPrivPrivRec -{ - /* Place machine-specific fields in here. - * Since this is mi code, we do not really have machine-specific fields. - */ - - /* Pointer back to our screen private with which we are associated. */ - DbeScreenPrivPtr pDbeScreenPriv; - -} MiDbeScreenPrivPrivRec, *MiDbeScreenPrivPrivPtr; - -#endif /* MIDBE_STRUCT_H */ - diff --git a/nx-X11/programs/Xserver/dix/Imakefile b/nx-X11/programs/Xserver/dix/Imakefile index ccdae3b821..efd34cbec0 100644 --- a/nx-X11/programs/Xserver/dix/Imakefile +++ b/nx-X11/programs/Xserver/dix/Imakefile @@ -123,10 +123,16 @@ VENDORRELEASE = XVendorRelease #endif #endif +#if defined(NXAgentServer) && NXAgentServer + NX_DEFINES = -DNXAGENT_SERVER +#endif + SITE_DEFINES = $(SITE_FONT_PATH) $(SITE_DISPLAY_CLASS) VENDOR_DEFINES = $(VENDOR_STRING) $(VENDOR_RELEASE) $(QUARTZ_DEFINES) +DEFINES = $(NX_DEFINES) + NormalLibraryObjectRule() NormalLibraryTarget(dix,$(OBJS)) LintLibraryTarget(dix,$(SRCS) $(XPSRC)) @@ -135,7 +141,6 @@ NormalLintTarget($(SRCS) $(XPSRC)) SpecialCObjectRule(globals,$(ICONFIGFILES),$(SITE_DEFINES) $(EXT_DEFINES)) SpecialCObjectRule(main,$(ICONFIGFILES),$(VENDOR_DEFINES)) SpecialCObjectRule(pixmap,$(ICONFIGFILES),$(_NOOP_)) -SpecialCObjectRule(privates,$(ICONFIGFILES),$(_NOOP_)) SpecialCObjectRule(window,$(ICONFIGFILES),$(QUARTZ_DEFINES)) NormalLibraryTarget(xpstubs,$(XPOBJ)) diff --git a/nx-X11/programs/Xserver/dix/colormap.c b/nx-X11/programs/Xserver/dix/colormap.c index db2b64714e..fbac23b606 100644 --- a/nx-X11/programs/Xserver/dix/colormap.c +++ b/nx-X11/programs/Xserver/dix/colormap.c @@ -273,16 +273,24 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, if ((class | DynamicClass) == DirectColor) sizebytes *= 3; sizebytes += sizeof(ColormapRec); - pmap = (ColormapPtr) malloc(sizebytes); - if (!pmap) - return (BadAlloc); -#if defined(_XSERVER64) - pmap->pad0 = 0; - pmap->pad1 = 0; -#if (X_BYTE_ORDER == X_LITTLE_ENDIAN) - pmap->pad2 = 0; -#endif -#endif + + if (mid == pScreen->defColormap) { + pmap = malloc(sizebytes); + 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; + } pmap->red = (EntryPtr)((char *)pmap + sizeof(ColormapRec)); sizebytes = size * sizeof(Entry); pmap->clientPixelsRed = (Pixel **)((char *)pmap->red + sizebytes); @@ -385,31 +393,15 @@ CreateColormap (Colormap mid, ScreenPtr pScreen, VisualPtr pVisual, pmap->numPixelsBlue[client] = size; } } + + pmap->flags |= BeingCreated; + if (!AddResource(mid, RT_COLORMAP, (void *)pmap)) return (BadAlloc); + /* If the device wants a chance to initialize the colormap in any way, * this is it. In specific, if this is a Static colormap, this is the * time to fill in the colormap's values */ - pmap->flags |= BeingCreated; - - - /* - * Allocate the array of devPrivate's for this colormap. - */ - - if (colormapPrivateCount == 0) - pmap->devPrivates = NULL; - else - { - pmap->devPrivates = (DevUnion *) calloc ( - sizeof(DevUnion), colormapPrivateCount); - if (!pmap->devPrivates) - { - FreeResource (mid, RT_NONE); - return BadAlloc; - } - } - if (!(*pScreen->CreateColormap)(pmap)) { FreeResource (mid, RT_NONE); @@ -473,10 +465,14 @@ FreeColormap (void * value, XID mid) } } - if (pmap->devPrivates) - free(pmap->devPrivates); - - free(pmap); + if (pmap->flags & IsDefault) { + dixFreePrivates(pmap->devPrivates, PRIVATE_COLORMAP); + free(pmap); + } + else + { + dixFreeObjectWithPrivates(pmap, PRIVATE_COLORMAP); + } return(Success); } diff --git a/nx-X11/programs/Xserver/dix/cursor.c b/nx-X11/programs/Xserver/dix/cursor.c index 658edcb876..8b597c6f33 100644 --- a/nx-X11/programs/Xserver/dix/cursor.c +++ b/nx-X11/programs/Xserver/dix/cursor.c @@ -70,6 +70,8 @@ typedef struct _GlyphShare { static GlyphSharePtr sharedGlyphs = (GlyphSharePtr)NULL; +DevScreenPrivateKeyRec cursorScreenDevPriv; + #ifdef XFIXES static CARD32 cursorSerial; #endif @@ -84,6 +86,7 @@ FreeCursorBits(CursorBitsPtr bits) #ifdef ARGB_CURSOR free(bits->argb); #endif + dixFiniPrivates(bits, PRIVATE_CURSOR_BITS); if (bits->refcnt == 0) { register GlyphSharePtr *prev, this; @@ -124,6 +127,7 @@ FreeCursor(void * value, XID cid) (void)( *pscr->UnrealizeCursor)( pscr, pCurs); } FreeCursorBits(pCurs->bits); + dixFiniPrivates(pCurs, PRIVATE_CURSOR); free( pCurs); return(Success); } @@ -172,14 +176,17 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb, int nscr; ScreenPtr pscr; - pCurs = (CursorPtr)malloc(sizeof(CursorRec) + sizeof(CursorBits)); + pCurs = (CursorPtr) calloc(CURSOR_REC_SIZE + CURSOR_BITS_SIZE, 1); if (!pCurs) { free(psrcbits); free(pmaskbits); return (CursorPtr)NULL; } - 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->mask = pmaskbits; #ifdef ARGB_CURSOR @@ -221,6 +228,7 @@ AllocCursorARGB(unsigned char *psrcbits, unsigned char *pmaskbits, CARD32 *argb, ( *pscr->UnrealizeCursor)( pscr, pCurs); } FreeCursorBits(bits); + dixFiniPrivates(pCurs, PRIVATE_CURSOR); free(pCurs); return (CursorPtr)NULL; } @@ -290,9 +298,10 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, } if (pShare) { - pCurs = (CursorPtr)malloc(sizeof(CursorRec)); + pCurs = (CursorPtr) calloc(CURSOR_REC_SIZE, 1); if (!pCurs) return BadAlloc; + dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR); bits = pShare->bits; bits->refcnt++; } @@ -332,17 +341,17 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, } if (sourcefont != maskfont) { - pCurs = (CursorPtr)malloc(sizeof(CursorRec) + sizeof(CursorBits)); + pCurs = (CursorPtr) calloc(CURSOR_REC_SIZE + CURSOR_BITS_SIZE, 1); if (pCurs) - bits = (CursorBitsPtr)((char *)pCurs + sizeof(CursorRec)); + bits = (CursorBitsPtr) ((char *) pCurs + CURSOR_REC_SIZE); else bits = (CursorBitsPtr)NULL; } else { - pCurs = (CursorPtr)malloc(sizeof(CursorRec)); + pCurs = (CursorPtr) calloc(CURSOR_REC_SIZE, 1); if (pCurs) - bits = (CursorBitsPtr)malloc(sizeof(CursorBits)); + bits = (CursorBitsPtr) calloc(CURSOR_BITS_SIZE, 1); else bits = (CursorBitsPtr)NULL; } @@ -353,6 +362,8 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, free(srcbits); return BadAlloc; } + dixInitPrivates(pCurs, pCurs + 1, PRIVATE_CURSOR); + dixInitPrivates(bits, bits + 1, PRIVATE_CURSOR_BITS); bits->source = srcbits; bits->mask = mskbits; #ifdef ARGB_CURSOR @@ -371,6 +382,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, if (!pShare) { FreeCursorBits(bits); + dixFiniPrivates(pCurs, PRIVATE_CURSOR); free(pCurs); return BadAlloc; } @@ -413,6 +425,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, ( *pscr->UnrealizeCursor)( pscr, pCurs); } FreeCursorBits(pCurs->bits); + dixFiniPrivates(pCurs, PRIVATE_CURSOR); free(pCurs); return BadAlloc; } diff --git a/nx-X11/programs/Xserver/dix/devices.c b/nx-X11/programs/Xserver/dix/devices.c index 51cf3fef98..cdbd3179bb 100644 --- a/nx-X11/programs/Xserver/dix/devices.c +++ b/nx-X11/programs/Xserver/dix/devices.c @@ -83,6 +83,12 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart) dev = (DeviceIntPtr) calloc(1, sizeof(DeviceIntRec)); if (!dev) return (DeviceIntPtr)NULL; + + if (!dixAllocatePrivates(&dev->devPrivates, PRIVATE_DEVICE)) { + free(dev); + return NULL; + } + dev->name = (char *)NULL; dev->type = 0; dev->id = inputInfo.numDevices; @@ -90,6 +96,7 @@ AddInputDevice(DeviceProc deviceProc, Bool autoStart) dev->public.on = FALSE; dev->public.processInputProc = (ProcessInputProc)NoopDDA; dev->public.realInputProc = (ProcessInputProc)NoopDDA; + dev->public.enqueueInputProc = EnqueueEvent; dev->deviceProc = deviceProc; dev->startup = autoStart; diff --git a/nx-X11/programs/Xserver/dix/dispatch.c b/nx-X11/programs/Xserver/dix/dispatch.c index 3c791465eb..5a09dbde1f 100644 --- a/nx-X11/programs/Xserver/dix/dispatch.c +++ b/nx-X11/programs/Xserver/dix/dispatch.c @@ -3566,7 +3566,7 @@ CloseDownClient(register ClientPtr client) nextFreeClientID = client->index; clients[client->index] = NullClient; SmartLastClient = NullClient; - free(client); + dixFreeObjectWithPrivates(client, PRIVATE_CLIENT); while (!clients[currentMaxClients-1]) currentMaxClients--; @@ -3652,54 +3652,6 @@ void InitClient(ClientPtr client, int i, void * ospriv) client->clientIds = NULL; } -#ifndef NXAGENT_SERVER -int -InitClientPrivates(ClientPtr client) -{ - register char *ptr; - DevUnion *ppriv; - register unsigned *sizes; - register unsigned size; - register int i; - - if (totalClientSize == sizeof(ClientRec)) - ppriv = (DevUnion *)NULL; - else if (client->index) - ppriv = (DevUnion *)(client + 1); - else - { - ppriv = (DevUnion *)malloc(totalClientSize - sizeof(ClientRec)); - if (!ppriv) - return 0; - } - client->devPrivates = ppriv; - sizes = clientPrivateSizes; - ptr = (char *)(ppriv + clientPrivateLen); - for (i = clientPrivateLen; --i >= 0; ppriv++, sizes++) - { - if ( (size = *sizes) ) - { - ppriv->ptr = (void *)ptr; - ptr += size; - } - else - ppriv->ptr = (void *)NULL; - } - - /* Allow registrants to initialize the serverClient devPrivates */ - if (!client->index && ClientStateCallback) - { - NewClientInfoRec clientinfo; - - clientinfo.client = client; - clientinfo.prefix = (xConnSetupPrefix *)NULL; - clientinfo.setup = (xConnSetup *) NULL; - CallCallbacks((&ClientStateCallback), (void *)&clientinfo); - } - return 1; -} -#endif /* NXAGENT_SERVER */ - /************************ * int NextAvailableClient(ospriv) * @@ -3716,14 +3668,14 @@ ClientPtr NextAvailableClient(void * ospriv) i = nextFreeClientID; if (i == MAXCLIENTS) return (ClientPtr)NULL; - clients[i] = client = (ClientPtr)malloc(totalClientSize); + clients[i] = client = + dixAllocateObjectWithPrivates(ClientRec, PRIVATE_CLIENT); if (!client) return (ClientPtr)NULL; InitClient(client, i, ospriv); - InitClientPrivates(client); if (!InitClientResources(client)) { - free(client); + dixFreeObjectWithPrivates(client, PRIVATE_CLIENT); return (ClientPtr)NULL; } data.reqType = 1; @@ -3731,7 +3683,7 @@ ClientPtr NextAvailableClient(void * ospriv) if (!InsertFakeRequest(client, (char *)&data, sz_xReq)) { FreeClientResources(client); - free(client); + dixFreeObjectWithPrivates(client, PRIVATE_CLIENT); return (ClientPtr)NULL; } if (i == currentMaxClients) @@ -4070,20 +4022,13 @@ static int init_screen(ScreenPtr pScreen, int i) void (**jNI) (); #endif /* DEBUG */ + dixInitScreenSpecificPrivates(pScreen); + + if (!dixAllocatePrivates(&pScreen->devPrivates, PRIVATE_SCREEN)) { + return -1; + } + pScreen->myNum = i; - pScreen->WindowPrivateLen = 0; - pScreen->WindowPrivateSizes = (unsigned *)NULL; - pScreen->totalWindowSize = - ((sizeof(WindowRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); - pScreen->GCPrivateLen = 0; - pScreen->GCPrivateSizes = (unsigned *)NULL; - pScreen->totalGCSize = - ((sizeof(GC) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); -#ifdef PIXPRIV - pScreen->PixmapPrivateLen = 0; - pScreen->PixmapPrivateSizes = (unsigned *)NULL; - pScreen->totalPixmapSize = BitmapBytePad(sizeof(PixmapRec)*8); -#endif pScreen->ClipNotify = 0; /* for R4 ddx compatibility */ pScreen->CreateScreenResources = 0; @@ -4130,15 +4075,6 @@ static int init_screen(ScreenPtr pScreen, int i) return 0; } -void FreeScreen(ScreenPtr); - -/* - grow the array of screenRecs if necessary. - call the device-supplied initialization procedure - with its screen number, a pointer to its ScreenRec, argc, and argv. - return the number of successfully installed screens. -*/ - int AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , int /*argc */ , @@ -4158,11 +4094,6 @@ AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , if (!pScreen) return -1; - pScreen->devPrivates = (DevUnion *)calloc(sizeof(DevUnion), - screenPrivateCount); - if (!pScreen->devPrivates && screenPrivateCount) - return -1; - ret = init_screen(pScreen, i); if (ret != 0) { free(pScreen); @@ -4181,22 +4112,15 @@ AddScreen(Bool (*pfnInit) (ScreenPtr /*pScreen */ , screenInfo.numScreens++; if (!(*pfnInit)(pScreen, argc, argv)) { - FreeScreen(pScreen); - screenInfo.numScreens--; - return -1; + dixFreeScreenSpecificPrivates(pScreen); + dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN); + free(pScreen); + screenInfo.numScreens--; + return -1; } - return i; -} -void -FreeScreen(ScreenPtr pScreen) -{ - pScreen->root = NullWindow; - free(pScreen->WindowPrivateSizes); - free(pScreen->GCPrivateSizes); -#ifdef PIXPRIV - free(pScreen->PixmapPrivateSizes); -#endif - free(pScreen->devPrivates); - free(pScreen); + dixRegisterScreenPrivateKey(&cursorScreenDevPriv, pScreen, PRIVATE_CURSOR, + 0); + + return i; } diff --git a/nx-X11/programs/Xserver/dix/events.c b/nx-X11/programs/Xserver/dix/events.c index e936be77ed..c3c76a922a 100644 --- a/nx-X11/programs/Xserver/dix/events.c +++ b/nx-X11/programs/Xserver/dix/events.c @@ -146,8 +146,6 @@ extern Bool XkbFilterEvents(ClientPtr, int, xEvent *); #include "dixgrabs.h" #include "dispatch.h" -#define EXTENSION_EVENT_BASE 64 - #define NoSuchEvent 0x80000000 /* so doesn't match NoEventMask */ #define StructureAndSubMask ( StructureNotifyMask | SubstructureNotifyMask ) #define AllButtonsMask ( \ diff --git a/nx-X11/programs/Xserver/dix/extension.c b/nx-X11/programs/Xserver/dix/extension.c index 763f57337c..490648c4d2 100644 --- a/nx-X11/programs/Xserver/dix/extension.c +++ b/nx-X11/programs/Xserver/dix/extension.c @@ -62,8 +62,6 @@ SOFTWARE. #include #endif -#define EXTENSION_BASE 128 -#define EXTENSION_EVENT_BASE 64 #define LAST_EVENT 128 #define LAST_ERROR 255 @@ -75,39 +73,6 @@ int lastEvent = EXTENSION_EVENT_BASE; static int lastError = FirstExtensionError; static unsigned int NumExtensions = 0; -extern int extensionPrivateLen; -extern unsigned *extensionPrivateSizes; -extern unsigned totalExtensionSize; - -static void -InitExtensionPrivates(ExtensionEntry *ext) -{ - register char *ptr; - DevUnion *ppriv; - register unsigned *sizes; - register unsigned size; - register int i; - - if (totalExtensionSize == sizeof(ExtensionEntry)) - ppriv = (DevUnion *)NULL; - else - ppriv = (DevUnion *)(ext + 1); - - ext->devPrivates = ppriv; - sizes = extensionPrivateSizes; - ptr = (char *)(ppriv + extensionPrivateLen); - for (i = extensionPrivateLen; --i >= 0; ppriv++, sizes++) - { - if ( (size = *sizes) ) - { - ppriv->ptr = (void *)ptr; - ptr += size; - } - else - ppriv->ptr = (void *)NULL; - } -} - ExtensionEntry * AddExtension(char *name, int NumEvents, int NumErrors, int (*MainProc)(ClientPtr c1), @@ -124,16 +89,19 @@ AddExtension(char *name, int NumEvents, int NumErrors, (unsigned)(lastError + NumErrors > LAST_ERROR)) return((ExtensionEntry *) NULL); - ext = (ExtensionEntry *) malloc(totalExtensionSize); + ext = (ExtensionEntry *) malloc(sizeof(ExtensionEntry)); if (!ext) return((ExtensionEntry *) NULL); - bzero(ext, totalExtensionSize); - InitExtensionPrivates(ext); + if (!dixAllocatePrivates(&ext->devPrivates, PRIVATE_EXTENSION)) { + free(ext); + return NULL; + } ext->name = (char *)malloc(strlen(name) + 1); ext->num_aliases = 0; ext->aliases = (char **)NULL; if (!ext->name) { + dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION); free(ext); return((ExtensionEntry *) NULL); } @@ -144,6 +112,7 @@ AddExtension(char *name, int NumEvents, int NumErrors, if (!newexts) { free(ext->name); + dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION); free(ext); return((ExtensionEntry *) NULL); } @@ -312,6 +281,7 @@ CloseDownExtensions() for (j = extensions[i]->num_aliases; --j >= 0;) free(extensions[i]->aliases[j]); free(extensions[i]->aliases); + dixFreePrivates(extensions[i]->devPrivates, PRIVATE_EXTENSION); free(extensions[i]); } free(extensions); diff --git a/nx-X11/programs/Xserver/dix/gc.c b/nx-X11/programs/Xserver/dix/gc.c index d40334f5f5..55dd0ea45e 100644 --- a/nx-X11/programs/Xserver/dix/gc.c +++ b/nx-X11/programs/Xserver/dix/gc.c @@ -61,6 +61,7 @@ SOFTWARE. #include "scrnintstr.h" #include "region.h" +#include "privates.h" #include "dix.h" #include @@ -557,67 +558,22 @@ DoChangeGC(register GC *pGC, register BITS32 mask, XID *pval, int fPointer) return dixChangeGC(NullClient, pGC, mask, pval, NULL); } - -/* CreateGC(pDrawable, mask, pval, pStatus) - creates a default GC for the given drawable, using mask to fill - in any non-default values. - Returns a pointer to the new GC on success, NULL otherwise. - returns status of non-default fields in pStatus -BUG: - should check for failure to create default tile - -*/ - static GCPtr -AllocateGC(ScreenPtr pScreen) +NewGCObject(ScreenPtr pScreen, int depth) { GCPtr pGC; - register char *ptr; - register DevUnion *ppriv; - register unsigned *sizes; - register unsigned size; - register int i; - pGC = (GCPtr)malloc(pScreen->totalGCSize); - if (pGC) - { - ppriv = (DevUnion *)(pGC + 1); - pGC->devPrivates = ppriv; - sizes = pScreen->GCPrivateSizes; - ptr = (char *)(ppriv + pScreen->GCPrivateLen); - for (i = pScreen->GCPrivateLen; --i >= 0; ppriv++, sizes++) - { - if ( (size = *sizes) ) - { - ppriv->ptr = (void *)ptr; - ptr += size; - } - else - ppriv->ptr = (void *)NULL; - } + pGC = dixAllocateScreenObjectWithPrivates(pScreen, GC, PRIVATE_GC); + if (!pGC) { + return (GCPtr) NULL; } - return pGC; -} - -GCPtr -CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus) -{ - register GCPtr pGC; - pGC = AllocateGC(pDrawable->pScreen); - if (!pGC) - { - *pStatus = BadAlloc; - return (GCPtr)NULL; - } - - pGC->pScreen = pDrawable->pScreen; - pGC->depth = pDrawable->depth; + pGC->pScreen = pScreen; + pGC->depth = depth; pGC->alu = GXcopy; /* dst <- src */ pGC->planemask = ~0; pGC->serialNumber = GC_CHANGE_SERIAL_BIT; pGC->funcs = 0; - pGC->fgPixel = 0; pGC->bgPixel = 1; pGC->lineWidth = 0; @@ -627,21 +583,10 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus) pGC->fillStyle = FillSolid; pGC->fillRule = EvenOddRule; pGC->arcMode = ArcPieSlice; - if (mask & GCForeground) - { - /* - * magic special case -- ChangeGC checks for this condition - * and snags the Foreground value to create a pseudo default-tile - */ - pGC->tileIsPixel = FALSE; - pGC->tile.pixmap = NullPixmap; - } - else - { - pGC->tileIsPixel = TRUE; - pGC->tile.pixel = 0; - } + pGC->tile.pixel = 0; + pGC->tile.pixmap = NullPixmap; + pGC->tileIsPixel = TRUE; pGC->patOrg.x = 0; pGC->patOrg.y = 0; pGC->subWindowMode = ClipByChildren; @@ -658,9 +603,37 @@ CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus) /* use the default font and stipple */ pGC->font = defaultFont; - defaultFont->refcnt++; + if (pGC->font) /* necessary, because open of default font could fail */ + pGC->font->refcnt++; + pGC->stipple = pGC->pScreen->PixmapPerDepth[0]; - pGC->stipple->refcnt++; + if (pGC->stipple) + pGC->stipple->refcnt++; + + return pGC; +} + +/* CreateGC(pDrawable, mask, pval, pStatus) + creates a default GC for the given drawable, using mask to fill + in any non-default values. + Returns a pointer to the new GC on success, NULL otherwise. + returns status of non-default fields in pStatus +BUG: + should check for failure to create default tile + +*/ + +GCPtr +CreateGC(DrawablePtr pDrawable, BITS32 mask, XID *pval, int *pStatus) +{ + register GCPtr pGC; + + pGC = NewGCObject(pDrawable->pScreen, pDrawable->depth); + if (!pGC) + { + *pStatus = BadAlloc; + return (GCPtr)NULL; + } pGC->stateChanges = (1 << (GCLastBit+1)) - 1; if (!(*pGC->pScreen->CreateGC)(pGC)) @@ -903,7 +876,7 @@ FreeGC(void * value, XID gid) (*pGC->funcs->DestroyGC) (pGC); if (pGC->dash != DefaultDash) free(pGC->dash); - free(pGC); + dixFreeObjectWithPrivates(pGC, PRIVATE_GC); return(Success); } @@ -936,44 +909,10 @@ CreateScratchGC(ScreenPtr pScreen, unsigned depth) { register GCPtr pGC; - pGC = AllocateGC(pScreen); + pGC = NewGCObject(pScreen, depth); if (!pGC) return (GCPtr)NULL; - pGC->pScreen = pScreen; - pGC->depth = depth; - pGC->alu = GXcopy; /* dst <- src */ - pGC->planemask = ~0; - pGC->serialNumber = 0; - - pGC->fgPixel = 0; - pGC->bgPixel = 1; - pGC->lineWidth = 0; - pGC->lineStyle = LineSolid; - pGC->capStyle = CapButt; - pGC->joinStyle = JoinMiter; - pGC->fillStyle = FillSolid; - pGC->fillRule = EvenOddRule; - pGC->arcMode = ArcPieSlice; - pGC->font = defaultFont; - if ( pGC->font) /* necessary, because open of default font could fail */ - pGC->font->refcnt++; - pGC->tileIsPixel = TRUE; - pGC->tile.pixel = 0; - pGC->stipple = NullPixmap; - pGC->patOrg.x = 0; - pGC->patOrg.y = 0; - pGC->subWindowMode = ClipByChildren; - pGC->graphicsExposures = TRUE; - pGC->clipOrg.x = 0; - pGC->clipOrg.y = 0; - pGC->clientClipType = CT_NONE; - pGC->dashOffset = 0; - pGC->numInDashList = 2; - pGC->dash = DefaultDash; - pGC->lastWinOrg.x = 0; - pGC->lastWinOrg.y = 0; - pGC->stateChanges = (1 << (GCLastBit+1)) - 1; if (!(*pScreen->CreateGC)(pGC)) { diff --git a/nx-X11/programs/Xserver/dix/main.c b/nx-X11/programs/Xserver/dix/main.c index d425872dfe..13a9ac354b 100644 --- a/nx-X11/programs/Xserver/dix/main.c +++ b/nx-X11/programs/Xserver/dix/main.c @@ -120,8 +120,6 @@ Equipment Corporation. #include "dpmsproc.h" #endif -extern int InitClientPrivates(ClientPtr client); - extern void Dispatch(void); xConnSetupPrefix connSetupPrefix; @@ -131,8 +129,6 @@ extern FontPtr defaultFont; extern void InitProcVectors(void); extern Bool CreateGCperDepthArray(void); -extern void FreeScreen(ScreenPtr pScreen); - #ifndef PANORAMIX static #endif @@ -248,6 +244,15 @@ main(int argc, char *argv[], char *envp[]) clients[0] = serverClient; currentMaxClients = 1; + /* Initialize privates before first allocation */ + dixResetPrivates(); + + /* 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 */ FatalError("couldn't init server resources"); @@ -263,16 +268,6 @@ main(int argc, char *argv[], char *envp[]) #else InitGlyphCaching(); #endif /* of HAS_XFONT2 */ - ResetExtensionPrivates(); - ResetClientPrivates(); - ResetScreenPrivates(); - ResetWindowPrivates(); - ResetGCPrivates(); -#ifdef PIXPRIV - ResetPixmapPrivates(); -#endif - ResetColormapPrivates(); - ResetDevicePrivateIndex(); InitFonts(); InitCallbackManager(); InitVisualWrap(); @@ -283,8 +278,7 @@ main(int argc, char *argv[], char *envp[]) if (screenInfo.numVideoScreens < 0) screenInfo.numVideoScreens = screenInfo.numScreens; InitExtensions(argc, argv); - if (!InitClientPrivates(serverClient)) - FatalError("failed to allocate serverClient devprivates"); + for (i = 0; i < screenInfo.numScreens; i++) { ScreenPtr pScreen = screenInfo.screens[i]; @@ -300,11 +294,6 @@ main(int argc, char *argv[], char *envp[]) if (!CreateRootWindow(pScreen)) FatalError("failed to create root window"); } - InitInput(argc, argv); - if (InitAndStartDevices() != Success) - FatalError("failed to initialize core devices"); - ReserveClientIds(serverClient); - if (loadableFonts) { SetFontPath(serverClient, 0, (unsigned char *)defaultFontPath); } else { @@ -335,6 +324,12 @@ main(int argc, char *argv[], char *envp[]) for (i = 0; i < screenInfo.numScreens; i++) InitRootWindow(screenInfo.screens[i]->root); DefineInitialRootWindow(screenInfo.screens[0]->root); + + InitInput(argc, argv); + if (InitAndStartDevices() != Success) + FatalError("failed to initialize core devices"); + ReserveClientIds(serverClient); + SaveScreens(SCREEN_SAVER_FORCER, ScreenSaverReset); #ifdef PANORAMIX @@ -379,8 +374,10 @@ main(int argc, char *argv[], char *envp[]) FreeScratchPixmapsForScreen(i); FreeGCperDepth(i); FreeDefaultStipple(i); + dixFreeScreenSpecificPrivates(screenInfo.screens[i]); (* screenInfo.screens[i]->CloseScreen)(screenInfo.screens[i]); - FreeScreen(screenInfo.screens[i]); + dixFreePrivates(screenInfo.screens[i]->devPrivates, PRIVATE_SCREEN); + free(screenInfo.screens[i]); screenInfo.numScreens = i; } FreeFonts(); @@ -388,7 +385,7 @@ main(int argc, char *argv[], char *envp[]) FreeAuditTimer(); ReleaseClientIds(serverClient); - free(serverClient->devPrivates); + dixFreePrivates(serverClient->devPrivates, PRIVATE_CLIENT); serverClient->devPrivates = NULL; if (dispatchException & DE_TERMINATE) @@ -520,7 +517,7 @@ CreateConnectionBlock() root.maxInstalledMaps = pScreen->maxInstalledCmaps; root.rootVisualID = pScreen->rootVisual; root.backingStore = pScreen->backingStoreSupport; - root.saveUnders = pScreen->saveUnderSupport != NotUseful; + root.saveUnders = FALSE; root.rootDepth = pScreen->rootDepth; root.nDepths = pScreen->numDepths; memmove(pBuf, (char *)&root, sizeof(xWindowRoot)); diff --git a/nx-X11/programs/Xserver/dix/pixmap.c b/nx-X11/programs/Xserver/dix/pixmap.c index 247fa34ab3..0a9d431bd4 100644 --- a/nx-X11/programs/Xserver/dix/pixmap.c +++ b/nx-X11/programs/Xserver/dix/pixmap.c @@ -91,8 +91,16 @@ FreeScratchPixmapHeader(PixmapPtr pPixmap) Bool CreateScratchPixmapsForScreen(int scrnum) { + ScreenPtr pScreen = screenInfo.screens[scrnum]; + + unsigned int pixmap_size; + + pixmap_size = sizeof(PixmapRec) + dixScreenSpecificPrivatesSize(pScreen, PRIVATE_PIXMAP); + pScreen->totalPixmapSize = + BitmapBytePad(pixmap_size * 8); + /* let it be created on first use */ - screenInfo.screens[scrnum]->pScratchPixmap = NULL; + pScreen->pScratchPixmap = NULL; return TRUE; } @@ -103,57 +111,29 @@ FreeScratchPixmapsForScreen(int scrnum) FreeScratchPixmapHeader(screenInfo.screens[scrnum]->pScratchPixmap); } - /* callable by ddx */ PixmapPtr AllocatePixmap(ScreenPtr pScreen, int pixDataSize) { PixmapPtr pPixmap; -#ifdef PIXPRIV - char *ptr; - DevUnion *ppriv; - unsigned *sizes; - unsigned size; - int i; - - if (pScreen->totalPixmapSize > ((size_t)-1) - pixDataSize) - return NullPixmap; - - /* - * FIXME: Allocate 4 bytes at the end of each pixmap. This - * is a quick workaround intended to fix a problem reported - * by Valgrind due to fbBlt() writing just after the end of - * the pixmap buffer. This may be a RENDER bug. - * This is not included in xorg upstream! - */ - - pPixmap = (PixmapPtr)calloc(1, pScreen->totalPixmapSize + pixDataSize + 4); - if (!pPixmap) - return NullPixmap; - ppriv = (DevUnion *)(pPixmap + 1); - pPixmap->devPrivates = ppriv; - sizes = pScreen->PixmapPrivateSizes; - ptr = (char *)(ppriv + pScreen->PixmapPrivateLen); - for (i = pScreen->PixmapPrivateLen; --i >= 0; ppriv++, sizes++) - { - if ((size = *sizes) != 0) - { - ppriv->ptr = (void *)ptr; - ptr += size; - } - else - ppriv->ptr = (void *)NULL; - } -#else - pPixmap = (PixmapPtr)calloc(1, sizeof(PixmapRec) + pixDataSize); -#endif -#ifdef _XSERVER64 - if (pPixmap) { - pPixmap->drawable.pad0 = 0; - pPixmap->drawable.pad1 = 0; - } -#endif + assert(pScreen->totalPixmapSize > 0); + + if (pScreen->totalPixmapSize > ((size_t) - 1) - pixDataSize) + return NullPixmap; + pPixmap = malloc(pScreen->totalPixmapSize + pixDataSize); + if (!pPixmap) + return NullPixmap; + + dixInitScreenPrivates(pScreen, pPixmap, pPixmap + 1, PRIVATE_PIXMAP); return pPixmap; } + +/* callable by ddx */ +void +FreePixmap(PixmapPtr pPixmap) +{ + dixFiniPrivates(pPixmap, PRIVATE_PIXMAP); + free(pPixmap); +} diff --git a/nx-X11/programs/Xserver/dix/privates.c b/nx-X11/programs/Xserver/dix/privates.c index 6c793ef975..01bc331c56 100644 --- a/nx-X11/programs/Xserver/dix/privates.c +++ b/nx-X11/programs/Xserver/dix/privates.c @@ -25,432 +25,776 @@ other dealings in this Software without prior written authorization from The Open Group. */ +/* + * Copyright © 2010, Keith Packard + * Copyright © 2010, Jamey Sharp + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that copyright + * notice and this permission notice appear in supporting documentation, and + * that the name of the copyright holders not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. The copyright holders make no representations + * about the suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ #ifdef HAVE_DIX_CONFIG_H #include #endif -#include -#include "scrnintstr.h" -#include "misc.h" -#include "os.h" +#include #include "windowstr.h" #include "resource.h" -#include "dixstruct.h" +#include "privates.h" #include "gcstruct.h" +#include "cursorstr.h" #include "colormapst.h" -#include "servermd.h" -#include "site.h" +#include "inputstr.h" +#include "scrnintstr.h" +#include "extnsionst.h" #include "inputstr.h" #include "extnsionst.h" -/* - * See the Wrappers and devPrivates section in "Definition of the - * Porting Layer for the X v11 Sample Server" (doc/Server/ddx.tbl.ms) - * for information on how to use devPrivates. - */ - -/* - * extension private machinery - */ - -static int extensionPrivateCount; -int extensionPrivateLen; -unsigned *extensionPrivateSizes; -unsigned totalExtensionSize; - -void -ResetExtensionPrivates() +static DevPrivateSetRec global_keys[PRIVATE_LAST]; + +static const Bool xselinux_private[PRIVATE_LAST] = { + [PRIVATE_SCREEN] = TRUE, + [PRIVATE_CLIENT] = TRUE, + [PRIVATE_WINDOW] = TRUE, + [PRIVATE_PIXMAP] = TRUE, + [PRIVATE_GC] = TRUE, + [PRIVATE_CURSOR] = TRUE, + [PRIVATE_COLORMAP] = TRUE, + [PRIVATE_DEVICE] = TRUE, + [PRIVATE_EXTENSION] = TRUE, + [PRIVATE_SELECTION] = TRUE, + [PRIVATE_PROPERTY] = TRUE, + [PRIVATE_PICTURE] = TRUE, + [PRIVATE_GLYPHSET] = TRUE, +}; + +static const char *key_names[PRIVATE_LAST] = { + /* XSELinux uses the same private keys for numerous objects */ + [PRIVATE_XSELINUX] = "XSELINUX", + + /* Otherwise, you get a private in just the requested structure + */ + /* These can have objects created before all of the keys are registered */ + [PRIVATE_SCREEN] = "SCREEN", + [PRIVATE_EXTENSION] = "EXTENSION", + [PRIVATE_COLORMAP] = "COLORMAP", + [PRIVATE_DEVICE] = "DEVICE", + + /* These cannot have any objects before all relevant keys are registered */ + [PRIVATE_CLIENT] = "CLIENT", + [PRIVATE_PROPERTY] = "PROPERTY", + [PRIVATE_SELECTION] = "SELECTION", + [PRIVATE_WINDOW] = "WINDOW", + [PRIVATE_PIXMAP] = "PIXMAP", + [PRIVATE_GC] = "GC", + [PRIVATE_CURSOR] = "CURSOR", + [PRIVATE_CURSOR_BITS] = "CURSOR_BITS", + + /* extension privates */ + [PRIVATE_GLYPH] = "GLYPH", + [PRIVATE_GLYPHSET] = "GLYPHSET", + [PRIVATE_PICTURE] = "PICTURE", + [PRIVATE_SYNC_FENCE] = "SYNC_FENCE", +}; + +static const Bool screen_specific_private[PRIVATE_LAST] = { + [PRIVATE_SCREEN] = FALSE, + [PRIVATE_CLIENT] = FALSE, + [PRIVATE_WINDOW] = TRUE, + [PRIVATE_PIXMAP] = TRUE, + [PRIVATE_GC] = TRUE, + [PRIVATE_CURSOR] = FALSE, + [PRIVATE_COLORMAP] = FALSE, + [PRIVATE_DEVICE] = FALSE, + [PRIVATE_EXTENSION] = FALSE, + [PRIVATE_SELECTION] = FALSE, + [PRIVATE_PROPERTY] = FALSE, + [PRIVATE_PICTURE] = TRUE, + [PRIVATE_GLYPHSET] = FALSE, +}; + +typedef Bool (*FixupFunc) (PrivatePtr *privates, int offset, unsigned bytes); + +typedef enum { FixupMove, FixupRealloc } FixupType; + +static Bool +dixReallocPrivates(PrivatePtr *privates, int old_offset, unsigned bytes) { - extensionPrivateCount = 0; - extensionPrivateLen = 0; - free(extensionPrivateSizes); - extensionPrivateSizes = (unsigned *)NULL; - totalExtensionSize = - ((sizeof(ExtensionEntry) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); + void *new_privates; + + new_privates = realloc(*privates, old_offset + bytes); + if (!new_privates) + return FALSE; + memset((char *) new_privates + old_offset, '\0', bytes); + *privates = new_privates; + return TRUE; } -int -AllocateExtensionPrivateIndex() +static Bool +dixMovePrivates(PrivatePtr *privates, int new_offset, unsigned bytes) { - return extensionPrivateCount++; + memmove((char *) *privates + bytes, *privates, new_offset - bytes); + memset(*privates, '\0', bytes); + return TRUE; } -Bool -AllocateExtensionPrivate(int index2, unsigned amount) +static Bool +fixupOneScreen(ScreenPtr pScreen, FixupFunc fixup, unsigned bytes) { - unsigned oldamount; - - /* Round up sizes for proper alignment */ - amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); - - if (index2 >= extensionPrivateLen) - { - unsigned *nsizes; - nsizes = (unsigned *)realloc(extensionPrivateSizes, - (index2 + 1) * sizeof(unsigned)); - if (!nsizes) - return FALSE; - while (extensionPrivateLen <= index2) - { - nsizes[extensionPrivateLen++] = 0; - totalExtensionSize += sizeof(DevUnion); - } - extensionPrivateSizes = nsizes; - } - oldamount = extensionPrivateSizes[index2]; - if (amount > oldamount) - { - extensionPrivateSizes[index2] = amount; - totalExtensionSize += (amount - oldamount); + intptr_t dist; + char *old; + char *new; + DevPrivateKey *keyp, key; + DevPrivateType type; + int size; + + old = (char *) pScreen->devPrivates; + size = global_keys[PRIVATE_SCREEN].offset; + if (!fixup (&pScreen->devPrivates, size, bytes)) + return FALSE; + + /* Screen privates can contain screen-specific private keys + * for other types. When they move, the linked list we use to + * track them gets scrambled. Fix that by computing the change + * in the location of each private adjusting our linked list + * pointers to match + */ + + new = (char *) pScreen->devPrivates; + + /* Moving means everyone shifts up in the privates by 'bytes' amount, + * realloc means the base pointer moves + */ + if (fixup == dixMovePrivates) + new += bytes; + + dist = new - old; + + if (dist) { + for (type = PRIVATE_XSELINUX; type < PRIVATE_LAST; type++) + + /* Walk the privates list, being careful as the + * pointers are scrambled before we patch them. + */ + for (keyp = &pScreen->screenSpecificPrivates[type].key; + (key = *keyp) != NULL; + keyp = &key->next) + { + + /* Only mangle things if the private structure + * is contained within the allocation. Privates + * stored elsewhere will be left alone + */ + if (old <= (char *) key && (char *) key < old + size) + { + /* Compute new location of key */ + key = (DevPrivateKey) ((char *) key + dist); + + /* Patch the list */ + *keyp = key; + } + } } return TRUE; } -/* - * client private machinery - */ +static Bool +fixupScreens(FixupFunc fixup, unsigned bytes) +{ + int s; -static int clientPrivateCount; -int clientPrivateLen; -unsigned *clientPrivateSizes; -unsigned totalClientSize; + for (s = 0; s < screenInfo.numScreens; s++) + if (!fixupOneScreen (screenInfo.screens[s], fixup, bytes)) + return FALSE; -void -ResetClientPrivates() +#ifndef NXAGENT_SERVER + for (s = 0; s < screenInfo.numGPUScreens; s++) + if (!fixupOneScreen (screenInfo.gpuscreens[s], fixup, bytes)) + return FALSE; +#endif /* NXAGENT_SERVER */ + return TRUE; +} + +static Bool +fixupServerClient(FixupFunc fixup, unsigned bytes) { - clientPrivateCount = 0; - clientPrivateLen = 0; - free(clientPrivateSizes); - clientPrivateSizes = (unsigned *)NULL; - totalClientSize = - ((sizeof(ClientRec) + sizeof(long) - 1) / sizeof(long)) * sizeof(long); + if (serverClient) + return fixup(&serverClient->devPrivates, global_keys[PRIVATE_CLIENT].offset, + bytes); + return TRUE; } -int -AllocateClientPrivateIndex() +static Bool +fixupExtensions(FixupFunc fixup, unsigned bytes) { - return clientPrivateCount++; + unsigned char major; + ExtensionEntry *extension; + + for (major = EXTENSION_BASE; (extension = GetExtensionEntry(major)); + major++) + if (!fixup + (&extension->devPrivates, global_keys[PRIVATE_EXTENSION].offset, bytes)) + return FALSE; + return TRUE; } -Bool -AllocateClientPrivate(int index2, unsigned amount) +static Bool +fixupDefaultColormaps(FixupFunc fixup, unsigned bytes) { - unsigned oldamount; - - /* Round up sizes for proper alignment */ - amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); - - if (index2 >= clientPrivateLen) - { - unsigned *nsizes; - nsizes = (unsigned *)realloc(clientPrivateSizes, - (index2 + 1) * sizeof(unsigned)); - if (!nsizes) - return FALSE; - while (clientPrivateLen <= index2) - { - nsizes[clientPrivateLen++] = 0; - totalClientSize += sizeof(DevUnion); - } - clientPrivateSizes = nsizes; + int s; + + for (s = 0; s < screenInfo.numScreens; s++) { + ColormapPtr cmap; + +#ifndef NXAGENT_SERVER + dixLookupResourceByType((void **) &cmap, + screenInfo.screens[s]->defColormap, RT_COLORMAP, + serverClient, DixDestroyAccess); +#else /* !defined(NXAGENT_SERVER) */ + cmap = (void *) LookupIDByType(screenInfo.screens[s]->defColormap, RT_COLORMAP); +#endif + if (cmap && + !fixup(&cmap->devPrivates, screenInfo.screens[s]->screenSpecificPrivates[PRIVATE_COLORMAP].offset, bytes)) + return FALSE; } - oldamount = clientPrivateSizes[index2]; - if (amount > oldamount) - { - clientPrivateSizes[index2] = amount; - totalClientSize += (amount - oldamount); + return TRUE; +} + +static Bool +fixupDeviceList(DeviceIntPtr device, FixupFunc fixup, unsigned bytes) +{ + while (device) { + if (!fixup(&device->devPrivates, global_keys[PRIVATE_DEVICE].offset, bytes)) + return FALSE; + device = device->next; } return TRUE; } -/* - * screen private machinery - */ +static Bool +fixupDevices(FixupFunc fixup, unsigned bytes) +{ + return (fixupDeviceList(inputInfo.devices, fixup, bytes) && + fixupDeviceList(inputInfo.off_devices, fixup, bytes)); +} -int screenPrivateCount; +static Bool (*const allocated_early[PRIVATE_LAST]) (FixupFunc, unsigned) = { + [PRIVATE_SCREEN] = fixupScreens, + [PRIVATE_CLIENT] = fixupServerClient, + [PRIVATE_EXTENSION] = fixupExtensions, + [PRIVATE_COLORMAP] = fixupDefaultColormaps, + [PRIVATE_DEVICE] = fixupDevices, +}; -void -ResetScreenPrivates() +static void +grow_private_set(DevPrivateSetPtr set, unsigned bytes) { - screenPrivateCount = 0; + DevPrivateKey k; + + for (k = set->key; k; k = k->next) + k->offset += bytes; + set->offset += bytes; } -/* this can be called after some screens have been created, - * so we have to worry about resizing existing devPrivates - */ -int -AllocateScreenPrivateIndex() +static void +grow_screen_specific_set(DevPrivateType type, unsigned bytes) { - int idx; - int i; - ScreenPtr pScreen; - DevUnion *nprivs; - - idx = screenPrivateCount++; - for (i = 0; i < screenInfo.numScreens; i++) - { - pScreen = screenInfo.screens[i]; - nprivs = (DevUnion *)realloc(pScreen->devPrivates, - screenPrivateCount * sizeof(DevUnion)); - if (!nprivs) - { - screenPrivateCount--; - return -1; - } - /* Zero the new private */ - bzero(&nprivs[idx], sizeof(DevUnion)); - pScreen->devPrivates = nprivs; + int s; + + /* Update offsets for all screen-specific keys */ + for (s = 0; s < screenInfo.numScreens; s++) { + ScreenPtr pScreen = screenInfo.screens[s]; + + grow_private_set(&pScreen->screenSpecificPrivates[type], bytes); } - return idx; -} +#ifndef NXAGENT_SERVER + for (s = 0; s < screenInfo.numGPUScreens; s++) { + ScreenPtr pScreen = screenInfo.gpuscreens[s]; + grow_private_set(&pScreen->screenSpecificPrivates[type], bytes); + } +#endif +} /* - * window private machinery + * Register a private key. This takes the type of object the key will + * be used with, which may be PRIVATE_ALL indicating that this key + * will be used with all of the private objects. If 'size' is + * non-zero, then the specified amount of space will be allocated in + * the private storage. Otherwise, space for a single pointer will + * be allocated which can be set with dixSetPrivate */ +Bool +dixRegisterPrivateKey(DevPrivateKey key, DevPrivateType type, unsigned size) +{ + DevPrivateType t; + int offset; + unsigned bytes; -static int windowPrivateCount; + if (key->initialized) { + assert(size == key->size); + return TRUE; + } -void -ResetWindowPrivates() -{ - windowPrivateCount = 0; -} + /* Compute required space */ + bytes = size; + if (size == 0) + bytes = sizeof(void *); + + /* align to pointer size */ + bytes = (bytes + sizeof(void *) - 1) & ~(sizeof(void *) - 1); + + /* Update offsets for all affected keys */ + if (type == PRIVATE_XSELINUX) { + + /* Resize if we can, or make sure nothing's allocated if we can't + */ + for (t = PRIVATE_XSELINUX; t < PRIVATE_LAST; t++) + if (xselinux_private[t]) { + if (!allocated_early[t]) + assert(!global_keys[t].created); + else if (!allocated_early[t] (dixReallocPrivates, bytes)) + return FALSE; + } + + /* Move all existing keys up in the privates space to make + * room for this new global key + */ + for (t = PRIVATE_XSELINUX; t < PRIVATE_LAST; t++) { + if (xselinux_private[t]) { + grow_private_set(&global_keys[t], bytes); + grow_screen_specific_set(t, bytes); + if (allocated_early[t]) + allocated_early[t] (dixMovePrivates, bytes); + } + + } + + offset = 0; + } + else { + /* Resize if we can, or make sure nothing's allocated if we can't */ + if (!allocated_early[type]) + assert(!global_keys[type].created); + else if (!allocated_early[type] (dixReallocPrivates, bytes)) + return FALSE; + offset = global_keys[type].offset; + global_keys[type].offset += bytes; + grow_screen_specific_set(type, bytes); + } -int -AllocateWindowPrivateIndex() -{ - return windowPrivateCount++; + /* Setup this key */ + key->offset = offset; + key->size = size; + key->initialized = TRUE; + key->type = type; + key->allocated = FALSE; + key->next = global_keys[type].key; + global_keys[type].key = key; + + return TRUE; } Bool -AllocateWindowPrivate(register ScreenPtr pScreen, int index2, unsigned amount) +dixRegisterScreenPrivateKey(DevScreenPrivateKey screenKey, ScreenPtr pScreen, + DevPrivateType type, unsigned size) { - unsigned oldamount; - - /* Round up sizes for proper alignment */ - amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); - - if (index2 >= pScreen->WindowPrivateLen) - { - unsigned *nsizes; - nsizes = (unsigned *)realloc(pScreen->WindowPrivateSizes, - (index2 + 1) * sizeof(unsigned)); - if (!nsizes) - return FALSE; - while (pScreen->WindowPrivateLen <= index2) - { - nsizes[pScreen->WindowPrivateLen++] = 0; - pScreen->totalWindowSize += sizeof(DevUnion); - } - pScreen->WindowPrivateSizes = nsizes; + DevPrivateKey key; + + if (!dixRegisterPrivateKey(&screenKey->screenKey, PRIVATE_SCREEN, 0)) + return FALSE; + key = dixGetPrivate(&pScreen->devPrivates, &screenKey->screenKey); + if (key != NULL) { + assert(key->size == size); + assert(key->type == type); + return TRUE; } - oldamount = pScreen->WindowPrivateSizes[index2]; - if (amount > oldamount) - { - pScreen->WindowPrivateSizes[index2] = amount; - pScreen->totalWindowSize += (amount - oldamount); + key = calloc(sizeof(DevPrivateKeyRec), 1); + if (!key) + return FALSE; + if (!dixRegisterPrivateKey(key, type, size)) { + free(key); + return FALSE; } + key->allocated = TRUE; + dixSetPrivate(&pScreen->devPrivates, &screenKey->screenKey, key); return TRUE; } +DevPrivateKey +_dixGetScreenPrivateKey(const DevScreenPrivateKey key, ScreenPtr pScreen) +{ + return dixGetPrivate(&pScreen->devPrivates, &key->screenKey); +} /* - * gc private machinery + * Initialize privates by zeroing them */ +void +_dixInitPrivates(PrivatePtr *privates, void *addr, DevPrivateType type) +{ + assert (!screen_specific_private[type]); + + global_keys[type].created++; + if (xselinux_private[type]) + global_keys[PRIVATE_XSELINUX].created++; + if (global_keys[type].offset == 0) + addr = 0; + *privates = addr; + memset(addr, '\0', global_keys[type].offset); +} -static int gcPrivateCount; - +/* + * Clean up privates + */ void -ResetGCPrivates() +_dixFiniPrivates(PrivatePtr privates, DevPrivateType type) { - gcPrivateCount = 0; + global_keys[type].created--; + if (xselinux_private[type]) + global_keys[PRIVATE_XSELINUX].created--; } -int -AllocateGCPrivateIndex() +/* + * Allocate new object with privates. + * + * This is expected to be invoked from the + * dixAllocateObjectWithPrivates macro + */ +void * +_dixAllocateObjectWithPrivates(unsigned baseSize, unsigned clear, + unsigned offset, DevPrivateType type) { - return gcPrivateCount++; + unsigned totalSize; + void *object; + PrivatePtr privates; + PrivatePtr *devPrivates; + + assert(type > PRIVATE_SCREEN && type < PRIVATE_LAST); + assert(!screen_specific_private[type]); + + /* round up so that void * is aligned */ + baseSize = (baseSize + sizeof(void *) - 1) & ~(sizeof(void *) - 1); + totalSize = baseSize + global_keys[type].offset; + object = malloc(totalSize); + if (!object) + return NULL; + + memset(object, '\0', clear); + privates = (PrivatePtr) (((char *) object) + baseSize); + devPrivates = (PrivatePtr *) ((char *) object + offset); + + _dixInitPrivates(devPrivates, privates, type); + + return object; } +/* + * Allocate privates separately from containing object. + * Used for clients and screens. + */ Bool -AllocateGCPrivate(register ScreenPtr pScreen, int index2, unsigned amount) +dixAllocatePrivates(PrivatePtr *privates, DevPrivateType type) { - unsigned oldamount; - - /* Round up sizes for proper alignment */ - amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); - - if (index2 >= pScreen->GCPrivateLen) - { - unsigned *nsizes; - nsizes = (unsigned *)realloc(pScreen->GCPrivateSizes, - (index2 + 1) * sizeof(unsigned)); - if (!nsizes) - return FALSE; - while (pScreen->GCPrivateLen <= index2) - { - nsizes[pScreen->GCPrivateLen++] = 0; - pScreen->totalGCSize += sizeof(DevUnion); - } - pScreen->GCPrivateSizes = nsizes; + unsigned size; + PrivatePtr p; + + assert(type > PRIVATE_XSELINUX && type < PRIVATE_LAST); + assert(!screen_specific_private[type]); + + size = global_keys[type].offset; + if (!size) { + p = NULL; } - oldamount = pScreen->GCPrivateSizes[index2]; - if (amount > oldamount) - { - pScreen->GCPrivateSizes[index2] = amount; - pScreen->totalGCSize += (amount - oldamount); + else { + if (!(p = malloc(size))) + return FALSE; } + + _dixInitPrivates(privates, p, type); + ++global_keys[type].allocated; + return TRUE; } - /* - * pixmap private machinery + * Free an object that has privates + * + * This is expected to be invoked from the + * dixFreeObjectWithPrivates macro */ -#ifdef PIXPRIV -static int pixmapPrivateCount; +void +_dixFreeObjectWithPrivates(void *object, PrivatePtr privates, + DevPrivateType type) +{ + _dixFiniPrivates(privates, type); + free(object); +} +/* + * Called to free screen or client privates + */ void -ResetPixmapPrivates() +dixFreePrivates(PrivatePtr privates, DevPrivateType type) { - pixmapPrivateCount = 0; + _dixFiniPrivates(privates, type); + --global_keys[type].allocated; + free(privates); } -int -AllocatePixmapPrivateIndex() +/* + * Return size of privates for the specified type + */ +extern _X_EXPORT int +dixPrivatesSize(DevPrivateType type) { - return pixmapPrivateCount++; + assert(type >= PRIVATE_SCREEN && type < PRIVATE_LAST); + assert (!screen_specific_private[type]); + + return global_keys[type].offset; } -Bool -AllocatePixmapPrivate(register ScreenPtr pScreen, int index2, unsigned amount) +/* Table of devPrivates offsets */ +static const int offsets[] = { + -1, /* RT_NONE */ + offsetof(WindowRec, devPrivates), /* RT_WINDOW */ + offsetof(PixmapRec, devPrivates), /* RT_PIXMAP */ + offsetof(GC, devPrivates), /* RT_GC */ + -1, /* RT_FONT */ + offsetof(CursorRec, devPrivates), /* RT_CURSOR */ + offsetof(ColormapRec, devPrivates), /* RT_COLORMAP */ +}; + +int +dixLookupPrivateOffset(RESTYPE type) { - unsigned oldamount; - - /* Round up sizes for proper alignment */ - amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); - - if (index2 >= pScreen->PixmapPrivateLen) - { - unsigned *nsizes; - nsizes = (unsigned *)realloc(pScreen->PixmapPrivateSizes, - (index2 + 1) * sizeof(unsigned)); - if (!nsizes) - return FALSE; - while (pScreen->PixmapPrivateLen <= index2) - { - nsizes[pScreen->PixmapPrivateLen++] = 0; - pScreen->totalPixmapSize += sizeof(DevUnion); - } - pScreen->PixmapPrivateSizes = nsizes; + /* + * Special kludge for DBE which registers a new resource type that + * points at pixmaps (thanks, DBE) + */ + if (type & RC_DRAWABLE) { + if (type == RT_WINDOW) + return offsets[RT_WINDOW & TypeMask]; + else + return offsets[RT_PIXMAP & TypeMask]; } - oldamount = pScreen->PixmapPrivateSizes[index2]; - if (amount > oldamount) - { - pScreen->PixmapPrivateSizes[index2] = amount; - pScreen->totalPixmapSize += (amount - oldamount); - } - pScreen->totalPixmapSize = BitmapBytePad(pScreen->totalPixmapSize * 8); - return TRUE; + type = type & TypeMask; + if (type < ARRAY_SIZE(offsets)) + return offsets[type]; + return -1; } -#endif - /* - * colormap private machinery + * Screen-specific privates */ -int colormapPrivateCount; +extern _X_EXPORT Bool +dixRegisterScreenSpecificPrivateKey(ScreenPtr pScreen, DevPrivateKey key, + DevPrivateType type, unsigned size) +{ + int offset; + unsigned bytes; + + if (!screen_specific_private[type]) + FatalError("Attempt to allocate screen-specific private storage for type %s\n", + key_names[type]); + if (key->initialized) { + assert(size == key->size); + return TRUE; + } + + /* Compute required space */ + bytes = size; + if (size == 0) + bytes = sizeof(void *); + + /* align to void * size */ + bytes = (bytes + sizeof(void *) - 1) & ~(sizeof(void *) - 1); + + assert (!allocated_early[type]); + assert (!pScreen->screenSpecificPrivates[type].created); + offset = pScreen->screenSpecificPrivates[type].offset; + pScreen->screenSpecificPrivates[type].offset += bytes; + + /* Setup this key */ + key->offset = offset; + key->size = size; + key->initialized = TRUE; + key->type = type; + key->allocated = FALSE; + key->next = pScreen->screenSpecificPrivates[type].key; + pScreen->screenSpecificPrivates[type].key = key; + + return TRUE; +} + +/* Clean up screen-specific privates before CloseScreen */ void -ResetColormapPrivates() +dixFreeScreenSpecificPrivates(ScreenPtr pScreen) { - colormapPrivateCount = 0; -} + DevPrivateType t; + for (t = PRIVATE_XSELINUX; t < PRIVATE_LAST; t++) { + DevPrivateKey key; -int -AllocateColormapPrivateIndex (InitCmapPrivFunc initPrivFunc) -{ - int index; - int i; - ColormapPtr pColormap; - DevUnion *privs; - - index = colormapPrivateCount++; - - for (i = 0; i < screenInfo.numScreens; i++) - { - /* - * AllocateColormapPrivateIndex may be called after the - * default colormap has been created on each screen! - * - * We must resize the devPrivates array for the default - * colormap on each screen, making room for this new private. - * We also call the initialization function 'initPrivFunc' on - * the new private allocated for each default colormap. - */ - - ScreenPtr pScreen = screenInfo.screens[i]; - - pColormap = (ColormapPtr) LookupIDByType ( - pScreen->defColormap, RT_COLORMAP); - - if (pColormap) - { - privs = (DevUnion *) realloc (pColormap->devPrivates, - colormapPrivateCount * sizeof(DevUnion)); - if (!privs) { - colormapPrivateCount--; - return -1; - } - bzero(&privs[index], sizeof(DevUnion)); - pColormap->devPrivates = privs; - if (!(*initPrivFunc)(pColormap,index)) - { - colormapPrivateCount--; - return -1; - } - } + for (key = pScreen->screenSpecificPrivates[t].key; key; key = key->next) { + key->initialized = FALSE; + } } +} - return index; +/* Initialize screen-specific privates in AddScreen */ +void +dixInitScreenSpecificPrivates(ScreenPtr pScreen) +{ + DevPrivateType t; + + for (t = PRIVATE_XSELINUX; t < PRIVATE_LAST; t++) + pScreen->screenSpecificPrivates[t].offset = global_keys[t].offset; } -/* - * device private machinery - */ +/* Initialize screen-specific privates in AddScreen */ +void +_dixInitScreenPrivates(ScreenPtr pScreen, PrivatePtr *privates, void *addr, DevPrivateType type) +{ + int privates_size; + assert (screen_specific_private[type]); + + if (pScreen) { + privates_size = pScreen->screenSpecificPrivates[type].offset; + pScreen->screenSpecificPrivates[type].created++; + } + else + privates_size = global_keys[type].offset; + + global_keys[type].created++; + if (xselinux_private[type]) + global_keys[PRIVATE_XSELINUX].created++; + if (privates_size == 0) + addr = 0; + *privates = addr; + memset(addr, '\0', privates_size); +} -static int devicePrivateIndex = 0; +void * +_dixAllocateScreenObjectWithPrivates(ScreenPtr pScreen, + unsigned baseSize, + unsigned clear, + unsigned offset, + DevPrivateType type) +{ + unsigned totalSize; + void *object; + PrivatePtr privates; + PrivatePtr *devPrivates; + int privates_size; + + assert(type > PRIVATE_SCREEN && type < PRIVATE_LAST); + assert (screen_specific_private[type]); + + if (pScreen) + privates_size = pScreen->screenSpecificPrivates[type].offset; + else + privates_size = global_keys[type].offset; + /* round up so that pointer is aligned */ + baseSize = (baseSize + sizeof(void *) - 1) & ~(sizeof(void *) - 1); + totalSize = baseSize + privates_size; + object = malloc(totalSize); + if (!object) + return NULL; + + memset(object, '\0', clear); + privates = (PrivatePtr) (((char *) object) + baseSize); + devPrivates = (PrivatePtr *) ((char *) object + offset); + + _dixInitScreenPrivates(pScreen, devPrivates, privates, type); + + return object; +} int -AllocateDevicePrivateIndex() +dixScreenSpecificPrivatesSize(ScreenPtr pScreen, DevPrivateType type) { - return devicePrivateIndex++; + assert(type >= PRIVATE_SCREEN && type < PRIVATE_LAST); + + if (screen_specific_private[type]) + return pScreen->screenSpecificPrivates[type].offset; + else + return global_keys[type].offset; } -Bool -AllocateDevicePrivate(DeviceIntPtr device, int index) +void +dixPrivateUsage(void) { - if (device->nPrivates < ++index) { - DevUnion *nprivs = (DevUnion *) realloc(device->devPrivates, - index * sizeof(DevUnion)); - if (!nprivs) - return FALSE; - device->devPrivates = nprivs; - bzero(&nprivs[device->nPrivates], sizeof(DevUnion) - * (index - device->nPrivates)); - device->nPrivates = index; - return TRUE; - } else { - return TRUE; + int objects = 0; + int bytes = 0; + int alloc = 0; + DevPrivateType t; + + for (t = PRIVATE_XSELINUX + 1; t < PRIVATE_LAST; t++) { + if (global_keys[t].offset) { + ErrorF + ("%s: %d objects of %d bytes = %d total bytes %d private allocs\n", + key_names[t], global_keys[t].created, global_keys[t].offset, + global_keys[t].created * global_keys[t].offset, global_keys[t].allocated); + bytes += global_keys[t].created * global_keys[t].offset; + objects += global_keys[t].created; + alloc += global_keys[t].allocated; + } } + ErrorF("TOTAL: %d objects, %d bytes, %d allocs\n", objects, bytes, alloc); } void -ResetDevicePrivateIndex(void) +dixResetPrivates(void) +{ + DevPrivateType t; + + for (t = PRIVATE_XSELINUX; t < PRIVATE_LAST; t++) { + DevPrivateKey key, next; + + for (key = global_keys[t].key; key; key = next) { + next = key->next; + key->offset = 0; + key->initialized = FALSE; + key->size = 0; + key->type = 0; + if (key->allocated) + free(key); + } + if (global_keys[t].created) { + ErrorF("%d %ss still allocated at reset\n", + global_keys[t].created, key_names[t]); + dixPrivateUsage(); + } + global_keys[t].key = NULL; + global_keys[t].offset = 0; + global_keys[t].created = 0; + global_keys[t].allocated = 0; + } +} + +Bool +dixPrivatesCreated(DevPrivateType type) { - devicePrivateIndex = 0; + if (global_keys[type].created) + return TRUE; + else + return FALSE; } diff --git a/nx-X11/programs/Xserver/dix/property.c b/nx-X11/programs/Xserver/dix/property.c index 66c38f56ce..9f7292a4b4 100644 --- a/nx-X11/programs/Xserver/dix/property.c +++ b/nx-X11/programs/Xserver/dix/property.c @@ -280,13 +280,13 @@ ChangeWindowProperty(WindowPtr pWin, Atom property, Atom type, int format, { if (!pWin->optional && !MakeWindowOptional (pWin)) return(BadAlloc); - pProp = (PropertyPtr)malloc(sizeof(PropertyRec)); + pProp = dixAllocateObjectWithPrivates(PropertyRec, PRIVATE_PROPERTY); if (!pProp) return(BadAlloc); data = (void *)malloc(totalSize); if (!data && len) { - free(pProp); + dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY); return(BadAlloc); } pProp->propertyName = property; @@ -404,7 +404,7 @@ DeleteProperty(WindowPtr pWin, Atom propName) event.u.property.time = currentTime.milliseconds; DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); free(pProp->data); - free(pProp); + dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY); } return(Success); } @@ -427,7 +427,7 @@ DeleteAllWindowProperties(WindowPtr pWin) DeliverEvents(pWin, &event, 1, (WindowPtr)NULL); pNextProp = pProp->next; free(pProp->data); - free(pProp); + dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY); pProp = pNextProp; } } @@ -601,7 +601,7 @@ ProcGetProperty(ClientPtr client) else prevProp->next = pProp->next; free(pProp->data); - free(pProp); + dixFreeObjectWithPrivates(pProp, PRIVATE_PROPERTY); } return(client->noClientException); } diff --git a/nx-X11/programs/Xserver/dix/window.c b/nx-X11/programs/Xserver/dix/window.c index 79045767f0..7bbe9a799c 100644 --- a/nx-X11/programs/Xserver/dix/window.c +++ b/nx-X11/programs/Xserver/dix/window.c @@ -176,9 +176,6 @@ static Bool TileScreenSaver(int i, int kind); #define SubStrSend(pWin,pParent) (StrSend(pWin) || SubSend(pParent)) -int numSaveUndersViewable = 0; -int deltaSaveUndersViewable = 0; - #if defined(DEBUG) || (defined(NXAGENT_SERVER) && defined(WINDOW_TREE_DEBUG)) /****** * PrintWindowTree @@ -264,8 +261,6 @@ int defaultBackingStore = NotUseful; /* hack to force no backing store */ Bool disableBackingStore = FALSE; Bool enableBackingStore = FALSE; -/* hack to force no save unders */ -Bool disableSaveUnders = FALSE; static void SetWindowToDefaults(register WindowPtr pWin) @@ -350,41 +345,6 @@ MakeRootTile(WindowPtr pWin) } #endif /* NXAGENT_SERVER */ -WindowPtr -AllocateWindow(ScreenPtr pScreen) -{ - WindowPtr pWin; - register char *ptr; - register DevUnion *ppriv; - register unsigned *sizes; - register unsigned size; - register int i; - - pWin = (WindowPtr)malloc(pScreen->totalWindowSize); - if (pWin) - { - ppriv = (DevUnion *)(pWin + 1); - pWin->devPrivates = ppriv; - sizes = pScreen->WindowPrivateSizes; - ptr = (char *)(ppriv + pScreen->WindowPrivateLen); - for (i = pScreen->WindowPrivateLen; --i >= 0; ppriv++, sizes++) - { - if ( (size = *sizes) ) - { - ppriv->ptr = (void *)ptr; - ptr += size; - } - else - ppriv->ptr = (void *)NULL; - } -#if _XSERVER64 - pWin->drawable.pad0 = 0; - pWin->drawable.pad1 = 0; -#endif - } - return pWin; -} - /***** * CreateRootWindow * Makes a window at initialization time for specified screen @@ -397,7 +357,7 @@ CreateRootWindow(ScreenPtr pScreen) BoxRec box; PixmapFormatRec *format; - pWin = AllocateWindow(pScreen); + pWin = dixAllocateScreenObjectWithPrivates(pScreen, WindowRec, PRIVATE_WINDOW); if (!pWin) return FALSE; @@ -481,20 +441,7 @@ CreateRootWindow(ScreenPtr pScreen) if (enableBackingStore) pScreen->backingStoreSupport = Always; -#ifdef DO_SAVE_UNDERS - if ((pScreen->backingStoreSupport != NotUseful) && - (pScreen->saveUnderSupport == NotUseful)) - { - /* - * If the screen has backing-store but no save-unders, let the - * clients know we can support save-unders using backing-store. - */ - pScreen->saveUnderSupport = USE_DIX_SAVE_UNDERS; - } -#endif /* DO_SAVE_UNDERS */ - - if (disableSaveUnders) - pScreen->saveUnderSupport = NotUseful; + pScreen->saveUnderSupport = NotUseful; return TRUE; } @@ -684,7 +631,7 @@ CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w, return NullWindow; } - pWin = AllocateWindow(pScreen); + pWin = dixAllocateScreenObjectWithPrivates(pScreen, WindowRec, PRIVATE_WINDOW); if (!pWin) { *error = BadAlloc; @@ -714,7 +661,7 @@ CreateWindow(Window wid, register WindowPtr pParent, int x, int y, unsigned w, { if (!MakeWindowOptional (pWin)) { - free (pWin); + dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW); *error = BadAlloc; return NullWindow; } @@ -885,10 +832,6 @@ CrushTree(WindowPtr pWin) } FreeResource(pChild->drawable.id, RT_WINDOW); pSib = pChild->nextSib; -#ifdef DO_SAVE_UNDERS - if (pChild->saveUnder && pChild->viewable) - deltaSaveUndersViewable--; -#endif pChild->viewable = FALSE; if (pChild->realized) { @@ -896,7 +839,7 @@ CrushTree(WindowPtr pWin) (*UnrealizeWindow)(pChild); } FreeWindowResources(pChild); - free(pChild); + dixFreeObjectWithPrivates(pChild, PRIVATE_WINDOW); if ( (pChild = pSib) ) break; pChild = pParent; @@ -948,7 +891,7 @@ DeleteWindow(void * value, XID wid) if (pWin->prevSib) pWin->prevSib->nextSib = pWin->nextSib; } - free(pWin); + dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW); return Success; } #endif /* NXAGENT_SERVER */ @@ -1226,47 +1169,7 @@ ChangeWindowAttributes(register WindowPtr pWin, Mask vmask, XID *vlist, ClientPt client->errorValue = val; goto PatchUp; } -#ifdef DO_SAVE_UNDERS - if (pWin->parent && (pWin->saveUnder != val) && (pWin->viewable) && - DO_SAVE_UNDERS(pWin)) - { - /* - * Re-check all siblings and inferiors for obscurity or - * exposition (hee hee). - */ - if (pWin->saveUnder) - deltaSaveUndersViewable--; - else - deltaSaveUndersViewable++; - pWin->saveUnder = val; - - if (pWin->firstChild) - { - pLayerWin = (*pScreen->GetLayerWindow)(pWin); - if ((*pScreen->ChangeSaveUnder)(pLayerWin->parent, pWin->nextSib)) - (*pScreen->PostChangeSaveUnder)(pLayerWin->parent, - pWin->nextSib); - } - else - { - if ((*pScreen->ChangeSaveUnder)(pWin, pWin->nextSib)) - (*pScreen->PostChangeSaveUnder)(pWin, - pWin->nextSib); - } - } - else - { - /* If we're changing the saveUnder attribute of the root - * window, all we do is set pWin->saveUnder so that - * GetWindowAttributes returns the right value. We don't - * do the "normal" save-under processing (as above). - * Hope that doesn't cause any problems. - */ - pWin->saveUnder = val; - } -#else pWin->saveUnder = val; -#endif /* DO_SAVE_UNDERS */ break; case CWEventMask: @@ -2169,9 +2072,6 @@ ReflectStackChange( Bool WasViewable = (Bool)pWin->viewable; Bool anyMarked; WindowPtr pFirstChange; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif WindowPtr pLayerWin; ScreenPtr pScreen = pWin->drawable.pScreen; @@ -2186,21 +2086,11 @@ ReflectStackChange( anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, &pLayerWin); if (pLayerWin != pWin) pFirstChange = pLayerWin; -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange); - } -#endif /* DO_SAVE_UNDERS */ if (anyMarked) { (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, kind); (*pScreen->HandleExposures)(pLayerWin->parent); } -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange); -#endif /* DO_SAVE_UNDERS */ if (anyMarked && pWin->drawable.pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, kind); } @@ -2670,10 +2560,6 @@ RealizeTree(WindowPtr pWin) if (pChild->mapped) { pChild->realized = TRUE; -#ifdef DO_SAVE_UNDERS - if (pChild->saveUnder) - deltaSaveUndersViewable++; -#endif pChild->viewable = (pChild->drawable.class == InputOutput); (* Realize)(pChild); if (pChild->firstChild) @@ -2705,9 +2591,6 @@ MapWindow(register WindowPtr pWin, ClientPtr client) register ScreenPtr pScreen; register WindowPtr pParent; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif WindowPtr pLayerWin; if (pWin->mapped) @@ -2760,21 +2643,11 @@ MapWindow(register WindowPtr pWin, ClientPtr client) { anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin); -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib); - } -#endif /* DO_SAVE_UNDERS */ if (anyMarked) { (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTMap); (*pScreen->HandleExposures)(pLayerWin->parent); } -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib); -#endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTMap); } @@ -2814,17 +2687,11 @@ MapSubwindows(register WindowPtr pParent, ClientPtr client) { register WindowPtr pWin; WindowPtr pFirstMapped = NullWindow; -#ifdef DO_SAVE_UNDERS - WindowPtr pFirstSaveUndered = NullWindow; -#endif register ScreenPtr pScreen; register Mask parentRedirect; register Mask parentNotify; xEvent event; Bool anyMarked; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif WindowPtr pLayerWin; pScreen = pParent->drawable.pScreen; @@ -2866,12 +2733,6 @@ MapSubwindows(register WindowPtr pParent, ClientPtr client) { anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin, (WindowPtr *)NULL); -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = TRUE; - } -#endif /* DO_SAVE_UNDERS */ } } } @@ -2888,38 +2749,9 @@ MapSubwindows(register WindowPtr pParent, ClientPtr client) } if (anyMarked) { -#ifdef DO_SAVE_UNDERS - if (pLayerWin->parent != pParent) - { - if (dosave || (DO_SAVE_UNDERS(pLayerWin))) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, - pLayerWin); - } - } - else if (dosave) - { - dosave = FALSE; - for (pWin = pParent->firstChild; pWin; pWin = pWin->nextSib) - { - if (DO_SAVE_UNDERS(pWin)) - { - dosave |= (*pScreen->ChangeSaveUnder)(pWin, - pWin->nextSib); - if (dosave && !pFirstSaveUndered) - pFirstSaveUndered = pWin; - } - } - } -#endif /* DO_SAVE_UNDERS */ (*pScreen->ValidateTree)(pLayerWin->parent, pFirstMapped, VTMap); (*pScreen->HandleExposures)(pLayerWin->parent); } -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, - pFirstSaveUndered->nextSib); -#endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstMapped, VTMap); @@ -2958,14 +2790,7 @@ UnrealizeTree( DeleteWindowFromAnyEvents(pChild, FALSE); if (pChild->viewable) { -#ifdef DO_SAVE_UNDERS - if (pChild->saveUnder) - deltaSaveUndersViewable--; -#endif pChild->viewable = FALSE; - if (pChild->backStorage) - (*pChild->drawable.pScreen->SaveDoomedAreas)( - pChild, &pChild->clipList, 0, 0); (* MarkUnrealizedWindow)(pChild, pWin, fromConfigure); pChild->drawable.serialNumber = NEXT_SERIAL_NUMBER; } @@ -3027,16 +2852,6 @@ UnmapWindow(register WindowPtr pWin, Bool fromConfigure) (*pScreen->ValidateTree)(pLayerWin->parent, pWin, VTUnmap); (*pScreen->HandleExposures)(pLayerWin->parent); } -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib) ) - { - (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib); - } - } - pWin->DIXsaveUnder = FALSE; -#endif /* DO_SAVE_UNDERS */ if (!fromConfigure && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pWin, VTUnmap); } @@ -3091,15 +2906,6 @@ UnmapSubwindows(register WindowPtr pWin) pChild->mapped = FALSE; if (pChild->realized) UnrealizeTree(pChild, FALSE); - if (wasViewable) - { -#ifdef DO_SAVE_UNDERS - pChild->DIXsaveUnder = FALSE; -#endif /* DO_SAVE_UNDERS */ - if (pChild->backStorage) - (*pScreen->SaveDoomedAreas)( - pChild, &pChild->clipList, 0, 0); - } } } if (wasViewable) @@ -3128,13 +2934,6 @@ UnmapSubwindows(register WindowPtr pWin) (*pScreen->ValidateTree)(pLayerWin->parent, pHead, VTUnmap); (*pScreen->HandleExposures)(pLayerWin->parent); } -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin)) - (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin); - } -#endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pHead, VTUnmap); } @@ -3893,5 +3692,17 @@ DrawLogo(WindowPtr pWin) FreeScratchGC(pGC); } - #endif + +VisualPtr +WindowGetVisual(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + VisualID vid = wVisual(pWin); + int i; + + for (i = 0; i < pScreen->numVisuals; i++) + if (pScreen->visuals[i].vid == vid) + return &pScreen->visuals[i]; + return 0; +} diff --git a/nx-X11/programs/Xserver/fb/Imakefile b/nx-X11/programs/Xserver/fb/Imakefile index 5daa10c6f0..273b3d5eec 100644 --- a/nx-X11/programs/Xserver/fb/Imakefile +++ b/nx-X11/programs/Xserver/fb/Imakefile @@ -30,7 +30,6 @@ SRCS = $(XFMODSRC) \ fbbits.c \ fbblt.c \ fbbltone.c \ - fbbstore.c \ fbcmap.c \ $(RENDERSRC) \ fbcopy.c \ @@ -66,7 +65,6 @@ OBJS = $(XFMODOBJ) \ fbbits.o \ fbblt.o \ fbbltone.o \ - fbbstore.o \ fbcmap.o \ $(RENDEROBJ) \ fbcopy.o \ @@ -128,7 +126,6 @@ LinkSourceFile(fbarc.c,LinkDirectory) LinkSourceFile(fbbits.c,LinkDirectory) LinkSourceFile(fbblt.c,LinkDirectory) LinkSourceFile(fbbltone.c,LinkDirectory) -LinkSourceFile(fbbstore.c,LinkDirectory) LinkSourceFile(fbcmap.c,LinkDirectory) #if BuildRender LinkSourceFile(fbcompose.c,LinkDirectory) diff --git a/nx-X11/programs/Xserver/fb/fb.h b/nx-X11/programs/Xserver/fb/fb.h index 61bf18caf4..42b9d01893 100644 --- a/nx-X11/programs/Xserver/fb/fb.h +++ b/nx-X11/programs/Xserver/fb/fb.h @@ -36,7 +36,6 @@ #include "windowstr.h" #include "mi.h" #include "migc.h" -#include "mibstore.h" #ifdef RENDER #include "picturestr.h" #else @@ -558,14 +557,12 @@ extern void fbSetBits (FbStip *bits, int stride, FbStip data); } \ } -/* XXX fb*PrivateIndex should be static, but it breaks the ABI */ +extern DevPrivateKey fbGetScreenPrivateKey(void); + +#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey())) + -extern int fbGCPrivateIndex; -extern int fbGetGCPrivateIndex(void); -#ifndef FB_NO_WINDOW_PIXMAPS -extern int fbWinPrivateIndex; -extern int fbGetWinPrivateIndex(void); -#endif extern const GCOps fbGCOps; extern const GCFuncs fbGCFuncs; @@ -578,24 +575,16 @@ extern const GCFuncs fbGCFuncs; # define FB_OLD_MISCREENINIT /* miScreenInit requires 14 args, not 13 */ #endif -#ifdef FB_24_32BIT -#define FB_SCREEN_PRIVATE -#endif - -#ifdef FB_SCREEN_PRIVATE -extern int fbScreenPrivateIndex; -extern int fbGetScreenPrivateIndex(void); - /* private field of a screen */ typedef struct { unsigned char win32bpp; /* window bpp for 32-bpp images */ unsigned char pix32bpp; /* pixmap bpp for 32-bpp images */ + DevPrivateKeyRec gcPrivateKeyRec; + #ifndef FB_NO_WINDOW_PIXMAPS + DevPrivateKeyRec winPrivateKeyRec; + #endif } FbScreenPrivRec, *FbScreenPrivPtr; -#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \ - (pScreen)->devPrivates[fbGetScreenPrivateIndex()].ptr) -#endif - /* private field of GC */ typedef struct { #ifdef FB_OLD_GC @@ -616,8 +605,10 @@ typedef struct { unsigned char bpp; /* current drawable bpp */ } FbGCPrivRec, *FbGCPrivPtr; -#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\ - (pGC)->devPrivates[fbGetGCPrivateIndex()].ptr) +#define fbGetGCPrivateKey(pGC) (&fbGetScreenPrivate((pGC)->pScreen)->gcPrivateKeyRec) + +#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\ + dixLookupPrivate(&(pGC)->devPrivates, fbGetGCPrivateKey(pGC))) #ifdef FB_OLD_GC #define fbGetCompositeClip(pGC) (fbGetGCPrivate(pGC)->pCompositeClip) @@ -635,8 +626,10 @@ typedef struct { #ifdef FB_NO_WINDOW_PIXMAPS #define fbGetWindowPixmap(d) fbGetScreenPixmap(((DrawablePtr) (d))->pScreen) #else -#define fbGetWindowPixmap(pWin) ((PixmapPtr)\ - ((WindowPtr) (pWin))->devPrivates[fbGetWinPrivateIndex()].ptr) +#define fbGetWinPrivateKey(pWin) (&fbGetScreenPrivate(((DrawablePtr) (pWin))->pScreen)->winPrivateKeyRec) + +#define fbGetWindowPixmap(pWin) ((PixmapPtr)\ + dixLookupPrivate(&((WindowPtr)(pWin))->devPrivates, fbGetWinPrivateKey(pWin))) #endif #ifdef ROOTLESS @@ -793,7 +786,7 @@ fb24_32ModifyPixmapHeader (PixmapPtr pPixmap, * fballpriv.c */ Bool -fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex); +fbAllocatePrivates(ScreenPtr pScreen); /* * fbarc.c @@ -1220,23 +1213,6 @@ fbBltPlane (FbBits *src, FbStip bgxor, Pixel planeMask); -/* - * fbbstore.c - */ -void -fbSaveAreas(PixmapPtr pPixmap, - RegionPtr prgnSave, - int xorg, - int yorg, - WindowPtr pWin); - -void -fbRestoreAreas(PixmapPtr pPixmap, - RegionPtr prgnRestore, - int xorg, - int yorg, - WindowPtr pWin); - /* * fbcmap.c */ diff --git a/nx-X11/programs/Xserver/fb/fballpriv.c b/nx-X11/programs/Xserver/fb/fballpriv.c index d2d8866e22..af0c382907 100644 --- a/nx-X11/programs/Xserver/fb/fballpriv.c +++ b/nx-X11/programs/Xserver/fb/fballpriv.c @@ -28,65 +28,30 @@ #include "fb.h" -#ifdef FB_SCREEN_PRIVATE -int fbScreenPrivateIndex; -int fbGetScreenPrivateIndex(void) +static DevPrivateKeyRec fbScreenPrivateKeyRec; +DevPrivateKey +fbGetScreenPrivateKey(void) { - return fbScreenPrivateIndex; + return &fbScreenPrivateKeyRec; } -#endif -int fbGCPrivateIndex; -int fbGetGCPrivateIndex(void) -{ - return fbGCPrivateIndex; -} -#ifndef FB_NO_WINDOW_PIXMAPS -int fbWinPrivateIndex; -int fbGetWinPrivateIndex(void) -{ - return fbWinPrivateIndex; -} -#endif -int fbGeneration; - -#ifdef FB_OLD_SCREEN -#define miAllocateGCPrivateIndex() AllocateGCPrivateIndex() -#endif Bool -fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex) +fbAllocatePrivates(ScreenPtr pScreen) { - if (fbGeneration != serverGeneration) - { - fbGCPrivateIndex = miAllocateGCPrivateIndex (); -#ifndef FB_NO_WINDOW_PIXMAPS - fbWinPrivateIndex = AllocateWindowPrivateIndex(); -#endif -#ifdef FB_SCREEN_PRIVATE - fbScreenPrivateIndex = AllocateScreenPrivateIndex (); - if (fbScreenPrivateIndex == -1) - return FALSE; -#endif - - fbGeneration = serverGeneration; - } - if (pGCIndex) - *pGCIndex = fbGCPrivateIndex; - if (!AllocateGCPrivate(pScreen, fbGCPrivateIndex, sizeof(FbGCPrivRec))) - return FALSE; + FbScreenPrivPtr pScrPriv; + + if (!dixRegisterPrivateKey + (&fbScreenPrivateKeyRec, PRIVATE_SCREEN, sizeof(FbScreenPrivRec))) + return FALSE; + + pScrPriv = fbGetScreenPrivate(pScreen); + + if (!dixRegisterScreenSpecificPrivateKey (pScreen, &pScrPriv->gcPrivateKeyRec, PRIVATE_GC, sizeof(FbGCPrivRec))) + return FALSE; #ifndef FB_NO_WINDOW_PIXMAPS - if (!AllocateWindowPrivate(pScreen, fbWinPrivateIndex, 0)) - return FALSE; + if (!dixRegisterScreenSpecificPrivateKey (pScreen, &pScrPriv->winPrivateKeyRec, PRIVATE_WINDOW, 0)) + return FALSE; #endif -#ifdef FB_SCREEN_PRIVATE - { - FbScreenPrivPtr pScreenPriv; - pScreenPriv = (FbScreenPrivPtr) malloc (sizeof (FbScreenPrivRec)); - if (!pScreenPriv) - return FALSE; - pScreen->devPrivates[fbScreenPrivateIndex].ptr = (void *) pScreenPriv; - } -#endif return TRUE; } diff --git a/nx-X11/programs/Xserver/fb/fbbstore.c b/nx-X11/programs/Xserver/fb/fbbstore.c deleted file mode 100644 index 75f6084c07..0000000000 --- a/nx-X11/programs/Xserver/fb/fbbstore.c +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Id: fbbstore.c,v 1.1 1999/11/02 03:54:45 keithp Exp $ - * - * Copyright © 1998 Keith Packard - * - * Permission to use, copy, modify, distribute, and sell this software and its - * documentation for any purpose is hereby granted without fee, provided that - * the above copyright notice appear in all copies and that both that - * copyright notice and this permission notice appear in supporting - * documentation, and that the name of Keith Packard not be used in - * advertising or publicity pertaining to distribution of the software without - * specific, written prior permission. Keith Packard makes no - * representations about the suitability of this software for any purpose. It - * is provided "as is" without express or implied warranty. - * - * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER - * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "fb.h" - -void -fbSaveAreas(PixmapPtr pPixmap, - RegionPtr prgnSave, - int xorg, - int yorg, - WindowPtr pWin) -{ - fbCopyWindowProc (&pWin->drawable, - &pPixmap->drawable, - 0, - RegionRects(prgnSave), - RegionNumRects(prgnSave), - xorg, yorg, - FALSE, - FALSE, - 0,0); -} - -void -fbRestoreAreas(PixmapPtr pPixmap, - RegionPtr prgnRestore, - int xorg, - int yorg, - WindowPtr pWin) -{ - fbCopyWindowProc (&pPixmap->drawable, - &pWin->drawable, - 0, - RegionRects(prgnRestore), - RegionNumRects(prgnRestore), - -xorg, -yorg, - FALSE, - FALSE, - 0,0); -} diff --git a/nx-X11/programs/Xserver/fb/fboverlay.c b/nx-X11/programs/Xserver/fb/fboverlay.c index 6e0bbf2522..1b4fc3b0d9 100644 --- a/nx-X11/programs/Xserver/fb/fboverlay.c +++ b/nx-X11/programs/Xserver/fb/fboverlay.c @@ -34,12 +34,13 @@ #include "shmint.h" #endif -int fbOverlayGeneration; -int fbOverlayScreenPrivateIndex = -1; +static DevPrivateKeyRec fbOverlayScreenPrivateKeyRec; -int fbOverlayGetScreenPrivateIndex(void) +#define fbOverlayScreenPrivateKey (&fbOverlayScreenPrivateKeyRec) + +DevPrivateKey fbOverlayGetScreenPrivateKey(void) { - return fbOverlayScreenPrivateIndex; + return fbOverlayScreenPrivateKey; } /* @@ -56,17 +57,15 @@ fbOverlayCreateWindow(WindowPtr pWin) if (pWin->drawable.class != InputOutput) return TRUE; -#ifdef FB_SCREEN_PRIVATE if (pWin->drawable.bitsPerPixel == 32) pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp; -#endif for (i = 0; i < pScrPriv->nlayers; i++) { pPixmap = pScrPriv->layer[i].u.run.pixmap; if (pWin->drawable.depth == pPixmap->drawable.depth) { - pWin->devPrivates[fbWinPrivateIndex].ptr = (void *) pPixmap; + dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(pWin), pPixmap); /* * Make sure layer keys are written correctly by * having non-root layers set to full while the @@ -109,7 +108,7 @@ fbOverlayWindowLayer(WindowPtr pWin) int i; for (i = 0; i < pScrPriv->nlayers; i++) - if (pWin->devPrivates[fbWinPrivateIndex].ptr == + if (dixLookupPrivate(&pWin->devPrivates, fbGetWinPrivateKey(pWin)) == (void *) pScrPriv->layer[i].u.run.pixmap) return i; return 0; @@ -359,11 +358,9 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, VisualID defaultVisual; FbOverlayScrPrivPtr pScrPriv; - if (fbOverlayGeneration != serverGeneration) - { - fbOverlayScreenPrivateIndex = AllocateScreenPrivateIndex (); - fbOverlayGeneration = serverGeneration; - } + if (!dixRegisterPrivateKey + (&fbOverlayScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; pScrPriv = malloc (sizeof (FbOverlayScrPrivRec)); if (!pScrPriv) @@ -395,7 +392,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, } } #endif -#ifdef FB_SCREEN_PRIVATE if (imagebpp == 32) { fbGetScreenPrivate(pScreen)->win32bpp = bpp; @@ -406,7 +402,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, fbGetScreenPrivate(pScreen)->win32bpp = 32; fbGetScreenPrivate(pScreen)->pix32bpp = 32; } -#endif if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &depth1, &defaultVisual, ((unsigned long)1<<(bpp1-1)) | @@ -438,7 +433,7 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen, pScrPriv->layer[1].u.init.width = width2; pScrPriv->layer[1].u.init.depth = depth2; - pScreen->devPrivates[fbOverlayScreenPrivateIndex].ptr = (void *) pScrPriv; + dixSetPrivate(&pScreen->devPrivates, fbOverlayScreenPrivateKey, pScrPriv); /* overwrite miCloseScreen with our own */ pScreen->CloseScreen = fbOverlayCloseScreen; diff --git a/nx-X11/programs/Xserver/fb/fboverlay.h b/nx-X11/programs/Xserver/fb/fboverlay.h index 2bb8b176a0..e4e237de1f 100644 --- a/nx-X11/programs/Xserver/fb/fboverlay.h +++ b/nx-X11/programs/Xserver/fb/fboverlay.h @@ -24,9 +24,9 @@ #ifndef _FBOVERLAY_H_ #define _FBOVERLAY_H_ -extern int fbOverlayGeneration; -extern int fbOverlayScreenPrivateIndex; /* XXX should be static */ -extern int fbOverlayGetScreenPrivateIndex(void); +#include "privates.h" + +extern DevPrivateKey fbOverlayGetScreenPrivateKey(void); #ifndef FB_OVERLAY_MAX #define FB_OVERLAY_MAX 2 @@ -57,8 +57,8 @@ typedef struct _fbOverlayScrPriv { } FbOverlayScrPrivRec, *FbOverlayScrPrivPtr; #define fbOverlayGetScrPriv(s) \ - ((fbOverlayGetScreenPrivateIndex() != -1) ? \ - (s)->devPrivates[fbOverlayGetScreenPrivateIndex()].ptr : NULL) + dixLookupPrivate(&(s)->devPrivates, fbOverlayGetScreenPrivateKey()) + Bool fbOverlayCreateWindow(WindowPtr pWin); diff --git a/nx-X11/programs/Xserver/fb/fbpixmap.c b/nx-X11/programs/Xserver/fb/fbpixmap.c index 5f24433e3b..dac8f6af47 100644 --- a/nx-X11/programs/Xserver/fb/fbpixmap.c +++ b/nx-X11/programs/Xserver/fb/fbpixmap.c @@ -93,10 +93,8 @@ fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth, { int bpp; bpp = BitsPerPixel (depth); -#ifdef FB_SCREEN_PRIVATE if (bpp == 32 && depth <= 24) bpp = fbGetScreenPrivate(pScreen)->pix32bpp; -#endif return fbCreatePixmapBpp (pScreen, width, height, depth, bpp, usage_hint); } diff --git a/nx-X11/programs/Xserver/fb/fbscreen.c b/nx-X11/programs/Xserver/fb/fbscreen.c index b0e6d9a6b3..96f1addcc7 100644 --- a/nx-X11/programs/Xserver/fb/fbscreen.c +++ b/nx-X11/programs/Xserver/fb/fbscreen.c @@ -39,9 +39,8 @@ fbCloseScreen (ScreenPtr pScreen) free (depths); free (pScreen->visuals); free (pScreen->devPrivate); -#ifdef FB_SCREEN_PRIVATE - free (pScreen->devPrivates[fbScreenPrivateIndex].ptr); -#endif + if (pScreen->devPrivate) + FreePixmap((PixmapPtr)pScreen->devPrivate); return TRUE; } @@ -96,7 +95,7 @@ _fbSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap) #ifdef FB_NO_WINDOW_PIXMAPS FatalError ("Attempted to set window pixmap without fb support\n"); #else - pWindow->devPrivates[fbWinPrivateIndex].ptr = (void *) pPixmap; + dixSetPrivate(&pWindow->devPrivates, fbGetWinPrivateKey(pWindow), pPixmap); #endif } #endif @@ -111,7 +110,7 @@ fbSetupScreen(ScreenPtr pScreen, int width, /* pixel width of frame buffer */ int bpp) /* bits per pixel for screen */ { - if (!fbAllocatePrivates(pScreen, (int *) 0)) + if (!fbAllocatePrivates(pScreen)) return FALSE; pScreen->defColormap = FakeClientID(0); /* let CreateDefColormap do whatever it wants for pixels */ @@ -146,12 +145,6 @@ fbSetupScreen(ScreenPtr pScreen, #ifndef FB_OLD_SCREEN pScreen->GetWindowPixmap = _fbGetWindowPixmap; pScreen->SetWindowPixmap = _fbSetWindowPixmap; - - pScreen->BackingStoreFuncs.SaveAreas = fbSaveAreas; - pScreen->BackingStoreFuncs.RestoreAreas = fbRestoreAreas; - pScreen->BackingStoreFuncs.SetClipmaskRgn = 0; - pScreen->BackingStoreFuncs.GetImagePixmap = 0; - pScreen->BackingStoreFuncs.GetSpansPixmap = 0; #endif return TRUE; @@ -213,7 +206,6 @@ fbFinishScreenInit(ScreenPtr pScreen, } } #endif -#ifdef FB_SCREEN_PRIVATE if (imagebpp == 32) { fbGetScreenPrivate(pScreen)->win32bpp = bpp; @@ -224,7 +216,6 @@ fbFinishScreenInit(ScreenPtr pScreen, fbGetScreenPrivate(pScreen)->win32bpp = 32; fbGetScreenPrivate(pScreen)->pix32bpp = 32; } -#endif rootdepth = 0; if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth, &defaultVisual,((unsigned long)1<<(imagebpp-1)), 8)) @@ -245,14 +236,6 @@ fbFinishScreenInit(ScreenPtr pScreen, pScreen->ModifyPixmapHeader = fb24_32ModifyPixmapHeader; pScreen->CreateScreenResources = fb24_32CreateScreenResources; } -#endif -#if 0 - /* leave backing store initialization to the enclosing code so - * it can choose the correct order of wrappers - */ - /* init backing store here so we can overwrite CloseScreen without stepping - * on the backing store wrapped version */ - fbInitializeBackingStore (pScreen); #endif return TRUE; } @@ -275,26 +258,3 @@ fbScreenInit(ScreenPtr pScreen, return FALSE; return TRUE; } - - -#ifdef FB_OLD_SCREEN -const miBSFuncRec fbBSFuncRec = { - fbSaveAreas, - fbRestoreAreas, - (void (*)(GCPtr, RegionPtr)) 0, - (PixmapPtr (*)(void)) 0, - (PixmapPtr (*)(void)) 0, -}; -#endif - -#if 0 -void -fbInitializeBackingStore (ScreenPtr pScreen) -{ -#ifdef FB_OLD_SCREEN - miInitializeBackingStore (pScreen, (miBSFuncRec *) &fbBSFuncRec); -#else - miInitializeBackingStore (pScreen); -#endif -} -#endif diff --git a/nx-X11/programs/Xserver/fb/fbwindow.c b/nx-X11/programs/Xserver/fb/fbwindow.c index c4e28de5ba..0b8dd44486 100644 --- a/nx-X11/programs/Xserver/fb/fbwindow.c +++ b/nx-X11/programs/Xserver/fb/fbwindow.c @@ -34,13 +34,11 @@ Bool fbCreateWindow(WindowPtr pWin) { #ifndef FB_NO_WINDOW_PIXMAPS - pWin->devPrivates[fbWinPrivateIndex].ptr = - (void *) fbGetScreenPixmap(pWin->drawable.pScreen); + dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(pWin), + fbGetScreenPixmap(pWin->drawable.pScreen)); #endif -#ifdef FB_SCREEN_PRIVATE if (pWin->drawable.bitsPerPixel == 32) pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp; -#endif return TRUE; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Client.c b/nx-X11/programs/Xserver/hw/nxagent/Client.c index 206b6d8e36..3566b72cd0 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Client.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Client.c @@ -100,7 +100,7 @@ void nxagentCheckRestartedClients(struct timeval **timeout); * Allow attaching private members to the client. */ -int nxagentClientPrivateIndex; +DevPrivateKeyRec nxagentClientPrivateKeyRec; /* * The master nxagent holds in nxagentShadowCounter @@ -109,6 +109,8 @@ int nxagentClientPrivateIndex; int nxagentShadowCounter = 0; +// FIXME: Where to attach the agent client privates??? + void nxagentInitClientPrivates(ClientPtr client) { if (nxagentClientPriv(client)) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Client.h b/nx-X11/programs/Xserver/hw/nxagent/Client.h index 8f4f503ba3..e2982148b7 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Client.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Client.h @@ -26,6 +26,8 @@ #ifndef __Client_H__ #define __Client_H__ +#include "privates.h" + #define MAX_CONNECTIONS 256 /* @@ -50,12 +52,14 @@ typedef struct _PrivClientRec long clientBytes; enum ClientHint clientHint; -} PrivClientRec; +} nxagentPrivClientRec, *nxagentPrivClientPtr; + +extern DevPrivateKeyRec nxagentClientPrivateKeyRec; -extern int nxagentClientPrivateIndex; +#define nxagentClientPrivateKey (&nxagentClientPrivateKeyRec) -#define nxagentClientPriv(pClient) \ - ((PrivClientRec *)((pClient)->devPrivates[nxagentClientPrivateIndex].ptr)) +#define nxagentClientPriv(pClient) ((nxagentPrivClientPtr) \ + dixLookupPrivate(&(pClient)->devPrivates, nxagentClientPrivateKey)) void nxagentInitClientPrivates(ClientPtr); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c index a67115cec2..94d5e2640c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Cursor.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Cursor.c @@ -239,9 +239,8 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) bg_color.green = pCursor->backGreen; bg_color.blue = pCursor->backBlue; - pCursor->devPriv[pScreen->myNum] = (void *) malloc(sizeof(nxagentPrivCursor)); - - nxagentCursorPriv(pCursor, pScreen)->cursor = + nxagentSetCursorPriv(pCursor, pScreen, malloc(sizeof(nxagentPrivCursorRec))); + nxagentCursor(pCursor, pScreen) = XCreatePixmapCursor(nxagentDisplay, source, mask, &fg_color, &bg_color, pCursor->bits->xhot, pCursor->bits->yhot); @@ -249,8 +248,8 @@ Bool nxagentRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) #ifdef TEST fprintf(stderr, "nxagentRealizeCursor: Set cursor private at [%p] cursor is [%ld].\n", - (void *) nxagentCursorPriv(pCursor, pScreen), - nxagentCursorPriv(pCursor, pScreen) -> cursor); + (void *) nxagentGetCursorPriv(pCursor, pScreen), + nxagentCursor(pCursor, pScreen)); #endif XFreePixmap(nxagentDisplay, source); @@ -275,7 +274,7 @@ Bool nxagentUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) nxagentCursor(pCursor, pScreen) = None; } - free(nxagentCursorPriv(pCursor, pScreen)); + free(nxagentGetCursorPriv(pCursor, pScreen)); return True; } @@ -340,7 +339,7 @@ void nxagentReconnectCursor(void * p0, XID x1, void * p2) return; } - if (nxagentCursorPriv(pCursor, nxagentDefaultScreen) == 0) + if (nxagentGetCursorPriv(pCursor, nxagentDefaultScreen)) { if (nxagentIsAnimCursor(pCursor)) { @@ -374,7 +373,7 @@ void nxagentReconnectCursor(void * p0, XID x1, void * p2) } else { - free(nxagentCursorPriv(pCursor, nxagentDefaultScreen)); + free(nxagentGetCursorPriv(pCursor, nxagentDefaultScreen)); if (!nxagentRealizeCursor(nxagentDefaultScreen, pCursor)) { fprintf(stderr, "nxagentReconnectCursor: nxagentRealizeCursor failed\n"); @@ -397,7 +396,7 @@ void nxagentReDisplayCurrentCursor(void) CursorPtr pCursor = GetSpriteCursor(); if (pCursor && - nxagentCursorPriv(pCursor, nxagentDefaultScreen) && + nxagentGetCursorPriv(pCursor, nxagentDefaultScreen) && nxagentCursor(pCursor, nxagentDefaultScreen)) { nxagentDisplayCursor(nxagentDefaultScreen, pCursor); @@ -454,7 +453,7 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2) return; } - if (nxagentCursorPriv(pCursor, nxagentDefaultScreen) == 0) + if (nxagentGetCursorPriv(pCursor, nxagentDefaultScreen)) { if (nxagentIsAnimCursor(pCursor)) { @@ -492,7 +491,7 @@ void nxagentDisconnectCursor(void * p0, XID x1, void * p2) (void *) nxagentDefaultScreen); fprintf(stderr, "nxagentDisconnectCursor: Cursor private is at [%p].\n", - (void *) nxagentCursorPriv(pCursor, nxagentDefaultScreen)); + (void *) nxagentGetCursorPriv(pCursor, nxagentDefaultScreen)); #endif #ifdef TEST diff --git a/nx-X11/programs/Xserver/hw/nxagent/Cursor.h b/nx-X11/programs/Xserver/hw/nxagent/Cursor.h index b115dfa38b..faccab5d45 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Cursor.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Cursor.h @@ -43,13 +43,38 @@ is" without express or implied warranty. #include "cursorstr.h" #include "picturestr.h" +extern DevPrivateKeyRec nxagentCursorScreenKeyRec; + +#define nxagentCursorScreenKey (&nxagentCursorScreenKeyRec) + typedef struct { Cursor cursor; PicturePtr picture; int uses_render; int x; int y; -} nxagentPrivCursor; +} nxagentPrivCursorRec, *nxagentPrivCursorPtr; + +#define nxagentGetCursorPriv(pCursor, pScreen) ((nxagentPrivCursorPtr) \ + dixLookupScreenPrivate(&(pCursor)->devPrivates, CursorScreenKey, pScreen)) + +#define nxagentSetCursorPriv(pCursor, pScreen, v) \ + dixSetScreenPrivate(&(pCursor)->devPrivates, CursorScreenKey, pScreen, v) + +#define nxagentCursor(pCursor, pScreen) \ + (nxagentGetCursorPriv(pCursor, pScreen)->cursor) + +#define nxagentCursorPicture(pCursor, pScreen) \ + (nxagentGetCursorPriv(pCursor, pScreen)->picture) + +#define nxagentCursorUsesRender(pCursor, pScreen) \ + (nxagentGetCursorPriv(pCursor, pScreen)->uses_render) + +#define nxagentCursorXOffset(pCursor, pScreen) \ + (nxagentGetCursorPriv(pCursor, pScreen)->x) + +#define nxagentCursorYOffset(pCursor, pScreen) \ + (nxagentGetCursorPriv(pCursor, pScreen)->y) /* * _AnimCurElt and _AnimCur already defined in animcur.c. @@ -69,25 +94,6 @@ CursorBitsPtr nxagentAnimCursorBits; #define nxagentIsAnimCursor(c) ((c)->bits == nxagentAnimCursorBits) #define nxagentGetAnimCursor(c) ((AnimCurPtr) ((c) + 1)) - -#define nxagentCursorPriv(pCursor, pScreen) \ - ((nxagentPrivCursor *)((pCursor)->devPriv[pScreen->myNum])) - -#define nxagentCursor(pCursor, pScreen) \ - (nxagentCursorPriv(pCursor, pScreen)->cursor) - -#define nxagentCursorPicture(pCursor, pScreen) \ - (nxagentCursorPriv(pCursor, pScreen)->picture) - -#define nxagentCursorUsesRender(pCursor, pScreen) \ - (nxagentCursorPriv(pCursor, pScreen)->uses_render) - -#define nxagentCursorXOffset(pCursor, pScreen) \ - (nxagentCursorPriv(pCursor, pScreen)->x) - -#define nxagentCursorYOffset(pCursor, pScreen) \ - (nxagentCursorPriv(pCursor, pScreen)->y) - void nxagentConstrainCursor(ScreenPtr pScreen, BoxPtr pBox); void nxagentCursorLimits(ScreenPtr pScreen, CursorPtr pCursor, diff --git a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c index 5228705466..b2c3a1be7c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Drawable.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Drawable.c @@ -44,8 +44,6 @@ #include "compext/Compext.h" -#include "mibstorest.h" - #define PANIC #define WARNING #undef TEST @@ -3055,7 +3053,6 @@ int nxagentSynchronizationPredicate(void) void nxagentSendBackgroundExpose(WindowPtr pWin, PixmapPtr pBackground, RegionPtr pExpose) { RegionRec expose; - miBSWindowPtr pBackingStore; RegionInit(&expose, NullBox, 1); @@ -3111,21 +3108,6 @@ void nxagentSendBackgroundExpose(WindowPtr pWin, PixmapPtr pBackground, RegionPt expose.extents.x1, expose.extents.y1, expose.extents.x2, expose.extents.y2); #endif - /* - * This prevents hidden region to be exposed. - */ - - pBackingStore = (miBSWindowPtr)pWin->backStorage; - - if ((pBackingStore != NULL) && (RegionNil(&pBackingStore->SavedRegion) == 0)) - { - RegionTranslate(&expose, -pWin -> drawable.x, -pWin -> drawable.y); - - RegionSubtract(&expose, &expose, &pBackingStore -> SavedRegion); - - RegionTranslate(&expose, pWin -> drawable.x, pWin -> drawable.y); - } - RegionIntersect(&expose, &expose, &pWin -> clipList); /* diff --git a/nx-X11/programs/Xserver/hw/nxagent/Events.c b/nx-X11/programs/Xserver/hw/nxagent/Events.c index 0eca8e491b..4cffa7ac4f 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Events.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Events.c @@ -38,7 +38,6 @@ #include "selection.h" #include "keysym.h" #include "fb.h" -#include "mibstorest.h" #include "osdep.h" #include "Agent.h" @@ -2538,55 +2537,15 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) { /* * Send an expose event to client, instead of graphics - * expose. If target drawable is a backing pixmap, send - * expose event for the saved window, else do nothing. + * expose. */ RegionPtr exposeRegion; BoxRec rect; WindowPtr pWin; - StoringPixmapPtr pStoringPixmapRec = NULL; - miBSWindowPtr pBSwindow = NULL; - int drawableType; pWin = nxagentWindowPtr(X -> xgraphicsexpose.drawable); - if (pWin != NULL) - { - drawableType = DRAWABLE_WINDOW; - } - else - { - drawableType = DRAWABLE_PIXMAP; - } - - if (drawableType == DRAWABLE_PIXMAP) - { - pStoringPixmapRec = nxagentFindItemBSPixmapList(X -> xgraphicsexpose.drawable); - - if (pStoringPixmapRec == NULL) - { - #ifdef TEST - fprintf(stderr, "nxagentHandleGraphicsExposeEvent: WARNING! Storing pixmap not found.\n"); - #endif - - return 1; - } - - pBSwindow = (miBSWindowPtr) pStoringPixmapRec -> pSavedWindow -> backStorage; - - if (pBSwindow == NULL) - { - #ifdef TEST - fprintf(stderr, "nxagentHandleGraphicsExposeEvent: WARNING! Back storage not found.\n"); - #endif - - return 1; - } - - pWin = pStoringPixmapRec -> pSavedWindow; - } - /* * Rectangle affected by GraphicsExpose * event. @@ -2599,33 +2558,6 @@ int nxagentHandleGraphicsExposeEvent(XEvent *X) exposeRegion = RegionCreate(&rect, 0); - if (drawableType == DRAWABLE_PIXMAP) - { - #ifdef TEST - fprintf(stderr, "nxagentHandleGraphicsExposeEvent: Handling GraphicsExpose event on pixmap with id" - " [%lu].\n", X -> xgraphicsexpose.drawable); - #endif - - /* - * The exposeRegion coordinates are relative - * to the pixmap to which GraphicsExpose - * event refers. But the BS coordinates of - * the savedRegion are relative to the - * window. - */ - - RegionTranslate(exposeRegion, pStoringPixmapRec -> backingStoreX, - pStoringPixmapRec -> backingStoreY); - - /* - * We remove from SavedRegion the part - * affected by the GraphicsExpose event. - */ - - RegionSubtract(&(pBSwindow -> SavedRegion), &(pBSwindow -> SavedRegion), - exposeRegion); - } - /* * Store the exposeRegion in order to send * the expose event later. The coordinates diff --git a/nx-X11/programs/Xserver/hw/nxagent/GC.c b/nx-X11/programs/Xserver/hw/nxagent/GC.c index 2fac2f1002..9be648be39 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GC.c +++ b/nx-X11/programs/Xserver/hw/nxagent/GC.c @@ -74,7 +74,7 @@ RESTYPE RT_NX_GC; #undef TEST #undef DEBUG -int nxagentGCPrivateIndex; +DevPrivateKeyRec nxagentGCPrivateKeyRec; nxagentGraphicContextsPtr nxagentGraphicContexts; int nxagentGraphicContextsSize; @@ -177,7 +177,7 @@ Bool nxagentCreateGC(GCPtr pGC) fprintf(stderr, "nxagentCreateGC: GC [%p]\n", (void *) pGC); #endif - pPriv = (pGC)->devPrivates[fbGCPrivateIndex].ptr; + pPriv = fbGetGCPrivate(pGC); fbGetRotatedPixmap(pGC) = 0; fbGetExpose(pGC) = 1; diff --git a/nx-X11/programs/Xserver/hw/nxagent/GCs.h b/nx-X11/programs/Xserver/hw/nxagent/GCs.h index 84b0063abd..408648e206 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/GCs.h +++ b/nx-X11/programs/Xserver/hw/nxagent/GCs.h @@ -55,9 +55,11 @@ typedef struct { PixmapPtr pPixmap; -} nxagentPrivGC; +} nxagentPrivGCRec, *nxagentPrivGCPtr; -extern int nxagentGCPrivateIndex; +extern DevPrivateKeyRec nxagentGCPrivateKeyRec; + +#define nxagentGCPrivateKey (&nxagentGCPrivateKeyRec) typedef struct _nxagentGraphicContextsRec { @@ -71,8 +73,8 @@ typedef nxagentGraphicContextsRec *nxagentGraphicContextsPtr; extern nxagentGraphicContextsPtr nxagentGraphicContexts; extern int nxagentGraphicContextsSize; -#define nxagentGCPriv(pGC) \ - ((nxagentPrivGC *)((pGC) -> devPrivates[nxagentGCPrivateIndex].ptr)) +#define nxagentGCPriv(pGC) ((nxagentPrivGCPtr) \ + dixLookupPrivate(&(pGC)->devPrivates, nxagentGCPrivateKey)) #define nxagentGC(pGC) (nxagentGCPriv(pGC) -> gc) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Init.c b/nx-X11/programs/Xserver/hw/nxagent/Init.c index 12f7f0b06e..2dd236da82 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Init.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Init.c @@ -72,6 +72,10 @@ is" without express or implied warranty. #include "Error.h" #include "Keystroke.h" +#ifdef XKB +#include "xkbsrv.h" +#endif + #include #include "compext/Compext.h" #include "Reconnect.h" @@ -95,7 +99,7 @@ extern int (*ProcVector[256])(ClientPtr); * From the fb code. */ -extern int fbGCPrivateIndex; +extern DevPrivateKeyRec fbGCPrivateKeyRec; /* * Stubs for the DPMS extension. @@ -312,8 +316,6 @@ void InitOutput(ScreenInfo *screenInfo, int argc, char *argv[]) } } - nxagentInitBSPixmapList(); - /* * Open the display. We are at the early startup and * the information we'll get from the remote X server @@ -362,8 +364,6 @@ FIXME: These variables, if not removed at all because have probably * Get our own privates' index. */ - nxagentWindowPrivateIndex = AllocateWindowPrivateIndex(); - nxagentGCPrivateIndex = AllocateGCPrivateIndex(); RT_NX_GC = CreateNewResourceType(nxagentDestroyNewGCResourceType); #ifdef HAS_XFONT2 nxagentFontPrivateIndex = xfont2_allocate_font_private_index(); @@ -371,15 +371,12 @@ FIXME: These variables, if not removed at all because have probably nxagentFontPrivateIndex = AllocateFontPrivateIndex(); #endif /* HAS_XFONT2 */ RT_NX_FONT = CreateNewResourceType(nxagentDestroyNewFontResourceType); - nxagentClientPrivateIndex = AllocateClientPrivateIndex(); - nxagentPixmapPrivateIndex = AllocatePixmapPrivateIndex(); RT_NX_PIXMAP = CreateNewResourceType(nxagentDestroyNewPixmapResourceType); RT_NX_CORR_BACKGROUND = CreateNewResourceType(nxagentDestroyCorruptedBackgroundResource); RT_NX_CORR_WINDOW = CreateNewResourceType(nxagentDestroyCorruptedWindowResource); RT_NX_CORR_PIXMAP = CreateNewResourceType(nxagentDestroyCorruptedPixmapResource); - fbGCPrivateIndex = AllocateGCPrivateIndex(); if (nxagentNumScreens == 0) { @@ -425,6 +422,11 @@ void InitInput(argc, argv) { void *ptr, *kbd; +#ifdef XKB + if (!noXkbExtension) + XkbInitPrivates(); +#endif + ptr = AddInputDevice(nxagentPointerProc, True); kbd = AddInputDevice(nxagentKeyboardProc, True); diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index 5cfa927690..c3e87673f6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -1320,44 +1320,3 @@ CloseDownClient(register ClientPtr client) } } -int -InitClientPrivates(ClientPtr client) -{ - register char *ptr; - DevUnion *ppriv; - register unsigned *sizes; - register unsigned size; - register int i; - - if (totalClientSize == sizeof(ClientRec)) - ppriv = (DevUnion *)NULL; - else if (client->index) - ppriv = (DevUnion *)(client + 1); - else - { - ppriv = (DevUnion *)malloc(totalClientSize - sizeof(ClientRec)); - if (!ppriv) - return 0; - } - client->devPrivates = ppriv; - sizes = clientPrivateSizes; - ptr = (char *)(ppriv + clientPrivateLen); - for (i = clientPrivateLen; --i >= 0; ppriv++, sizes++) - { - if ( (size = *sizes) ) - { - ppriv->ptr = (void *)ptr; - ptr += size; - } - else - ppriv->ptr = (void *)NULL; - } - - /* - * Initialize the private members. - */ - - nxagentInitClientPrivates(client); - - return 1; -} diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphSet.h b/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphSet.h index 98f331dd7f..66fea4d428 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphSet.h +++ b/nx-X11/programs/Xserver/hw/nxagent/NXglyphstr_GlyphSet.h @@ -57,7 +57,7 @@ typedef struct _GlyphSet { int fdepth; GlyphHashRec hash; int maxPrivate; - void **devPrivates; + PrivateRec *devPrivates; CARD32 remoteID; } GlyphSetRec, *GlyphSetPtr; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c b/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c index 48b5655645..95d568bbcf 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c @@ -257,21 +257,6 @@ miHandleExposures(pSrcDrawable, pDstDrawable, /* now get the hidden parts of the source box*/ RegionSubtract(&rgnExposed, &rgnExposed, prgnSrcClip); - if (pSrcWin && pSrcWin->backStorage) - { - /* - * Copy any areas from the source backing store. Modifies - * rgnExposed. - */ - (* pSrcWin->drawable.pScreen->ExposeCopy) ((WindowPtr)pSrcDrawable, - pDstDrawable, - pGC, - &rgnExposed, - srcx, srcy, - dstx, dsty, - plane); - } - /* move them over the destination */ RegionTranslate(&rgnExposed, dstx-srcx, dsty-srcy); @@ -309,15 +294,6 @@ miHandleExposures(pSrcDrawable, pDstDrawable, expBox = *RegionExtents(&rgnExposed); RegionReset(&rgnExposed, &expBox); - /* need to clear out new areas of backing store */ - if (pWin->backStorage) - (void) (* pWin->drawable.pScreen->ClearBackingStore)( - pWin, - expBox.x1, - expBox.y1, - expBox.x2 - expBox.x1, - expBox.y2 - expBox.y1, - FALSE); } if ((pDstDrawable->type != DRAWABLE_PIXMAP) && (((WindowPtr)pDstDrawable)->backgroundState != None)) @@ -385,18 +361,6 @@ miWindowExposures(pWin, prgn, other_exposed) int total; RegionPtr exposures = prgn; - if (pWin->backStorage && prgn) - /* - * in some cases, backing store will cause a different - * region to be exposed than needs to be repainted - * (like when a window is mapped). RestoreAreas is - * allowed to return a region other than prgn, - * in which case this routine will free the resultant - * region. If exposures is null, then no events will - * be sent to the client; if prgn is empty - * no areas will be repainted. - */ - exposures = (*pWin->drawable.pScreen->RestoreAreas)(pWin, prgn); if ((prgn && !RegionNil(prgn)) || (exposures && !RegionNil(exposures)) || other_exposed) { @@ -450,14 +414,6 @@ miWindowExposures(pWin, prgn, other_exposed) /* PaintWindowBackground doesn't clip, so we have to */ RegionIntersect(prgn, prgn, &pWin->clipList); /* need to clear out new areas of backing store, too */ - if (pWin->backStorage) - (void) (* pWin->drawable.pScreen->ClearBackingStore)( - pWin, - box.x1 - pWin->drawable.x, - box.y1 - pWin->drawable.y, - box.x2 - box.x1, - box.y2 - box.y1, - FALSE); } if (prgn && !RegionNil(prgn)) (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, PW_BACKGROUND); @@ -648,9 +604,6 @@ int what; pWin = pRoot; } - if (pWin->backStorage) - (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack); - mask = gcmask; gcmask = 0; i = 0; @@ -729,9 +682,6 @@ int what; (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect); free(prect); - if (pWin->backStorage) - (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing); - if (usingScratchGC) { if (what == PW_BORDER) diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c index 4ea7d2d731..88678d5d40 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXpicture.c @@ -56,7 +56,6 @@ /* prototypes */ PictFormatPtr PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp); -PicturePtr AllocatePicture (ScreenPtr pScreen); PicturePtr CreatePicture (Picture pid, DrawablePtr pDrawable, PictFormatPtr pFormat, @@ -184,40 +183,6 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) return pFormats; } -PicturePtr -AllocatePicture (ScreenPtr pScreen) -{ - PictureScreenPtr ps = GetPictureScreen(pScreen); - PicturePtr pPicture; - char *ptr; - DevUnion *ppriv; - unsigned int *sizes; - unsigned int size; - int i; - - pPicture = (PicturePtr) calloc(1, ps->totalPictureSize); - if (!pPicture) - return 0; - ppriv = (DevUnion *)(pPicture + 1); - pPicture->devPrivates = ppriv; - sizes = ps->PicturePrivateSizes; - ptr = (char *)(ppriv + ps->PicturePrivateLen); - for (i = ps->PicturePrivateLen; --i >= 0; ppriv++, sizes++) - { - if ( (size = *sizes) ) - { - ppriv->ptr = (void *)ptr; - ptr += size; - } - else - ppriv->ptr = (void *)NULL; - } - - nxagentPicturePriv(pPicture) -> picture = 0; - - return pPicture; -} - PicturePtr CreatePicture (Picture pid, DrawablePtr pDrawable, @@ -230,7 +195,8 @@ CreatePicture (Picture pid, PicturePtr pPicture; PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen); - pPicture = AllocatePicture (pDrawable->pScreen); + pPicture = dixAllocateScreenObjectWithPrivates(pDrawable->pScreen, + PictureRec, PRIVATE_PICTURE); if (!pPicture) { *error = BadAlloc; @@ -304,48 +270,10 @@ CreateSolidPicture (Picture pid, xRenderColor *color, int *error) static PicturePtr createSourcePicture(void) { PicturePtr pPicture; - - extern int nxagentPicturePrivateIndex; - - unsigned int totalPictureSize; - - DevUnion *ppriv; - - char *privPictureRecAddr; - - int i; - - /* - * Compute size of entire PictureRect, plus privates. - */ - - totalPictureSize = sizeof(PictureRec) + - picturePrivateCount * sizeof(DevUnion) + - sizeof(nxagentPrivPictureRec); - - pPicture = (PicturePtr) calloc(1, totalPictureSize); - - if (pPicture != NULL) - { - ppriv = (DevUnion *) (pPicture + 1); - - for (i = 0; i < picturePrivateCount; ++i) - { - /* - * Other privates are inaccessible. - */ - - ppriv[i].ptr = NULL; - } - - privPictureRecAddr = (char *) &ppriv[picturePrivateCount]; - - ppriv[nxagentPicturePrivateIndex].ptr = (void *) privPictureRecAddr; - - pPicture -> devPrivates = ppriv; - - nxagentPicturePriv(pPicture) -> picture = 0; - } + pPicture = dixAllocateScreenObjectWithPrivates(NULL, PictureRec, + PRIVATE_PICTURE); + if (!pPicture) + return 0; pPicture->pDrawable = 0; pPicture->pFormat = 0; @@ -356,17 +284,19 @@ static PicturePtr createSourcePicture(void) } int -FreePicture (void * value, - XID pid) +FreePicture (void * value, + XID pid) { - PicturePtr pPicture = (PicturePtr) value; + PicturePtr pPicture = (PicturePtr) value; + if (--pPicture->refcnt == 0) { + nxagentDestroyPicture(pPicture); - if (pPicture->transform) - free (pPicture->transform); + if (pPicture->transform) + free (pPicture->transform); if (!pPicture->pDrawable) { if (pPicture->pSourcePict) { if (pPicture->pSourcePict->type != SourcePictTypeSolidFill) @@ -374,21 +304,21 @@ FreePicture (void * value, free(pPicture->pSourcePict); } } else { - ScreenPtr pScreen = pPicture->pDrawable->pScreen; + ScreenPtr pScreen = pPicture->pDrawable->pScreen; PictureScreenPtr ps = GetPictureScreen(pScreen); - + if (pPicture->alphaMap) FreePicture ((void *) pPicture->alphaMap, (XID) 0); (*ps->DestroyPicture) (pPicture); (*ps->DestroyPictureClip) (pPicture); if (pPicture->pDrawable->type == DRAWABLE_WINDOW) { - WindowPtr pWindow = (WindowPtr) pPicture->pDrawable; - PicturePtr *pPrev; + WindowPtr pWindow = (WindowPtr) pPicture->pDrawable; + PicturePtr *pPrev; - for (pPrev = (PicturePtr *) &((pWindow)->devPrivates[PictureWindowPrivateIndex].ptr); - *pPrev; - pPrev = &(*pPrev)->pNext) + for (pPrev = (PicturePtr *) dixLookupPrivateAddr + (&pWindow->devPrivates, PictureWindowPrivateKey); + *pPrev; pPrev = &(*pPrev)->pNext) { if (*pPrev == pPicture) { @@ -402,7 +332,7 @@ FreePicture (void * value, (*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable); } } - free (pPicture); + dixFreeObjectWithPrivates(pPicture, PRIVATE_PICTURE); } return Success; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c index ce4ea9d5fe..0c0d7d2f9c 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c @@ -1508,11 +1508,6 @@ ProcRenderCreateAnimCursor (ClientPtr client) nxagentAnimCursorBits = pCursor -> bits; - for (i = 0; i < MAXSCREENS; i++) - { - pCursor -> devPriv[i] = NULL; - } - if (AddResource (stuff->cid, RT_CURSOR, (void *)pCursor)) return client->noClientException; return BadAlloc; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c index 5e8e8ed6bb..f0b1dbcf08 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXshm.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXshm.c @@ -90,8 +90,8 @@ ShmExtensionInit(void) #ifdef MUST_CHECK_FOR_SHM_SYSCALL if (!CheckForShmSyscall()) { - ErrorF("MIT-SHM extension disabled due to lack of kernel support\n"); - return; + ErrorF("MIT-SHM extension disabled due to lack of kernel support\n"); + return; } #endif @@ -100,58 +100,39 @@ ShmExtensionInit(void) return; } + if (!ShmRegisterPrivates()) + return; + sharedPixmaps = xFalse; - pixmapFormat = 0; { - sharedPixmaps = nxagentOption(SharedPixmaps); - pixmapFormat = shmPixFormat[0]; - for (i = 0; i < screenInfo.numScreens; i++) - { - if (!shmFuncs[i]) - { - #ifdef TEST - fprintf(stderr, "ShmExtensionInit: Registering shmFuncs as miFuncs.\n"); - #endif - shmFuncs[i] = &miFuncs; + sharedPixmaps = xTrue; + for (i = 0; i < screenInfo.numScreens; i++) { + ShmScrPrivateRec *screen_priv = + ShmInitScreenPriv(screenInfo.screens[i]); + if (!screen_priv->shmFuncs) + screen_priv->shmFuncs = &miFuncs; + if (!screen_priv->shmFuncs->CreatePixmap) + sharedPixmaps = xFalse; } - if (!shmFuncs[i]->CreatePixmap) - sharedPixmaps = xFalse; - if (shmPixFormat[i] && (shmPixFormat[i] != pixmapFormat)) - { - sharedPixmaps = xFalse; - pixmapFormat = 0; - } - } - if (!pixmapFormat) - pixmapFormat = ZPixmap; - if (sharedPixmaps) - { - for (i = 0; i < screenInfo.numScreens; i++) - { - destroyPixmap[i] = screenInfo.screens[i]->DestroyPixmap; - screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap; - } -#ifdef PIXPRIV - shmPixmapPrivate = AllocatePixmapPrivateIndex(); - for (i = 0; i < screenInfo.numScreens; i++) - { - if (!AllocatePixmapPrivate(screenInfo.screens[i], - shmPixmapPrivate, 0)) - return; - } -#endif - } + if (sharedPixmaps) + for (i = 0; i < screenInfo.numScreens; i++) { + ShmScrPrivateRec *screen_priv = + ShmGetScreenPriv(screenInfo.screens[i]); + screen_priv->destroyPixmap = + screenInfo.screens[i]->DestroyPixmap; + screenInfo.screens[i]->DestroyPixmap = ShmDestroyPixmap; + } } ShmSegType = CreateNewResourceType(ShmDetachSegment); if (ShmSegType && - (extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors, - ProcShmDispatch, SProcShmDispatch, - ShmResetProc, StandardMinorOpcode))) + (extEntry = AddExtension(SHMNAME, ShmNumberEvents, ShmNumberErrors, + ProcShmDispatch, SProcShmDispatch, + ShmResetProc, StandardMinorOpcode))) { - ShmReqCode = (unsigned char)extEntry->base; - ShmCompletionCode = extEntry->eventBase; - BadShmSegCode = extEntry->errorBase; - EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent; + ShmReqCode = (unsigned char)extEntry->base; + ShmCompletionCode = extEntry->eventBase; + BadShmSegCode = extEntry->errorBase; + EventSwapVector[ShmCompletionCode] = (EventSwapPtr) SShmCompletionEvent; } } @@ -275,8 +256,9 @@ ProcShmPutImage(client) register DrawablePtr pDraw; long length; ShmDescPtr shmdesc; - REQUEST(xShmPutImageReq); + ShmScrPrivateRec *screen_priv; + REQUEST(xShmPutImageReq); REQUEST_SIZE_MATCH(xShmPutImageReq); VALIDATE_DRAWABLE_AND_GC(stuff->drawable, pDraw, pGC, client); VERIFY_SHMPTR(stuff->shmseg, stuff->offset, FALSE, shmdesc, client); @@ -346,10 +328,11 @@ ProcShmPutImage(client) #endif #ifdef TEST - fprintf(stderr, "ProcShmPutImage: Calling (*shmFuncs[pDraw->pScreen->myNum]->PutImage)().\n"); + fprintf(stderr, "ProcShmPutImage: Calling (*screen_priv->shmFuncs->PutImage)().\n"); #endif - (*shmFuncs[pDraw->pScreen->myNum]->PutImage)( + screen_priv = ShmGetScreenPriv(pDraw->pScreen); + (*screen_priv->shmFuncs->PutImage)( pDraw, pGC, stuff->depth, stuff->format, stuff->totalWidth, stuff->totalHeight, stuff->srcX, stuff->srcY, diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c index 64bbf67c4e..b81ddb0762 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXwindow.c @@ -353,7 +353,7 @@ DeleteWindow(void * value, XID wid) nxagentSetInstalledColormapWindows(pWin -> drawable.pScreen); } - free(pWin); + dixFreeObjectWithPrivates(pWin, PRIVATE_WINDOW); return Success; } @@ -837,9 +837,6 @@ MapWindow(register WindowPtr pWin, ClientPtr client) register ScreenPtr pScreen; register WindowPtr pParent; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif WindowPtr pLayerWin; #ifdef TEST @@ -899,21 +896,11 @@ MapWindow(register WindowPtr pWin, ClientPtr client) { anyMarked = (*pScreen->MarkOverlappedWindows)(pWin, pWin, &pLayerWin); -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib); - } -#endif /* DO_SAVE_UNDERS */ if (anyMarked) { (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTMap); (*pScreen->HandleExposures)(pLayerWin->parent); } -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib); -#endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTMap); } @@ -994,16 +981,6 @@ UnmapWindow(register WindowPtr pWin, Bool fromConfigure) (*pScreen->ValidateTree)(pLayerWin->parent, pWin, VTUnmap); (*pScreen->HandleExposures)(pLayerWin->parent); } -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - if ( (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib) ) - { - (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib); - } - } - pWin->DIXsaveUnder = FALSE; -#endif /* DO_SAVE_UNDERS */ if (!fromConfigure && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pWin, VTUnmap); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c index 421e023c17..7417cfe027 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmap.c @@ -69,7 +69,7 @@ RESTYPE RT_NX_PIXMAP; #include "Font.h" #endif -int nxagentPixmapPrivateIndex; +DevPrivateKeyRec nxagentPixmapPrivateKeyRec; int nxagentCorruptedPixmaps; int nxagentCorruptedBackgrounds; @@ -452,8 +452,6 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) (void *) pPixmap); #endif - nxagentRemoveItemBSPixmapList(nxagentPixmap(pPixmap)); - nxagentDestroyVirtualPixmap(pPixmap); if (pPixmapPriv -> corruptedRegion != NullRegion) @@ -501,7 +499,7 @@ Bool nxagentDestroyPixmap(PixmapPtr pPixmap) FreeResource(pPixmapPriv -> mid, RT_NONE); } - free(pPixmap); + FreePixmap(pPixmap); return True; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/Pixmaps.h b/nx-X11/programs/Xserver/hw/nxagent/Pixmaps.h index 00cc39c5f3..31b2c85656 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Pixmaps.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Pixmaps.h @@ -28,6 +28,7 @@ #include "resource.h" #include "Split.h" +#include "privates.h" extern RESTYPE RT_NX_PIXMAP; @@ -72,14 +73,12 @@ typedef struct typedef nxagentPrivPixmapRec *nxagentPrivPixmapPtr; -extern int nxagentPixmapPrivateIndex; +extern DevPrivateKeyRec nxagentPixmapPrivateKeyRec; -/* - * Pixmap privates macro. - */ +#define nxagentPixmapPrivateKey (&nxagentPixmapPrivateKeyRec) -#define nxagentPixmapPriv(pPixmap) \ - ((nxagentPrivPixmapPtr)((pPixmap) -> devPrivates[nxagentPixmapPrivateIndex].ptr)) +#define nxagentPixmapPriv(pPixmap) ((nxagentPrivPixmapPtr) \ + dixLookupPrivate(&(pPixmap)->devPrivates, nxagentPixmapPrivateKey)) #define nxagentPixmap(pPixmap) (nxagentPixmapPriv(pPixmap) -> id) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c index 9a6cbf28b8..62003675c6 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Reconnect.c @@ -394,8 +394,6 @@ void nxagentDisconnectSession(void) nxagentDisconnectAllPicture(); } - nxagentEmptyAllBackingStoreRegions(); - nxagentDisconnectAllWindows(); nxagentDisconnectAllCursor(); nxagentDisconnectAllPixmaps(); @@ -516,8 +514,6 @@ Bool nxagentReconnectSession(void) NXTransContinue(NULL); - nxagentEmptyBSPixmapList(); - if (nxagentReconnectAllPixmaps(reconnectLossyLevel[PIXMAP_STEP]) == 0) { failedStep = PIXMAP_STEP; diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.c b/nx-X11/programs/Xserver/hw/nxagent/Render.c index b58a16f3d0..56f8e4a769 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.c @@ -102,7 +102,7 @@ int nxagentRenderEnable = UNDEFINED; int nxagentRenderVersionMajor; int nxagentRenderVersionMinor; -int nxagentPicturePrivateIndex = 0; +DevPrivateKeyRec nxagentPicturePrivateKeyRec; static int nxagentNumFormats = 0; @@ -517,9 +517,10 @@ void nxagentRenderExtensionInit(void) int nxagentCursorSaveRenderInfo(ScreenPtr pScreen, CursorPtr pCursor) { - pCursor -> devPriv[pScreen -> myNum] = malloc(sizeof(nxagentPrivCursor)); - if (nxagentCursorPriv(pCursor, pScreen) == NULL) + nxagentSetCursorPriv(pCursor, pScreen, malloc(sizeof(nxagentPrivCursorRec))); + + if (nxagentGetCursorPriv(pCursor, pScreen) == NULL) { FatalError("malloc failed"); } @@ -840,7 +841,7 @@ void nxagentDestroyPicture(PicturePtr pPicture) XRenderFreePicture(nxagentDisplay, nxagentPicturePriv(pPicture) -> picture); - + #ifdef DEBUG XSync(nxagentDisplay, 0); @@ -2655,9 +2656,9 @@ Bool nxagentPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats) return FALSE; } - nxagentPicturePrivateIndex = AllocatePicturePrivateIndex(); - - AllocatePicturePrivate(pScreen, nxagentPicturePrivateIndex, sizeof(nxagentPrivPictureRec)); + if (!dixRegisterPrivateKey + (&nxagentPicturePrivateKeyRec, PRIVATE_PICTURE, sizeof(nxagentPrivPictureRec))) + return FALSE; #endif diff --git a/nx-X11/programs/Xserver/hw/nxagent/Render.h b/nx-X11/programs/Xserver/hw/nxagent/Render.h index 1c56ec16b9..87e3deeec8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Render.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Render.h @@ -82,12 +82,14 @@ typedef struct XRenderPictureAttributes_ lastServerValues; -} nxagentPrivPictureRec; +} nxagentPrivPictureRec, *nxagentPrivPicturePtr; -typedef nxagentPrivPictureRec *nxagentPrivPicturePtr; +extern DevPrivateKeyRec nxagentPicturePrivateKeyRec; -#define nxagentPicturePriv(pPicture) \ - ((nxagentPrivPicturePtr) ((pPicture) -> devPrivates[nxagentPicturePrivateIndex].ptr)) +#define nxagentPicturePrivateKey (&nxagentPicturePrivateKeyRec) + +#define nxagentPicturePriv(pScreen) ((nxagentPrivPicturePtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, nxagentPicturePrivateKey)) #define nxagentPicture(pPicture) (nxagentPicturePriv(pPicture) -> picture) diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.c b/nx-X11/programs/Xserver/hw/nxagent/Screen.c index 6eae711f59..cc6c22aae7 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.c @@ -104,8 +104,6 @@ is" without express or implied warranty. #include "compext/Compext.h" -#include "mibstorest.h" - /* * Set here the required log level. */ @@ -144,6 +142,7 @@ extern Bool nxagentReportWindowIds; Window nxagentDefaultWindows[MAXSCREENS]; Window nxagentInputWindows[MAXSCREENS]; Window nxagentScreenSaverWindows[MAXSCREENS]; +DevPrivateKeyRec nxagentCursorScreenKeyRec; #ifdef NXAGENT_ONSTART Atom nxagentWMStart; @@ -872,11 +871,6 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, pScreen->myNum); #endif - if (nxagentRenderEnable && nxagentReconnectTrap == False) - { - PictureScreenPrivateIndex = -1; - } - nxagentDefaultScreen = pScreen; nxagentQueryAtoms(pScreen); @@ -1166,13 +1160,21 @@ Bool nxagentOpenScreen(ScreenPtr pScreen, * Initialize all our privates. */ - if (AllocateWindowPrivate(pScreen, nxagentWindowPrivateIndex, sizeof(nxagentPrivWindowRec)) == 0 || - AllocateGCPrivate(pScreen, nxagentGCPrivateIndex, sizeof(nxagentPrivGC)) == 0 || - AllocateClientPrivate(nxagentClientPrivateIndex, sizeof(PrivClientRec)) == 0 || - AllocatePixmapPrivate(pScreen, nxagentPixmapPrivateIndex, sizeof(nxagentPrivPixmapRec)) == 0) - { - return False; - } + if (!dixRegisterPrivateKey + (&nxagentWindowPrivateKeyRec, PRIVATE_WINDOW, sizeof(nxagentPrivWindowRec))) + return FALSE; + if (!dixRegisterPrivateKey + (&nxagentGCPrivateKeyRec, PRIVATE_GC, sizeof(nxagentPrivGCRec))) + return FALSE; + if (!dixRegisterPrivateKey + (&nxagentClientPrivateKeyRec, PRIVATE_PIXMAP, sizeof(nxagentPrivClientRec))) + return FALSE; + if (!dixRegisterPrivateKey + (&nxagentPixmapPrivateKeyRec, PRIVATE_PIXMAP, sizeof(nxagentPrivPixmapRec))) + return FALSE; + if (!dixRegisterPrivateKey + (&nxagentCursorScreenKeyRec, PRIVATE_SCREEN, sizeof(nxagentPrivCursorRec))) + return FALSE; /* * Initialize the depths. @@ -1609,26 +1611,11 @@ N/A * Backing store procedures. */ - pScreen->SaveDoomedAreas = (void (*)()) 0; - pScreen->RestoreAreas = (RegionPtr (*)()) 0; - pScreen->ExposeCopy = (void (*)()) 0; - pScreen->TranslateBackingStore = (RegionPtr (*)()) 0; - pScreen->ClearBackingStore = (RegionPtr (*)()) 0; - pScreen->DrawGuarantee = (void (*)()) 0; - if (enableBackingStore == 1) { #ifdef TEST fprintf(stderr, "nxagentOpenScreen: Going to initialize backing store.\n"); #endif - - pScreen -> BackingStoreFuncs.SaveAreas = nxagentSaveAreas; - pScreen -> BackingStoreFuncs.RestoreAreas = nxagentRestoreAreas; - pScreen -> BackingStoreFuncs.SetClipmaskRgn = 0; - pScreen -> BackingStoreFuncs.GetImagePixmap = 0; - pScreen -> BackingStoreFuncs.GetSpansPixmap = 0; - - miInitializeBackingStore(pScreen); } /* @@ -2170,10 +2157,6 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable) WindowPtr pChild; Bool WasViewable = (Bool)(pWin->viewable); Bool anyMarked = FALSE; - RegionPtr pOldClip = NULL, bsExposed; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif WindowPtr pLayerWin; BoxRec box; @@ -2231,12 +2214,6 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable) if (WasViewable) { - if (pWin->backStorage) - { - pOldClip = RegionCreate(NullBox, 1); - RegionCopy(pOldClip, &pWin->clipList); - } - if (pWin->firstChild) { anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin->firstChild, @@ -2249,47 +2226,14 @@ static void nxagentSetRootClip (ScreenPtr pScreen, Bool enable) anyMarked = TRUE; } -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin); - } -#endif /* DO_SAVE_UNDERS */ - if (anyMarked) (*pScreen->ValidateTree)(pWin, NullWindow, VTOther); } - if (pWin->backStorage && pOldClip && - ((pWin->backingStore == Always) || WasViewable)) - { - if (!WasViewable) - pOldClip = &pWin->clipList; /* a convenient empty region */ - bsExposed = (*pScreen->TranslateBackingStore) - (pWin, 0, 0, pOldClip, - pWin->drawable.x, pWin->drawable.y); - if (WasViewable) - RegionDestroy(pOldClip); - if (bsExposed) - { - RegionPtr valExposed = NullRegion; - - if (pWin->valdata) - valExposed = &pWin->valdata->after.exposed; - (*pScreen->WindowExposures) (pWin, valExposed, bsExposed); - if (valExposed) - RegionEmpty(valExposed); - RegionDestroy(bsExposed); - } - } if (WasViewable) { if (anyMarked) (*pScreen->HandleExposures)(pWin); -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin); -#endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pWin, NullWindow, VTOther); } @@ -4291,262 +4235,6 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen) return TRUE; } -void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, WindowPtr pWin) -{ - PixmapPtr pVirtualPixmap; - nxagentPrivPixmapPtr pPrivPixmap; - XlibGC gc; - XGCValues values; - int i; - int xSrc, ySrc, xDst, yDst, w, h; - int nRects; - int size; - BoxPtr pBox; - XRectangle *pRects; - BoxRec extents; - RegionRec cleanRegion; - - miBSWindowPtr pBackingStore = (miBSWindowPtr) pWin -> backStorage; - - pVirtualPixmap = nxagentVirtualPixmap(pPixmap); - - pPrivPixmap = nxagentPixmapPriv(pPixmap); - - pPrivPixmap -> isBackingPixmap = 1; - - fbCopyWindowProc(&pWin -> drawable, &pVirtualPixmap -> drawable, 0, RegionRects(prgnSave), - RegionNumRects(prgnSave), xorg, yorg, FALSE, FALSE, 0, 0); - - values.subwindow_mode = IncludeInferiors; - - gc = XCreateGC(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), GCSubwindowMode, &values); - - /* - * Initialize to the corrupted region. - * Coordinates are relative to the window. - */ - - RegionInit(&cleanRegion, NullBox, 1); - - RegionCopy(&cleanRegion, nxagentCorruptedRegion((DrawablePtr) pWin)); - - /* - * Subtract the corrupted region from the saved region. - */ - - RegionSubtract(&pBackingStore -> SavedRegion, &pBackingStore -> SavedRegion, &cleanRegion); - - /* - * Translate the corrupted region. Coordinates - * are relative to the backing store pixmap. - */ - - RegionTranslate(&cleanRegion, -pBackingStore -> x, -pBackingStore -> y); - - /* - * Compute the clean region to be saved: subtract - * the corrupted region from the region to be saved. - */ - - RegionSubtract(&cleanRegion, prgnSave, &cleanRegion); - - nRects = RegionNumRects(&cleanRegion); - size = nRects * sizeof(*pRects); - pRects = (XRectangle *) malloc(size); - pBox = RegionRects(&cleanRegion); - - for (i = nRects; i-- > 0;) - { - pRects[i].x = pBox[i].x1; - pRects[i].y = pBox[i].y1; - pRects[i].width = pBox[i].x2 - pBox[i].x1; - pRects[i].height = pBox[i].y2 - pBox[i].y1; - } - - XSetClipRectangles(nxagentDisplay, gc, 0, 0, pRects, nRects, Unsorted); - - free((char *) pRects); - - extents = *RegionExtents(&cleanRegion); - - RegionUninit(&cleanRegion); - - xDst = extents.x1; - yDst = extents.y1; - -/* - * Left here the wrong solution. The window could be not - * configured yet on the real X, whilst the x and y in the - * WindowRec are the new coordinates. The right solution - * is the other, as it is independent from the window - * coordinates. - * - * xSrc = xDst + xorg - pWin -> drawable.x; - * ySrc = yDst + yorg - pWin -> drawable.y; - */ - - xSrc = xDst + pBackingStore -> x; - ySrc = yDst + pBackingStore -> y; - - w = extents.x2 - extents.x1; - h = extents.y2 - extents.y1; - - XCopyArea(nxagentDisplay, nxagentWindow(pWin), nxagentPixmap(pPixmap), gc, - xSrc, ySrc, w, h, xDst, yDst); - - nxagentAddItemBSPixmapList(nxagentPixmap(pPixmap), pPixmap, pWin, - pBackingStore -> x, pBackingStore -> y); - - #ifdef TEST - fprintf(stderr,"nxagentSaveAreas: Added pixmap [%p] with id [%d] on window [%p] to BSPixmapList.\n", - (void *) pPixmap, nxagentPixmap(pPixmap), (void *) pWin); - #endif - - XFreeGC(nxagentDisplay, gc); - - return; -} - -void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, - int yorg, WindowPtr pWin) -{ - PixmapPtr pVirtualPixmap; - RegionPtr clipRegion; - XlibGC gc; - XGCValues values; - int i; - int xSrc, ySrc, xDst, yDst, w, h; - int nRects; - int size; - BoxPtr pBox; - XRectangle *pRects; - BoxRec extents; - miBSWindowPtr pBackingStore; - - /* - * Limit the area to restore to the - * root window size. - */ - - RegionIntersect(prgnRestore, prgnRestore, - &pWin -> drawable.pScreen -> root -> winSize); - - pBackingStore = (miBSWindowPtr) pWin -> backStorage; - - pVirtualPixmap = nxagentVirtualPixmap(pPixmap); - - fbCopyWindowProc(&pVirtualPixmap -> drawable, &pWin -> drawable, 0, RegionRects(prgnRestore), - RegionNumRects(prgnRestore), -xorg, -yorg, FALSE, FALSE, 0, 0); - - values.subwindow_mode = ClipByChildren; - - gc = XCreateGC(nxagentDisplay, nxagentWindow(screenInfo.screens[0]->root), GCSubwindowMode, &values); - - /* - * Translate the reference point to the origin of the window. - */ - - RegionTranslate(prgnRestore, - -pWin -> drawable.x - pWin -> borderWidth, - -pWin -> drawable.y - pWin -> borderWidth); - - clipRegion = prgnRestore; - - if (nxagentDrawableStatus((DrawablePtr) pPixmap) == NotSynchronized) - { - clipRegion = RegionCreate(NullBox, 1); - - RegionCopy(clipRegion, - nxagentCorruptedRegion((DrawablePtr) pPixmap)); - - /* - * Translate the reference point to the origin of the window. - */ - - RegionTranslate(clipRegion, - pBackingStore -> x, pBackingStore -> y); - - RegionIntersect(clipRegion, prgnRestore, clipRegion); - - /* - * Subtract the corrupted region from the saved areas. - * miBSRestoreAreas will return the exposure region. - */ - - RegionSubtract(&pBackingStore->SavedRegion, - &pBackingStore->SavedRegion, clipRegion); - - /* - * Store the corrupted region to send expose later. - */ - - if (nxagentRemoteExposeRegion != NULL) - { - RegionTranslate(clipRegion, pWin -> drawable.x, pWin -> drawable.y); - - RegionUnion(nxagentRemoteExposeRegion, nxagentRemoteExposeRegion, clipRegion); - - RegionTranslate(clipRegion, -pWin -> drawable.x, -pWin -> drawable.y); - } - - /* - * Compute the region to be restored. - */ - - RegionSubtract(clipRegion, prgnRestore, clipRegion); - } - - nRects = RegionNumRects(clipRegion); - size = nRects * sizeof(*pRects); - pRects = (XRectangle *) malloc(size); - pBox = RegionRects(clipRegion); - - for (i = nRects; i-- > 0;) - { - pRects[i].x = pBox[i].x1; - pRects[i].y = pBox[i].y1; - pRects[i].width = pBox[i].x2 - pBox[i].x1; - pRects[i].height = pBox[i].y2 - pBox[i].y1; - } - - XSetClipRectangles(nxagentDisplay, gc, 0, 0, pRects, nRects, Unsorted); - - free(pRects); - - extents = *RegionExtents(clipRegion); - - xDst = extents.x1; - yDst = extents.y1; - - xSrc = xDst - xorg + pWin -> drawable.x; - ySrc = yDst - yorg + pWin -> drawable.y; - - w = extents.x2 - extents.x1; - h = extents.y2 - extents.y1; - - nxagentFlushConfigureWindow(); - - XCopyArea(nxagentDisplay, nxagentPixmap(pPixmap), nxagentWindow(pWin), gc, - xSrc, ySrc, w, h, xDst, yDst); - - XFreeGC(nxagentDisplay, gc); - - if (clipRegion != NULL && clipRegion != prgnRestore) - { - RegionDestroy(clipRegion); - } - - /* - * Restore the reference point to the origin of the screen. - */ - - RegionTranslate(prgnRestore, - pWin -> drawable.x - pWin -> borderWidth, - pWin -> drawable.y + pWin -> borderWidth); - - return; -} - void nxagentSetWMNormalHints(int screen, int width, int height) { XSizeHints* sizeHints = XAllocSizeHints(); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Screen.h b/nx-X11/programs/Xserver/hw/nxagent/Screen.h index 2f93105eff..28babb079e 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Screen.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Screen.h @@ -116,10 +116,6 @@ int nxagentAdjustRandRXinerama(ScreenPtr pScreen); extern Bool nxagentReconnectScreen(void *p0); -void nxagentSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, WindowPtr pWin); - -void nxagentRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, int yorg, WindowPtr pWin); - extern int monitorResolution; int nxagentShadowCreateMainWindow( ScreenPtr pScreen, WindowPtr pWin,int width, int height); diff --git a/nx-X11/programs/Xserver/hw/nxagent/Visual.c b/nx-X11/programs/Xserver/hw/nxagent/Visual.c index a29560d43c..0af3559dc3 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Visual.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Visual.c @@ -40,7 +40,6 @@ is" without express or implied warranty. #include "scrnintstr.h" #include "dix.h" #include "mi.h" -#include "mibstore.h" #include "resource.h" #include "X.h" diff --git a/nx-X11/programs/Xserver/hw/nxagent/Window.c b/nx-X11/programs/Xserver/hw/nxagent/Window.c index b12fe76de8..4a9ed79c70 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Window.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Window.c @@ -38,7 +38,6 @@ #include "selection.h" #include "mi.h" #include "fb.h" -#include "mibstorest.h" #include "Agent.h" #include "Display.h" @@ -73,7 +72,7 @@ * Used to register the window's privates. */ -int nxagentWindowPrivateIndex; +DevPrivateKeyRec nxagentWindowPrivateKeyRec; /* * Number of windows which need synchronization. @@ -125,14 +124,11 @@ extern Bool nxagentReportPrivateWindowIds; int nxagentSplashCount = 0; #define RECTLIMIT 25 -#define BSPIXMAPLIMIT 128 Bool nxagentExposeArrayIsInitialized = False; Window nxagentConfiguredSynchroWindow; static int nxagentExposeSerial = 0; -StoringPixmapPtr nxagentBSPixmapList[BSPIXMAPLIMIT]; - /* * Used to walk through the window hierarchy * to find a window @@ -1860,7 +1856,7 @@ FIXME: When the caller is nxagentReconfigureWindow if (nxagentOption(Rootless)) { if (pWin->cursorIsNone == 0 && pWin->optional != NULL && - pWin->optional->cursor != NULL && nxagentCursorPriv(pWin -> + pWin->optional->cursor != NULL && nxagentGetCursorPriv(pWin -> optional -> cursor, pWin -> drawable.pScreen) != NULL) { attributes.cursor = nxagentCursor(pWin -> optional -> cursor, @@ -2670,7 +2666,7 @@ void nxagentDisconnectWindow(void * p0, XID x1, void * p2) ScreenPtr pScreen = pWin -> drawable.pScreen; if ((pCursor = wCursor(pWin)) && - nxagentCursorPriv(pCursor, pScreen) && + nxagentGetCursorPriv(pCursor, pScreen) && nxagentCursor(pCursor, pScreen)) { #ifdef NXAGENT_RECONNECT_CURSOR_DEBUG_disabled @@ -3182,7 +3178,7 @@ static void nxagentReconfigureWindowCursor(void * param0, XID param1, void * dat pScreen = pWin -> drawable.pScreen; - if (!(nxagentCursorPriv(pCursor, pScreen))) + if (!(nxagentGetCursorPriv(pCursor, pScreen))) { return; } @@ -3789,189 +3785,3 @@ StaticResizedWindowStruct *nxagentFindStaticResizedWindow(unsigned long sequence return ret; } - -void nxagentEmptyBackingStoreRegion(void * param0, XID param1, void * data_buffer) -{ - WindowPtr pWin = (WindowPtr) param0; - - miBSWindowPtr pBackingStore = (miBSWindowPtr)pWin->backStorage; - - if (pBackingStore != NULL) - { - RegionEmpty(&pBackingStore->SavedRegion); - - #ifdef TEST - fprintf(stderr, "nxagentEmptyBackingStoreRegion: Emptying saved region for window at [%p].\n", (void*) pWin); - #endif - - if (pBackingStore -> pBackingPixmap != NULL) - { - #ifdef TEST - fprintf(stderr, "nxagentEmptyBackingStoreRegion: Emptying corrupted region for drawable at [%p].\n", - (void*) pBackingStore -> pBackingPixmap); - #endif - - nxagentUnmarkCorruptedRegion((DrawablePtr) pBackingStore -> pBackingPixmap, NullRegion); - } - } -} - -void nxagentEmptyAllBackingStoreRegions(void) -{ - if (nxagentLoopOverWindows(nxagentEmptyBackingStoreRegion) == 0) - { - #ifdef WARNING - fprintf(stderr, "nxagentEmptyAllSavedRegions: Failed to empty backing store saved regions.\n"); - #endif - } -} - -void nxagentInitBSPixmapList(void) -{ - memset(nxagentBSPixmapList, 0, BSPIXMAPLIMIT * sizeof( StoringPixmapPtr)); -} - -int nxagentAddItemBSPixmapList(unsigned long id, PixmapPtr pPixmap, WindowPtr pWin, int bsx, int bsy) -{ - int i; - - for (i = 0; i < BSPIXMAPLIMIT; i++) - { - if (nxagentBSPixmapList[i] == NULL) - { - nxagentBSPixmapList[i] = malloc(sizeof(StoringPixmapRec)); - - if (nxagentBSPixmapList[i] == NULL) - { - FatalError("nxagentAddItemBSPixmapList: Failed to allocate memory for nxagentBSPixmapList.\n"); - } - - nxagentBSPixmapList[i] -> storingPixmapId = id; - nxagentBSPixmapList[i] -> pStoringPixmap = pPixmap; - nxagentBSPixmapList[i] -> pSavedWindow = pWin; - nxagentBSPixmapList[i] -> backingStoreX = bsx; - nxagentBSPixmapList[i] -> backingStoreY = bsy; - - #ifdef TEST - fprintf(stderr, "nxagentAddItemBSPixmapList: Added Pixmap with id [%lu] to nxagentBSPixmapList.\n", id); - #endif - - return 1; - } - - if (nxagentBSPixmapList[i] -> storingPixmapId == id) - { - nxagentBSPixmapList[i] -> pStoringPixmap = pPixmap; - nxagentBSPixmapList[i] -> pSavedWindow = pWin; - nxagentBSPixmapList[i] -> backingStoreX = bsx; - nxagentBSPixmapList[i] -> backingStoreY = bsy; - - #ifdef TEST - fprintf(stderr, "nxagentAddItemBSPixmapList: Updated existing item for id [%lu].\n", id); - #endif - - return 1; - } - } - - #ifdef TEST - fprintf(stderr, "nxagentAddItemBSPixmapList: WARNING! List item full.\n"); - #endif - - return 0; -} - -int nxagentRemoveItemBSPixmapList(unsigned long pixmapId) -{ - int i; - int j; - - if (pixmapId == 0 || nxagentBSPixmapList[0] == NULL) - { - return 0; - } - - for (i = 0; i < BSPIXMAPLIMIT; i++) - { - if ((nxagentBSPixmapList[i] != NULL) && - (nxagentBSPixmapList[i] -> storingPixmapId == pixmapId)) - { - free(nxagentBSPixmapList[i]); - nxagentBSPixmapList[i] = NULL; - - if (i < BSPIXMAPLIMIT - 1) - { - for (j = i; j < BSPIXMAPLIMIT -1; j++) - { - nxagentBSPixmapList[j] = nxagentBSPixmapList[j + 1]; - } - - if (nxagentBSPixmapList[j] == nxagentBSPixmapList[j - 1]) - { - nxagentBSPixmapList[j] = NULL; - } - } - - #ifdef TEST - fprintf(stderr, "nxagentRemoveItemBSPixmapList: Removed Pixmap with id [%lu] from list.\n", - pixmapId); - #endif - - return 1; - } - } - - #ifdef TEST - fprintf(stderr, "nxagentRemoveItemBSPixmapList: WARNING! Can't remove item [%lu]: item not found.\n", - pixmapId); - #endif - - return 0; -} - -int nxagentEmptyBSPixmapList(void) -{ - int i; - - for (i = 0; i < BSPIXMAPLIMIT; i++) - { - free(nxagentBSPixmapList[i]); - nxagentBSPixmapList[i] = NULL; - } - - return 1; -} - -StoringPixmapPtr nxagentFindItemBSPixmapList(unsigned long pixmapId) -{ - int i; - - for (i = 0; i < BSPIXMAPLIMIT; i++) - { - if ((nxagentBSPixmapList[i] != NULL) && - (nxagentBSPixmapList[i] -> storingPixmapId == pixmapId)) - { - #ifdef TEST - fprintf(stderr, "nxagentFindItemBSPixmapList: pixmapId [%lu].\n", pixmapId); - fprintf(stderr, "nxagentFindItemBSPixmapList: nxagentBSPixmapList[%d] -> storingPixmapId [%lu].\n", - i, nxagentBSPixmapList[i] -> storingPixmapId); - #endif - - return nxagentBSPixmapList[i]; - } - } - - #ifdef TEST - fprintf(stderr, "nxagentFindItemBSPixmapList: WARNING! Item not found.\n"); - #endif - - #ifdef TEST - fprintf(stderr, "nxagentFindItemBSPixmapList: Pixmap with id [%lu] not found.\n", - pixmapId); - fprintf(stderr, "nxagentBSPixmapList[%d] = [%p].\n", - i, (void *) nxagentBSPixmapList[i]); - #endif - - return NULL; -} - diff --git a/nx-X11/programs/Xserver/hw/nxagent/Windows.h b/nx-X11/programs/Xserver/hw/nxagent/Windows.h index 8612cdf82d..eb15bf0efb 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Windows.h +++ b/nx-X11/programs/Xserver/hw/nxagent/Windows.h @@ -31,6 +31,7 @@ #include "Pixmaps.h" #include "validate.h" +#include "privates.h" typedef struct { @@ -82,9 +83,9 @@ typedef struct SplitResourcePtr splitResource; -} nxagentPrivWindowRec; +} nxagentPrivWindowRec, *nxagentPrivWindowPtr; -typedef nxagentPrivWindowRec *nxagentPrivWindowPtr; +extern DevPrivateKeyRec nxagentWindowPrivateKeyRec; typedef struct { @@ -102,17 +103,12 @@ typedef struct typedef StoringPixmapRec *StoringPixmapPtr; -int nxagentAddItemBSPixmapList(unsigned long, PixmapPtr, WindowPtr, int, int); -int nxagentRemoveItemBSPixmapList(unsigned long); -void nxagentInitBSPixmapList(void); -int nxagentEmptyBSPixmapList(void); -StoringPixmapPtr nxagentFindItemBSPixmapList (unsigned long); - extern int nxagentWindowPrivateIndex; -#define nxagentWindowPriv(pWin) \ - ((nxagentPrivWindowPtr)((pWin)->devPrivates[nxagentWindowPrivateIndex].ptr)) +#define nxagentWindowPrivateKey (&nxagentWindowPrivateKeyRec) +#define nxagentWindowPriv(pWin) ((nxagentPrivWindowPtr) \ + dixLookupPrivate(&(pWin)->devPrivates, nxagentWindowPrivateKey)) #define nxagentWindow(pWin) (nxagentWindowPriv(pWin)->window) /* diff --git a/nx-X11/programs/Xserver/include/Imakefile b/nx-X11/programs/Xserver/include/Imakefile index 4c168edf10..9ffe4c81a7 100644 --- a/nx-X11/programs/Xserver/include/Imakefile +++ b/nx-X11/programs/Xserver/include/Imakefile @@ -14,9 +14,6 @@ all:: depend:: InstallDriverSDKNonExecFile(XIstubs.h,$(DRIVERSDKINCLUDEDIR)) -InstallDriverSDKNonExecFile(Xprintf.h,$(DRIVERSDKINCLUDEDIR)) -InstallDriverSDKNonExecFile(bstore.h,$(DRIVERSDKINCLUDEDIR)) -InstallDriverSDKNonExecFile(bstorestr.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(client.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(colormap.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(colormapst.h,$(DRIVERSDKINCLUDEDIR)) @@ -39,6 +36,7 @@ InstallDriverSDKNonExecFile(opaque.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(os.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(pixmap.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(pixmapstr.h,$(DRIVERSDKINCLUDEDIR)) +InstallDriverSDKNonExecFile(privates.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(property.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(propertyst.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(region.h,$(DRIVERSDKINCLUDEDIR)) diff --git a/nx-X11/programs/Xserver/include/bstore.h b/nx-X11/programs/Xserver/include/bstore.h deleted file mode 100644 index 843d6bb359..0000000000 --- a/nx-X11/programs/Xserver/include/bstore.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 1987 by the Regents of the University of California - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies. The University of - * California makes no representations about the suitability of this software - * for any purpose. It is provided "as is" without express or implied - * warranty. - */ - -/* - * Moved here from mi to allow wrapping of lower level backing store functions. - * -- 1997.10.27 Marc Aurele La France (tsi@xfree86.org) - */ - -#ifndef _BSTORE_H_ -#define _BSTORE_H_ - -#include "bstorestr.h" - -#endif /* _BSTORE_H_ */ diff --git a/nx-X11/programs/Xserver/include/bstorestr.h b/nx-X11/programs/Xserver/include/bstorestr.h deleted file mode 100644 index 14e2fe1dac..0000000000 --- a/nx-X11/programs/Xserver/include/bstorestr.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1987 by the Regents of the University of California - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose and without fee is hereby granted, provided - * that the above copyright notice appear in all copies. The University of - * California makes no representations about the suitability of this software - * for any purpose. It is provided "as is" without express or implied - * warranty. - */ - -/* - * Moved here from mi to allow wrapping of lower level backing store functions. - * -- 1997.10.27 Marc Aurele La France (tsi@xfree86.org) - */ - -#ifndef _BSTORESTR_H_ -#define _BSTORESTR_H_ - -#include "gc.h" -#include "pixmap.h" -#include "region.h" -#include "window.h" - -typedef void (* BackingStoreSaveAreasProcPtr)( - PixmapPtr /*pBackingPixmap*/, - RegionPtr /*pObscured*/, - int /*x*/, - int /*y*/, - WindowPtr /*pWin*/); - -typedef void (* BackingStoreRestoreAreasProcPtr)( - PixmapPtr /*pBackingPixmap*/, - RegionPtr /*pExposed*/, - int /*x*/, - int /*y*/, - WindowPtr /*pWin*/); - -typedef void (* BackingStoreSetClipmaskRgnProcPtr)( - GCPtr /*pBackingGC*/, - RegionPtr /*pbackingCompositeClip*/); - -typedef PixmapPtr (* BackingStoreGetImagePixmapProcPtr)(void); - -typedef PixmapPtr (* BackingStoreGetSpansPixmapProcPtr)(void); - -typedef struct _BSFuncs { - - BackingStoreSaveAreasProcPtr SaveAreas; - BackingStoreRestoreAreasProcPtr RestoreAreas; - BackingStoreSetClipmaskRgnProcPtr SetClipmaskRgn; - BackingStoreGetImagePixmapProcPtr GetImagePixmap; - BackingStoreGetSpansPixmapProcPtr GetSpansPixmap; - -} BSFuncRec, *BSFuncPtr; - -#endif /* _BSTORESTR_H_ */ diff --git a/nx-X11/programs/Xserver/include/colormapst.h b/nx-X11/programs/Xserver/include/colormapst.h index d269875810..9aca6bc39d 100644 --- a/nx-X11/programs/Xserver/include/colormapst.h +++ b/nx-X11/programs/Xserver/include/colormapst.h @@ -48,10 +48,9 @@ SOFTWARE. #ifndef CMAPSTRUCT_H #define CMAPSTRUCT_H 1 -#include - #include "colormap.h" #include "screenint.h" +#include "privates.h" /* Shared color -- the color is used by AllocColorPlanes */ typedef struct @@ -90,26 +89,15 @@ typedef struct _CMEntry Bool fShared; } Entry; -/* - * COLORMAPs can be used for either Direct or Pseudo color. PseudoColor +/* COLORMAPs can be used for either Direct or Pseudo color. PseudoColor * only needs one cell table, we arbitrarily pick red. We keep track - * of that table with freeRed, numPixelsRed, and clientPixelsRed - * - * The padN variables are unfortunate ABI BC. See fdo bug #6924. - */ + * of that table with freeRed, numPixelsRed, and clientPixelsRed */ typedef struct _ColormapRec { VisualPtr pVisual; short class; /* PseudoColor or DirectColor */ -#if defined(_XSERVER64) - short pad0; - XID pad1; -#endif XID mid; /* client's name for colormap */ -#if defined(_XSERVER64) && (X_BYTE_ORDER == X_LITTLE_ENDIAN) - XID pad2; -#endif ScreenPtr pScreen; /* screen map is associated with */ short flags; /* 1 = IsDefault * 2 = AllAllocated */ @@ -126,7 +114,7 @@ typedef struct _ColormapRec Entry *green; Entry *blue; void * devPriv; - DevUnion *devPrivates; /* dynamic devPrivates added after devPriv + PrivateRec *devPrivates; /* dynamic devPrivates added after devPriv already existed - must keep devPriv */ } ColormapRec; diff --git a/nx-X11/programs/Xserver/include/cursor.h b/nx-X11/programs/Xserver/include/cursor.h index 4b94448886..50b5e7f642 100644 --- a/nx-X11/programs/Xserver/include/cursor.h +++ b/nx-X11/programs/Xserver/include/cursor.h @@ -51,6 +51,7 @@ SOFTWARE. #include "misc.h" #include "screenint.h" #include "window.h" +#include "privates.h" #define NullCursor ((CursorPtr)NULL) @@ -62,6 +63,10 @@ SOFTWARE. typedef struct _Cursor *CursorPtr; typedef struct _CursorMetric *CursorMetricPtr; +extern DevScreenPrivateKeyRec cursorScreenDevPriv; + +#define CursorScreenKey (&cursorScreenDevPriv) + extern CursorPtr rootCursor; extern int FreeCursor( diff --git a/nx-X11/programs/Xserver/include/cursorstr.h b/nx-X11/programs/Xserver/include/cursorstr.h index bc7d24c041..8a41342f5a 100644 --- a/nx-X11/programs/Xserver/include/cursorstr.h +++ b/nx-X11/programs/Xserver/include/cursorstr.h @@ -49,6 +49,8 @@ SOFTWARE. #define CURSORSTRUCT_H #include "cursor.h" +#include "privates.h" + /* * device-independent cursor storage */ @@ -63,24 +65,28 @@ typedef struct _CursorBits { Bool emptyMask; /* all zeros mask */ unsigned short width, height, xhot, yhot; /* metrics */ int refcnt; /* can be shared */ - void * devPriv[MAXSCREENS]; /* set by pScr->RealizeCursor*/ + PrivateRec *devPrivates; /* set by pScr->RealizeCursor */ #ifdef ARGB_CURSOR CARD32 *argb; /* full-color alpha blended */ #endif } CursorBits, *CursorBitsPtr; +#define CURSOR_BITS_SIZE (sizeof(CursorBits) + dixPrivatesSize(PRIVATE_CURSOR_BITS)) + typedef struct _Cursor { CursorBitsPtr bits; unsigned short foreRed, foreGreen, foreBlue; /* device-independent color */ unsigned short backRed, backGreen, backBlue; /* device-independent color */ int refcnt; - void * devPriv[MAXSCREENS]; /* set by pScr->RealizeCursor*/ + PrivateRec *devPrivates; /* set by pScr->RealizeCursor */ #ifdef XFIXES CARD32 serialNumber; Atom name; #endif } CursorRec; +#define CURSOR_REC_SIZE (sizeof(CursorRec) + dixPrivatesSize(PRIVATE_CURSOR)) + typedef struct _CursorMetric { unsigned short width, height, xhot, yhot; } CursorMetricRec; diff --git a/nx-X11/programs/Xserver/include/dix.h b/nx-X11/programs/Xserver/include/dix.h index 4a57f724d1..4bca741107 100644 --- a/nx-X11/programs/Xserver/include/dix.h +++ b/nx-X11/programs/Xserver/include/dix.h @@ -62,6 +62,7 @@ SOFTWARE. #define REQUEST(type) \ register type *stuff = (type *)client->requestBuffer +#define ARRAY_SIZE(a) (sizeof((a)) / sizeof((a)[0])) #define REQUEST_SIZE_MATCH(req)\ if ((sizeof(req) >> 2) != client->req_len)\ @@ -667,14 +668,6 @@ void ScreenRestructured (ScreenPtr pScreen); #endif -extern void ResetClientPrivates(void); - -extern int AllocateClientPrivateIndex(void); - -extern Bool AllocateClientPrivate( - int /*index*/, - unsigned /*amount*/); - /* * callback manager stuff */ diff --git a/nx-X11/programs/Xserver/include/dixstruct.h b/nx-X11/programs/Xserver/include/dixstruct.h index cdd2543a6a..6a56c818eb 100644 --- a/nx-X11/programs/Xserver/include/dixstruct.h +++ b/nx-X11/programs/Xserver/include/dixstruct.h @@ -30,6 +30,7 @@ SOFTWARE. #include "cursor.h" #include "gc.h" #include "pixmap.h" +#include "privates.h" #include /* @@ -112,7 +113,7 @@ typedef struct _Client { Bool big_requests; /* supports large requests */ int priority; ClientState clientState; - DevUnion *devPrivates; + PrivateRec *devPrivates; #ifdef XKB unsigned short xkbClientFlags; unsigned short mapNotifyMask; diff --git a/nx-X11/programs/Xserver/include/extnsionst.h b/nx-X11/programs/Xserver/include/extnsionst.h index 09cbb6b4c2..5a1342e224 100644 --- a/nx-X11/programs/Xserver/include/extnsionst.h +++ b/nx-X11/programs/Xserver/include/extnsionst.h @@ -53,6 +53,7 @@ SOFTWARE. #include "screenint.h" #include "extension.h" #include "gc.h" +#include "privates.h" typedef struct _ExtensionEntry { int index; @@ -72,7 +73,7 @@ typedef struct _ExtensionEntry { #ifdef XCSECURITY Bool secure; /* extension visible to untrusted clients? */ #endif - DevUnion *devPrivates; + PrivateRec *devPrivates; } ExtensionEntry; /* diff --git a/nx-X11/programs/Xserver/include/gcstruct.h b/nx-X11/programs/Xserver/include/gcstruct.h index 9a8169cab7..af25d3e717 100644 --- a/nx-X11/programs/Xserver/include/gcstruct.h +++ b/nx-X11/programs/Xserver/include/gcstruct.h @@ -56,6 +56,7 @@ SOFTWARE. #include "region.h" #include "pixmap.h" #include "screenint.h" +#include "privates.h" #include /* @@ -92,7 +93,6 @@ typedef struct _GCFuncs { void (* CopyClip)( GCPtr /*pgcDst*/, GCPtr /*pgcSrc*/); - DevUnion devPrivate; } GCFuncs; /* @@ -265,8 +265,6 @@ typedef struct _GCOps { #ifdef NEED_LINEHELPER void (* LineHelper)(); #endif - - DevUnion devPrivate; } GCOps; /* there is padding in the bit fields because the Sun compiler doesn't @@ -312,7 +310,7 @@ typedef struct _GC { unsigned long serialNumber; GCFuncs *funcs; GCOps *ops; - DevUnion *devPrivates; + PrivateRec *devPrivates; /* * The following were moved here from private storage to allow device- * independent access to them from screen wrappers. diff --git a/nx-X11/programs/Xserver/include/input.h b/nx-X11/programs/Xserver/include/input.h index 7cfbf32a70..ce6597b073 100644 --- a/nx-X11/programs/Xserver/include/input.h +++ b/nx-X11/programs/Xserver/include/input.h @@ -154,10 +154,6 @@ typedef struct { unsigned char id; } LedCtrl; -extern int AllocateDevicePrivateIndex(void); -extern Bool AllocateDevicePrivate(DeviceIntPtr device, int index); -extern void ResetDevicePrivateIndex(void); - extern KeybdCtrl defaultKeyboardControl; extern PtrCtrl defaultPointerControl; diff --git a/nx-X11/programs/Xserver/include/inputstr.h b/nx-X11/programs/Xserver/include/inputstr.h index 5e2e269680..e94d456613 100644 --- a/nx-X11/programs/Xserver/include/inputstr.h +++ b/nx-X11/programs/Xserver/include/inputstr.h @@ -283,7 +283,7 @@ typedef struct _DeviceIntRec { #ifdef XKB struct _XkbInterest * xkb_interest; #endif - DevUnion *devPrivates; + PrivateRec *devPrivates; int nPrivates; DeviceUnwrapProc unwrapProc; } DeviceIntRec; diff --git a/nx-X11/programs/Xserver/include/misc.h b/nx-X11/programs/Xserver/include/misc.h index 27137cd504..a7757ee044 100644 --- a/nx-X11/programs/Xserver/include/misc.h +++ b/nx-X11/programs/Xserver/include/misc.h @@ -109,6 +109,9 @@ extern unsigned long serverGeneration; #define MAXFORMATS 8 #define MAXVISUALS_PER_SCREEN 50 +#define EXTENSION_EVENT_BASE 64 +#define EXTENSION_BASE 128 + typedef unsigned long PIXEL; typedef unsigned long ATOM; diff --git a/nx-X11/programs/Xserver/include/miscstruct.h b/nx-X11/programs/Xserver/include/miscstruct.h index f3cd476148..a519be36b4 100644 --- a/nx-X11/programs/Xserver/include/miscstruct.h +++ b/nx-X11/programs/Xserver/include/miscstruct.h @@ -59,20 +59,10 @@ typedef xPoint DDXPointRec; typedef struct pixman_box16 BoxRec; typedef union _DevUnion { - void * ptr; - long val; - unsigned long uval; - RegionPtr (*fptr)( - DrawablePtr /* pSrcDrawable */, - DrawablePtr /* pDstDrawable */, - GCPtr /* pGC */, - int /* srcx */, - int /* srcy */, - int /* width */, - int /* height */, - int /* dstx */, - int /* dsty */, - unsigned long /* bitPlane */); + void *ptr; + long val; + unsigned long uval; + void *(*fptr) (void); } DevUnion; #endif /* MISCSTRUCT_H */ diff --git a/nx-X11/programs/Xserver/include/opaque.h b/nx-X11/programs/Xserver/include/opaque.h index c68275394c..3dcf773454 100644 --- a/nx-X11/programs/Xserver/include/opaque.h +++ b/nx-X11/programs/Xserver/include/opaque.h @@ -58,7 +58,6 @@ extern Bool explicit_display; extern int defaultBackingStore; extern Bool disableBackingStore; extern Bool enableBackingStore; -extern Bool disableSaveUnders; extern Bool PartialNetwork; #ifndef NOLOGOHACK extern int logoScreenSaver; diff --git a/nx-X11/programs/Xserver/include/pixmap.h b/nx-X11/programs/Xserver/include/pixmap.h index 7d893d57ca..90c6dcbe07 100644 --- a/nx-X11/programs/Xserver/include/pixmap.h +++ b/nx-X11/programs/Xserver/include/pixmap.h @@ -105,4 +105,6 @@ extern PixmapPtr AllocatePixmap( ScreenPtr /*pScreen*/, int /*pixDataSize*/); +extern void FreePixmap(PixmapPtr /*pPixmap */ ); + #endif /* PIXMAP_H */ diff --git a/nx-X11/programs/Xserver/include/pixmapstr.h b/nx-X11/programs/Xserver/include/pixmapstr.h index d7f934a346..88723a2120 100644 --- a/nx-X11/programs/Xserver/include/pixmapstr.h +++ b/nx-X11/programs/Xserver/include/pixmapstr.h @@ -51,6 +51,7 @@ SOFTWARE. #include "pixmap.h" #include "screenint.h" #include "regionstr.h" +#include "privates.h" /* * The padN members are unfortunate ABI BC. See fdo bug #6924. @@ -82,12 +83,10 @@ typedef struct _Drawable { typedef struct _Pixmap { DrawableRec drawable; + PrivateRec *devPrivates; int refcnt; int devKind; DevUnion devPrivate; -#ifdef PIXPRIV - DevUnion *devPrivates; /* real devPrivates like gcs & windows */ -#endif #ifdef COMPOSITE short screen_x; short screen_y; diff --git a/nx-X11/programs/Xserver/include/privates.h b/nx-X11/programs/Xserver/include/privates.h new file mode 100644 index 0000000000..e89c3e4401 --- /dev/null +++ b/nx-X11/programs/Xserver/include/privates.h @@ -0,0 +1,363 @@ +/*********************************************************** + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +******************************************************************/ + +#ifndef PRIVATES_H +#define PRIVATES_H 1 + +#include +#include +#include +#include "misc.h" + +/***************************************************************** + * STUFF FOR PRIVATES + *****************************************************************/ + +typedef struct _Private PrivateRec, *PrivatePtr; + +typedef enum { + /* XSELinux uses the same private keys for numerous objects */ + PRIVATE_XSELINUX, + + /* Otherwise, you get a private in just the requested structure + */ + /* These can have objects created before all of the keys are registered */ + PRIVATE_SCREEN, + PRIVATE_EXTENSION, + PRIVATE_COLORMAP, + PRIVATE_DEVICE, + + /* These cannot have any objects before all relevant keys are registered */ + PRIVATE_CLIENT, + PRIVATE_PROPERTY, + PRIVATE_SELECTION, + PRIVATE_WINDOW, + PRIVATE_PIXMAP, + PRIVATE_GC, + PRIVATE_CURSOR, + PRIVATE_CURSOR_BITS, + + /* extension privates */ + PRIVATE_GLYPH, + PRIVATE_GLYPHSET, + PRIVATE_PICTURE, + PRIVATE_SYNC_FENCE, + + /* last private type */ + PRIVATE_LAST, +} DevPrivateType; + +typedef struct _DevPrivateKeyRec { + int offset; + int size; + Bool initialized; + Bool allocated; + DevPrivateType type; + struct _DevPrivateKeyRec *next; +} DevPrivateKeyRec, *DevPrivateKey; + +typedef struct _DevPrivateSetRec { + DevPrivateKey key; + unsigned offset; + int created; + int allocated; +} DevPrivateSetRec, *DevPrivateSetPtr; + +typedef struct _DevScreenPrivateKeyRec { + DevPrivateKeyRec screenKey; +} DevScreenPrivateKeyRec, *DevScreenPrivateKey; + +/* + * Let drivers know how to initialize private keys + */ + +#define HAS_DEVPRIVATEKEYREC 1 +#define HAS_DIXREGISTERPRIVATEKEY 1 + +/* + * Register a new private index for the private type. + * + * This initializes the specified key and optionally requests pre-allocated + * private space for your driver/module. If you request no extra space, you + * may set and get a single pointer value using this private key. Otherwise, + * you can get the address of the extra space and store whatever data you like + * there. + * + * You may call dixRegisterPrivateKey more than once on the same key, but the + * size and type must match or the server will abort. + * + * dixRegisterPrivateKey returns FALSE if it fails to allocate memory + * during its operation. + */ +extern _X_EXPORT Bool + dixRegisterPrivateKey(DevPrivateKey key, DevPrivateType type, unsigned size); + +/* + * Check whether a private key has been registered + */ +static inline Bool +dixPrivateKeyRegistered(DevPrivateKey key) +{ + return key->initialized; +} + +/* + * Get the address of the private storage. + * + * For keys with pre-defined storage, this gets the base of that storage + * Otherwise, it returns the place where the private pointer is stored. + */ +static inline void * +dixGetPrivateAddr(PrivatePtr *privates, const DevPrivateKey key) +{ + assert(key->initialized); + return (char *) (*privates) + key->offset; +} + +/* + * Fetch a private pointer stored in the object + * + * Returns the pointer stored with dixSetPrivate. + * This must only be used with keys that have + * no pre-defined storage + */ +static inline void * +dixGetPrivate(PrivatePtr *privates, const DevPrivateKey key) +{ + assert(key->size == 0); + return *(void **) dixGetPrivateAddr(privates, key); +} + +/* + * Associate 'val' with 'key' in 'privates' so that later calls to + * dixLookupPrivate(privates, key) will return 'val'. + */ +static inline void +dixSetPrivate(PrivatePtr *privates, const DevPrivateKey key, void *val) +{ + assert(key->size == 0); + *(void **) dixGetPrivateAddr(privates, key) = val; +} + +#include "dix.h" +#include "resource.h" + +/* + * Lookup a pointer to the private record. + * + * For privates with defined storage, return the address of the + * storage. For privates without defined storage, return the pointer + * contents + */ +static inline void * +dixLookupPrivate(PrivatePtr *privates, const DevPrivateKey key) +{ + if (key->size) + return dixGetPrivateAddr(privates, key); + else + return dixGetPrivate(privates, key); +} + +/* + * Look up the address of the pointer to the storage + * + * This returns the place where the private pointer is stored, + * which is only valid for privates without predefined storage. + */ +static inline void ** +dixLookupPrivateAddr(PrivatePtr *privates, const DevPrivateKey key) +{ + assert(key->size == 0); + return (void **) dixGetPrivateAddr(privates, key); +} + +extern _X_EXPORT Bool + +dixRegisterScreenPrivateKey(DevScreenPrivateKey key, ScreenPtr pScreen, + DevPrivateType type, unsigned size); + +extern _X_EXPORT DevPrivateKey + _dixGetScreenPrivateKey(const DevScreenPrivateKey key, ScreenPtr pScreen); + +static inline void * +dixGetScreenPrivateAddr(PrivatePtr *privates, const DevScreenPrivateKey key, + ScreenPtr pScreen) +{ + return dixGetPrivateAddr(privates, _dixGetScreenPrivateKey(key, pScreen)); +} + +static inline void * +dixGetScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key, + ScreenPtr pScreen) +{ + return dixGetPrivate(privates, _dixGetScreenPrivateKey(key, pScreen)); +} + +static inline void +dixSetScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key, + ScreenPtr pScreen, void *val) +{ + dixSetPrivate(privates, _dixGetScreenPrivateKey(key, pScreen), val); +} + +static inline void * +dixLookupScreenPrivate(PrivatePtr *privates, const DevScreenPrivateKey key, + ScreenPtr pScreen) +{ + return dixLookupPrivate(privates, _dixGetScreenPrivateKey(key, pScreen)); +} + +static inline void ** +dixLookupScreenPrivateAddr(PrivatePtr *privates, const DevScreenPrivateKey key, + ScreenPtr pScreen) +{ + return dixLookupPrivateAddr(privates, + _dixGetScreenPrivateKey(key, pScreen)); +} + +/* + * These functions relate to allocations related to a specific screen; + * space will only be available for objects allocated for use on that + * screen. As such, only objects which are related directly to a specific + * screen are candidates for allocation this way, this includes + * windows, pixmaps, gcs, pictures and colormaps. This key is + * used just like any other key using dixGetPrivate and friends. + * + * This is distinctly different from the ScreenPrivateKeys above which + * allocate space in global objects like cursor bits for a specific + * screen, allowing multiple screen-related chunks of storage in a + * single global object. + */ + +#define HAVE_SCREEN_SPECIFIC_PRIVATE_KEYS 1 + +extern _X_EXPORT Bool +dixRegisterScreenSpecificPrivateKey(ScreenPtr pScreen, DevPrivateKey key, + DevPrivateType type, unsigned size); + +/* Clean up screen-specific privates before CloseScreen */ +extern void +dixFreeScreenSpecificPrivates(ScreenPtr pScreen); + +/* Initialize screen-specific privates in AddScreen */ +extern void +dixInitScreenSpecificPrivates(ScreenPtr pScreen); + +/* is this private created - so hotplug can avoid crashing */ +Bool dixPrivatesCreated(DevPrivateType type); + +extern _X_EXPORT void * +_dixAllocateScreenObjectWithPrivates(ScreenPtr pScreen, + unsigned size, + unsigned clear, + unsigned offset, + DevPrivateType type); + +#define dixAllocateScreenObjectWithPrivates(s, t, type) _dixAllocateScreenObjectWithPrivates(s, sizeof(t), sizeof(t), offsetof(t, devPrivates), type) + +extern _X_EXPORT int +dixScreenSpecificPrivatesSize(ScreenPtr pScreen, DevPrivateType type); + +extern _X_EXPORT void +_dixInitScreenPrivates(ScreenPtr pScreen, PrivatePtr *privates, void *addr, DevPrivateType type); + +#define dixInitScreenPrivates(s, o, v, type) _dixInitScreenPrivates(s, &(o)->devPrivates, (v), type); + +/* + * Allocates private data separately from main object. + * + * For objects created during server initialization, this allows those + * privates to be re-allocated as new private keys are registered. + * + * This includes screens, the serverClient, default colormaps and + * extensions entries. + */ +extern _X_EXPORT Bool + dixAllocatePrivates(PrivatePtr *privates, DevPrivateType type); + +/* + * Frees separately allocated private data + */ +extern _X_EXPORT void + dixFreePrivates(PrivatePtr privates, DevPrivateType type); + +/* + * Initialize privates by zeroing them + */ +extern _X_EXPORT void +_dixInitPrivates(PrivatePtr *privates, void *addr, DevPrivateType type); + +#define dixInitPrivates(o, v, type) _dixInitPrivates(&(o)->devPrivates, (v), type); + +/* + * Clean up privates + */ +extern _X_EXPORT void + _dixFiniPrivates(PrivatePtr privates, DevPrivateType type); + +#define dixFiniPrivates(o,t) _dixFiniPrivates((o)->devPrivates,t) + +/* + * Allocates private data at object creation time. Required + * for almost all objects, except for the list described + * above for dixAllocatePrivates. + */ +extern _X_EXPORT void *_dixAllocateObjectWithPrivates(unsigned size, + unsigned clear, + unsigned offset, + DevPrivateType type); + +#define dixAllocateObjectWithPrivates(t, type) (t *) _dixAllocateObjectWithPrivates(sizeof(t), sizeof(t), offsetof(t, devPrivates), type) + +extern _X_EXPORT void + +_dixFreeObjectWithPrivates(void *object, PrivatePtr privates, + DevPrivateType type); + +#define dixFreeObjectWithPrivates(o,t) _dixFreeObjectWithPrivates(o, (o)->devPrivates, t) + +/* + * Return size of privates for the specified type + */ +extern _X_EXPORT int + dixPrivatesSize(DevPrivateType type); + +/* + * Dump out private stats to ErrorF + */ +extern void + dixPrivateUsage(void); + +/* + * Resets the privates subsystem. dixResetPrivates is called from the main loop + * before each server generation. This function must only be called by main(). + */ +extern _X_EXPORT void + dixResetPrivates(void); + +/* + * Looks up the offset where the devPrivates field is located. + * + * Returns -1 if the specified resource has no dev privates. + * The position of the devPrivates field varies by structure + * and calling code might only know the resource type, not the + * structure definition. + */ +extern _X_EXPORT int + dixLookupPrivateOffset(RESTYPE type); + +/* + * Convenience macro for adding an offset to an object pointer + * when making a call to one of the devPrivates functions + */ +#define DEVPRIV_AT(ptr, offset) ((PrivatePtr *)((char *)(ptr) + offset)) + +#endif /* PRIVATES_H */ diff --git a/nx-X11/programs/Xserver/include/propertyst.h b/nx-X11/programs/Xserver/include/propertyst.h index 493d6595ef..3e48680e73 100644 --- a/nx-X11/programs/Xserver/include/propertyst.h +++ b/nx-X11/programs/Xserver/include/propertyst.h @@ -60,6 +60,7 @@ typedef struct _Property { short format; /* format of data for swapping - 8,16,32 */ long size; /* size of data in (format/8) bytes */ void *data; /* private to client */ + PrivateRec *devPrivates; } PropertyRec; #endif /* PROPERTYSTRUCT_H */ diff --git a/nx-X11/programs/Xserver/include/screenint.h b/nx-X11/programs/Xserver/include/screenint.h index abaa6f85b1..b6dfc91e03 100644 --- a/nx-X11/programs/Xserver/include/screenint.h +++ b/nx-X11/programs/Xserver/include/screenint.h @@ -55,28 +55,6 @@ typedef struct _Visual *VisualPtr; typedef struct _Depth *DepthPtr; typedef struct _Screen *ScreenPtr; -extern void ResetScreenPrivates(void); - -extern int AllocateScreenPrivateIndex(void); - -extern void ResetWindowPrivates(void); - -extern int AllocateWindowPrivateIndex(void); - -extern Bool AllocateWindowPrivate( - ScreenPtr /* pScreen */, - int /* index */, - unsigned /* amount */); - -extern void ResetGCPrivates(void); - -extern int AllocateGCPrivateIndex(void); - -extern Bool AllocateGCPrivate( - ScreenPtr /* pScreen */, - int /* index */, - unsigned /* amount */); - extern int AddScreen( Bool (* /*pfnInit*/)( ScreenPtr /*pScreen*/, @@ -85,26 +63,6 @@ extern int AddScreen( int /*argc*/, char** /*argv*/); -#ifdef PIXPRIV - -extern void ResetPixmapPrivates(void); - -extern int AllocatePixmapPrivateIndex(void); - -extern Bool AllocatePixmapPrivate( - ScreenPtr /* pScreen */, - int /* index */, - unsigned /* amount */); - -#endif /* PIXPRIV */ - -extern void ResetColormapPrivates(void); - - typedef struct _ColormapRec *ColormapPtr; -typedef int (*InitCmapPrivFunc)(ColormapPtr, int); - -extern int AllocateColormapPrivateIndex( - InitCmapPrivFunc /* initPrivFunc */); #endif /* SCREENINT_H */ diff --git a/nx-X11/programs/Xserver/include/scrnintstr.h b/nx-X11/programs/Xserver/include/scrnintstr.h index 5a3f32309e..33741b8ae3 100644 --- a/nx-X11/programs/Xserver/include/scrnintstr.h +++ b/nx-X11/programs/Xserver/include/scrnintstr.h @@ -50,12 +50,12 @@ SOFTWARE. #include "screenint.h" #include "regionstr.h" -#include "bstore.h" #include "colormap.h" #include "cursor.h" #include "validate.h" #include #include "dix.h" +#include "privates.h" typedef struct _PixmapFormat { unsigned char depth; @@ -213,48 +213,6 @@ typedef PixmapPtr (* CreatePixmapProcPtr)( typedef Bool (* DestroyPixmapProcPtr)( PixmapPtr /*pPixmap*/); -typedef void (* SaveDoomedAreasProcPtr)( - WindowPtr /*pWindow*/, - RegionPtr /*prgnSave*/, - int /*xorg*/, - int /*yorg*/); - -typedef RegionPtr (* RestoreAreasProcPtr)( - WindowPtr /*pWindow*/, - RegionPtr /*prgnRestore*/); - -typedef void (* ExposeCopyProcPtr)( - WindowPtr /*pSrc*/, - DrawablePtr /*pDst*/, - GCPtr /*pGC*/, - RegionPtr /*prgnExposed*/, - int /*srcx*/, - int /*srcy*/, - int /*dstx*/, - int /*dsty*/, - unsigned long /*plane*/); - -typedef RegionPtr (* TranslateBackingStoreProcPtr)( - WindowPtr /*pWindow*/, - int /*windx*/, - int /*windy*/, - RegionPtr /*oldClip*/, - int /*oldx*/, - int /*oldy*/); - -typedef RegionPtr (* ClearBackingStoreProcPtr)( - WindowPtr /*pWindow*/, - int /*x*/, - int /*y*/, - int /*w*/, - int /*h*/, - Bool /*generateExposures*/); - -typedef void (* DrawGuaranteeProcPtr)( - WindowPtr /*pWindow*/, - GCPtr /*pGC*/, - int /*guarantee*/); - typedef Bool (* RealizeFontProcPtr)( ScreenPtr /*pScreen*/, FontPtr /*pFont*/); @@ -566,12 +524,8 @@ typedef struct _Screen { short numVisuals; VisualPtr visuals; WindowPtr root; - int WindowPrivateLen; - unsigned *WindowPrivateSizes; - unsigned totalWindowSize; - int GCPrivateLen; - unsigned *GCPrivateSizes; - unsigned totalGCSize; + + DevPrivateSetRec screenSpecificPrivates[PRIVATE_LAST]; /* Random screen procedures */ @@ -606,20 +560,6 @@ typedef struct _Screen { CreatePixmapProcPtr CreatePixmap; DestroyPixmapProcPtr DestroyPixmap; - /* Backing store procedures */ - - SaveDoomedAreasProcPtr SaveDoomedAreas; - RestoreAreasProcPtr RestoreAreas; - ExposeCopyProcPtr ExposeCopy; - TranslateBackingStoreProcPtr TranslateBackingStore; - ClearBackingStoreProcPtr ClearBackingStore; - DrawGuaranteeProcPtr DrawGuarantee; - /* - * A read/write copy of the lower level backing store vector is needed now - * that the functions can be wrapped. - */ - BSFuncRec BackingStoreFuncs; - /* Font procedures */ RealizeFontProcPtr RealizeFont; @@ -690,7 +630,7 @@ typedef struct _Screen { void * wakeupData; /* anybody can get a piece of this array */ - DevUnion *devPrivates; + PrivateRec *devPrivates; CreateScreenResourcesProcPtr CreateScreenResources; ModifyPixmapHeaderProcPtr ModifyPixmapHeader; diff --git a/nx-X11/programs/Xserver/include/window.h b/nx-X11/programs/Xserver/include/window.h index 6e93e8ff8d..fdd5698be0 100644 --- a/nx-X11/programs/Xserver/include/window.h +++ b/nx-X11/programs/Xserver/include/window.h @@ -264,11 +264,6 @@ extern RegionPtr CreateBoundingShape( extern RegionPtr CreateClipShape( WindowPtr /* pWin */ ); -extern void DisableMapUnmapEvents( +extern VisualPtr WindowGetVisual( WindowPtr /* pWin */ ); -extern void EnableMapUnmapEvents( - WindowPtr /* pWin */ ); -extern Bool MapUnmapEventsEnabled( - WindowPtr /* pWin */ ); - #endif /* WINDOW_H */ diff --git a/nx-X11/programs/Xserver/include/windowstr.h b/nx-X11/programs/Xserver/include/windowstr.h index 36d598c6e5..f7efa7bf36 100644 --- a/nx-X11/programs/Xserver/include/windowstr.h +++ b/nx-X11/programs/Xserver/include/windowstr.h @@ -59,9 +59,6 @@ SOFTWARE. #include #include "opaque.h" -#define GuaranteeNothing 0 -#define GuaranteeVisBack 1 - #define SameBackground(as, a, bs, b) \ ((as) == (bs) && ((as) == None || \ (as) == ParentRelative || \ @@ -165,7 +162,7 @@ typedef struct _Window { #ifdef COMPOSITE unsigned redirectDraw:2; /* rendering is redirected from here */ #endif - DevUnion *devPrivates; + PrivateRec *devPrivates; } WindowRec; /* @@ -233,23 +230,4 @@ typedef struct _ScreenSaverStuff { extern int screenIsSaved; extern ScreenSaverStuffRec savedScreenInfo[MAXSCREENS]; -/* - * this is the configuration parameter "NO_BACK_SAVE" - * it means that any existant backing store should not - * be used to implement save unders. - */ - -#ifndef NO_BACK_SAVE -#define DO_SAVE_UNDERS(pWin) ((pWin)->drawable.pScreen->saveUnderSupport ==\ - USE_DIX_SAVE_UNDERS) -/* - * saveUnderSupport is set to this magic value when using DIXsaveUnders - */ - -#define USE_DIX_SAVE_UNDERS 0x40 -#endif - -extern int numSaveUndersViewable; -extern int deltaSaveUndersViewable; - #endif /* WINDOWSTRUCT_H */ diff --git a/nx-X11/programs/Xserver/include/xkbsrv.h b/nx-X11/programs/Xserver/include/xkbsrv.h index 9f9ccc5c3f..e1516e004e 100644 --- a/nx-X11/programs/Xserver/include/xkbsrv.h +++ b/nx-X11/programs/Xserver/include/xkbsrv.h @@ -244,12 +244,18 @@ typedef struct oldprocs->unwrapProc = device->unwrapProc; \ device->unwrapProc = unwrapproc; -#define UNWRAP_PROCESS_INPUT_PROC(device, oldprocs) \ - device->public.processInputProc = oldprocs->processInputProc; \ +#define UNWRAP_PROCESS_INPUT_PROC(device, oldprocs, backupproc) \ + backupproc = device->public.realInputProc; \ + if (device->public.processInputProc == device->public.realInputProc)\ + device->public.processInputProc = oldprocs->realInputProc; \ device->public.realInputProc = oldprocs->realInputProc; \ device->unwrapProc = oldprocs->unwrapProc; -#define XKBDEVICEINFO(dev) ((xkbDeviceInfoPtr) (dev)->devPrivates[xkbDevicePrivateIndex].ptr) +extern DevPrivateKeyRec xkbDevicePrivateKeyRec; + +#define xkbDevicePrivateKey (&xkbDevicePrivateKeyRec) + +#define XKBDEVICEINFO(dev) ((xkbDeviceInfoPtr)dixLookupPrivate(&(dev)->devPrivates, xkbDevicePrivateKey)) /***====================================================================***/ @@ -343,6 +349,8 @@ extern int XkbProcessArguments( int /* i */ ); +extern Bool XkbInitPrivates(void); + extern void XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc); extern void XkbFreeCompatMap( diff --git a/nx-X11/programs/Xserver/mi/Imakefile b/nx-X11/programs/Xserver/mi/Imakefile index 9124ace89c..3282cb3b84 100644 --- a/nx-X11/programs/Xserver/mi/Imakefile +++ b/nx-X11/programs/Xserver/mi/Imakefile @@ -73,7 +73,6 @@ SRCS = $(CBRT_SRC) \ mizerclip.c \ mifpolycon.c \ midash.c \ - mibstore.c \ $(MIINITEXTSRC) \ mieq.c \ mipointer.c \ @@ -111,7 +110,6 @@ OBJS = $(CBRT_OBJ) \ mizerclip.o \ mifpolycon.o \ midash.o \ - mibstore.o \ $(MIINITEXTOBJ) \ mieq.o \ mipointer.o \ @@ -190,7 +188,6 @@ AllTarget($(EXTRAMIINITEXTOBJ)) DependTarget() InstallDriverSDKNonExecFile(mi.h,$(DRIVERSDKINCLUDEDIR)) -InstallDriverSDKNonExecFile(mibstore.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(micmap.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(migc.h,$(DRIVERSDKINCLUDEDIR)) InstallDriverSDKNonExecFile(miline.h,$(DRIVERSDKINCLUDEDIR)) diff --git a/nx-X11/programs/Xserver/mi/mi.h b/nx-X11/programs/Xserver/mi/mi.h index a1ad969ac2..207b0bc3a9 100644 --- a/nx-X11/programs/Xserver/mi/mi.h +++ b/nx-X11/programs/Xserver/mi/mi.h @@ -55,6 +55,8 @@ SOFTWARE. #include #include "input.h" #include "cursor.h" +#include "privates.h" +#include "colormap.h" #define MiBits CARD32 @@ -456,7 +458,7 @@ extern Bool miScreenInit( VisualPtr /*visuals*/ ); -extern int miAllocateGCPrivateIndex( +extern DevPrivateKeyRec miAllocateGCPrivateKeyRec( void ); @@ -530,16 +532,6 @@ extern void miClearToBackground( Bool /*generateExposures*/ ); -extern Bool miChangeSaveUnder( - WindowPtr /*pWin*/, - WindowPtr /*first*/ -); - -extern void miPostChangeSaveUnder( - WindowPtr /*pWin*/, - WindowPtr /*pFirst*/ -); - extern void miMarkWindow( WindowPtr /*pWin*/ ); diff --git a/nx-X11/programs/Xserver/mi/mibstore.c b/nx-X11/programs/Xserver/mi/mibstore.c deleted file mode 100644 index 3eafac2353..0000000000 --- a/nx-X11/programs/Xserver/mi/mibstore.c +++ /dev/null @@ -1,3897 +0,0 @@ -/*********************************************************** - -Copyright 1987, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by the Regents of the University of California - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, provided -that the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation, and that the name The Open Group not be used in advertising or publicity -pertaining to distribution of the software without specific, written prior -permission. - -The University of California makes no representations about the suitability -of this software for any purpose. It is provided "as is" without express or -implied warranty. - -******************************************************************/ - - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include -#include -#include -#include "misc.h" -#include "regionstr.h" -#include "scrnintstr.h" -#include "gcstruct.h" -#include "windowstr.h" -#include "pixmapstr.h" -#include -#include "dixfontstr.h" -#include "dixstruct.h" /* For requestingClient */ -#include "mi.h" -#include "mibstorest.h" - -/* - * When the server fails to allocate a backing store pixmap, if you want - * it to dynamically retry to allocate backing store on every subsequent - * graphics op, you can enable BSEAGER; otherwise, backing store will be - * disabled on the window until it is unmapped and then remapped. - */ -/* #define BSEAGER */ - -/*- - * NOTES ON USAGE: - * - * The functions in this file implement a machine-independent backing-store - * scheme. To use it, the output library must do the following: - * - Provide a SaveAreas function that takes a destination pixmap, a - * region of the areas to save (in the pixmap's coordinate system) - * and the screen origin of the region. It should copy the areas from - * the screen into the pixmap. - * - Provide a RestoreAreas function that takes a source pixmap, a region - * of the areas to restore (in the screen's coordinate system) and the - * origin of the pixmap on the screen. It should copy the areas from - * the pixmap into the screen. - * - Provide a SetClipmaskRgn function that takes a gc and a region - * and merges the region into any CT_PIXMAP client clip that - * is specified in the GC. This routine is only needed if - * miValidateBackingStore will see CT_PIXMAP clip lists; not - * true for any of the sample servers (which convert the PIXMAP - * clip lists into CT_REGION clip lists; an expensive but simple - * to code option). - * - The function placed in a window's ClearToBackground vector must call - * pScreen->ClearBackingStore with the window, followed by - * the window-relative x and y coordinates, followed by the width and - * height of the area to be cleared, followed by the generateExposures - * flag. This has been taken care of in miClearToBackground. - * - Whatever determines GraphicsExpose events for the CopyArea and - * CopyPlane requests should call pWin->backStorage->ExposeCopy - * with the source and destination drawables, the GC used, a source- - * window-relative region of exposed areas, the source and destination - * coordinates and the bitplane copied, if CopyPlane, or 0, if - * CopyArea. - * - * JUSTIFICATION - * This is a cross between saving everything and just saving the - * obscued areas (as in Pike's layers.) This method has the advantage - * of only doing each output operation once per pixel, visible or - * invisible, and avoids having to do all the crufty storage - * management of keeping several separate rectangles. Since the - * ddx layer ouput primitives are required to draw through clipping - * rectangles anyway, sending multiple drawing requests for each of - * several rectangles isn't necessary. (Of course, it could be argued - * that the ddx routines should just take one rectangle each and - * get called multiple times, but that would make taking advantage of - * smart hardware harder, and probably be slower as well.) - */ - -#define SETUP_BACKING_TERSE(pGC) \ - miBSGCPtr pGCPrivate = (miBSGCPtr)(pGC)->devPrivates[miBSGCIndex].ptr; \ - GCFuncs *oldFuncs = pGC->funcs; - -#define SETUP_BACKING(pDrawable,pGC) \ - miBSWindowPtr pBackingStore = \ - (miBSWindowPtr)((WindowPtr)(pDrawable))->backStorage; \ - DrawablePtr pBackingDrawable = (DrawablePtr) \ - pBackingStore->pBackingPixmap; \ - SETUP_BACKING_TERSE(pGC) \ - GCPtr pBackingGC = pGCPrivate->pBackingGC; - -#define PROLOGUE(pGC) { \ - pGC->ops = pGCPrivate->wrapOps;\ - pGC->funcs = pGCPrivate->wrapFuncs; \ - } - -#define EPILOGUE(pGC) { \ - pGCPrivate->wrapOps = (pGC)->ops; \ - (pGC)->ops = &miBSGCOps; \ - (pGC)->funcs = oldFuncs; \ - } - -static void miCreateBSPixmap(WindowPtr pWin, BoxPtr pExtents); -static void miDestroyBSPixmap(WindowPtr pWin); -static void miTileVirtualBS(WindowPtr pWin); -static void miBSAllocate(WindowPtr pWin), miBSFree(WindowPtr pWin); -static Bool miBSCreateGCPrivate(GCPtr pGC); -static void miBSClearBackingRegion(WindowPtr pWin, RegionPtr pRgn); - -#define MoreCopy0 ; -#define MoreCopy2 *dstCopy++ = *srcCopy++; *dstCopy++ = *srcCopy++; -#define MoreCopy4 MoreCopy2 MoreCopy2 - -#define copyData(src,dst,n,morecopy) \ -{ \ - register short *srcCopy = (short *)(src); \ - register short *dstCopy = (short *)(dst); \ - register int i; \ - register int bsx = pBackingStore->x; \ - register int bsy = pBackingStore->y; \ - for (i = n; --i >= 0; ) \ - { \ - *dstCopy++ = *srcCopy++ - bsx; \ - *dstCopy++ = *srcCopy++ - bsy; \ - morecopy \ - } \ -} - -#define copyPoints(src,dst,n,mode) \ -if (mode == CoordModeOrigin) \ -{ \ - copyData(src,dst,n,MoreCopy0); \ -} \ -else \ -{ \ - memmove((char *)(dst), (char *)(src), (n) << 2); \ - *((short *)(dst)) -= pBackingStore->x; \ - *((short *)(dst) + 1) -= pBackingStore->y; \ -} - -/* - * wrappers for screen funcs - */ - -static int miBSScreenIndex; -static unsigned long miBSGeneration = 0; - -static Bool miBSCloseScreen(ScreenPtr pScreen); -static void miBSGetImage(DrawablePtr pDrawable, int sx, int sy, - int w, int h, unsigned int format, - unsigned long planemask, char *pdstLine); -static void miBSGetSpans(DrawablePtr pDrawable, int wMax, - DDXPointPtr ppt, int *pwidth, int nspans, - char *pdstStart); -static Bool miBSChangeWindowAttributes(WindowPtr pWin, - unsigned long mask); -static Bool miBSCreateGC(GCPtr pGC); -static Bool miBSDestroyWindow(WindowPtr pWin); - -/* - * backing store screen functions - */ - -static void miBSSaveDoomedAreas(WindowPtr pWin, RegionPtr pObscured, - int dx, int dy); -static RegionPtr miBSRestoreAreas(WindowPtr pWin, RegionPtr prgnExposed); -static void miBSExposeCopy(WindowPtr pSrc, DrawablePtr pDst, - GCPtr pGC, RegionPtr prgnExposed, - int srcx, int srcy, int dstx, int dsty, - unsigned long plane); -static RegionPtr miBSTranslateBackingStore(WindowPtr pWin, int windx, - int windy, RegionPtr oldClip, - int oldx, int oldy); -static RegionPtr miBSClearBackingStore(WindowPtr pWin, int x, int y, - int w, int h, Bool generateExposures); -static void miBSDrawGuarantee(WindowPtr pWin, GCPtr pGC, - int guarantee); - -/* - * wrapper vectors for GC funcs and ops - */ - -static int miBSGCIndex; - -static void miBSValidateGC(GCPtr pGC, unsigned long stateChanges, - DrawablePtr pDrawable); -static void miBSCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); -static void miBSDestroyGC(GCPtr pGC); -static void miBSChangeGC(GCPtr pGC, unsigned long mask); -static void miBSChangeClip(GCPtr pGC, int type, void * pvalue, int nrects); -static void miBSDestroyClip(GCPtr pGC); -static void miBSCopyClip(GCPtr pgcDst, GCPtr pgcSrc); - -static GCFuncs miBSGCFuncs = { - miBSValidateGC, - miBSChangeGC, - miBSCopyGC, - miBSDestroyGC, - miBSChangeClip, - miBSDestroyClip, - miBSCopyClip, -}; - -static void miBSFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nInit, - DDXPointPtr pptInit, int *pwidthInit, - int fSorted); -static void miBSSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *psrc, - DDXPointPtr ppt, int *pwidth, int nspans, - int fSorted); -static void miBSPutImage(DrawablePtr pDrawable, GCPtr pGC, int depth, - int x, int y, int w, int h, int leftPad, - int format, char *pBits); -static RegionPtr miBSCopyArea(DrawablePtr pSrc, DrawablePtr pDst, - GCPtr pGC, int srcx, int srcy, int w, int h, - int dstx, int dsty); -static RegionPtr miBSCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, - GCPtr pGC, int srcx, int srcy, int w, int h, - int dstx, int dsty, unsigned long plane); -static void miBSPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, - int npt, xPoint *pptInit); -static void miBSPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, - int npt, DDXPointPtr pptInit); -static void miBSPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, - xSegment *pSegs); -static void miBSPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, - int nrects, xRectangle *pRects); -static void miBSPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, - xArc *parcs); -static void miBSFillPolygon(DrawablePtr pDrawable, GCPtr pGC, - int shape, int mode, int count, - DDXPointPtr pPts); -static void miBSPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, - int nrectFill, xRectangle *prectInit); -static void miBSPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, - int narcs, xArc *parcs); -static int miBSPolyText8(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, int count, char *chars); -static int miBSPolyText16(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, int count, - unsigned short *chars); -static void miBSImageText8(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, int count, char *chars); -static void miBSImageText16(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, int count, - unsigned short *chars); -static void miBSImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, void * pglyphBase); -static void miBSPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, - int x, int y, unsigned int nglyph, - CharInfoPtr *ppci, void * pglyphBase); -static void miBSPushPixels(GCPtr pGC, PixmapPtr pBitMap, - DrawablePtr pDst, int w, int h, - int x, int y); -#ifdef NEED_LINEHELPER -static void miBSLineHelper(void); -#endif - -static GCOps miBSGCOps = { - miBSFillSpans, miBSSetSpans, miBSPutImage, - miBSCopyArea, miBSCopyPlane, miBSPolyPoint, - miBSPolylines, miBSPolySegment, miBSPolyRectangle, - miBSPolyArc, miBSFillPolygon, miBSPolyFillRect, - miBSPolyFillArc, miBSPolyText8, miBSPolyText16, - miBSImageText8, miBSImageText16, miBSImageGlyphBlt, - miBSPolyGlyphBlt, miBSPushPixels -#ifdef NEED_LINEHELPER - , miBSLineHelper -#endif -}; - -#define FUNC_PROLOGUE(pGC, pPriv) \ - ((pGC)->funcs = pPriv->wrapFuncs),\ - ((pGC)->ops = pPriv->wrapOps) - -#define FUNC_EPILOGUE(pGC, pPriv) \ - ((pGC)->funcs = &miBSGCFuncs),\ - ((pGC)->ops = &miBSGCOps) - -/* - * every GC in the server is initially wrapped with these - * "cheap" functions. This allocates no memory and is used - * to discover GCs used with windows which have backing - * store enabled - */ - -static void miBSCheapValidateGC(GCPtr pGC, unsigned long stateChanges, - DrawablePtr pDrawable); -static void miBSCheapCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst); -static void miBSCheapDestroyGC(GCPtr pGC); -static void miBSCheapChangeGC(GCPtr pGC, unsigned long mask); -static void miBSCheapChangeClip(GCPtr pGC, int type, void * pvalue, - int nrects); -static void miBSCheapDestroyClip(GCPtr pGC); -static void miBSCheapCopyClip(GCPtr pgcDst, GCPtr pgcSrc); - -static GCFuncs miBSCheapGCFuncs = { - miBSCheapValidateGC, - miBSCheapChangeGC, - miBSCheapCopyGC, - miBSCheapDestroyGC, - miBSCheapChangeClip, - miBSCheapDestroyClip, - miBSCheapCopyClip, -}; - -#define CHEAP_FUNC_PROLOGUE(pGC) \ - ((pGC)->funcs = (GCFuncs *) (pGC)->devPrivates[miBSGCIndex].ptr) - -#define CHEAP_FUNC_EPILOGUE(pGC) \ - ((pGC)->funcs = &miBSCheapGCFuncs) - -/* - * called from device screen initialization proc. Gets a GCPrivateIndex - * and wraps appropriate per-screen functions. pScreen->BackingStoreFuncs - * must be previously initialized. - */ - -void -miInitializeBackingStore (pScreen) - ScreenPtr pScreen; -{ - miBSScreenPtr pScreenPriv; - - if (miBSGeneration != serverGeneration) - { - miBSScreenIndex = AllocateScreenPrivateIndex (); - if (miBSScreenIndex < 0) - return; - miBSGCIndex = AllocateGCPrivateIndex (); - miBSGeneration = serverGeneration; - } - if (!AllocateGCPrivate(pScreen, miBSGCIndex, 0)) - return; - pScreenPriv = (miBSScreenPtr) malloc (sizeof (miBSScreenRec)); - if (!pScreenPriv) - return; - - pScreenPriv->CloseScreen = pScreen->CloseScreen; - pScreenPriv->GetImage = pScreen->GetImage; - pScreenPriv->GetSpans = pScreen->GetSpans; - pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes; - pScreenPriv->CreateGC = pScreen->CreateGC; - pScreenPriv->DestroyWindow = pScreen->DestroyWindow; - - pScreen->CloseScreen = miBSCloseScreen; - pScreen->GetImage = miBSGetImage; - pScreen->GetSpans = miBSGetSpans; - pScreen->ChangeWindowAttributes = miBSChangeWindowAttributes; - pScreen->CreateGC = miBSCreateGC; - pScreen->DestroyWindow = miBSDestroyWindow; - - pScreen->SaveDoomedAreas = miBSSaveDoomedAreas; - pScreen->RestoreAreas = miBSRestoreAreas; - pScreen->ExposeCopy = miBSExposeCopy; - pScreen->TranslateBackingStore = miBSTranslateBackingStore; - pScreen->ClearBackingStore = miBSClearBackingStore; - pScreen->DrawGuarantee = miBSDrawGuarantee; - - pScreen->devPrivates[miBSScreenIndex].ptr = (void *) pScreenPriv; -} - -/* - * Screen function wrappers - */ - -#define SCREEN_PROLOGUE(pScreen, field)\ - ((pScreen)->field = \ - ((miBSScreenPtr) \ - (pScreen)->devPrivates[miBSScreenIndex].ptr)->field) - -#define SCREEN_EPILOGUE(pScreen, field, wrapper)\ - ((pScreen)->field = wrapper) - -/* - * CloseScreen wrapper -- unwrap everything, free the private data - * and call the wrapped function - */ - -static Bool -miBSCloseScreen (pScreen) - ScreenPtr pScreen; -{ - miBSScreenPtr pScreenPriv; - - pScreenPriv = (miBSScreenPtr) pScreen->devPrivates[miBSScreenIndex].ptr; - - pScreen->CloseScreen = pScreenPriv->CloseScreen; - pScreen->GetImage = pScreenPriv->GetImage; - pScreen->GetSpans = pScreenPriv->GetSpans; - pScreen->ChangeWindowAttributes = pScreenPriv->ChangeWindowAttributes; - pScreen->CreateGC = pScreenPriv->CreateGC; - - free ((void *) pScreenPriv); - - return (*pScreen->CloseScreen) (pScreen); -} - -static void miBSFillVirtualBits(DrawablePtr pDrawable, GCPtr pGC, - RegionPtr pRgn, int x, int y, int state, - PixUnion pixunion, unsigned long planemask); - -static void -miBSGetImage (pDrawable, sx, sy, w, h, format, planemask, pdstLine) - DrawablePtr pDrawable; - int sx, sy, w, h; - unsigned int format; - unsigned long planemask; - char *pdstLine; -{ - ScreenPtr pScreen = pDrawable->pScreen; - BoxRec bounds; - unsigned char depth; - - SCREEN_PROLOGUE (pScreen, GetImage); - - if (pDrawable->type != DRAWABLE_PIXMAP && - ((WindowPtr) pDrawable)->visibility != VisibilityUnobscured) - { - PixmapPtr pPixmap; - miBSWindowPtr pWindowPriv; - GCPtr pGC = NULL; - WindowPtr pWin, pSrcWin; - int xoff, yoff; - RegionRec Remaining; - RegionRec Border; - RegionRec Inside; - BoxPtr pBox; - int n; - - pWin = (WindowPtr) pDrawable; - pPixmap = 0; - depth = pDrawable->depth; - bounds.x1 = sx + pDrawable->x; - bounds.y1 = sy + pDrawable->y; - bounds.x2 = bounds.x1 + w; - bounds.y2 = bounds.y1 + h; - RegionInit(&Remaining, &bounds, 0); - for (;;) - { - bounds.x1 = sx + pDrawable->x - pWin->drawable.x; - bounds.y1 = sy + pDrawable->y - pWin->drawable.y; - bounds.x2 = bounds.x1 + w; - bounds.y2 = bounds.y1 + h; - if (pWin->viewable && pWin->backStorage && - pWin->drawable.depth == depth && - (RegionContainsRect(&(pWindowPriv = - (miBSWindowPtr) pWin->backStorage)->SavedRegion, - &bounds) != rgnOUT || - RegionContainsRect(&Remaining, - RegionExtents(&pWin->borderSize)) != rgnOUT)) - { - if (!pPixmap) - { - XID subWindowMode = IncludeInferiors; - int x, y; - - pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, depth, - CREATE_PIXMAP_USAGE_SCRATCH); - if (!pPixmap) - goto punt; - pGC = GetScratchGC (depth, pScreen); - if (!pGC) - { - (*pScreen->DestroyPixmap) (pPixmap); - goto punt; - } - ChangeGC (pGC, GCSubwindowMode, &subWindowMode); - ValidateGC ((DrawablePtr)pPixmap, pGC); - RegionNull(&Border); - RegionNull(&Inside); - pSrcWin = (WindowPtr) pDrawable; - x = sx; - y = sy; - if (pSrcWin->parent) - { - x += pSrcWin->origin.x; - y += pSrcWin->origin.y; - pSrcWin = pSrcWin->parent; - } - (*pGC->ops->CopyArea) ((DrawablePtr)pSrcWin, - (DrawablePtr)pPixmap, pGC, - x, y, w, h, - 0, 0); - RegionSubtract(&Remaining, &Remaining, - &((WindowPtr) pDrawable)->borderClip); - } - - RegionIntersect(&Inside, &Remaining, &pWin->winSize); - RegionTranslate(&Inside, - -pWin->drawable.x, - -pWin->drawable.y); - RegionIntersect(&Inside, &Inside, - &pWindowPriv->SavedRegion); - - /* offset of sub-window in GetImage pixmap */ - xoff = pWin->drawable.x - pDrawable->x - sx; - yoff = pWin->drawable.y - pDrawable->y - sy; - - if (RegionNumRects(&Inside) > 0) - { - switch (pWindowPriv->status) - { - case StatusContents: - pBox = RegionRects(&Inside); - for (n = RegionNumRects(&Inside); --n >= 0;) - { - (*pGC->ops->CopyArea) ( - (DrawablePtr)pWindowPriv->pBackingPixmap, - (DrawablePtr)pPixmap, pGC, - pBox->x1 - pWindowPriv->x, - pBox->y1 - pWindowPriv->y, - pBox->x2 - pBox->x1, - pBox->y2 - pBox->y1, - pBox->x1 + xoff, - pBox->y1 + yoff); - ++pBox; - } - break; - case StatusVirtual: - case StatusVDirty: - if (pWindowPriv->backgroundState == BackgroundPixmap || - pWindowPriv->backgroundState == BackgroundPixel) - miBSFillVirtualBits ((DrawablePtr) pPixmap, pGC, &Inside, - xoff, yoff, - (int) pWindowPriv->backgroundState, - pWindowPriv->background, ~0L); - break; - } - } - RegionSubtract(&Border, &pWin->borderSize, - &pWin->winSize); - RegionIntersect(&Border, &Border, &Remaining); - if (RegionNumRects(&Border) > 0) - { - RegionTranslate(&Border, -pWin->drawable.x, - -pWin->drawable.y); - miBSFillVirtualBits ((DrawablePtr) pPixmap, pGC, &Border, - xoff, yoff, - pWin->borderIsPixel ? (int)BackgroundPixel : (int)BackgroundPixmap, - pWin->border, ~0L); - } - } - - if (pWin->viewable && pWin->firstChild) - pWin = pWin->firstChild; - else - { - while (!pWin->nextSib && pWin != (WindowPtr) pDrawable) - pWin = pWin->parent; - if (pWin == (WindowPtr) pDrawable) - break; - pWin = pWin->nextSib; - } - } - - RegionUninit(&Remaining); - - if (pPixmap) - { - RegionUninit(&Border); - RegionUninit(&Inside); - (*pScreen->GetImage) ((DrawablePtr) pPixmap, - 0, 0, w, h, format, planemask, pdstLine); - (*pScreen->DestroyPixmap) (pPixmap); - FreeScratchGC (pGC); - } - else - { - goto punt; - } - } - else - { -punt: ; - (*pScreen->GetImage) (pDrawable, sx, sy, w, h, - format, planemask, pdstLine); - } - - SCREEN_EPILOGUE (pScreen, GetImage, miBSGetImage); -} - -static void -miBSGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart) - DrawablePtr pDrawable; - int wMax; - DDXPointPtr ppt; - int *pwidth; - int nspans; - char *pdstStart; -{ - ScreenPtr pScreen = pDrawable->pScreen; - BoxRec bounds; - int i; - WindowPtr pWin; - int dx, dy; - - SCREEN_PROLOGUE (pScreen, GetSpans); - - if (pDrawable->type != DRAWABLE_PIXMAP && ((WindowPtr) pDrawable)->backStorage) - { - PixmapPtr pPixmap; - miBSWindowPtr pWindowPriv; - GCPtr pGC; - - pWin = (WindowPtr) pDrawable; - pWindowPriv = (miBSWindowPtr) pWin->backStorage; - pPixmap = pWindowPriv->pBackingPixmap; - - bounds.x1 = ppt->x; - bounds.y1 = ppt->y; - bounds.x2 = bounds.x1 + *pwidth; - bounds.y2 = ppt->y; - for (i = 0; i < nspans; i++) - { - if (ppt[i].x < bounds.x1) - bounds.x1 = ppt[i].x; - if (ppt[i].x + pwidth[i] > bounds.x2) - bounds.x2 = ppt[i].x + pwidth[i]; - if (ppt[i].y < bounds.y1) - bounds.y1 = ppt[i].y; - else if (ppt[i].y > bounds.y2) - bounds.y2 = ppt[i].y; - } - - switch (RegionContainsRect(&pWindowPriv->SavedRegion, &bounds)) - { - case rgnPART: - if (!pPixmap) - { - miCreateBSPixmap (pWin, NullBox); - if (!(pPixmap = pWindowPriv->pBackingPixmap)) - break; - } - pWindowPriv->status = StatusNoPixmap; - pGC = GetScratchGC(pPixmap->drawable.depth, - pPixmap->drawable.pScreen); - if (pGC) - { - ValidateGC ((DrawablePtr) pPixmap, pGC); - (*pGC->ops->CopyArea) - (pDrawable, (DrawablePtr) pPixmap, pGC, - bounds.x1, bounds.y1, - bounds.x2 - bounds.x1, bounds.y2 - bounds.y1, - bounds.x1 + pPixmap->drawable.x - pWin->drawable.x - - pWindowPriv->x, - bounds.y1 + pPixmap->drawable.y - pWin->drawable.y - - pWindowPriv->y); - FreeScratchGC(pGC); - } - pWindowPriv->status = StatusContents; - /* fall through */ - case rgnIN: - if (!pPixmap) - { - miCreateBSPixmap (pWin, NullBox); - if (!(pPixmap = pWindowPriv->pBackingPixmap)) - break; - } - dx = pPixmap->drawable.x - pWin->drawable.x - pWindowPriv->x; - dy = pPixmap->drawable.y - pWin->drawable.y - pWindowPriv->y; - for (i = 0; i < nspans; i++) - { - ppt[i].x += dx; - ppt[i].y += dy; - } - (*pScreen->GetSpans) ((DrawablePtr) pPixmap, wMax, ppt, pwidth, - nspans, pdstStart); - break; - case rgnOUT: - (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, - pdstStart); - break; - } - } - else - { - (*pScreen->GetSpans) (pDrawable, wMax, ppt, pwidth, nspans, pdstStart); - } - - SCREEN_EPILOGUE (pScreen, GetSpans, miBSGetSpans); -} - -static Bool -miBSChangeWindowAttributes (pWin, mask) - WindowPtr pWin; - unsigned long mask; -{ - ScreenPtr pScreen; - Bool ret; - - pScreen = pWin->drawable.pScreen; - - SCREEN_PROLOGUE (pScreen, ChangeWindowAttributes); - - ret = (*pScreen->ChangeWindowAttributes) (pWin, mask); - - if (ret && (mask & CWBackingStore)) - { - if (pWin->backingStore != NotUseful || pWin->DIXsaveUnder) - miBSAllocate (pWin); - else - miBSFree (pWin); - } - - SCREEN_EPILOGUE (pScreen, ChangeWindowAttributes, miBSChangeWindowAttributes); - - return ret; -} - -/* - * GC Create wrapper. Set up the cheap GC func wrappers to track - * GC validation on BackingStore windows - */ - -static Bool -miBSCreateGC (pGC) - GCPtr pGC; -{ - ScreenPtr pScreen = pGC->pScreen; - Bool ret; - - SCREEN_PROLOGUE (pScreen, CreateGC); - - if ( (ret = (*pScreen->CreateGC) (pGC)) ) - { - pGC->devPrivates[miBSGCIndex].ptr = (void *) pGC->funcs; - pGC->funcs = &miBSCheapGCFuncs; - } - - SCREEN_EPILOGUE (pScreen, CreateGC, miBSCreateGC); - - return ret; -} - -static Bool -miBSDestroyWindow (pWin) - WindowPtr pWin; -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - Bool ret; - - SCREEN_PROLOGUE (pScreen, DestroyWindow); - - ret = (*pScreen->DestroyWindow) (pWin); - - miBSFree (pWin); - - SCREEN_EPILOGUE (pScreen, DestroyWindow, miBSDestroyWindow); - - return ret; -} - -/* - * cheap GC func wrappers. Simply track validation on windows - * with backing store to enable the real func/op wrappers - */ - -static void -miBSCheapValidateGC (pGC, stateChanges, pDrawable) - GCPtr pGC; - unsigned long stateChanges; - DrawablePtr pDrawable; -{ - CHEAP_FUNC_PROLOGUE (pGC); - - if (pDrawable->type != DRAWABLE_PIXMAP && - ((WindowPtr) pDrawable)->backStorage != NULL && - miBSCreateGCPrivate (pGC)) - { - (*pGC->funcs->ValidateGC) (pGC, stateChanges, pDrawable); - } - else - { - (*pGC->funcs->ValidateGC) (pGC, stateChanges, pDrawable); - - /* rewrap funcs as Validate may have changed them */ - pGC->devPrivates[miBSGCIndex].ptr = (void *) pGC->funcs; - - CHEAP_FUNC_EPILOGUE (pGC); - } -} - -static void -miBSCheapChangeGC (pGC, mask) - GCPtr pGC; - unsigned long mask; -{ - CHEAP_FUNC_PROLOGUE (pGC); - - (*pGC->funcs->ChangeGC) (pGC, mask); - - CHEAP_FUNC_EPILOGUE (pGC); -} - -static void -miBSCheapCopyGC (pGCSrc, mask, pGCDst) - GCPtr pGCSrc, pGCDst; - unsigned long mask; -{ - CHEAP_FUNC_PROLOGUE (pGCDst); - - (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); - - CHEAP_FUNC_EPILOGUE (pGCDst); -} - -static void -miBSCheapDestroyGC (pGC) - GCPtr pGC; -{ - CHEAP_FUNC_PROLOGUE (pGC); - - (*pGC->funcs->DestroyGC) (pGC); - - /* leave it unwrapped */ -} - -static void -miBSCheapChangeClip (pGC, type, pvalue, nrects) - GCPtr pGC; - int type; - void * pvalue; - int nrects; -{ - CHEAP_FUNC_PROLOGUE (pGC); - - (*pGC->funcs->ChangeClip) (pGC, type, pvalue, nrects); - - CHEAP_FUNC_EPILOGUE (pGC); -} - -static void -miBSCheapCopyClip(pgcDst, pgcSrc) - GCPtr pgcDst, pgcSrc; -{ - CHEAP_FUNC_PROLOGUE (pgcDst); - - (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); - - CHEAP_FUNC_EPILOGUE (pgcDst); -} - -static void -miBSCheapDestroyClip(pGC) - GCPtr pGC; -{ - CHEAP_FUNC_PROLOGUE (pGC); - - (* pGC->funcs->DestroyClip)(pGC); - - CHEAP_FUNC_EPILOGUE (pGC); -} - -/* - * create the full func/op wrappers for a GC - */ - -static Bool -miBSCreateGCPrivate (pGC) - GCPtr pGC; -{ - miBSGCRec *pPriv; - - pPriv = (miBSGCRec *) malloc (sizeof (miBSGCRec)); - if (!pPriv) - return FALSE; - pPriv->pBackingGC = NULL; - pPriv->guarantee = GuaranteeNothing; - pPriv->serialNumber = 0; - pPriv->stateChanges = (1 << (GCLastBit + 1)) - 1; - pPriv->wrapOps = pGC->ops; - pPriv->wrapFuncs = pGC->funcs; - pGC->funcs = &miBSGCFuncs; - pGC->ops = &miBSGCOps; - pGC->devPrivates[miBSGCIndex].ptr = (void *) pPriv; - return TRUE; -} - -static void -miBSDestroyGCPrivate (GCPtr pGC) -{ - miBSGCRec *pPriv; - - pPriv = (miBSGCRec *) pGC->devPrivates[miBSGCIndex].ptr; - if (pPriv) - { - pGC->devPrivates[miBSGCIndex].ptr = (void *) pPriv->wrapFuncs; - pGC->funcs = &miBSCheapGCFuncs; - pGC->ops = pPriv->wrapOps; - if (pPriv->pBackingGC) - FreeGC (pPriv->pBackingGC, (GContext) 0); - free ((void *) pPriv); - } -} - -/* - * GC ops -- wrap each GC operation with our own function - */ - -/*- - *----------------------------------------------------------------------- - * miBSFillSpans -- - * Perform a FillSpans, routing output to backing-store as needed. - * - * Results: - * None. - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSFillSpans(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) - DrawablePtr pDrawable; - GCPtr pGC; - int nInit; /* number of spans to fill */ - DDXPointPtr pptInit; /* pointer to list of start points */ - int *pwidthInit; /* pointer to list of n widths */ - int fSorted; -{ - DDXPointPtr pptCopy, pptReset; - int *pwidthCopy; - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - pptCopy = (DDXPointPtr)malloc(nInit*sizeof(DDXPointRec)); - pwidthCopy=(int *)malloc(nInit*sizeof(int)); - if (pptCopy && pwidthCopy) - { - copyData(pptInit, pptCopy, nInit, MoreCopy0); - memmove((char *)pwidthCopy,(char *)pwidthInit,nInit*sizeof(int)); - - (* pGC->ops->FillSpans)(pDrawable, pGC, nInit, pptInit, - pwidthInit, fSorted); - if (pGC->miTranslate) - { - int dx, dy; - int nReset; - - pptReset = pptCopy; - dx = pDrawable->x - pBackingDrawable->x; - dy = pDrawable->y - pBackingDrawable->y; - nReset = nInit; - while (nReset--) - { - pptReset->x -= dx; - pptReset->y -= dy; - ++pptReset; - } - } - (* pBackingGC->ops->FillSpans)(pBackingDrawable, - pBackingGC, nInit, pptCopy, pwidthCopy, - fSorted); - } - if (pwidthCopy) free(pwidthCopy); - if (pptCopy) free(pptCopy); - - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSSetSpans -- - * Perform a SetSpans, routing output to backing-store as needed. - * - * Results: - * None. - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted) - DrawablePtr pDrawable; - GCPtr pGC; - char *psrc; - register DDXPointPtr ppt; - int *pwidth; - int nspans; - int fSorted; -{ - DDXPointPtr pptCopy, pptReset; - int *pwidthCopy; - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - pptCopy = (DDXPointPtr)malloc(nspans*sizeof(DDXPointRec)); - pwidthCopy=(int *)malloc(nspans*sizeof(int)); - if (pptCopy && pwidthCopy) - { - copyData(ppt, pptCopy, nspans, MoreCopy0); - memmove((char *)pwidthCopy,(char *)pwidth,nspans*sizeof(int)); - - (* pGC->ops->SetSpans)(pDrawable, pGC, psrc, ppt, pwidth, - nspans, fSorted); - if (pGC->miTranslate) - { - int dx, dy; - int nReset; - - pptReset = pptCopy; - dx = pDrawable->x - pBackingDrawable->x; - dy = pDrawable->y - pBackingDrawable->y; - nReset = nspans; - while (nReset--) - { - pptReset->x -= dx; - pptReset->y -= dy; - ++pptReset; - } - } - (* pBackingGC->ops->SetSpans)(pBackingDrawable, pBackingGC, - psrc, pptCopy, pwidthCopy, nspans, fSorted); - } - if (pwidthCopy) free(pwidthCopy); - if (pptCopy) free(pptCopy); - - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSPutImage -- - * Perform a PutImage, routing output to backing-store as needed. - * - * Results: - * None. - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSPutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format, pBits) - DrawablePtr pDrawable; - GCPtr pGC; - int depth; - int x; - int y; - int w; - int h; - int leftPad; - int format; - char *pBits; -{ - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - (*pGC->ops->PutImage)(pDrawable, pGC, - depth, x, y, w, h, leftPad, format, pBits); - (*pBackingGC->ops->PutImage)(pBackingDrawable, pBackingGC, - depth, x - pBackingStore->x, y - pBackingStore->y, - w, h, leftPad, format, pBits); - - EPILOGUE (pGC); -} - -typedef RegionPtr (* CopyAreaProcPtr)(DrawablePtr, DrawablePtr, GCPtr, - int, int, int, int, int, int); -typedef RegionPtr (* CopyPlaneProcPtr)(DrawablePtr, DrawablePtr, GCPtr, - int, int, int, int, int, int, - unsigned long bitPlane); -/*- - *----------------------------------------------------------------------- - * miBSDoCopy -- - * Perform a CopyArea or CopyPlane within a window that has backing - * store enabled. - * - * Results: - * TRUE if the copy was performed or FALSE if a regular one should - * be done. - * - * Side Effects: - * Things are copied (no s***!) - * - * Notes: - * The idea here is to form two regions that cover the source box. - * One contains the exposed rectangles while the other contains - * the obscured ones. An array of pairs is then - * formed where the indicates the area to be copied and the - * indicates from where it is to be copied (exposed regions - * come from the screen while obscured ones come from the backing - * pixmap). The array 'sequence' is then filled with the indices of - * the pairs in the order in which they should be copied to prevent - * things from getting screwed up. A call is also made through the - * backingGC to take care of any copying into the backing pixmap. - * - *----------------------------------------------------------------------- - */ -static Bool -miBSDoCopy( - WindowPtr pWin, /* Window being scrolled */ - GCPtr pGC, /* GC we're called through */ - int srcx, /* X of source rectangle */ - int srcy, /* Y of source rectangle */ - int w, /* Width of source rectangle */ - int h, /* Height of source rectangle */ - int dstx, /* X of destination rectangle */ - int dsty, /* Y of destination rectangle */ - unsigned long plane, /* Plane to copy (0 for CopyArea) */ - CopyPlaneProcPtr copyProc, /* Procedure to call to perform the copy */ - RegionPtr *ppRgn) /* resultant Graphics Expose region */ -{ - RegionPtr pRgnExp; /* Exposed region */ - RegionPtr pRgnObs; /* Obscured region */ - BoxRec box; /* Source box (screen coord) */ - struct BoxDraw { - BoxPtr pBox; /* Source box */ - enum { - win, pix - } source; /* Place from which to copy */ - } *boxes; /* Array of box/drawable pairs covering - * source box. */ - int *sequence; /* Sequence of boxes to move */ - register int i, j, k, l, y; - register BoxPtr pBox; - int dx, dy, nrects; - Bool graphicsExposures; - CopyPlaneProcPtr pixCopyProc; - int numRectsExp, numRectsObs; - BoxPtr pBoxExp, pBoxObs; - - SETUP_BACKING (pWin, pGC); - (void)oldFuncs; - - /* - * Create a region of exposed boxes in pRgnExp. - */ - box.x1 = srcx + pWin->drawable.x; - box.x2 = box.x1 + w; - box.y1 = srcy + pWin->drawable.y; - box.y2 = box.y1 + h; - - pRgnExp = RegionCreate(&box, 1); - RegionIntersect(pRgnExp, pRgnExp, &pWin->clipList); - pRgnObs = RegionCreate(NULL, 1); - RegionInverse(pRgnObs, pRgnExp, &box); - - /* - * Translate regions into window coordinates for proper calls - * to the copyProc, then make sure none of the obscured region sticks - * into invalid areas of the backing pixmap. - */ - RegionTranslate(pRgnExp, - -pWin->drawable.x, - -pWin->drawable.y); - RegionTranslate(pRgnObs, - -pWin->drawable.x, - -pWin->drawable.y); - RegionIntersect(pRgnObs, pRgnObs, &pBackingStore->SavedRegion); - - /* - * If the obscured region is empty, there's no point being fancy. - */ - if (!RegionNotEmpty(pRgnObs)) - { - RegionDestroy(pRgnExp); - RegionDestroy(pRgnObs); - - return (FALSE); - } - - numRectsExp = RegionNumRects(pRgnExp); - pBoxExp = RegionRects(pRgnExp); - pBoxObs = RegionRects(pRgnObs); - numRectsObs = RegionNumRects(pRgnObs); - nrects = numRectsExp + numRectsObs; - - boxes = (struct BoxDraw *)malloc(nrects * sizeof(struct BoxDraw)); - sequence = (int *) malloc(nrects * sizeof(int)); - *ppRgn = NULL; - - if (!boxes || !sequence) - { - if (sequence) free(sequence); - if (boxes) free(boxes); - RegionDestroy(pRgnExp); - RegionDestroy(pRgnObs); - - return(TRUE); - } - - /* - * Order the boxes in the two regions so we know from which drawable - * to copy which box, storing the result in the boxes array - */ - for (i = 0, j = 0, k = 0; - (i < numRectsExp) && (j < numRectsObs); - k++) - { - if (pBoxExp[i].y1 < pBoxObs[j].y1) - { - boxes[k].pBox = &pBoxExp[i]; - boxes[k].source = win; - i++; - } - else if ((pBoxObs[j].y1 < pBoxExp[i].y1) || - (pBoxObs[j].x1 < pBoxExp[i].x1)) - { - boxes[k].pBox = &pBoxObs[j]; - boxes[k].source = pix; - j++; - } - else - { - boxes[k].pBox = &pBoxExp[i]; - boxes[k].source = win; - i++; - } - } - - /* - * Catch any leftover boxes from either region (note that only - * one can have leftover boxes...) - */ - if (i != numRectsExp) - { - do - { - boxes[k].pBox = &pBoxExp[i]; - boxes[k].source = win; - i++; - k++; - } while (i < numRectsExp); - - } - else - { - do - { - boxes[k].pBox = &pBoxObs[j]; - boxes[k].source = pix; - j++; - k++; - } while (j < numRectsObs); - } - - if (dsty <= srcy) - { - /* - * Scroll up or vertically stationary, so vertical order is ok. - */ - if (dstx <= srcx) - { - /* - * Scroll left or horizontally stationary, so horizontal order - * is ok as well. - */ - for (i = 0; i < nrects; i++) - { - sequence[i] = i; - } - } - else - { - /* - * Scroll right. Need to reverse the rectangles within each - * band. - */ - for (i = 0, j = 1, k = 0; - i < nrects; - j = i + 1, k = i) - { - y = boxes[i].pBox->y1; - while ((j < nrects) && (boxes[j].pBox->y1 == y)) - { - j++; - } - for (j--; j >= k; j--, i++) - { - sequence[i] = j; - } - } - } - } - else - { - /* - * Scroll down. Must reverse vertical banding, at least. - */ - if (dstx < srcx) - { - /* - * Scroll left. Horizontal order is ok. - */ - for (i = nrects - 1, j = i - 1, k = i, l = 0; - i >= 0; - j = i - 1, k = i) - { - /* - * Find extent of current horizontal band, then reverse - * the order of the whole band. - */ - y = boxes[i].pBox->y1; - while ((j >= 0) && (boxes[j].pBox->y1 == y)) - { - j--; - } - for (j++; j <= k; j++, i--, l++) - { - sequence[l] = j; - } - } - } - else - { - /* - * Scroll right or horizontal stationary. - * Reverse horizontal order as well (if stationary, horizontal - * order can be swapped without penalty and this is faster - * to compute). - */ - for (i = 0, j = nrects - 1; i < nrects; i++, j--) - { - sequence[i] = j; - } - } - } - - /* - * XXX: To avoid getting multiple NoExpose events from this operation, - * we turn OFF graphicsExposures in the gc and deal with any uncopied - * areas later, if there's something not in backing-store. - */ - - graphicsExposures = pGC->graphicsExposures; - pGC->graphicsExposures = FALSE; - - dx = dstx - srcx; - dy = dsty - srcy; - - /* - * Figure out which copy procedure to use from the backing GC. Note we - * must do this because some implementations (sun's, e.g.) have - * pBackingGC a fake GC with the real one below it, thus the devPriv for - * pBackingGC won't be what the output library expects. - */ - if (plane != 0) - { - pixCopyProc = pBackingGC->ops->CopyPlane; - } - else - { - pixCopyProc = (CopyPlaneProcPtr)pBackingGC->ops->CopyArea; - } - - for (i = 0; i < nrects; i++) - { - pBox = boxes[sequence[i]].pBox; - - /* - * If we're copying from the pixmap, we need to place its contents - * onto the screen before scrolling the pixmap itself. If we're copying - * from the window, we need to copy its contents into the pixmap before - * we scroll the window itself. - */ - if (boxes[sequence[i]].source == pix) - { - (void) (* copyProc) (pBackingDrawable, &(pWin->drawable), pGC, - pBox->x1 - pBackingStore->x, - pBox->y1 - pBackingStore->y, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1, - pBox->x1 + dx, pBox->y1 + dy, plane); - (void) (* pixCopyProc) (pBackingDrawable, pBackingDrawable, pBackingGC, - pBox->x1 - pBackingStore->x, - pBox->y1 - pBackingStore->y, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1, - pBox->x1 + dx - pBackingStore->x, - pBox->y1 + dy - pBackingStore->y, plane); - } - else - { - (void) (* pixCopyProc) (&(pWin->drawable), pBackingDrawable, pBackingGC, - pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1, - pBox->x1 + dx - pBackingStore->x, - pBox->y1 + dy - pBackingStore->y, plane); - (void) (* copyProc) (&(pWin->drawable), &(pWin->drawable), pGC, - pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1, - pBox->x1 + dx, pBox->y1 + dy, plane); - } - } - free(sequence); - free(boxes); - - pGC->graphicsExposures = graphicsExposures; - /* - * Form union of rgnExp and rgnObs and see if covers entire area - * to be copied. Store the resultant region for miBSCopyArea - * to return to dispatch which will send the appropriate expose - * events. - */ - RegionUnion(pRgnExp, pRgnExp, pRgnObs); - box.x1 = srcx; - box.x2 = srcx + w; - box.y1 = srcy; - box.y2 = srcy + h; - if (RegionContainsRect(pRgnExp, &box) == rgnIN) - { - RegionEmpty(pRgnExp); - } - else - { - RegionInverse(pRgnExp, pRgnExp, &box); - RegionTranslate(pRgnExp, - dx + pWin->drawable.x, - dy + pWin->drawable.y); - RegionIntersect(pRgnObs, pRgnExp, &pWin->clipList); - (*pWin->drawable.pScreen->PaintWindowBackground) (pWin, - pRgnObs, PW_BACKGROUND); - RegionTranslate(pRgnExp, - -pWin->drawable.x, - -pWin->drawable.y); - miBSClearBackingRegion (pWin, pRgnExp); - } - if (graphicsExposures) - *ppRgn = pRgnExp; - else - RegionDestroy(pRgnExp); - RegionDestroy(pRgnObs); - - return (TRUE); -} - -/*- - *----------------------------------------------------------------------- - * miBSCopyArea -- - * Perform a CopyArea from the source to the destination, extracting - * from the source's backing-store and storing into the destination's - * backing-store without messing anything up. If the source and - * destination are different, there's not too much to worry about: - * we can just issue several calls to the regular CopyArea function. - * - * Results: - * None. - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static RegionPtr -miBSCopyArea (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty) - DrawablePtr pSrc; - DrawablePtr pDst; - GCPtr pGC; - int srcx; - int srcy; - int w; - int h; - int dstx; - int dsty; -{ - BoxPtr pExtents; - long dx, dy; - int bsrcx, bsrcy, bw, bh, bdstx, bdsty; - RegionPtr pixExposed = 0, winExposed = 0; - - SETUP_BACKING(pDst, pGC); - - PROLOGUE(pGC); - - if ((pSrc != pDst) || - (!miBSDoCopy((WindowPtr)pSrc, pGC, srcx, srcy, w, h, dstx, dsty, - (unsigned long) 0, (CopyPlaneProcPtr)pGC->ops->CopyArea, - &winExposed))) - { - /* - * always copy to the backing store first, miBSDoCopy - * returns FALSE if the *source* region is disjoint - * from the backing store saved region. So, copying - * *to* the backing store is always safe - */ - if (pGC->clientClipType != CT_PIXMAP) - { - /* - * adjust srcx, srcy, w, h, dstx, dsty to be clipped to - * the backing store. An unnecessary optimisation, - * but a useful one when GetSpans is slow. - */ - pExtents = RegionExtents( - (RegionPtr)pBackingGC->clientClip); - bsrcx = srcx; - bsrcy = srcy; - bw = w; - bh = h; - bdstx = dstx; - bdsty = dsty; - dx = pExtents->x1 - bdstx; - if (dx > 0) - { - bsrcx += dx; - bdstx += dx; - bw -= dx; - } - dy = pExtents->y1 - bdsty; - if (dy > 0) - { - bsrcy += dy; - bdsty += dy; - bh -= dy; - } - dx = (bdstx + bw) - pExtents->x2; - if (dx > 0) - bw -= dx; - dy = (bdsty + bh) - pExtents->y2; - if (dy > 0) - bh -= dy; - if (bw > 0 && bh > 0) - pixExposed = (* pBackingGC->ops->CopyArea) (pSrc, - pBackingDrawable, pBackingGC, - bsrcx, bsrcy, bw, bh, bdstx - pBackingStore->x, - bdsty - pBackingStore->y); - } - else - pixExposed = (* pBackingGC->ops->CopyArea) (pSrc, - pBackingDrawable, pBackingGC, - srcx, srcy, w, h, - dstx - pBackingStore->x, dsty - pBackingStore->y); - - winExposed = (* pGC->ops->CopyArea) (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty); - } - - /* - * compute the composite graphics exposure region - */ - if (winExposed) - { - if (pixExposed){ - RegionUnion(winExposed, winExposed, pixExposed); - RegionDestroy(pixExposed); - } - } else - winExposed = pixExposed; - - EPILOGUE (pGC); - - return winExposed; -} - -/*- - *----------------------------------------------------------------------- - * miBSCopyPlane -- - * - * Results: - * None. - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static RegionPtr -miBSCopyPlane (pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty, plane) - DrawablePtr pSrc; - DrawablePtr pDst; - register GC *pGC; - int srcx, - srcy; - int w, - h; - int dstx, - dsty; - unsigned long plane; -{ - BoxPtr pExtents; - long dx, dy; - int bsrcx, bsrcy, bw, bh, bdstx, bdsty; - RegionPtr winExposed = 0, pixExposed = 0; - SETUP_BACKING(pDst, pGC); - - PROLOGUE(pGC); - - if ((pSrc != pDst) || - (!miBSDoCopy((WindowPtr)pSrc, pGC, srcx, srcy, w, h, dstx, dsty, - plane, pGC->ops->CopyPlane, &winExposed))) - { - /* - * always copy to the backing store first, miBSDoCopy - * returns FALSE if the *source* region is disjoint - * from the backing store saved region. So, copying - * *to* the backing store is always safe - */ - if (pGC->clientClipType != CT_PIXMAP) - { - /* - * adjust srcx, srcy, w, h, dstx, dsty to be clipped to - * the backing store. An unnecessary optimisation, - * but a useful one when GetSpans is slow. - */ - pExtents = RegionExtents( - (RegionPtr)pBackingGC->clientClip); - bsrcx = srcx; - bsrcy = srcy; - bw = w; - bh = h; - bdstx = dstx; - bdsty = dsty; - dx = pExtents->x1 - bdstx; - if (dx > 0) - { - bsrcx += dx; - bdstx += dx; - bw -= dx; - } - dy = pExtents->y1 - bdsty; - if (dy > 0) - { - bsrcy += dy; - bdsty += dy; - bh -= dy; - } - dx = (bdstx + bw) - pExtents->x2; - if (dx > 0) - bw -= dx; - dy = (bdsty + bh) - pExtents->y2; - if (dy > 0) - bh -= dy; - if (bw > 0 && bh > 0) - pixExposed = (* pBackingGC->ops->CopyPlane) (pSrc, - pBackingDrawable, - pBackingGC, bsrcx, bsrcy, bw, bh, - bdstx - pBackingStore->x, - bdsty - pBackingStore->y, plane); - } - else - pixExposed = (* pBackingGC->ops->CopyPlane) (pSrc, - pBackingDrawable, - pBackingGC, srcx, srcy, w, h, - dstx - pBackingStore->x, - dsty - pBackingStore->y, plane); - - winExposed = (* pGC->ops->CopyPlane) (pSrc, pDst, pGC, srcx, srcy, w, h, - dstx, dsty, plane); - - } - - /* - * compute the composite graphics exposure region - */ - if (winExposed) - { - if (pixExposed) - { - RegionUnion(winExposed, winExposed, pixExposed); - RegionDestroy(pixExposed); - } - } else - winExposed = pixExposed; - - EPILOGUE (pGC); - - return winExposed; -} - -/*- - *----------------------------------------------------------------------- - * miBSPolyPoint -- - * Perform a PolyPoint, routing output to backing-store as needed. - * - * Results: - * None. - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSPolyPoint (pDrawable, pGC, mode, npt, pptInit) - DrawablePtr pDrawable; - GCPtr pGC; - int mode; /* Origin or Previous */ - int npt; - xPoint *pptInit; -{ - xPoint *pptCopy; - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - pptCopy = (xPoint *)malloc(npt*sizeof(xPoint)); - if (pptCopy) - { - copyPoints(pptInit, pptCopy, npt, mode); - - (* pGC->ops->PolyPoint) (pDrawable, pGC, mode, npt, pptInit); - - (* pBackingGC->ops->PolyPoint) (pBackingDrawable, - pBackingGC, mode, npt, pptCopy); - - free(pptCopy); - } - - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSPolyLines -- - * Perform a Polylines, routing output to backing-store as needed. - * - * Results: - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSPolylines (pDrawable, pGC, mode, npt, pptInit) - DrawablePtr pDrawable; - GCPtr pGC; - int mode; - int npt; - DDXPointPtr pptInit; -{ - DDXPointPtr pptCopy; - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - pptCopy = (DDXPointPtr)malloc(npt*sizeof(DDXPointRec)); - if (pptCopy) - { - copyPoints(pptInit, pptCopy, npt, mode); - - (* pGC->ops->Polylines)(pDrawable, pGC, mode, npt, pptInit); - (* pBackingGC->ops->Polylines)(pBackingDrawable, - pBackingGC, mode, npt, pptCopy); - free(pptCopy); - } - - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSPolySegment -- - * Perform a PolySegment, routing output to backing-store as needed. - * - * Results: - * None. - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSPolySegment(pDrawable, pGC, nseg, pSegs) - DrawablePtr pDrawable; - GCPtr pGC; - int nseg; - xSegment *pSegs; -{ - xSegment *pSegsCopy; - - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - pSegsCopy = (xSegment *)malloc(nseg*sizeof(xSegment)); - if (pSegsCopy) - { - copyData(pSegs, pSegsCopy, nseg << 1, MoreCopy0); - - (* pGC->ops->PolySegment)(pDrawable, pGC, nseg, pSegs); - (* pBackingGC->ops->PolySegment)(pBackingDrawable, - pBackingGC, nseg, pSegsCopy); - - free(pSegsCopy); - } - - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSPolyRectangle -- - * Perform a PolyRectangle, routing output to backing-store as needed. - * - * Results: - * None - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSPolyRectangle(pDrawable, pGC, nrects, pRects) - DrawablePtr pDrawable; - GCPtr pGC; - int nrects; - xRectangle *pRects; -{ - xRectangle *pRectsCopy; - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - pRectsCopy =(xRectangle *)malloc(nrects*sizeof(xRectangle)); - if (pRectsCopy) - { - copyData(pRects, pRectsCopy, nrects, MoreCopy2); - - (* pGC->ops->PolyRectangle)(pDrawable, pGC, nrects, pRects); - (* pBackingGC->ops->PolyRectangle)(pBackingDrawable, - pBackingGC, nrects, pRectsCopy); - - free(pRectsCopy); - } - - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSPolyArc -- - * Perform a PolyArc, routing output to backing-store as needed. - * - * Results: - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSPolyArc(pDrawable, pGC, narcs, parcs) - DrawablePtr pDrawable; - GCPtr pGC; - int narcs; - xArc *parcs; -{ - xArc *pArcsCopy; - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - pArcsCopy = (xArc *)malloc(narcs*sizeof(xArc)); - if (pArcsCopy) - { - copyData(parcs, pArcsCopy, narcs, MoreCopy4); - - (* pGC->ops->PolyArc)(pDrawable, pGC, narcs, parcs); - (* pBackingGC->ops->PolyArc)(pBackingDrawable, pBackingGC, - narcs, pArcsCopy); - - free(pArcsCopy); - } - - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSFillPolygon -- - * Perform a FillPolygon, routing output to backing-store as needed. - * - * Results: - * None. - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSFillPolygon(pDrawable, pGC, shape, mode, count, pPts) - DrawablePtr pDrawable; - register GCPtr pGC; - int shape, mode; - register int count; - DDXPointPtr pPts; -{ - DDXPointPtr pPtsCopy; - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - pPtsCopy = (DDXPointPtr)malloc(count*sizeof(DDXPointRec)); - if (pPtsCopy) - { - copyPoints(pPts, pPtsCopy, count, mode); - (* pGC->ops->FillPolygon)(pDrawable, pGC, shape, mode, count, pPts); - (* pBackingGC->ops->FillPolygon)(pBackingDrawable, - pBackingGC, shape, mode, - count, pPtsCopy); - - free(pPtsCopy); - } - - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSPolyFillRect -- - * Perform a PolyFillRect, routing output to backing-store as needed. - * - * Results: - * None. - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSPolyFillRect(pDrawable, pGC, nrectFill, prectInit) - DrawablePtr pDrawable; - GCPtr pGC; - int nrectFill; /* number of rectangles to fill */ - xRectangle *prectInit; /* Pointer to first rectangle to fill */ -{ - xRectangle *pRectCopy; - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - pRectCopy = - (xRectangle *)malloc(nrectFill*sizeof(xRectangle)); - if (pRectCopy) - { - copyData(prectInit, pRectCopy, nrectFill, MoreCopy2); - - (* pGC->ops->PolyFillRect)(pDrawable, pGC, nrectFill, prectInit); - (* pBackingGC->ops->PolyFillRect)(pBackingDrawable, - pBackingGC, nrectFill, pRectCopy); - - free(pRectCopy); - } - - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSPolyFillArc -- - * Perform a PolyFillArc, routing output to backing-store as needed. - * - * Results: - * None. - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSPolyFillArc(pDrawable, pGC, narcs, parcs) - DrawablePtr pDrawable; - GCPtr pGC; - int narcs; - xArc *parcs; -{ - xArc *pArcsCopy; - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - pArcsCopy = (xArc *)malloc(narcs*sizeof(xArc)); - if (pArcsCopy) - { - copyData(parcs, pArcsCopy, narcs, MoreCopy4); - (* pGC->ops->PolyFillArc)(pDrawable, pGC, narcs, parcs); - (* pBackingGC->ops->PolyFillArc)(pBackingDrawable, - pBackingGC, narcs, pArcsCopy); - free(pArcsCopy); - } - - EPILOGUE (pGC); -} - - -/*- - *----------------------------------------------------------------------- - * miBSPolyText8 -- - * Perform a PolyText8, routing output to backing-store as needed. - * - * Results: - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static int -miBSPolyText8(pDrawable, pGC, x, y, count, chars) - DrawablePtr pDrawable; - GCPtr pGC; - int x, y; - int count; - char *chars; -{ - int result; - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - result = (* pGC->ops->PolyText8)(pDrawable, pGC, x, y, count, chars); - (* pBackingGC->ops->PolyText8)(pBackingDrawable, pBackingGC, - x - pBackingStore->x, y - pBackingStore->y, - count, chars); - - EPILOGUE (pGC); - return result; -} - -/*- - *----------------------------------------------------------------------- - * miBSPolyText16 -- - * Perform a PolyText16, routing output to backing-store as needed. - * - * Results: - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static int -miBSPolyText16(pDrawable, pGC, x, y, count, chars) - DrawablePtr pDrawable; - GCPtr pGC; - int x, y; - int count; - unsigned short *chars; -{ - int result; - SETUP_BACKING (pDrawable, pGC); - - PROLOGUE(pGC); - - result = (* pGC->ops->PolyText16)(pDrawable, pGC, x, y, count, chars); - (* pBackingGC->ops->PolyText16)(pBackingDrawable, pBackingGC, - x - pBackingStore->x, y - pBackingStore->y, - count, chars); - - EPILOGUE (pGC); - - return result; -} - -/*- - *----------------------------------------------------------------------- - * miBSImageText8 -- - * Perform a ImageText8, routing output to backing-store as needed. - * - * Results: - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSImageText8(pDrawable, pGC, x, y, count, chars) - DrawablePtr pDrawable; - GCPtr pGC; - int x, y; - int count; - char *chars; -{ - SETUP_BACKING (pDrawable, pGC); - PROLOGUE(pGC); - - (* pGC->ops->ImageText8)(pDrawable, pGC, x, y, count, chars); - (* pBackingGC->ops->ImageText8)(pBackingDrawable, pBackingGC, - x - pBackingStore->x, y - pBackingStore->y, - count, chars); - - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSImageText16 -- - * Perform a ImageText16, routing output to backing-store as needed. - * - * Results: - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSImageText16(pDrawable, pGC, x, y, count, chars) - DrawablePtr pDrawable; - GCPtr pGC; - int x, y; - int count; - unsigned short *chars; -{ - SETUP_BACKING (pDrawable, pGC); - PROLOGUE(pGC); - - (* pGC->ops->ImageText16)(pDrawable, pGC, x, y, count, chars); - (* pBackingGC->ops->ImageText16)(pBackingDrawable, pBackingGC, - x - pBackingStore->x, y - pBackingStore->y, - count, chars); - - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSImageGlyphBlt -- - * Perform a ImageGlyphBlt, routing output to backing-store as needed. - * - * Results: - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) - DrawablePtr pDrawable; - GCPtr pGC; - int x, y; - unsigned int nglyph; - CharInfoPtr *ppci; /* array of character info */ - void * pglyphBase; /* start of array of glyphs */ -{ - SETUP_BACKING (pDrawable, pGC); - PROLOGUE(pGC); - - (* pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci, - pglyphBase); - (* pBackingGC->ops->ImageGlyphBlt)(pBackingDrawable, pBackingGC, - x - pBackingStore->x, y - pBackingStore->y, - nglyph, ppci, pglyphBase); - - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSPolyGlyphBlt -- - * Perform a PolyGlyphBlt, routing output to backing-store as needed. - * - * Results: - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase) - DrawablePtr pDrawable; - GCPtr pGC; - int x, y; - unsigned int nglyph; - CharInfoPtr *ppci; /* array of character info */ - void * pglyphBase; /* start of array of glyphs */ -{ - SETUP_BACKING (pDrawable, pGC); - PROLOGUE(pGC); - - (* pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, - ppci, pglyphBase); - (* pBackingGC->ops->PolyGlyphBlt)(pBackingDrawable, pBackingGC, - x - pBackingStore->x, y - pBackingStore->y, - nglyph, ppci, pglyphBase); - EPILOGUE (pGC); -} - -/*- - *----------------------------------------------------------------------- - * miBSPushPixels -- - * Perform a PushPixels, routing output to backing-store as needed. - * - * Results: - * - * Side Effects: - * - *----------------------------------------------------------------------- - */ -static void -miBSPushPixels(pGC, pBitMap, pDst, w, h, x, y) - GCPtr pGC; - PixmapPtr pBitMap; - DrawablePtr pDst; - int w, h, x, y; -{ - SETUP_BACKING (pDst, pGC); - PROLOGUE(pGC); - - (* pGC->ops->PushPixels)(pGC, pBitMap, pDst, w, h, x, y); - if (pGC->miTranslate) { - x -= pDst->x; - y -= pDst->y; - } - (* pBackingGC->ops->PushPixels)(pBackingGC, pBitMap, - pBackingDrawable, w, h, - x - pBackingStore->x, y - pBackingStore->y); - - EPILOGUE (pGC); -} - -#ifdef NEED_LINEHELPER -/*- - *----------------------------------------------------------------------- - * miBSLineHelper -- - * - * Results: should never be called - * - * Side Effects: server dies - * - *----------------------------------------------------------------------- - */ -static void -miBSLineHelper() -{ - FatalError("miBSLineHelper called\n"); -} -#endif - -/*- - *----------------------------------------------------------------------- - * miBSClearBackingStore -- - * Clear the given area of the backing pixmap with the background of - * the window, whatever it is. If generateExposures is TRUE, generate - * exposure events for the area. Note that if the area has any - * part outside the saved portions of the window, we do not allow the - * count in the expose events to be 0, since there will be more - * expose events to come. - * - * Results: - * None. - * - * Side Effects: - * Areas of pixmap are cleared and Expose events are generated. - * - *----------------------------------------------------------------------- - */ -static RegionPtr -miBSClearBackingStore(pWin, x, y, w, h, generateExposures) - WindowPtr pWin; - int x; - int y; - int w; - int h; - Bool generateExposures; -{ - RegionPtr pRgn; - int i; - miBSWindowPtr pBackingStore; - ScreenPtr pScreen; - GCPtr pGC; - int ts_x_origin, - ts_y_origin; - void *gcvalues[4]; - unsigned long gcmask; - xRectangle *rects; - BoxPtr pBox; - BoxRec box; - PixUnion background; - char backgroundState; - int numRects; - - pBackingStore = (miBSWindowPtr)pWin->backStorage; - pScreen = pWin->drawable.pScreen; - - if ((pBackingStore->status == StatusNoPixmap) || - (pBackingStore->status == StatusBadAlloc)) - return NullRegion; - - if (w == 0) - w = (int) pWin->drawable.width - x; - if (h == 0) - h = (int) pWin->drawable.height - y; - - box.x1 = x; - box.y1 = y; - box.x2 = x + w; - box.y2 = y + h; - pRgn = RegionCreate(&box, 1); - if (!pRgn) - return NullRegion; - RegionIntersect(pRgn, pRgn, &pBackingStore->SavedRegion); - - if (RegionNotEmpty(pRgn)) - { - /* - * if clearing entire window, simply make new virtual - * tile. For the root window, we also destroy the pixmap - * to save a pile of memory - */ - if (x == 0 && y == 0 && - w == pWin->drawable.width && - h == pWin->drawable.height) - { - if (!pWin->parent) - miDestroyBSPixmap (pWin); - if (pBackingStore->status != StatusContents) - miTileVirtualBS (pWin); - } - - ts_x_origin = ts_y_origin = 0; - - backgroundState = pWin->backgroundState; - background = pWin->background; - if (backgroundState == ParentRelative) { - WindowPtr pParent; - - pParent = pWin; - while (pParent->backgroundState == ParentRelative) { - ts_x_origin -= pParent->origin.x; - ts_y_origin -= pParent->origin.y; - pParent = pParent->parent; - } - backgroundState = pParent->backgroundState; - background = pParent->background; - } - - if ((backgroundState != None) && - ((pBackingStore->status == StatusContents) || - !SameBackground (pBackingStore->backgroundState, - pBackingStore->background, - backgroundState, - background))) - { - if (!pBackingStore->pBackingPixmap) - miCreateBSPixmap(pWin, NullBox); - - pGC = GetScratchGC(pWin->drawable.depth, pScreen); - if (pGC && pBackingStore->pBackingPixmap) - { - /* - * First take care of any ParentRelative stuff by altering the - * tile/stipple origin to match the coordinates of the upper-left - * corner of the first ancestor without a ParentRelative background. - * This coordinate is, of course, negative. - */ - - if (backgroundState == BackgroundPixel) - { - gcvalues[0] = (void *) background.pixel; - gcvalues[1] = (void *)FillSolid; - gcmask = GCForeground|GCFillStyle; - } - else - { - gcvalues[0] = (void *)FillTiled; - gcvalues[1] = (void *) background.pixmap; - gcmask = GCFillStyle|GCTile; - } - gcvalues[2] = (void *)(long)(ts_x_origin - pBackingStore->x); - gcvalues[3] = (void *)(long)(ts_y_origin - pBackingStore->y); - gcmask |= GCTileStipXOrigin|GCTileStipYOrigin; - DoChangeGC(pGC, gcmask, (XID *)gcvalues, TRUE); - ValidateGC((DrawablePtr)pBackingStore->pBackingPixmap, pGC); - - /* - * Figure out the array of rectangles to fill and fill them with - * PolyFillRect in the proper mode, as set in the GC above. - */ - numRects = RegionNumRects(pRgn); - rects = (xRectangle *)malloc(numRects*sizeof(xRectangle)); - - if (rects) - { - for (i = 0, pBox = RegionRects(pRgn); - i < numRects; - i++, pBox++) - { - rects[i].x = pBox->x1 - pBackingStore->x; - rects[i].y = pBox->y1 - pBackingStore->y; - rects[i].width = pBox->x2 - pBox->x1; - rects[i].height = pBox->y2 - pBox->y1; - } - (* pGC->ops->PolyFillRect) ( - (DrawablePtr)pBackingStore->pBackingPixmap, - pGC, numRects, rects); - free(rects); - } - FreeScratchGC(pGC); - } - } - - if (!generateExposures) - { - RegionDestroy(pRgn); - pRgn = NULL; - } - else - { - /* - * result must be screen relative, but is currently - * drawable relative. - */ - RegionTranslate(pRgn, pWin->drawable.x, - pWin->drawable.y); - } - } - else - { - RegionDestroy(pRgn); - pRgn = NULL; - } - return pRgn; -} - -static void -miBSClearBackingRegion (pWin, pRgn) - WindowPtr pWin; - RegionPtr pRgn; -{ - BoxPtr pBox; - int i; - - i = RegionNumRects(pRgn); - pBox = RegionRects(pRgn); - while (i--) - { - (void) miBSClearBackingStore(pWin, pBox->x1, pBox->y1, - pBox->x2 - pBox->x1, - pBox->y2 - pBox->y1, - FALSE); - pBox++; - } -} - -/* - * fill a region of the destination with virtual bits - * - * pRgn is to be translated by (x,y) - */ - -static void -miBSFillVirtualBits (pDrawable, pGC, pRgn, x, y, state, pixunion, planeMask) - DrawablePtr pDrawable; - GCPtr pGC; - RegionPtr pRgn; - int x, y; - int state; - PixUnion pixunion; - unsigned long planeMask; -{ - int i; - BITS32 gcmask; - void * gcval[5]; - xRectangle *pRect; - BoxPtr pBox; - WindowPtr pWin; - int numRects; - - if (state == None) - return; - numRects = RegionNumRects(pRgn); - pRect = (xRectangle *)malloc(numRects * sizeof(xRectangle)); - if (!pRect) - return; - pWin = 0; - if (pDrawable->type != DRAWABLE_PIXMAP) - { - pWin = (WindowPtr) pDrawable; - if (!pWin->backStorage) - pWin = 0; - } - i = 0; - gcmask = 0; - gcval[i++] = (void *)planeMask; - gcmask |= GCPlaneMask; - if (state == BackgroundPixel) - { - if (pGC->fgPixel != pixunion.pixel) - { - gcval[i++] = (void *)pixunion.pixel; - gcmask |= GCForeground; - } - if (pGC->fillStyle != FillSolid) - { - gcval[i++] = (void *)FillSolid; - gcmask |= GCFillStyle; - } - } - else - { - if (pGC->fillStyle != FillTiled) - { - gcval[i++] = (void *)FillTiled; - gcmask |= GCFillStyle; - } - if (pGC->tileIsPixel || pGC->tile.pixmap != pixunion.pixmap) - { - gcval[i++] = (void *)pixunion.pixmap; - gcmask |= GCTile; - } - if (pGC->patOrg.x != x) - { - gcval[i++] = (void *)(long)x; - gcmask |= GCTileStipXOrigin; - } - if (pGC->patOrg.y != y) - { - gcval[i++] = (void *)(long)y; - gcmask |= GCTileStipYOrigin; - } - } - if (gcmask) - DoChangeGC (pGC, gcmask, (XID *)gcval, 1); - - if (pWin) - (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack); - - if (pDrawable->serialNumber != pGC->serialNumber) - ValidateGC (pDrawable, pGC); - - pBox = RegionRects(pRgn); - for (i = numRects; --i >= 0; pBox++, pRect++) - { - pRect->x = pBox->x1 + x; - pRect->y = pBox->y1 + y; - pRect->width = pBox->x2 - pBox->x1; - pRect->height = pBox->y2 - pBox->y1; - } - pRect -= numRects; - (*pGC->ops->PolyFillRect) (pDrawable, pGC, numRects, pRect); - if (pWin) - (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing); - free (pRect); -} - -/*- - *----------------------------------------------------------------------- - * miBSAllocate -- - * Create and install backing store info for a window - * - *----------------------------------------------------------------------- - */ - -static void -miBSAllocate(pWin) - WindowPtr pWin; -{ - register miBSWindowPtr pBackingStore; - - if (pWin->drawable.pScreen->backingStoreSupport == NotUseful) - return; - if (!(pBackingStore = (miBSWindowPtr)pWin->backStorage)) - { - - pBackingStore = (miBSWindowPtr)malloc(sizeof(miBSWindowRec)); - if (!pBackingStore) - return; - - pBackingStore->pBackingPixmap = NullPixmap; - pBackingStore->x = 0; - pBackingStore->y = 0; - RegionNull(&pBackingStore->SavedRegion); - pBackingStore->viewable = (char)pWin->viewable; - pBackingStore->status = StatusNoPixmap; - pBackingStore->backgroundState = None; - pWin->backStorage = (void *) pBackingStore; - } - - /* - * Now want to initialize the backing pixmap and SavedRegion if - * necessary. The initialization consists of finding all the - * currently-obscured regions, by taking the inverse of the window's - * clip list, storing the result in SavedRegion, and exposing those - * areas of the window. - */ - - if (pBackingStore->status == StatusNoPixmap && - ((pWin->backingStore == WhenMapped && pWin->viewable) || - (pWin->backingStore == Always))) - { - BoxRec box; - RegionPtr pSavedRegion; - - pSavedRegion = &pBackingStore->SavedRegion; - - box.x1 = pWin->drawable.x; - box.x2 = box.x1 + (int) pWin->drawable.width; - box.y1 = pWin->drawable.y; - box.y2 = pWin->drawable.y + (int) pWin->drawable.height; - - RegionInverse(pSavedRegion, &pWin->clipList, &box); - RegionTranslate(pSavedRegion, - -pWin->drawable.x, - -pWin->drawable.y); -#ifdef SHAPE - if (wBoundingShape (pWin)) - RegionIntersect(pSavedRegion, pSavedRegion, - wBoundingShape (pWin)); - if (wClipShape (pWin)) - RegionIntersect(pSavedRegion, pSavedRegion, - wClipShape (pWin)); -#endif - /* if window is already on-screen, assume it has been drawn to */ - if (pWin->viewable) - pBackingStore->status = StatusVDirty; - miTileVirtualBS (pWin); - - /* - * deliver all the newly available regions - * as exposure events to the window - */ - - miSendExposures(pWin, pSavedRegion, 0, 0); - } - else if (!pWin->viewable) - { - /* - * Turn off backing store when we're not supposed to - * be saving anything - */ - if (pBackingStore->status != StatusNoPixmap) - { - RegionEmpty(&pBackingStore->SavedRegion); - miDestroyBSPixmap (pWin); - } - } -} - -/*- - *----------------------------------------------------------------------- - * miBSFree -- - * Destroy and free all the stuff associated with the backing-store - * for the given window. - * - * Results: - * None. - * - * Side Effects: - * The backing pixmap and all the regions and GC's are destroyed. - * - *----------------------------------------------------------------------- - */ -static void -miBSFree(pWin) - WindowPtr pWin; -{ - miBSWindowPtr pBackingStore; - - pBackingStore = (miBSWindowPtr)pWin->backStorage; - if (pBackingStore) - { - miDestroyBSPixmap (pWin); - - RegionUninit(&pBackingStore->SavedRegion); - - free(pBackingStore); - pWin->backStorage = NULL; - } -} - -/*- - *----------------------------------------------------------------------- - * miResizeBackingStore -- - * Alter the size of the backing pixmap as necessary when the - * SavedRegion changes size. The contents of the old pixmap are - * copied/shifted into the new/same pixmap. - * - * Results: - * The new Pixmap is created as necessary. - * - * Side Effects: - * The old pixmap is destroyed. - * - *----------------------------------------------------------------------- - */ -static void -miResizeBackingStore( - WindowPtr pWin, - int dx, /* bits are moving this far */ - int dy, /* bits are moving this far */ - Bool saveBits) /* bits are useful */ -{ - miBSWindowPtr pBackingStore; - PixmapPtr pBackingPixmap; - ScreenPtr pScreen; - GC *pGC; - BoxPtr extents; - PixmapPtr pNewPixmap; - int nx, ny; - int nw, nh; - - pBackingStore = (miBSWindowPtr)(pWin->backStorage); - pBackingPixmap = pBackingStore->pBackingPixmap; - if (!pBackingPixmap) - return; - pScreen = pWin->drawable.pScreen; - extents = RegionExtents(&pBackingStore->SavedRegion); - pNewPixmap = pBackingPixmap; - - nw = extents->x2 - extents->x1; - nh = extents->y2 - extents->y1; - - /* the policy here could be more sophisticated */ - if (nw != pBackingPixmap->drawable.width || - nh != pBackingPixmap->drawable.height) - { - if (!saveBits || !nw || !nh) - { - pNewPixmap = NullPixmap; - pBackingStore->status = StatusNoPixmap; - } - else - { - pNewPixmap = (PixmapPtr)(*pScreen->CreatePixmap) - (pScreen, - nw, nh, - pWin->drawable.depth, 0); - if (!pNewPixmap) - { -#ifdef BSEAGER - pBackingStore->status = StatusNoPixmap; -#else - pBackingStore->status = StatusBadAlloc; -#endif - } - } - } - if (!pNewPixmap) - { - pBackingStore->x = 0; - pBackingStore->y = 0; - } - else - { - nx = pBackingStore->x - extents->x1 + dx; - ny = pBackingStore->y - extents->y1 + dy; - pBackingStore->x = extents->x1; - pBackingStore->y = extents->y1; - - if (saveBits && (pNewPixmap != pBackingPixmap || nx != 0 || ny != 0)) - { - pGC = GetScratchGC(pNewPixmap->drawable.depth, pScreen); - if (pGC) - { - ValidateGC((DrawablePtr)pNewPixmap, pGC); - /* if we implement a policy where the pixmap can be larger than - * the region extents, we might want to optimize this copyarea - * by only copying the old extents, rather than the entire - * pixmap - */ - (*pGC->ops->CopyArea)((DrawablePtr)pBackingPixmap, - (DrawablePtr)pNewPixmap, pGC, - 0, 0, - pBackingPixmap->drawable.width, - pBackingPixmap->drawable.height, - nx, ny); - FreeScratchGC(pGC); - } - } - } - /* SavedRegion is used in the backingGC clip; force an update */ - pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER; - if (pNewPixmap != pBackingPixmap) - { - (* pScreen->DestroyPixmap)(pBackingPixmap); - pBackingStore->pBackingPixmap = pNewPixmap; - } -} - -/*- - *----------------------------------------------------------------------- - * miBSSaveDoomedAreas -- - * Saved the areas of the given window that are about to be - * obscured. If the window has moved, pObscured is expected to - * be at the new screen location and (dx,dy) is expected to be the offset - * to the window's previous location. - * - * Results: - * None. - * - * Side Effects: - * The region is copied from the screen into pBackingPixmap and - * SavedRegion is updated. - * - *----------------------------------------------------------------------- - */ -static void -miBSSaveDoomedAreas(pWin, pObscured, dx, dy) - register WindowPtr pWin; - RegionPtr pObscured; - int dx, dy; -{ - miBSWindowPtr pBackingStore; - ScreenPtr pScreen; - int x, y; - - pBackingStore = (miBSWindowPtr)pWin->backStorage; - pScreen = pWin->drawable.pScreen; - - /* - * If the window isn't realized, it's being unmapped, thus we don't - * want to save anything if backingStore isn't Always. - */ - if (!pWin->realized) - { - pBackingStore->viewable = (char)pWin->viewable; - if (pWin->backingStore != Always) - { - RegionEmpty(&pBackingStore->SavedRegion); - miDestroyBSPixmap (pWin); - return; - } - if (pBackingStore->status == StatusBadAlloc) - pBackingStore->status = StatusNoPixmap; - } - - /* Don't even pretend to save anything for a virtual background None */ - if ((pBackingStore->status == StatusVirtual) && - (pBackingStore->backgroundState == None)) - return; - - if (RegionNotEmpty(pObscured)) - { - BoxRec oldExtents; - x = pWin->drawable.x; - y = pWin->drawable.y; - RegionTranslate(pObscured, -x, -y); - oldExtents = *RegionExtents(&pBackingStore->SavedRegion); - RegionUnion(&pBackingStore->SavedRegion, - &pBackingStore->SavedRegion, - pObscured); - /* - * only save the bits if we've actually - * started using backing store - */ - if (pBackingStore->status != StatusVirtual) - { - if (!pBackingStore->pBackingPixmap) - miCreateBSPixmap (pWin, &oldExtents); - else - miResizeBackingStore(pWin, 0, 0, TRUE); - - if (pBackingStore->pBackingPixmap) { - if (pBackingStore->x | pBackingStore->y) - { - RegionTranslate(pObscured, - -pBackingStore->x, - -pBackingStore->y); - x += pBackingStore->x; - y += pBackingStore->y; - } - (* pScreen->BackingStoreFuncs.SaveAreas) - (pBackingStore->pBackingPixmap, pObscured, - x - dx, y - dy, pWin); - } - } - RegionTranslate(pObscured, x, y); - } - else - { - if (RegionBroken(pObscured)) - { - RegionEmpty(&pBackingStore->SavedRegion); - miDestroyBSPixmap (pWin); - return; - } - } -} - -/*- - *----------------------------------------------------------------------- - * miBSRestoreAreas -- - * Restore areas from backing-store that are no longer obscured. - * expects prgnExposed to contain a screen-relative area. - * - * Results: - * The region to generate exposure events on (which may be - * different from the region to paint). - * - * Side Effects: - * Areas are copied from pBackingPixmap to the screen. prgnExposed - * is altered to contain the region that could not be restored from - * backing-store. - * - * Notes: - * This is called before sending any exposure events to the client, - * and so might be called if the window has grown. Changing the backing - * pixmap doesn't require revalidating the backingGC because the - * client's next output request will result in a call to ValidateGC, - * since the window clip region has changed, which will in turn call - * miValidateBackingStore. - *----------------------------------------------------------------------- - */ -static RegionPtr -miBSRestoreAreas(pWin, prgnExposed) - register WindowPtr pWin; - RegionPtr prgnExposed; -{ - PixmapPtr pBackingPixmap; - miBSWindowPtr pBackingStore; - RegionPtr prgnSaved; - RegionPtr prgnRestored; - register ScreenPtr pScreen; - RegionPtr exposures = prgnExposed; - - pScreen = pWin->drawable.pScreen; - pBackingStore = (miBSWindowPtr)pWin->backStorage; - pBackingPixmap = pBackingStore->pBackingPixmap; - - prgnSaved = &pBackingStore->SavedRegion; - - if (pBackingStore->status == StatusContents) - { - RegionTranslate(prgnSaved, pWin->drawable.x, - pWin->drawable.y); - - prgnRestored = RegionCreate((BoxPtr)NULL, 1); - RegionIntersect(prgnRestored, prgnExposed, prgnSaved); - - /* - * Since prgnExposed is no longer obscured, we no longer - * will have a valid copy of it in backing-store, but there is a valid - * copy of it on screen, so subtract the area we just restored from - * from the area to be exposed. - */ - - if (RegionNotEmpty(prgnRestored)) - { - RegionSubtract(prgnSaved, prgnSaved, prgnExposed); - RegionSubtract(prgnExposed, prgnExposed, prgnRestored); - - /* - * Do the actual restoration - */ - (* pScreen->BackingStoreFuncs.RestoreAreas) (pBackingPixmap, - prgnRestored, - pWin->drawable.x + pBackingStore->x, - pWin->drawable.y + pBackingStore->y, - pWin); - /* - * if the saved region is completely empty, dispose of the - * backing pixmap, otherwise, retranslate the saved - * region to window relative - */ - - if (RegionNotEmpty(prgnSaved)) - { - RegionTranslate(prgnSaved, - -pWin->drawable.x, - -pWin->drawable.y); - miResizeBackingStore(pWin, 0, 0, TRUE); - } - else - miDestroyBSPixmap (pWin); - } - else - RegionTranslate(prgnSaved, - -pWin->drawable.x, -pWin->drawable.y); - RegionDestroy(prgnRestored); - - } - else if ((pBackingStore->status == StatusVirtual) || - (pBackingStore->status == StatusVDirty)) - { - RegionTranslate(prgnSaved, - pWin->drawable.x, pWin->drawable.y); - exposures = RegionCreate(NullBox, 1); - if (SameBackground (pBackingStore->backgroundState, - pBackingStore->background, - pWin->backgroundState, - pWin->background)) - { - RegionSubtract(exposures, prgnExposed, prgnSaved); - } - else - { - miTileVirtualBS(pWin); - - /* we need to expose all we have (virtually) retiled */ - RegionUnion(exposures, prgnExposed, prgnSaved); - } - RegionSubtract(prgnSaved, prgnSaved, prgnExposed); - RegionTranslate(prgnSaved, - -pWin->drawable.x, -pWin->drawable.y); - } - else if (pWin->viewable && !pBackingStore->viewable && - pWin->backingStore != Always) - { - /* - * The window was just mapped and nothing has been saved in - * backing-store from the last time it was mapped. We want to capture - * any output to regions that are already obscured but there are no - * bits to snag off the screen, so we initialize things just as we did - * in miBSAllocate, above. - */ - BoxRec box; - - prgnSaved = &pBackingStore->SavedRegion; - - box.x1 = pWin->drawable.x; - box.x2 = box.x1 + (int) pWin->drawable.width; - box.y1 = pWin->drawable.y; - box.y2 = box.y1 + (int) pWin->drawable.height; - - RegionInverse(prgnSaved, &pWin->clipList, &box); - RegionTranslate(prgnSaved, - -pWin->drawable.x, - -pWin->drawable.y); -#ifdef SHAPE - if (wBoundingShape (pWin)) - RegionIntersect(prgnSaved, prgnSaved, - wBoundingShape (pWin)); - if (wClipShape (pWin)) - RegionIntersect(prgnSaved, prgnSaved, - wClipShape (pWin)); -#endif - miTileVirtualBS(pWin); - - exposures = RegionCreate(&box, 1); - } - pBackingStore->viewable = (char)pWin->viewable; - return exposures; -} - - -/*- - *----------------------------------------------------------------------- - * miBSTranslateBackingStore -- - * Shift the backing-store in the given direction. Called when bit - * gravity is shifting things around. - * - * Results: - * An occluded region of the window which should be sent exposure events. - * This region should be in absolute coordinates (i.e. include - * new window position). - * - * Side Effects: - * If the window changed size as well as position, the backing pixmap - * is resized. The contents of the backing pixmap are shifted - * - * Warning: - * Bob and I have rewritten this routine quite a few times, each - * time it gets a few more cases correct, and introducing some - * interesting bugs. Naturally, I think the code is correct this - * time. - * - * Let me try to explain what this routine is for: - * - * It's called from SlideAndSizeWindow whenever a window - * with backing store is resized. There are two separate - * possibilities: - * - * a) The window has ForgetGravity - * - * In this case, windx, windy will be 0 and oldClip will - * be NULL. This indicates that all of the window contents - * currently saved offscreen should be discarded, and the - * entire window exposed. TranslateBackingStore, then, should - * prepare a completely new backing store region based on the - * new window clipList and return that region for exposure. - * - * b) The window has some other gravity - * - * In this case, windx, windy will be set to the distance - * that the bits should move within the window. oldClip - * will be set to the old visible portion of the window. - * TranslateBackingStore, then, should adjust the backing - * store to accommodate the portion of the existing backing - * store bits which coorespond to backing store bits which - * will still be occluded in the new configuration. oldx,oldy - * are set to the old position of the window on the screen. - * - * Furthermore, in this case any contents of the screen which - * are about to become occluded should be fetched from the screen - * and placed in backing store. This is to avoid the eventual - * occlusion by the win gravity shifting the child window bits around - * on top of this window, and potentially losing information - * - * It's also called from SetShape, but I think (he says not - * really knowing for sure) that this code will even work - * in that case. - *----------------------------------------------------------------------- - */ - -static RegionPtr -miBSTranslateBackingStore(pWin, windx, windy, oldClip, oldx, oldy) - WindowPtr pWin; - int windx; /* bit translation distance in window */ - int windy; - RegionPtr oldClip; /* Region being copied */ - int oldx; /* old window position */ - int oldy; -{ - register miBSWindowPtr pBackingStore; - register RegionPtr pSavedRegion; - register RegionPtr newSaved, doomed; - register ScreenPtr pScreen; - BoxRec extents; - int scrdx; /* bit translation distance on screen */ - int scrdy; - int dx; /* distance window moved on screen */ - int dy; - - pScreen = pWin->drawable.pScreen; - pBackingStore = (miBSWindowPtr)(pWin->backStorage); - if ((pBackingStore->status == StatusNoPixmap) || - (pBackingStore->status == StatusBadAlloc)) - return NullRegion; - - /* - * Compute the new saved region - */ - - newSaved = RegionCreate(NullBox, 1); - extents.x1 = pWin->drawable.x; - extents.x2 = pWin->drawable.x + (int) pWin->drawable.width; - extents.y1 = pWin->drawable.y; - extents.y2 = pWin->drawable.y + (int) pWin->drawable.height; - RegionInverse(newSaved, &pWin->clipList, &extents); - - RegionTranslate(newSaved, - -pWin->drawable.x, -pWin->drawable.y); -#ifdef SHAPE - if (wBoundingShape (pWin) || wClipShape (pWin)) { - if (wBoundingShape (pWin)) - RegionIntersect(newSaved, newSaved, - wBoundingShape (pWin)); - if (wClipShape (pWin)) - RegionIntersect(newSaved, newSaved, wClipShape (pWin)); - } -#endif - - pSavedRegion = &pBackingStore->SavedRegion; - - /* now find any visible areas we can save from the screen */ - /* and then translate newSaved to old local coordinates */ - if (oldClip) - { - /* bit gravity makes things virtually too hard, punt */ - if (((windx != 0) || (windy != 0)) && - (pBackingStore->status != StatusContents)) - miCreateBSPixmap(pWin, NullBox); - - /* - * The window is moving this far on the screen - */ - dx = pWin->drawable.x - oldx; - dy = pWin->drawable.y - oldy; - /* - * The bits will be moving on the screen by the - * amount the window is moving + the amount the - * bits are moving within the window - */ - scrdx = windx + dx; - scrdy = windy + dy; - - /* - * intersect at old bit position to discover the - * bits on the screen which can be put into the - * new backing store - */ - RegionTranslate(oldClip, windx - oldx, windy - oldy); - doomed = RegionCreate(NullBox, 1); - RegionIntersect(doomed, oldClip, newSaved); - RegionTranslate(oldClip, oldx - windx, oldy - windy); - - /* - * Translate the old saved region to the position in the - * window where it will appear to be - */ - RegionTranslate(pSavedRegion, windx, windy); - - /* - * Add the old saved region to the new saved region, so - * that calls to RestoreAreas will be able to fetch those - * bits back - */ - RegionUnion(newSaved, newSaved, pSavedRegion); - - /* - * Swap the new saved region into the window - */ - { - RegionRec tmp; - - tmp = *pSavedRegion; - *pSavedRegion = *newSaved; - *newSaved = tmp; - } - miResizeBackingStore (pWin, windx, windy, TRUE); - - /* - * Compute the newly enabled region - * of backing store. This region will be - * set to background in the backing pixmap and - * sent as exposure events to the client. - */ - RegionSubtract(newSaved, pSavedRegion, newSaved); - - /* - * Fetch bits which will be obscured from - * the screen - */ - if (RegionNotEmpty(doomed)) - { - /* - * Don't clear regions which have bits on the - * screen - */ - RegionSubtract(newSaved, newSaved, doomed); - - /* - * Make the region to SaveDoomedAreas absolute, instead - * of window relative. - */ - RegionTranslate(doomed, - pWin->drawable.x, pWin->drawable.y); - (* pScreen->SaveDoomedAreas) (pWin, doomed, scrdx, scrdy); - } - - RegionDestroy(doomed); - - /* - * and clear whatever there is that's new - */ - if (RegionNotEmpty(newSaved)) - { - miBSClearBackingRegion (pWin, newSaved); - /* - * Make the exposed region absolute - */ - RegionTranslate(newSaved, - pWin->drawable.x, - pWin->drawable.y); - } - else - { - RegionDestroy(newSaved); - newSaved = NullRegion; - } - } - else - { - /* - * ForgetGravity: just reset backing store and - * expose the whole mess - */ - RegionCopy(pSavedRegion, newSaved); - RegionTranslate(newSaved, - pWin->drawable.x, pWin->drawable.y); - - miResizeBackingStore (pWin, 0, 0, FALSE); - (void) miBSClearBackingStore (pWin, 0, 0, 0, 0, FALSE); - } - - return newSaved; -} - -/* - * Inform the backing store layer that you are about to validate - * a gc with a window, and that subsequent output to the window - * is (or is not) guaranteed to be already clipped to the visible - * regions of the window. - */ - -static void -miBSDrawGuarantee (pWin, pGC, guarantee) - WindowPtr pWin; - GCPtr pGC; - int guarantee; -{ - miBSGCPtr pPriv; - - if (pWin->backStorage) - { - pPriv = (miBSGCPtr)pGC->devPrivates[miBSGCIndex].ptr; - if (!pPriv) - (void) miBSCreateGCPrivate (pGC); - pPriv = (miBSGCPtr)pGC->devPrivates[miBSGCIndex].ptr; - if (pPriv) - { - /* - * XXX KLUDGE ALERT - * - * when the GC is Cheap pPriv will point - * at some device's gc func structure. guarantee - * will point at the ChangeGC entry of that struct - * and will never match a valid guarantee value. - */ - switch (pPriv->guarantee) - { - case GuaranteeNothing: - case GuaranteeVisBack: - pPriv->guarantee = guarantee; - break; - } - } - } -} - -#define noBackingCopy (GCGraphicsExposures|GCClipXOrigin|GCClipYOrigin| \ - GCClipMask|GCSubwindowMode| \ - GCTileStipXOrigin|GCTileStipYOrigin) - -/*- - *----------------------------------------------------------------------- - * miBSValidateGC -- - * Wrapper around output-library's ValidateGC routine - * - * Results: - * None. - * - * Side Effects: - * - * Notes: - * The idea here is to perform several functions: - * - All the output calls must be intercepted and routed to - * backing-store as necessary. - * - pGC in the window's devBackingStore must be set up with the - * clip list appropriate for writing to pBackingPixmap (i.e. - * the inverse of the window's clipList intersected with the - * clientClip of the GC). Since the destination for this GC is - * a pixmap, it is sufficient to set the clip list as its - * clientClip. - *----------------------------------------------------------------------- - */ - -static void -miBSValidateGC (pGC, stateChanges, pDrawable) - GCPtr pGC; - unsigned long stateChanges; - DrawablePtr pDrawable; -{ - GCPtr pBackingGC; - miBSWindowPtr pWindowPriv = NULL; - miBSGCPtr pPriv; - WindowPtr pWin; - int lift_functions; - RegionPtr backingCompositeClip = NULL; - - if (pDrawable->type != DRAWABLE_PIXMAP) - { - pWin = (WindowPtr) pDrawable; - pWindowPriv = (miBSWindowPtr) pWin->backStorage; - lift_functions = (pWindowPriv == (miBSWindowPtr) NULL); - } - else - { - pWin = (WindowPtr) NULL; - lift_functions = TRUE; - } - - pPriv = (miBSGCPtr)pGC->devPrivates[miBSGCIndex].ptr; - - FUNC_PROLOGUE (pGC, pPriv); - - (*pGC->funcs->ValidateGC) (pGC, stateChanges, pDrawable); - - /* - * rewrap funcs and ops as Validate may have changed them - */ - - pPriv->wrapFuncs = pGC->funcs; - pPriv->wrapOps = pGC->ops; - - if (!lift_functions && ((pPriv->guarantee == GuaranteeVisBack) || - (pWindowPriv->status == StatusNoPixmap) || - (pWindowPriv->status == StatusBadAlloc))) - lift_functions = TRUE; - - /* - * check to see if a new backingCompositeClip region must - * be generated - */ - - if (!lift_functions && - ((pDrawable->serialNumber != pPriv->serialNumber) || - (stateChanges&(GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)))) - { - if (RegionNotEmpty(&pWindowPriv->SavedRegion)) - { - backingCompositeClip = RegionCreate(NULL, 1); - if ((pGC->clientClipType == CT_NONE) || - (pGC->clientClipType == CT_PIXMAP)) - { - RegionCopy(backingCompositeClip, - &pWindowPriv->SavedRegion); - } - else - { - /* - * Make a new copy of the client clip, translated to - * its proper origin. - */ - - RegionCopy(backingCompositeClip, - pGC->clientClip); - RegionTranslate(backingCompositeClip, - pGC->clipOrg.x, - pGC->clipOrg.y); - RegionIntersect(backingCompositeClip, - backingCompositeClip, - &pWindowPriv->SavedRegion); - } - if (pGC->subWindowMode == IncludeInferiors) - { - RegionPtr translatedClip; - - /* XXX - * any output in IncludeInferiors mode will not - * be redirected to Inferiors backing store. This - * can be fixed only at great cost to the shadow routines. - */ - translatedClip = NotClippedByChildren (pWin); - RegionTranslate(translatedClip, - -pDrawable->x, - -pDrawable->y); - RegionSubtract(backingCompositeClip, - backingCompositeClip, translatedClip); - RegionDestroy(translatedClip); - } - if (!RegionNotEmpty(backingCompositeClip)) - lift_functions = TRUE; - } - else - { - lift_functions = TRUE; - } - - /* Reset the status when drawing to an unoccluded window so that - * future SaveAreas will actually copy bits from the screen. Note that - * output to root window in IncludeInferiors mode will not cause this - * to change. This causes all transient graphics by the window - * manager to the root window to not enable backing store. - */ - if (lift_functions && (pWindowPriv->status == StatusVirtual) && - (pWin->parent || pGC->subWindowMode != IncludeInferiors)) - pWindowPriv->status = StatusVDirty; - } - - /* - * if no backing store has been allocated, and it's needed, - * create it now. - */ - - if (!lift_functions && !pWindowPriv->pBackingPixmap) - { - miCreateBSPixmap (pWin, NullBox); - if (!pWindowPriv->pBackingPixmap) - lift_functions = TRUE; - } - - /* - * create the backing GC if needed, lift functions - * if the creation fails - */ - - if (!lift_functions && !pPriv->pBackingGC) - { - int status; - XID noexpose = xFalse; - - /* We never want ops with the backingGC to generate GraphicsExpose */ - pBackingGC = CreateGC ((DrawablePtr)pWindowPriv->pBackingPixmap, - GCGraphicsExposures, &noexpose, &status); - if (status != Success) - lift_functions = TRUE; - else - pPriv->pBackingGC = pBackingGC; - } - - pBackingGC = pPriv->pBackingGC; - - pPriv->stateChanges |= stateChanges; - - if (lift_functions) - { - if (backingCompositeClip) - RegionDestroy(backingCompositeClip); - - /* unwrap the GC again */ - miBSDestroyGCPrivate (pGC); - - return; - } - - /* - * the rest of this function gets the pBackingGC - * into shape for possible draws - */ - - pPriv->stateChanges &= ~noBackingCopy; - if (pPriv->stateChanges) - CopyGC(pGC, pBackingGC, pPriv->stateChanges); - if ((pGC->patOrg.x - pWindowPriv->x) != pBackingGC->patOrg.x || - (pGC->patOrg.y - pWindowPriv->y) != pBackingGC->patOrg.y) - { - XID vals[2]; - vals[0] = pGC->patOrg.x - pWindowPriv->x; - vals[1] = pGC->patOrg.y - pWindowPriv->y; - DoChangeGC(pBackingGC, GCTileStipXOrigin|GCTileStipYOrigin, vals, 0); - } - pPriv->stateChanges = 0; - - if (backingCompositeClip) - { - XID vals[2]; - - if (pGC->clientClipType == CT_PIXMAP) - { - (*pBackingGC->funcs->CopyClip)(pBackingGC, pGC); - RegionTranslate(backingCompositeClip, - -pGC->clipOrg.x, -pGC->clipOrg.y); - vals[0] = pGC->clipOrg.x - pWindowPriv->x; - vals[1] = pGC->clipOrg.y - pWindowPriv->y; - DoChangeGC(pBackingGC, GCClipXOrigin|GCClipYOrigin, vals, 0); - (* pGC->pScreen->BackingStoreFuncs.SetClipmaskRgn) - (pBackingGC, backingCompositeClip); - RegionDestroy(backingCompositeClip); - } - else - { - vals[0] = -pWindowPriv->x; - vals[1] = -pWindowPriv->y; - DoChangeGC(pBackingGC, GCClipXOrigin|GCClipYOrigin, vals, 0); - (*pBackingGC->funcs->ChangeClip) (pBackingGC, CT_REGION, backingCompositeClip, 0); - } - pPriv->serialNumber = pDrawable->serialNumber; - } - - if (pWindowPriv->pBackingPixmap->drawable.serialNumber - != pBackingGC->serialNumber) - { - ValidateGC((DrawablePtr)pWindowPriv->pBackingPixmap, pBackingGC); - } - - if (pBackingGC->clientClip == 0) - ErrorF ("backing store clip list nil"); - - FUNC_EPILOGUE (pGC, pPriv); -} - -static void -miBSChangeGC (pGC, mask) - GCPtr pGC; - unsigned long mask; -{ - miBSGCPtr pPriv = (miBSGCPtr) (pGC)->devPrivates[miBSGCIndex].ptr; - - FUNC_PROLOGUE (pGC, pPriv); - - (*pGC->funcs->ChangeGC) (pGC, mask); - - FUNC_EPILOGUE (pGC, pPriv); -} - -static void -miBSCopyGC (pGCSrc, mask, pGCDst) - GCPtr pGCSrc, pGCDst; - unsigned long mask; -{ - miBSGCPtr pPriv = (miBSGCPtr) (pGCDst)->devPrivates[miBSGCIndex].ptr; - - FUNC_PROLOGUE (pGCDst, pPriv); - - (*pGCDst->funcs->CopyGC) (pGCSrc, mask, pGCDst); - - FUNC_EPILOGUE (pGCDst, pPriv); -} - -static void -miBSDestroyGC (pGC) - GCPtr pGC; -{ - miBSGCPtr pPriv = (miBSGCPtr) (pGC)->devPrivates[miBSGCIndex].ptr; - - FUNC_PROLOGUE (pGC, pPriv); - - if (pPriv->pBackingGC) - FreeGC(pPriv->pBackingGC, (GContext)0); - - (*pGC->funcs->DestroyGC) (pGC); - - FUNC_EPILOGUE (pGC, pPriv); - - free(pPriv); -} - -static void -miBSChangeClip(pGC, type, pvalue, nrects) - GCPtr pGC; - int type; - void * pvalue; - int nrects; -{ - miBSGCPtr pPriv = (miBSGCPtr) (pGC)->devPrivates[miBSGCIndex].ptr; - - FUNC_PROLOGUE (pGC, pPriv); - - (* pGC->funcs->ChangeClip)(pGC, type, pvalue, nrects); - - FUNC_EPILOGUE (pGC, pPriv); -} - -static void -miBSCopyClip(pgcDst, pgcSrc) - GCPtr pgcDst, pgcSrc; -{ - miBSGCPtr pPriv = (miBSGCPtr) (pgcDst)->devPrivates[miBSGCIndex].ptr; - - FUNC_PROLOGUE (pgcDst, pPriv); - - (* pgcDst->funcs->CopyClip)(pgcDst, pgcSrc); - - FUNC_EPILOGUE (pgcDst, pPriv); -} - -static void -miBSDestroyClip(pGC) - GCPtr pGC; -{ - miBSGCPtr pPriv = (miBSGCPtr) (pGC)->devPrivates[miBSGCIndex].ptr; - - FUNC_PROLOGUE (pGC, pPriv); - - (* pGC->funcs->DestroyClip)(pGC); - - FUNC_EPILOGUE (pGC, pPriv); -} - -static void -miDestroyBSPixmap (pWin) - WindowPtr pWin; -{ - miBSWindowPtr pBackingStore; - ScreenPtr pScreen; - - pScreen = pWin->drawable.pScreen; - pBackingStore = (miBSWindowPtr) pWin->backStorage; - if (pBackingStore->pBackingPixmap) - (* pScreen->DestroyPixmap)(pBackingStore->pBackingPixmap); - pBackingStore->pBackingPixmap = NullPixmap; - pBackingStore->x = 0; - pBackingStore->y = 0; - if (pBackingStore->backgroundState == BackgroundPixmap) - (* pScreen->DestroyPixmap)(pBackingStore->background.pixmap); - pBackingStore->backgroundState = None; - pBackingStore->status = StatusNoPixmap; - pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER; -} - -static void -miTileVirtualBS (pWin) - WindowPtr pWin; -{ - miBSWindowPtr pBackingStore; - - pBackingStore = (miBSWindowPtr) pWin->backStorage; - if (pBackingStore->backgroundState == BackgroundPixmap) - (* pWin->drawable.pScreen->DestroyPixmap) - (pBackingStore->background.pixmap); - pBackingStore->backgroundState = pWin->backgroundState; - pBackingStore->background = pWin->background; - if (pBackingStore->backgroundState == BackgroundPixmap) - pBackingStore->background.pixmap->refcnt++; - - if (pBackingStore->status != StatusVDirty) - pBackingStore->status = StatusVirtual; - - /* - * punt parent relative tiles and do it now - */ - if (pBackingStore->backgroundState == ParentRelative) - miCreateBSPixmap (pWin, NullBox); -} - -#ifdef DEBUG -static int BSAllocationsFailed = 0; -#define FAILEDSIZE 32 -static struct { int w, h; } failedRecord[FAILEDSIZE]; -static int failedIndex; -#endif - -static void -miCreateBSPixmap (pWin, pExtents) - WindowPtr pWin; - BoxPtr pExtents; -{ - miBSWindowPtr pBackingStore; - ScreenPtr pScreen; - PixUnion background; - char backgroundState = 0; - BoxPtr extents; - Bool backSet; - - pScreen = pWin->drawable.pScreen; - pBackingStore = (miBSWindowPtr) pWin->backStorage; - if (pBackingStore->status == StatusBadAlloc) - return; - backSet = ((pBackingStore->status == StatusVirtual) || - (pBackingStore->status == StatusVDirty)); - - extents = RegionExtents(&pBackingStore->SavedRegion); - - if (!pBackingStore->pBackingPixmap && - extents->x2 != extents->x1 && - extents->y2 != extents->y1) - { - /* the policy here could be more sophisticated */ - pBackingStore->x = extents->x1; - pBackingStore->y = extents->y1; - pBackingStore->pBackingPixmap = - (PixmapPtr)(* pScreen->CreatePixmap) - (pScreen, - extents->x2 - extents->x1, - extents->y2 - extents->y1, - pWin->drawable.depth, 0); - } - if (!pBackingStore->pBackingPixmap) - { -#ifdef DEBUG - BSAllocationsFailed++; - /* - * record failed allocations - */ - failedRecord[failedIndex].w = pWin->drawable.width; - failedRecord[failedIndex].h = pWin->drawable.height; - failedIndex++; - if (failedIndex == FAILEDSIZE) - failedIndex = 0; -#endif -#ifdef BSEAGER - pBackingStore->status = StatusNoPixmap; -#else - pBackingStore->status = StatusBadAlloc; -#endif - return; - } - - pBackingStore->status = StatusContents; - - if (backSet) - { - backgroundState = pWin->backgroundState; - background = pWin->background; - - pWin->backgroundState = pBackingStore->backgroundState; - pWin->background = pBackingStore->background; - if (pWin->backgroundState == BackgroundPixmap) - pWin->background.pixmap->refcnt++; - } - - if (!pExtents) - pExtents = extents; - - if (pExtents->y1 != pExtents->y2) - { - RegionPtr exposed; - - exposed = miBSClearBackingStore(pWin, - pExtents->x1, pExtents->y1, - pExtents->x2 - pExtents->x1, - pExtents->y2 - pExtents->y1, - !backSet); - if (exposed) - { - miSendExposures(pWin, exposed, pWin->drawable.x, pWin->drawable.y); - RegionDestroy(exposed); - } - } - - if (backSet) - { - if (pWin->backgroundState == BackgroundPixmap) - (* pScreen->DestroyPixmap) (pWin->background.pixmap); - pWin->backgroundState = backgroundState; - pWin->background = background; - if (pBackingStore->backgroundState == BackgroundPixmap) - (* pScreen->DestroyPixmap) (pBackingStore->background.pixmap); - pBackingStore->backgroundState = None; - } -} - -/*- - *----------------------------------------------------------------------- - * miBSExposeCopy -- - * Handle the restoration of areas exposed by graphics operations. - * - * Results: - * None. - * - * Side Effects: - * prgnExposed has the areas exposed from backing-store removed - * from it. - * - *----------------------------------------------------------------------- - */ -static void -miBSExposeCopy (pSrc, pDst, pGC, prgnExposed, srcx, srcy, dstx, dsty, plane) - WindowPtr pSrc; - DrawablePtr pDst; - GCPtr pGC; - RegionPtr prgnExposed; - int srcx, srcy; - int dstx, dsty; - unsigned long plane; -{ - RegionRec tempRgn; - miBSWindowPtr pBackingStore; - CopyPlaneProcPtr copyProc; - GCPtr pScratchGC; - register BoxPtr pBox; - register int i; - register int dx, dy; - BITS32 gcMask; - - if (!RegionNotEmpty(prgnExposed)) - return; - pBackingStore = (miBSWindowPtr)pSrc->backStorage; - - if ((pBackingStore->status == StatusNoPixmap) || - (pBackingStore->status == StatusBadAlloc)) - return; - - RegionNull(&tempRgn); - RegionIntersect(&tempRgn, prgnExposed, - &pBackingStore->SavedRegion); - RegionSubtract(prgnExposed, prgnExposed, &tempRgn); - - if (plane != 0) { - copyProc = pGC->ops->CopyPlane; - } else { - copyProc = (CopyPlaneProcPtr)pGC->ops->CopyArea; - } - - dx = dstx - srcx; - dy = dsty - srcy; - - switch (pBackingStore->status) { - case StatusVirtual: - case StatusVDirty: - pScratchGC = GetScratchGC (pDst->depth, pDst->pScreen); - if (pScratchGC) - { - gcMask = 0; - if (pGC->alu != pScratchGC->alu) - gcMask = GCFunction; - if (pGC->planemask != pScratchGC->planemask) - gcMask |= GCPlaneMask; - if (gcMask) - CopyGC (pGC, pScratchGC, gcMask); - miBSFillVirtualBits (pDst, pScratchGC, &tempRgn, dx, dy, - (int) pBackingStore->backgroundState, - pBackingStore->background, - ~0L); - FreeScratchGC (pScratchGC); - } - break; - case StatusContents: - for (i = RegionNumRects(&tempRgn), pBox = RegionRects(&tempRgn); - --i >= 0; - pBox++) - { - (* copyProc) (&(pBackingStore->pBackingPixmap->drawable), pDst, pGC, - pBox->x1 - pBackingStore->x, - pBox->y1 - pBackingStore->y, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1, - pBox->x1 + dx, pBox->y1 + dy, plane); - } - break; - } - RegionUninit(&tempRgn); -} diff --git a/nx-X11/programs/Xserver/mi/mibstore.h b/nx-X11/programs/Xserver/mi/mibstore.h deleted file mode 100644 index 5f3597074b..0000000000 --- a/nx-X11/programs/Xserver/mi/mibstore.h +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * mibstore.h -- - * Header file for users of the MI backing-store scheme. - * - * Copyright (c) 1987 by the Regents of the University of California - * - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies. The University of California - * makes no representations about the suitability of this - * software for any purpose. It is provided "as is" without - * express or implied warranty. - * - * "$Xorg: mibstore.h,v 1.3 2000/08/17 19:53:37 cpqbld Exp $ - */ - - - -#ifndef _MIBSTORE_H -#define _MIBSTORE_H - -#include "screenint.h" - -extern void miInitializeBackingStore( - ScreenPtr /*pScreen*/ -); - -#endif /* _MIBSTORE_H */ diff --git a/nx-X11/programs/Xserver/mi/mibstorest.h b/nx-X11/programs/Xserver/mi/mibstorest.h deleted file mode 100644 index ccf4fb7016..0000000000 --- a/nx-X11/programs/Xserver/mi/mibstorest.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * mibstorest.h - * - * internal structure definitions for mi backing store - */ - - -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. -*/ - - -#ifdef HAVE_DIX_CONFIG_H -#include -#endif - -#include "mibstore.h" -#include "regionstr.h" - -/* - * One of these structures is allocated per GC used with a backing-store - * drawable. - */ - -typedef struct { - GCPtr pBackingGC; /* Copy of the GC but with graphicsExposures - * set FALSE and the clientClip set to - * clip output to the valid regions of the - * backing pixmap. */ - int guarantee; /* GuaranteeNothing, etc. */ - unsigned long serialNumber; /* clientClip computed time */ - unsigned long stateChanges; /* changes in parent gc since last copy */ - GCOps *wrapOps; /* wrapped ops */ - GCFuncs *wrapFuncs; /* wrapped funcs */ -} miBSGCRec, *miBSGCPtr; - -/* - * one of these structures is allocated per Window with backing store - */ - -typedef struct { - PixmapPtr pBackingPixmap; /* Pixmap for saved areas */ - short x; /* origin of pixmap relative to window */ - short y; - RegionRec SavedRegion; /* Valid area in pBackingPixmap */ - char viewable; /* Tracks pWin->viewable so SavedRegion may - * be initialized correctly when the window - * is first mapped */ - char status; /* StatusNoPixmap, etc. */ - char backgroundState; /* background type */ - PixUnion background; /* background pattern */ -} miBSWindowRec, *miBSWindowPtr; - -#define StatusNoPixmap 1 /* pixmap has not been created */ -#define StatusVirtual 2 /* pixmap is virtual, tiled with background */ -#define StatusVDirty 3 /* pixmap is virtual, visiblt has contents */ -#define StatusBadAlloc 4 /* pixmap create failed, do not try again */ -#define StatusContents 5 /* pixmap is created, has valid contents */ - -typedef struct { - /* - * screen func wrappers - */ - CloseScreenProcPtr CloseScreen; - GetImageProcPtr GetImage; - GetSpansProcPtr GetSpans; - ChangeWindowAttributesProcPtr ChangeWindowAttributes; - CreateGCProcPtr CreateGC; - DestroyWindowProcPtr DestroyWindow; -} miBSScreenRec, *miBSScreenPtr; diff --git a/nx-X11/programs/Xserver/mi/midispcur.c b/nx-X11/programs/Xserver/mi/midispcur.c index 92d0fb15c5..2b93402ef6 100644 --- a/nx-X11/programs/Xserver/mi/midispcur.c +++ b/nx-X11/programs/Xserver/mi/midispcur.c @@ -53,32 +53,29 @@ in this Software without prior written authorization from The Open Group. /* per-screen private data */ -static int miDCScreenIndex; -static unsigned long miDCGeneration = 0; +static DevPrivateKeyRec miDCScreenKeyRec; + +#define miDCScreenKey (&miDCScreenKeyRec) static Bool miDCCloseScreen(ScreenPtr pScreen); typedef struct { GCPtr pSourceGC, pMaskGC; GCPtr pSaveGC, pRestoreGC; - GCPtr pMoveGC; - GCPtr pPixSourceGC, pPixMaskGC; CloseScreenProcPtr CloseScreen; - PixmapPtr pSave, pTemp; + PixmapPtr pSave; #ifdef ARGB_CURSOR PicturePtr pRootPicture; - PicturePtr pTempPicture; #endif -} miDCScreenRec, *miDCScreenPtr; - -/* per-cursor per-screen private data */ -typedef struct { - PixmapPtr sourceBits; /* source bits */ - PixmapPtr maskBits; /* mask bits */ + PixmapPtr sourceBits; /* source bits */ + PixmapPtr maskBits; /* mask bits */ #ifdef ARGB_CURSOR - PicturePtr pPicture; + PicturePtr pPicture; #endif -} miDCCursorRec, *miDCCursorPtr; + CursorPtr pCursor; +} miDCScreenRec, *miDCScreenPtr; + +#define miGetDCScreen(s) ((miDCScreenPtr)(dixLookupPrivate(&(s)->devPrivates, miDCScreenKey))) /* * sprite/cursor method table @@ -93,11 +90,6 @@ static Bool miDCSaveUnderCursor(ScreenPtr pScreen, int x, int y, int w, int h); static Bool miDCRestoreUnderCursor(ScreenPtr pScreen, int x, int y, int w, int h); -static Bool miDCMoveCursor(ScreenPtr pScreen, CursorPtr pCursor, - int x, int y, int w, int h, int dx, int dy, - unsigned long source, unsigned long mask); -static Bool miDCChangeSave(ScreenPtr pScreen, int x, int y, int w, int h, - int dx, int dy); static miSpriteCursorFuncRec miDCFuncs = { miDCRealizeCursor, @@ -105,8 +97,6 @@ static miSpriteCursorFuncRec miDCFuncs = { miDCPutUpCursor, miDCSaveUnderCursor, miDCRestoreUnderCursor, - miDCMoveCursor, - miDCChangeSave, }; Bool @@ -114,41 +104,19 @@ miDCInitialize (pScreen, screenFuncs) ScreenPtr pScreen; miPointerScreenFuncPtr screenFuncs; { - miDCScreenPtr pScreenPriv; + miDCScreenPtr pScreenPriv; - if (miDCGeneration != serverGeneration) - { - miDCScreenIndex = AllocateScreenPrivateIndex (); - if (miDCScreenIndex < 0) - return FALSE; - miDCGeneration = serverGeneration; - } - pScreenPriv = (miDCScreenPtr) malloc (sizeof (miDCScreenRec)); + if (!dixRegisterPrivateKey(&miDCScreenKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + + pScreenPriv = (miDCScreenPtr) calloc (1, sizeof (miDCScreenRec)); if (!pScreenPriv) return FALSE; - /* - * initialize the entire private structure to zeros - */ - - pScreenPriv->pSourceGC = - pScreenPriv->pMaskGC = - pScreenPriv->pSaveGC = - pScreenPriv->pRestoreGC = - pScreenPriv->pMoveGC = - pScreenPriv->pPixSourceGC = - pScreenPriv->pPixMaskGC = NULL; -#ifdef ARGB_CURSOR - pScreenPriv->pRootPicture = NULL; - pScreenPriv->pTempPicture = NULL; -#endif - - pScreenPriv->pSave = pScreenPriv->pTemp = NULL; - pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = miDCCloseScreen; - - pScreen->devPrivates[miDCScreenIndex].ptr = (void *) pScreenPriv; + + dixSetPrivate(&pScreen->devPrivates, miDCScreenKey, pScreenPriv); if (!miSpriteInitialize (pScreen, &miDCFuncs, screenFuncs)) { @@ -162,71 +130,70 @@ miDCInitialize (pScreen, screenFuncs) #define tossPix(pix) (pix ? (*pScreen->DestroyPixmap) (pix) : TRUE) #define tossPict(pict) (pict ? FreePicture (pict, 0) : 0) +static void +miDCSwitchScreenCursor(ScreenPtr pScreen, CursorPtr pCursor, PixmapPtr sourceBits, PixmapPtr maskBits, PicturePtr pPicture) +{ + miDCScreenPtr pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miDCScreenKey); + + if (pScreenPriv->sourceBits) + (*pScreen->DestroyPixmap)(pScreenPriv->sourceBits); + pScreenPriv->sourceBits = sourceBits; + + if (pScreenPriv->maskBits) + (*pScreen->DestroyPixmap)(pScreenPriv->maskBits); + pScreenPriv->maskBits = maskBits; + +#ifdef ARGB_CURSOR + if (pScreenPriv->pPicture) + FreePicture(pScreenPriv->pPicture, 0); + pScreenPriv->pPicture = pPicture; +#endif + + pScreenPriv->pCursor = pCursor; +} + static Bool miDCCloseScreen (pScreen) ScreenPtr pScreen; { miDCScreenPtr pScreenPriv; - pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr; + pScreenPriv = (miDCScreenPtr) dixLookupPrivate(&pScreen->devPrivates, miDCScreenKey); pScreen->CloseScreen = pScreenPriv->CloseScreen; + + miDCSwitchScreenCursor(pScreen, NULL, NULL, NULL, NULL); tossGC (pScreenPriv->pSourceGC); tossGC (pScreenPriv->pMaskGC); tossGC (pScreenPriv->pSaveGC); tossGC (pScreenPriv->pRestoreGC); - tossGC (pScreenPriv->pMoveGC); - tossGC (pScreenPriv->pPixSourceGC); - tossGC (pScreenPriv->pPixMaskGC); tossPix (pScreenPriv->pSave); - tossPix (pScreenPriv->pTemp); #ifdef ARGB_CURSOR tossPict (pScreenPriv->pRootPicture); - tossPict (pScreenPriv->pTempPicture); #endif free ((void *) pScreenPriv); return (*pScreen->CloseScreen) (pScreen); } - static Bool miDCRealizeCursor (pScreen, pCursor) ScreenPtr pScreen; CursorPtr pCursor; { - if (pCursor->bits->refcnt <= 1) - pCursor->bits->devPriv[pScreen->myNum] = (void *)NULL; return TRUE; } #ifdef ARGB_CURSOR #define EnsurePicture(picture,draw,win) (picture || miDCMakePicture(&picture,draw,win)) -static VisualPtr -miDCGetWindowVisual (WindowPtr pWin) -{ - ScreenPtr pScreen = pWin->drawable.pScreen; - VisualID vid = wVisual (pWin); - int i; - - for (i = 0; i < pScreen->numVisuals; i++) - if (pScreen->visuals[i].vid == vid) - return &pScreen->visuals[i]; - return 0; -} - static PicturePtr miDCMakePicture (PicturePtr *ppPicture, DrawablePtr pDraw, WindowPtr pWin) { - ScreenPtr pScreen = pDraw->pScreen; - VisualPtr pVisual; PictFormatPtr pFormat; XID subwindow_mode = IncludeInferiors; PicturePtr pPicture; int error; - - pVisual = miDCGetWindowVisual (pWin); - if (!pVisual) - return 0; - pFormat = PictureMatchVisual (pScreen, pDraw->depth, pVisual); + + + pFormat = PictureWindowFormat(pWin); if (!pFormat) return 0; pPicture = CreatePicture (0, pDraw, pFormat, @@ -237,48 +204,42 @@ miDCMakePicture (PicturePtr *ppPicture, DrawablePtr pDraw, WindowPtr pWin) } #endif -static miDCCursorPtr +static Bool miDCRealize ( ScreenPtr pScreen, CursorPtr pCursor) { - miDCCursorPtr pPriv; + miDCScreenPtr pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miDCScreenKey); GCPtr pGC; XID gcvals[3]; + PixmapPtr sourceBits, maskBits; + + if (pScreenPriv->pCursor == pCursor) + return TRUE; - pPriv = (miDCCursorPtr) malloc (sizeof (miDCCursorRec)); - if (!pPriv) - return (miDCCursorPtr)NULL; #ifdef ARGB_CURSOR if (pCursor->bits->argb) { PixmapPtr pPixmap; PictFormatPtr pFormat; int error; + PicturePtr pPicture; pFormat = PictureMatchFormat (pScreen, 32, PICT_a8r8g8b8); - if (!pFormat) - { - free ((void *) pPriv); - return (miDCCursorPtr)NULL; - } + if(!pFormat) + return FALSE; - pPriv->sourceBits = 0; - pPriv->maskBits = 0; pPixmap = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width, pCursor->bits->height, 32, CREATE_PIXMAP_USAGE_SCRATCH); if (!pPixmap) - { - free ((void *) pPriv); - return (miDCCursorPtr)NULL; - } + return FALSE; + pGC = GetScratchGC (32, pScreen); if (!pGC) { (*pScreen->DestroyPixmap) (pPixmap); - free ((void *) pPriv); - return (miDCCursorPtr)NULL; + return FALSE; } ValidateGC (&pPixmap->drawable, pGC); (*pGC->ops->PutImage) (&pPixmap->drawable, pGC, 32, @@ -286,69 +247,65 @@ miDCRealize ( pCursor->bits->height, 0, ZPixmap, (char *) pCursor->bits->argb); FreeScratchGC (pGC); - pPriv->pPicture = CreatePicture (0, &pPixmap->drawable, - pFormat, 0, 0, serverClient, &error); + pPicture = CreatePicture(0, &pPixmap->drawable, + pFormat, 0, 0, serverClient, &error); (*pScreen->DestroyPixmap) (pPixmap); - if (!pPriv->pPicture) - { - free ((void *) pPriv); - return (miDCCursorPtr)NULL; - } - pCursor->bits->devPriv[pScreen->myNum] = (void *) pPriv; - return pPriv; + if (!pPicture) + return FALSE; + miDCSwitchScreenCursor(pScreen, pCursor, NULL, NULL, pPicture); + return TRUE; } - pPriv->pPicture = 0; #endif - pPriv->sourceBits = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width, pCursor->bits->height, 1, 0); - if (!pPriv->sourceBits) - { - free ((void *) pPriv); - return (miDCCursorPtr)NULL; - } - pPriv->maskBits = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width, pCursor->bits->height, 1, 0); - if (!pPriv->maskBits) - { - (*pScreen->DestroyPixmap) (pPriv->sourceBits); - free ((void *) pPriv); - return (miDCCursorPtr)NULL; + sourceBits = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width, + pCursor->bits->height, 1, 0); + if (!sourceBits) + return FALSE; + + maskBits = (*pScreen->CreatePixmap) (pScreen, pCursor->bits->width, + pCursor->bits->height, 1, 0); + if (!maskBits) { + (*pScreen->DestroyPixmap) (sourceBits); + return FALSE; } - pCursor->bits->devPriv[pScreen->myNum] = (void *) pPriv; /* create the two sets of bits, clipping as appropriate */ pGC = GetScratchGC (1, pScreen); if (!pGC) { - (void) miDCUnrealizeCursor (pScreen, pCursor); - return (miDCCursorPtr)NULL; + (*pScreen->DestroyPixmap) (sourceBits); + (*pScreen->DestroyPixmap) (maskBits); + return FALSE; } - ValidateGC ((DrawablePtr)pPriv->sourceBits, pGC); - (*pGC->ops->PutImage) ((DrawablePtr)pPriv->sourceBits, pGC, 1, + ValidateGC ((DrawablePtr) sourceBits, pGC); + (*pGC->ops->PutImage) ((DrawablePtr) sourceBits, pGC, 1, 0, 0, pCursor->bits->width, pCursor->bits->height, 0, XYPixmap, (char *)pCursor->bits->source); gcvals[0] = GXand; ChangeGC (pGC, GCFunction, gcvals); - ValidateGC ((DrawablePtr)pPriv->sourceBits, pGC); - (*pGC->ops->PutImage) ((DrawablePtr)pPriv->sourceBits, pGC, 1, + ValidateGC ((DrawablePtr) sourceBits, pGC); + (*pGC->ops->PutImage) ((DrawablePtr) sourceBits, pGC, 1, 0, 0, pCursor->bits->width, pCursor->bits->height, 0, XYPixmap, (char *)pCursor->bits->mask); /* mask bits -- pCursor->mask & ~pCursor->source */ gcvals[0] = GXcopy; ChangeGC (pGC, GCFunction, gcvals); - ValidateGC ((DrawablePtr)pPriv->maskBits, pGC); - (*pGC->ops->PutImage) ((DrawablePtr)pPriv->maskBits, pGC, 1, + ValidateGC ((DrawablePtr) maskBits, pGC); + (*pGC->ops->PutImage) ((DrawablePtr) maskBits, pGC, 1, 0, 0, pCursor->bits->width, pCursor->bits->height, 0, XYPixmap, (char *)pCursor->bits->mask); gcvals[0] = GXandInverted; ChangeGC (pGC, GCFunction, gcvals); - ValidateGC ((DrawablePtr)pPriv->maskBits, pGC); - (*pGC->ops->PutImage) ((DrawablePtr)pPriv->maskBits, pGC, 1, + ValidateGC ((DrawablePtr) maskBits, pGC); + (*pGC->ops->PutImage) ((DrawablePtr) maskBits, pGC, 1, 0, 0, pCursor->bits->width, pCursor->bits->height, 0, XYPixmap, (char *)pCursor->bits->source); FreeScratchGC (pGC); - return pPriv; + + miDCSwitchScreenCursor(pScreen, pCursor, sourceBits, maskBits, NULL); + return TRUE; } static Bool @@ -356,29 +313,16 @@ miDCUnrealizeCursor (pScreen, pCursor) ScreenPtr pScreen; CursorPtr pCursor; { - miDCCursorPtr pPriv; + miDCScreenPtr pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miDCScreenKey); - pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum]; - if (pPriv && (pCursor->bits->refcnt <= 1)) - { - if (pPriv->sourceBits) - (*pScreen->DestroyPixmap) (pPriv->sourceBits); - if (pPriv->maskBits) - (*pScreen->DestroyPixmap) (pPriv->maskBits); -#ifdef ARGB_CURSOR - if (pPriv->pPicture) - FreePicture (pPriv->pPicture, 0); -#endif - free ((void *) pPriv); - pCursor->bits->devPriv[pScreen->myNum] = (void *)NULL; - } + if (pCursor == pScreenPriv->pCursor) + miDCSwitchScreenCursor(pScreen, NULL, NULL, NULL, NULL); return TRUE; } static void miDCPutBits ( DrawablePtr pDrawable, - miDCCursorPtr pPriv, GCPtr sourceGC, GCPtr maskGC, int x_org, @@ -388,6 +332,7 @@ miDCPutBits ( unsigned long source, unsigned long mask) { + miDCScreenPtr pScreenPriv = dixLookupPrivate(&pDrawable->pScreen->devPrivates, miDCScreenKey); XID gcvals[1]; int x, y; @@ -410,7 +355,7 @@ miDCPutBits ( y = y_org; } - (*sourceGC->ops->PushPixels) (sourceGC, pPriv->sourceBits, pDrawable, w, h, x, y); + (*sourceGC->ops->PushPixels) (sourceGC, pScreenPriv->sourceBits, pDrawable, w, h, x, y); if (maskGC->fgPixel != mask) { gcvals[0] = mask; @@ -430,7 +375,7 @@ miDCPutBits ( y = y_org; } - (*maskGC->ops->PushPixels) (maskGC, pPriv->maskBits, pDrawable, w, h, x, y); + (*maskGC->ops->PushPixels) (maskGC, pScreenPriv->maskBits, pDrawable, w, h, x, y); } #define EnsureGC(gc,win) (gc || miDCMakeGC(&gc, win)) @@ -448,8 +393,6 @@ miDCMakeGC( gcvals[1] = FALSE; pGC = CreateGC((DrawablePtr)pWin, GCSubwindowMode|GCGraphicsExposures, gcvals, &status); - if (pGC && pWin->drawable.pScreen->DrawGuarantee) - (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack); *ppGC = pGC; return pGC; } @@ -462,26 +405,20 @@ miDCPutUpCursor (pScreen, pCursor, x, y, source, mask) int x, y; unsigned long source, mask; { - miDCScreenPtr pScreenPriv; - miDCCursorPtr pPriv; + miDCScreenPtr pScreenPriv = dixLookupPrivate(&pScreen->devPrivates, miDCScreenKey); WindowPtr pWin; - pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum]; - if (!pPriv) - { - pPriv = miDCRealize(pScreen, pCursor); - if (!pPriv) - return FALSE; - } - pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr; + if (!miDCRealize(pScreen, pCursor)) + return FALSE; + pWin = pScreen->root; #ifdef ARGB_CURSOR - if (pPriv->pPicture) + if (pScreenPriv->pPicture) { if (!EnsurePicture(pScreenPriv->pRootPicture, &pWin->drawable, pWin)) return FALSE; CompositePicture (PictOpOver, - pPriv->pPicture, + pScreenPriv->pPicture, NULL, pScreenPriv->pRootPicture, 0, 0, 0, 0, @@ -500,7 +437,7 @@ miDCPutUpCursor (pScreen, pCursor, x, y, source, mask) pScreenPriv->pSourceGC = 0; return FALSE; } - miDCPutBits ((DrawablePtr)pWin, pPriv, + miDCPutBits ((DrawablePtr)pWin, pScreenPriv->pSourceGC, pScreenPriv->pMaskGC, x, y, pCursor->bits->width, pCursor->bits->height, source, mask); @@ -518,7 +455,7 @@ miDCSaveUnderCursor (pScreen, x, y, w, h) WindowPtr pWin; GCPtr pGC; - pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr; + pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, miDCScreenKey); pSave = pScreenPriv->pSave; pWin = pScreen->root; if (!pSave || pSave->drawable.width < w || pSave->drawable.height < h) @@ -550,7 +487,7 @@ miDCRestoreUnderCursor (pScreen, x, y, w, h) WindowPtr pWin; GCPtr pGC; - pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr; + pScreenPriv = (miDCScreenPtr)dixLookupPrivate(&pScreen->devPrivates, miDCScreenKey); pSave = pScreenPriv->pSave; pWin = pScreen->root; if (!pSave) @@ -564,250 +501,3 @@ miDCRestoreUnderCursor (pScreen, x, y, w, h) 0, 0, w, h, x, y); return TRUE; } - -static Bool -miDCChangeSave (pScreen, x, y, w, h, dx, dy) - ScreenPtr pScreen; - int x, y, w, h, dx, dy; -{ - miDCScreenPtr pScreenPriv; - PixmapPtr pSave; - WindowPtr pWin; - GCPtr pGC; - int sourcex, sourcey, destx, desty, copyw, copyh; - - pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr; - pSave = pScreenPriv->pSave; - pWin = pScreen->root; - /* - * restore the bits which are about to get trashed - */ - if (!pSave) - return FALSE; - if (!EnsureGC(pScreenPriv->pRestoreGC, pWin)) - return FALSE; - pGC = pScreenPriv->pRestoreGC; - if (pWin->drawable.serialNumber != pGC->serialNumber) - ValidateGC ((DrawablePtr) pWin, pGC); - /* - * copy the old bits to the screen. - */ - if (dy > 0) - { - (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC, - 0, h - dy, w, dy, x + dx, y + h); - } - else if (dy < 0) - { - (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC, - 0, 0, w, -dy, x + dx, y + dy); - } - if (dy >= 0) - { - desty = y + dy; - sourcey = 0; - copyh = h - dy; - } - else - { - desty = y; - sourcey = - dy; - copyh = h + dy; - } - if (dx > 0) - { - (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC, - w - dx, sourcey, dx, copyh, x + w, desty); - } - else if (dx < 0) - { - (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pWin, pGC, - 0, sourcey, -dx, copyh, x + dx, desty); - } - if (!EnsureGC(pScreenPriv->pSaveGC, pWin)) - return FALSE; - pGC = pScreenPriv->pSaveGC; - if (pSave->drawable.serialNumber != pGC->serialNumber) - ValidateGC ((DrawablePtr) pSave, pGC); - /* - * move the bits that are still valid within the pixmap - */ - if (dx >= 0) - { - sourcex = 0; - destx = dx; - copyw = w - dx; - } - else - { - destx = 0; - sourcex = - dx; - copyw = w + dx; - } - if (dy >= 0) - { - sourcey = 0; - desty = dy; - copyh = h - dy; - } - else - { - desty = 0; - sourcey = -dy; - copyh = h + dy; - } - (*pGC->ops->CopyArea) ((DrawablePtr) pSave, (DrawablePtr) pSave, pGC, - sourcex, sourcey, copyw, copyh, destx, desty); - /* - * copy the new bits from the screen into the remaining areas of the - * pixmap - */ - if (dy > 0) - { - (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC, - x, y, w, dy, 0, 0); - } - else if (dy < 0) - { - (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC, - x, y + h + dy, w, -dy, 0, h + dy); - } - if (dy >= 0) - { - desty = dy; - sourcey = y + dy; - copyh = h - dy; - } - else - { - desty = 0; - sourcey = y; - copyh = h + dy; - } - if (dx > 0) - { - (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC, - x, sourcey, dx, copyh, 0, desty); - } - else if (dx < 0) - { - (*pGC->ops->CopyArea) ((DrawablePtr) pWin, (DrawablePtr) pSave, pGC, - x + w + dx, sourcey, -dx, copyh, w + dx, desty); - } - return TRUE; -} - -static Bool -miDCMoveCursor (pScreen, pCursor, x, y, w, h, dx, dy, source, mask) - ScreenPtr pScreen; - CursorPtr pCursor; - int x, y, w, h, dx, dy; - unsigned long source, mask; -{ - miDCCursorPtr pPriv; - miDCScreenPtr pScreenPriv; - int status; - WindowPtr pWin; - GCPtr pGC; - XID gcval = FALSE; - PixmapPtr pTemp; - - pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum]; - if (!pPriv) - { - pPriv = miDCRealize(pScreen, pCursor); - if (!pPriv) - return FALSE; - } - pScreenPriv = (miDCScreenPtr) pScreen->devPrivates[miDCScreenIndex].ptr; - pWin = pScreen->root; - pTemp = pScreenPriv->pTemp; - if (!pTemp || - pTemp->drawable.width != pScreenPriv->pSave->drawable.width || - pTemp->drawable.height != pScreenPriv->pSave->drawable.height) - { - if (pTemp) - (*pScreen->DestroyPixmap) (pTemp); -#ifdef ARGB_CURSOR - if (pScreenPriv->pTempPicture) - { - FreePicture (pScreenPriv->pTempPicture, 0); - pScreenPriv->pTempPicture = 0; - } -#endif - pScreenPriv->pTemp = pTemp = (*pScreen->CreatePixmap) - (pScreen, w, h, pScreenPriv->pSave->drawable.depth, 0); - if (!pTemp) - return FALSE; - } - if (!pScreenPriv->pMoveGC) - { - pScreenPriv->pMoveGC = CreateGC ((DrawablePtr)pTemp, - GCGraphicsExposures, &gcval, &status); - if (!pScreenPriv->pMoveGC) - return FALSE; - } - /* - * copy the saved area to a temporary pixmap - */ - pGC = pScreenPriv->pMoveGC; - if (pGC->serialNumber != pTemp->drawable.serialNumber) - ValidateGC ((DrawablePtr) pTemp, pGC); - (*pGC->ops->CopyArea)((DrawablePtr)pScreenPriv->pSave, - (DrawablePtr)pTemp, pGC, 0, 0, w, h, 0, 0); - - /* - * draw the cursor in the temporary pixmap - */ -#ifdef ARGB_CURSOR - if (pPriv->pPicture) - { - if (!EnsurePicture(pScreenPriv->pTempPicture, &pTemp->drawable, pWin)) - return FALSE; - CompositePicture (PictOpOver, - pPriv->pPicture, - NULL, - pScreenPriv->pTempPicture, - 0, 0, 0, 0, - dx, dy, - pCursor->bits->width, - pCursor->bits->height); - } - else -#endif - { - if (!pScreenPriv->pPixSourceGC) - { - pScreenPriv->pPixSourceGC = CreateGC ((DrawablePtr)pTemp, - GCGraphicsExposures, &gcval, &status); - if (!pScreenPriv->pPixSourceGC) - return FALSE; - } - if (!pScreenPriv->pPixMaskGC) - { - pScreenPriv->pPixMaskGC = CreateGC ((DrawablePtr)pTemp, - GCGraphicsExposures, &gcval, &status); - if (!pScreenPriv->pPixMaskGC) - return FALSE; - } - miDCPutBits ((DrawablePtr)pTemp, pPriv, - pScreenPriv->pPixSourceGC, pScreenPriv->pPixMaskGC, - dx, dy, pCursor->bits->width, pCursor->bits->height, - source, mask); - } - - /* - * copy the temporary pixmap onto the screen - */ - - if (!EnsureGC(pScreenPriv->pRestoreGC, pWin)) - return FALSE; - pGC = pScreenPriv->pRestoreGC; - if (pWin->drawable.serialNumber != pGC->serialNumber) - ValidateGC ((DrawablePtr) pWin, pGC); - - (*pGC->ops->CopyArea) ((DrawablePtr) pTemp, (DrawablePtr) pWin, - pGC, - 0, 0, w, h, x, y); - return TRUE; -} diff --git a/nx-X11/programs/Xserver/mi/miexpose.c b/nx-X11/programs/Xserver/mi/miexpose.c index 9135d2e6e9..531d6a87a5 100644 --- a/nx-X11/programs/Xserver/mi/miexpose.c +++ b/nx-X11/programs/Xserver/mi/miexpose.c @@ -118,12 +118,6 @@ background for the region, if the destination is a window. this should generally be called, even if graphicsExposures is false, because this is where bits get recovered from backing store. -NOTE: - added argument 'plane' is used to indicate how exposures from backing -store should be accomplished. If plane is 0 (i.e. no bit plane), CopyArea -should be used, else a CopyPlane of the indicated plane will be used. The -exposing is done by the backing store's GraphicsExpose function, of course. - */ #ifndef NXAGENT_SERVER @@ -255,21 +249,6 @@ miHandleExposures(pSrcDrawable, pDstDrawable, /* now get the hidden parts of the source box*/ RegionSubtract(&rgnExposed, &rgnExposed, prgnSrcClip); - if (pSrcWin && pSrcWin->backStorage) - { - /* - * Copy any areas from the source backing store. Modifies - * rgnExposed. - */ - (* pSrcWin->drawable.pScreen->ExposeCopy) ((WindowPtr)pSrcDrawable, - pDstDrawable, - pGC, - &rgnExposed, - srcx, srcy, - dstx, dsty, - plane); - } - /* move them over the destination */ RegionTranslate(&rgnExposed, dstx-srcx, dsty-srcy); @@ -307,15 +286,6 @@ miHandleExposures(pSrcDrawable, pDstDrawable, expBox = *RegionExtents(&rgnExposed); RegionReset(&rgnExposed, &expBox); - /* need to clear out new areas of backing store */ - if (pWin->backStorage) - (void) (* pWin->drawable.pScreen->ClearBackingStore)( - pWin, - expBox.x1, - expBox.y1, - expBox.x2 - expBox.x1, - expBox.y2 - expBox.y1, - FALSE); } if ((pDstDrawable->type != DRAWABLE_PIXMAP) && (((WindowPtr)pDstDrawable)->backgroundState != None)) @@ -498,18 +468,6 @@ miWindowExposures(pWin, prgn, other_exposed) register RegionPtr prgn, other_exposed; { RegionPtr exposures = prgn; - if (pWin->backStorage && prgn) - /* - * in some cases, backing store will cause a different - * region to be exposed than needs to be repainted - * (like when a window is mapped). RestoreAreas is - * allowed to return a region other than prgn, - * in which case this routine will free the resultant - * region. If exposures is null, then no events will - * be sent to the client; if prgn is empty - * no areas will be repainted. - */ - exposures = (*pWin->drawable.pScreen->RestoreAreas)(pWin, prgn); if ((prgn && !RegionNil(prgn)) || (exposures && !RegionNil(exposures)) || other_exposed) { @@ -554,14 +512,6 @@ miWindowExposures(pWin, prgn, other_exposed) /* PaintWindowBackground doesn't clip, so we have to */ RegionIntersect(prgn, prgn, &pWin->clipList); /* need to clear out new areas of backing store, too */ - if (pWin->backStorage) - (void) (* pWin->drawable.pScreen->ClearBackingStore)( - pWin, - box.x1 - pWin->drawable.x, - box.y1 - pWin->drawable.y, - box.x2 - box.x1, - box.y2 - box.y1, - FALSE); } if (prgn && !RegionNil(prgn)) (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, prgn, PW_BACKGROUND); @@ -786,9 +736,6 @@ int what; pWin = pRoot; } - if (pWin->backStorage) - (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeVisBack); - mask = gcmask; gcmask = 0; i = 0; @@ -867,9 +814,6 @@ int what; (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect); free(prect); - if (pWin->backStorage) - (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing); - if (usingScratchGC) { if (what == PW_BORDER) diff --git a/nx-X11/programs/Xserver/mi/migc.c b/nx-X11/programs/Xserver/mi/migc.c index 4d67cbf5d1..4c7351114b 100644 --- a/nx-X11/programs/Xserver/mi/migc.c +++ b/nx-X11/programs/Xserver/mi/migc.c @@ -55,38 +55,8 @@ miDestroyGC(pGC) (*pGC->pScreen->DestroyPixmap) (pGC->pRotatedPixmap); if (pGC->freeCompClip) RegionDestroy(pGC->pCompositeClip); - miDestroyGCOps(pGC->ops); } -/* - * create a private op array for a gc - */ - -GCOpsPtr -miCreateGCOps(prototype) - GCOpsPtr prototype; -{ - GCOpsPtr ret; - - /* XXX */ Must_have_memory = TRUE; - ret = (GCOpsPtr) malloc(sizeof(GCOps)); - /* XXX */ Must_have_memory = FALSE; - if (!ret) - return 0; - *ret = *prototype; - ret->devPrivate.val = 1; - return ret; -} - -void -miDestroyGCOps(ops) - GCOpsPtr ops; -{ - if (ops->devPrivate.val) - free(ops); -} - - void miDestroyClip(pGC) GCPtr pGC; diff --git a/nx-X11/programs/Xserver/mi/migc.h b/nx-X11/programs/Xserver/mi/migc.h index 9c579961ca..f2e8a5611c 100644 --- a/nx-X11/programs/Xserver/mi/migc.h +++ b/nx-X11/programs/Xserver/mi/migc.h @@ -36,14 +36,6 @@ extern void miDestroyGC( GCPtr /*pGC*/ ); -extern GCOpsPtr miCreateGCOps( - GCOpsPtr /*prototype*/ -); - -extern void miDestroyGCOps( - GCOpsPtr /*ops*/ -); - extern void miDestroyClip( GCPtr /*pGC*/ ); diff --git a/nx-X11/programs/Xserver/mi/miline.h b/nx-X11/programs/Xserver/mi/miline.h index 7028485f0d..1392a07c71 100644 --- a/nx-X11/programs/Xserver/mi/miline.h +++ b/nx-X11/programs/Xserver/mi/miline.h @@ -119,9 +119,8 @@ extern void miSetZeroLineBias( t = y1; y1 = y2; y2 = t;\ } -#define miGetZeroLineBias(_pScreen) \ - ((miZeroLineScreenIndex < 0) ? \ - 0 : ((_pScreen)->devPrivates[miZeroLineScreenIndex].uval)) +#define miGetZeroLineBias(_pScreen) ((unsigned long) (unsigned long*)\ + dixLookupPrivate(&(_pScreen)->devPrivates, miZeroLineScreenKey)) #define CalcLineDeltas(_x1,_y1,_x2,_y2,_adx,_ady,_sx,_sy,_SX,_SY,_octant) \ (_octant) = 0; \ @@ -148,7 +147,9 @@ extern void miSetZeroLineBias( #define IsXDecreasingOctant(_octant) ((_octant) & XDECREASING) #define IsYDecreasingOctant(_octant) ((_octant) & YDECREASING) -extern int miZeroLineScreenIndex; +extern _X_EXPORT DevPrivateKeyRec miZeroLineScreenKeyRec; + +#define miZeroLineScreenKey (&miZeroLineScreenKeyRec) extern int miZeroClipLine( int /*xmin*/, diff --git a/nx-X11/programs/Xserver/mi/mioverlay.c b/nx-X11/programs/Xserver/mi/mioverlay.c index c0d923a0f8..53796528f8 100644 --- a/nx-X11/programs/Xserver/mi/mioverlay.c +++ b/nx-X11/programs/Xserver/mi/mioverlay.c @@ -10,6 +10,7 @@ #include "mi.h" #include "gcstruct.h" #include "regionstr.h" +#include "privates.h" #include "mivalidate.h" #include "mioverlay.h" #include "migc.h" @@ -53,9 +54,12 @@ typedef struct { Bool copyUnderlay; } miOverlayScreenRec, *miOverlayScreenPtr; -static unsigned long miOverlayGeneration = 0; -int miOverlayWindowIndex = -1; -int miOverlayScreenIndex = -1; +static DevPrivateKeyRec miOverlayWindowKeyRec; + +#define miOverlayWindowKey (&miOverlayWindowKeyRec) +static DevPrivateKeyRec miOverlayScreenKeyRec; + +#define miOverlayScreenKey (&miOverlayScreenKeyRec) static void RebuildTree(WindowPtr); static Bool HasUnderlayChildren(WindowPtr); @@ -85,10 +89,10 @@ static void miOverlaySetShape(WindowPtr); #endif static void miOverlayChangeBorderWidth(WindowPtr, unsigned int); -#define MIOVERLAY_GET_SCREEN_PRIVATE(pScreen) \ - ((miOverlayScreenPtr)((pScreen)->devPrivates[miOverlayScreenIndex].ptr)) -#define MIOVERLAY_GET_WINDOW_PRIVATE(pWin) \ - ((miOverlayWindowPtr)((pWin)->devPrivates[miOverlayWindowIndex].ptr)) +#define MIOVERLAY_GET_SCREEN_PRIVATE(pScreen) ((miOverlayScreenPtr) \ + dixLookupPrivate(&(pScreen)->devPrivates, miOverlayScreenKey)) +#define MIOVERLAY_GET_WINDOW_PRIVATE(pWin) ((miOverlayWindowPtr) \ + dixLookupPrivate(&(pWin)->devPrivates, miOverlayWindowKey)) #define MIOVERLAY_GET_WINDOW_TREE(pWin) \ (MIOVERLAY_GET_WINDOW_PRIVATE(pWin)->tree) @@ -112,22 +116,17 @@ miInitOverlay( if(!inOverlayFunc || !transFunc) return FALSE; - if(miOverlayGeneration != serverGeneration) { - if(((miOverlayScreenIndex = AllocateScreenPrivateIndex()) < 0) || - ((miOverlayWindowIndex = AllocateWindowPrivateIndex()) < 0)) - return FALSE; - - miOverlayGeneration = serverGeneration; - } + if (!dixRegisterPrivateKey + (&miOverlayWindowKeyRec, PRIVATE_WINDOW, sizeof(miOverlayWindowRec))) + return FALSE; - if(!AllocateWindowPrivate(pScreen, miOverlayWindowIndex, - sizeof(miOverlayWindowRec))) - return FALSE; + if (!dixRegisterPrivateKey(&miOverlayScreenKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; if(!(pScreenPriv = malloc(sizeof(miOverlayScreenRec)))) return FALSE; - pScreen->devPrivates[miOverlayScreenIndex].ptr = (void *)pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, miOverlayScreenKey, pScreenPriv); pScreenPriv->InOverlay = inOverlayFunc; pScreenPriv->MakeTransparent = transFunc; @@ -943,9 +942,6 @@ miOverlayMoveWindow( short bw; RegionRec overReg, underReg; DDXPointRec oldpt; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif if (!(pParent = pWin->parent)) return ; @@ -983,11 +979,6 @@ miOverlayMoveWindow( miOverlayScreenPtr pPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen); (*pScreen->MarkOverlappedWindows) (pWin, windowToValidate, NULL); -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - dosave = (*pScreen->ChangeSaveUnder)(pWin, windowToValidate); -#endif /* DO_SAVE_UNDERS */ - (*pScreen->ValidateTree)(pWin->parent, NullWindow, kind); if(RegionNotEmpty(&underReg)) { pPriv->copyUnderlay = TRUE; @@ -1001,10 +992,6 @@ miOverlayMoveWindow( RegionUninit(&overReg); (*pScreen->HandleExposures)(pWin->parent); -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pWin, windowToValidate); -#endif /* DO_SAVE_UNDERS */ if (pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pWin->parent, NullWindow, kind); } @@ -1025,8 +1012,6 @@ miOverlayWindowExposures( RegionPtr exposures = prgn; ScreenPtr pScreen = pWin->drawable.pScreen; - if (pWin->backStorage && prgn) - exposures = (*pScreen->RestoreAreas)(pWin, prgn); if ((prgn && !RegionNil(prgn)) || (exposures && !RegionNil(exposures)) || other_exposed) { @@ -1067,15 +1052,6 @@ miOverlayWindowExposures( } else RegionIntersect(prgn, prgn, &pWin->clipList); - /* need to clear out new areas of backing store, too */ - if (pWin->backStorage) - (void) (*pScreen->ClearBackingStore)( - pWin, - box.x1 - pWin->drawable.x, - box.y1 - pWin->drawable.y, - box.x2 - box.x1, - box.y2 - box.y1, - FALSE); } if (prgn && !RegionNil(prgn)) (*pScreen->PaintWindowBackground)( @@ -1172,12 +1148,8 @@ miOverlayResizeWindow( RegionPtr oldWinClip = NULL, oldWinClip2 = NULL; RegionPtr borderVisible = NullRegion; RegionPtr borderVisible2 = NullRegion; - RegionPtr bsExposed = NullRegion; /* backing store exposures */ Bool shrunk = FALSE; /* shrunk in an inner dimension */ Bool moved = FALSE; /* window position changed */ -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif Bool doUnderlay; /* if this is a root window, can't be resized */ @@ -1309,11 +1281,6 @@ miOverlayResizeWindow( if(pTree) pTree->valdata->borderVisible = borderVisible2; -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - dosave = (*pScreen->ChangeSaveUnder)(pWin, pFirstChange); -#endif /* DO_SAVE_UNDERS */ - (*pScreen->ValidateTree)(pWin->parent, pFirstChange, VTOther); /* * the entire window is trashed unless bitGravity @@ -1326,17 +1293,6 @@ miOverlayResizeWindow( GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny); - if (pWin->backStorage && ((pWin->backingStore == Always) || WasViewable)) { - if (!WasViewable) - pRegion = &pWin->clipList; /* a convenient empty region */ - if (pWin->bitGravity == ForgetGravity) - bsExposed = (*pScreen->TranslateBackingStore) - (pWin, 0, 0, NullRegion, oldx, oldy); - else - bsExposed = (*pScreen->TranslateBackingStore) - (pWin, nx - x, ny - y, pRegion, oldx, oldy); - } - if (WasViewable) { miOverlayScreenPtr pPriv = MIOVERLAY_GET_SCREEN_PRIVATE(pScreen); miOverlayTwoRegions TwoRegions; @@ -1544,28 +1500,10 @@ miOverlayResizeWindow( RegionDestroy(destClip); if (destClip2) RegionDestroy(destClip2); - if (bsExposed) { - RegionPtr valExposed = NullRegion; - - if (pWin->valdata) - valExposed = &pWin->valdata->after.exposed; - (*pScreen->WindowExposures) (pWin, valExposed, bsExposed); - if (valExposed) - RegionEmpty(valExposed); - RegionDestroy(bsExposed); - } (*pScreen->HandleExposures)(pWin->parent); -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pWin, pFirstChange); -#endif /* DO_SAVE_UNDERS */ if (pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pWin->parent, pFirstChange, VTOther); } - else if (bsExposed) { - (*pScreen->WindowExposures) (pWin, NullRegion, bsExposed); - RegionDestroy(bsExposed); - } if (pWin->realized) WindowsRestructured (); } @@ -1577,10 +1515,7 @@ miOverlaySetShape(WindowPtr pWin) { Bool WasViewable = (Bool)(pWin->viewable); ScreenPtr pScreen = pWin->drawable.pScreen; - RegionPtr pOldClip = NULL, bsExposed; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif + RegionPtr pOldClip = NULL; if (WasViewable) { (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL); @@ -1618,40 +1553,11 @@ miOverlaySetShape(WindowPtr pWin) (*pScreen->MarkOverlappedWindows)(pWin, pWin, NULL); -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - dosave = (*pScreen->ChangeSaveUnder)(pWin, pWin); -#endif /* DO_SAVE_UNDERS */ - (*pScreen->ValidateTree)(pWin->parent, NullWindow, VTOther); } - if (pWin->backStorage && ((pWin->backingStore == Always) || WasViewable)) { - if (!WasViewable) - pOldClip = &pWin->clipList; /* a convenient empty region */ - bsExposed = (*pScreen->TranslateBackingStore) - (pWin, 0, 0, pOldClip, - pWin->drawable.x, pWin->drawable.y); - if (WasViewable) - RegionDestroy(pOldClip); - if (bsExposed) - { - RegionPtr valExposed = NullRegion; - - if (pWin->valdata) - valExposed = &pWin->valdata->after.exposed; - (*pScreen->WindowExposures) (pWin, valExposed, bsExposed); - if (valExposed) - RegionEmpty(valExposed); - RegionDestroy(bsExposed); - } - } if (WasViewable) { (*pScreen->HandleExposures)(pWin->parent); -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pWin, pWin); -#endif /* DO_SAVE_UNDERS */ if (pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pWin->parent, NullWindow, VTOther); } @@ -1672,9 +1578,6 @@ miOverlayChangeBorderWidth( register ScreenPtr pScreen; Bool WasViewable = (Bool)(pWin->viewable); Bool HadBorder; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif oldwidth = wBorderWidth (pWin); if (oldwidth == width) @@ -1708,17 +1611,9 @@ miOverlayChangeBorderWidth( } } } -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - dosave = (*pScreen->ChangeSaveUnder)(pWin, pWin->nextSib); -#endif /* DO_SAVE_UNDERS */ (*pScreen->ValidateTree)(pWin->parent, pWin, VTOther); (*pScreen->HandleExposures)(pWin->parent); -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pWin, pWin->nextSib); -#endif /* DO_SAVE_UNDERS */ if (pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pWin->parent, pWin, VTOther); } @@ -1798,10 +1693,6 @@ miOverlayClearToBackground( box.y1 = y1; box.y2 = y2; RegionInit(®, &box, 1); - if (pWin->backStorage) { - pBSReg = (* pScreen->ClearBackingStore)(pWin, x, y, w, h, - generateExposures); - } RegionIntersect(®, ®, clipList); if (generateExposures) diff --git a/nx-X11/programs/Xserver/mi/mipointer.c b/nx-X11/programs/Xserver/mi/mipointer.c index 5a874a4a0e..1060b761f4 100644 --- a/nx-X11/programs/Xserver/mi/mipointer.c +++ b/nx-X11/programs/Xserver/mi/mipointer.c @@ -45,16 +45,43 @@ in this Software without prior written authorization from The Open Group. # include "dixstruct.h" # include -int miPointerScreenIndex; -static unsigned long miPointerGeneration = 0; - -#define GetScreenPrivate(s) ((miPointerScreenPtr) ((s)->devPrivates[miPointerScreenIndex].ptr)) -#define SetupScreen(s) miPointerScreenPtr pScreenPriv = GetScreenPrivate(s) +#define MOTION_SIZE 256 + +typedef struct { + xTimecoord event; + ScreenPtr pScreen; +} miHistoryRec, *miHistoryPtr; + +typedef struct { + ScreenPtr pScreen; /* current screen */ + ScreenPtr pSpriteScreen; /* screen containing current sprite */ + CursorPtr pCursor; /* current cursor */ + CursorPtr pSpriteCursor; /* cursor on screen */ + BoxRec limits; /* current constraints */ + Bool confined; /* pointer can't change screens */ + int x, y; /* hot spot location */ + int devx, devy; /* sprite position */ + DevicePtr pPointer; /* pointer device structure */ + miHistoryRec history[MOTION_SIZE]; + int history_start, history_end; +} miPointerRec, *miPointerPtr; + +DevPrivateKeyRec miPointerScreenKeyRec; + +#define GetScreenPrivate(s) ((miPointerScreenPtr) \ + dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey)) +#define SetupScreen(s) miPointerScreenPtr pScreenPriv = GetScreenPrivate(s) + +DevPrivateKeyRec miPointerPrivKeyRec; + +#define MIPOINTER(dev) \ + (IsFloating(dev) ? \ + (miPointerPtr)dixLookupPrivate(&(dev)->devPrivates, miPointerPrivKey): \ + (miPointerPtr)dixLookupPrivate(&(GetMaster(dev, MASTER_POINTER))->devPrivates, miPointerPrivKey)) /* * until more than one pointer device exists. */ - static miPointerRec miPointer; static Bool miPointerRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); @@ -78,13 +105,12 @@ miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate) { miPointerScreenPtr pScreenPriv; - if (miPointerGeneration != serverGeneration) - { - miPointerScreenIndex = AllocateScreenPrivateIndex(); - if (miPointerScreenIndex < 0) - return FALSE; - miPointerGeneration = serverGeneration; - } + if (!dixRegisterPrivateKey(&miPointerScreenKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + + if (!dixRegisterPrivateKey(&miPointerPrivKeyRec, PRIVATE_DEVICE, 0)) + return FALSE; + pScreenPriv = (miPointerScreenPtr) malloc (sizeof (miPointerScreenRec)); if (!pScreenPriv) return FALSE; @@ -101,7 +127,7 @@ miPointerInitialize (pScreen, spriteFuncs, screenFuncs, waitForUpdate) pScreenPriv->showTransparent = FALSE; pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = miPointerCloseScreen; - pScreen->devPrivates[miPointerScreenIndex].ptr = (void *) pScreenPriv; + dixSetPrivate(&pScreen->devPrivates, miPointerScreenKey, pScreenPriv); /* * set up screen cursor method table */ diff --git a/nx-X11/programs/Xserver/mi/mipointer.h b/nx-X11/programs/Xserver/mi/mipointer.h index 4fd326fcef..2e58aa029a 100644 --- a/nx-X11/programs/Xserver/mi/mipointer.h +++ b/nx-X11/programs/Xserver/mi/mipointer.h @@ -155,6 +155,12 @@ extern void _miRegisterPointerDevice( DeviceIntPtr /*pDevice*/ ); -extern int miPointerScreenIndex; +extern _X_EXPORT DevPrivateKeyRec miPointerPrivKeyRec; + +#define miPointerPrivKey (&miPointerPrivKeyRec) + +extern _X_EXPORT DevPrivateKeyRec miPointerScreenKeyRec; + +#define miPointerScreenKey (&miPointerScreenKeyRec) #endif /* MIPOINTER_H */ diff --git a/nx-X11/programs/Xserver/mi/mipointrst.h b/nx-X11/programs/Xserver/mi/mipointrst.h index f1fbfe4f9d..7419ac1075 100644 --- a/nx-X11/programs/Xserver/mi/mipointrst.h +++ b/nx-X11/programs/Xserver/mi/mipointrst.h @@ -3,7 +3,6 @@ * */ - /* Copyright 1989, 1998 The Open Group @@ -29,34 +28,17 @@ used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The Open Group. */ +#ifndef MIPOINTRST_H +#define MIPOINTRST_H + #include "mipointer.h" #include "scrnintstr.h" -#define MOTION_SIZE 256 - -typedef struct { - xTimecoord event; - ScreenPtr pScreen; -} miHistoryRec, *miHistoryPtr; - -typedef struct { - ScreenPtr pScreen; /* current screen */ - ScreenPtr pSpriteScreen;/* screen containing current sprite */ - CursorPtr pCursor; /* current cursor */ - CursorPtr pSpriteCursor;/* cursor on screen */ - BoxRec limits; /* current constraints */ - Bool confined; /* pointer can't change screens */ - int x, y; /* hot spot location */ - int devx, devy; /* sprite position */ - DevicePtr pPointer; /* pointer device structure */ - miHistoryRec history[MOTION_SIZE]; - int history_start, history_end; -} miPointerRec, *miPointerPtr; - typedef struct { - miPointerSpriteFuncPtr spriteFuncs; /* sprite-specific methods */ - miPointerScreenFuncPtr screenFuncs; /* screen-specific methods */ - CloseScreenProcPtr CloseScreen; - Bool waitForUpdate; /* don't move cursor in SIGIO */ - Bool showTransparent; /* show empty cursors */ + miPointerSpriteFuncPtr spriteFuncs; /* sprite-specific methods */ + miPointerScreenFuncPtr screenFuncs; /* screen-specific methods */ + CloseScreenProcPtr CloseScreen; + Bool waitForUpdate; /* don't move cursor from input thread */ + Bool showTransparent; /* show empty cursors */ } miPointerScreenRec, *miPointerScreenPtr; +#endif /* MIPOINTRST_H */ diff --git a/nx-X11/programs/Xserver/mi/miscrinit.c b/nx-X11/programs/Xserver/mi/miscrinit.c index cb46d1fa7d..17636f6f08 100644 --- a/nx-X11/programs/Xserver/mi/miscrinit.c +++ b/nx-X11/programs/Xserver/mi/miscrinit.c @@ -270,8 +270,8 @@ miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, pScreen->wakeupData = (void *)0; pScreen->MarkWindow = miMarkWindow; pScreen->MarkOverlappedWindows = miMarkOverlappedWindows; - pScreen->ChangeSaveUnder = miChangeSaveUnder; - pScreen->PostChangeSaveUnder = miPostChangeSaveUnder; + pScreen->ChangeSaveUnder = NULL; + pScreen->PostChangeSaveUnder = NULL; pScreen->MoveWindow = miMoveWindow; pScreen->ResizeWindow = miSlideAndSizeWindow; pScreen->GetLayerWindow = miGetLayerWindow; @@ -283,13 +283,6 @@ miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, #endif pScreen->MarkUnrealizedWindow = miMarkUnrealizedWindow; - pScreen->SaveDoomedAreas = 0; - pScreen->RestoreAreas = 0; - pScreen->ExposeCopy = 0; - pScreen->TranslateBackingStore = 0; - pScreen->ClearBackingStore = 0; - pScreen->DrawGuarantee = 0; - miSetZeroLineBias(pScreen, DEFAULTZEROLINEBIAS); return miScreenDevPrivateInit(pScreen, width, pbits); @@ -303,27 +296,23 @@ miAllocateGCPrivateIndex() if (miGeneration != serverGeneration) { - privateIndex = AllocateGCPrivateIndex(); miGeneration = serverGeneration; } return privateIndex; } -int miZeroLineScreenIndex; -unsigned int miZeroLineGeneration = 0; +DevPrivateKeyRec miZeroLineScreenKeyRec; void miSetZeroLineBias(pScreen, bias) ScreenPtr pScreen; unsigned int bias; { - if (miZeroLineGeneration != serverGeneration) - { - miZeroLineScreenIndex = AllocateScreenPrivateIndex(); - miZeroLineGeneration = serverGeneration; - } - if (miZeroLineScreenIndex >= 0) - pScreen->devPrivates[miZeroLineScreenIndex].uval = bias; + if (!dixRegisterPrivateKey(&miZeroLineScreenKeyRec, PRIVATE_SCREEN, 0)) + return; + + dixSetPrivate(&pScreen->devPrivates, miZeroLineScreenKey, + (unsigned long *) (unsigned long) bias); } PixmapPtr diff --git a/nx-X11/programs/Xserver/mi/misprite.c b/nx-X11/programs/Xserver/mi/misprite.c index 62acb5d29e..ba44b6fa0f 100644 --- a/nx-X11/programs/Xserver/mi/misprite.c +++ b/nx-X11/programs/Xserver/mi/misprite.c @@ -63,13 +63,18 @@ in this Software without prior written authorization from The Open Group. #define SPRITE_DEBUG(x) #endif +static DevPrivateKeyRec miSpriteScreenKeyRec; + +static miSpriteScreenPtr +GetSpriteScreen(ScreenPtr pScreen) +{ + return dixLookupPrivate(&pScreen->devPrivates, &miSpriteScreenKeyRec); +} + /* * screen wrappers */ -static int miSpriteScreenIndex; -static unsigned long miSpriteGeneration = 0; - static Bool miSpriteCloseScreen(ScreenPtr pScreen); static void miSpriteGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h, unsigned int format, @@ -89,15 +94,12 @@ static void miSpriteInstallColormap(ColormapPtr pMap); static void miSpriteStoreColors(ColormapPtr pMap, int ndef, xColorItem *pdef); -static void miSpriteSaveDoomedAreas(WindowPtr pWin, - RegionPtr pObscured, int dx, - int dy); static void miSpriteComputeSaved(ScreenPtr pScreen); -#define SCREEN_PROLOGUE(pScreen, field)\ - ((pScreen)->field = \ - ((miSpriteScreenPtr) (pScreen)->devPrivates[miSpriteScreenIndex].ptr)->field) +#define SCREEN_PROLOGUE(pScreen, field) ((pScreen)->field = \ + ((miSpriteScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \ + &miSpriteScreenKeyRec))->field) #define SCREEN_EPILOGUE(pScreen, field)\ ((pScreen)->field = miSprite##field) @@ -129,11 +131,10 @@ static void miSpriteReportDamage (DamagePtr pDamage, RegionPtr pRegion, void *closure) { ScreenPtr pScreen = closure; - miSpriteScreenPtr pScreenPriv; - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen); if (pScreenPriv->isUp && + RegionContainsRect(pRegion, &pScreenPriv->saved) != rgnOUT) { SPRITE_DEBUG(("Damage remove\n")); @@ -155,19 +156,14 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) { miSpriteScreenPtr pScreenPriv; VisualPtr pVisual; - + if (!DamageSetup (pScreen)) return FALSE; - if (miSpriteGeneration != serverGeneration) - { - miSpriteScreenIndex = AllocateScreenPrivateIndex (); - if (miSpriteScreenIndex < 0) - return FALSE; - miSpriteGeneration = serverGeneration; - } - - pScreenPriv = (miSpriteScreenPtr) malloc (sizeof (miSpriteScreenRec)); + if (!dixRegisterPrivateKey(&miSpriteScreenKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + + pScreenPriv = GetSpriteScreen(pScreen); if (!pScreenPriv) return FALSE; @@ -195,8 +191,6 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) pScreenPriv->CopyWindow = pScreen->CopyWindow; - pScreenPriv->SaveDoomedAreas = pScreen->SaveDoomedAreas; - pScreenPriv->InstallColormap = pScreen->InstallColormap; pScreenPriv->StoreColors = pScreen->StoreColors; @@ -219,8 +213,9 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) pScreenPriv->colors[MASK_COLOR].red = 0; pScreenPriv->colors[MASK_COLOR].green = 0; pScreenPriv->colors[MASK_COLOR].blue = 0; - pScreen->devPrivates[miSpriteScreenIndex].ptr = (void *) pScreenPriv; - + + dixSetPrivate(&pScreen->devPrivates, &miSpriteScreenKeyRec, pScreenPriv); + pScreen->CloseScreen = miSpriteCloseScreen; pScreen->GetImage = miSpriteGetImage; pScreen->GetSpans = miSpriteGetSpans; @@ -228,8 +223,6 @@ miSpriteInitialize (pScreen, cursorFuncs, screenFuncs) pScreen->CopyWindow = miSpriteCopyWindow; - pScreen->SaveDoomedAreas = miSpriteSaveDoomedAreas; - pScreen->InstallColormap = miSpriteInstallColormap; pScreen->StoreColors = miSpriteStoreColors; @@ -251,9 +244,7 @@ static Bool miSpriteCloseScreen (pScreen) ScreenPtr pScreen; { - miSpriteScreenPtr pScreenPriv; - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen); pScreen->CloseScreen = pScreenPriv->CloseScreen; pScreen->GetImage = pScreenPriv->GetImage; @@ -263,7 +254,6 @@ miSpriteCloseScreen (pScreen) pScreen->InstallColormap = pScreenPriv->InstallColormap; pScreen->StoreColors = pScreenPriv->StoreColors; - pScreen->SaveDoomedAreas = pScreenPriv->SaveDoomedAreas; miSpriteIsUpFALSE (pScreen, pScreenPriv); DamageDestroy (pScreenPriv->pDamage); @@ -285,7 +275,7 @@ miSpriteGetImage (pDrawable, sx, sy, w, h, format, planemask, pdstLine) SCREEN_PROLOGUE (pScreen, GetImage); - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = GetSpriteScreen(pScreen); if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp && @@ -315,7 +305,7 @@ miSpriteGetSpans (pDrawable, wMax, ppt, pwidth, nspans, pdstStart) SCREEN_PROLOGUE (pScreen, GetSpans); - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = GetSpriteScreen(pScreen); if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp) { @@ -357,7 +347,7 @@ miSpriteSourceValidate (pDrawable, x, y, width, height) SCREEN_PROLOGUE (pScreen, SourceValidate); - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = GetSpriteScreen(pScreen); if (pDrawable->type == DRAWABLE_WINDOW && pScreenPriv->isUp && ORG_OVERLAP(&pScreenPriv->saved, pDrawable->x, pDrawable->y, @@ -381,7 +371,7 @@ miSpriteCopyWindow (WindowPtr pWindow, DDXPointRec ptOldOrg, RegionPtr prgnSrc) SCREEN_PROLOGUE (pScreen, CopyWindow); - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = GetSpriteScreen(pScreen); /* * Damage will take care of destination check */ @@ -404,9 +394,8 @@ miSpriteBlockHandler (i, blockData, pTimeout, pReadmask) void * pReadmask; { ScreenPtr pScreen = screenInfo.screens[i]; - miSpriteScreenPtr pPriv; - pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); SCREEN_PROLOGUE(pScreen, BlockHandler); @@ -426,9 +415,7 @@ miSpriteInstallColormap (pMap) ColormapPtr pMap; { ScreenPtr pScreen = pMap->pScreen; - miSpriteScreenPtr pPriv; - - pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); SCREEN_PROLOGUE(pScreen, InstallColormap); @@ -452,12 +439,11 @@ miSpriteStoreColors (pMap, ndef, pdef) xColorItem *pdef; { ScreenPtr pScreen = pMap->pScreen; - miSpriteScreenPtr pPriv; int i; int updated; VisualPtr pVisual; - pPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + miSpriteScreenPtr pPriv = GetSpriteScreen(pScreen); SCREEN_PROLOGUE(pScreen, StoreColors); @@ -524,8 +510,7 @@ miSpriteStoreColors (pMap, ndef, pdef) static void miSpriteFindColors (ScreenPtr pScreen) { - miSpriteScreenPtr pScreenPriv = (miSpriteScreenPtr) - pScreen->devPrivates[miSpriteScreenIndex].ptr; + miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen); CursorPtr pCursor; xColorItem *sourceColor, *maskColor; @@ -556,45 +541,6 @@ miSpriteFindColors (ScreenPtr pScreen) pScreenPriv->checkPixels = FALSE; } -/* - * BackingStore wrappers - */ - -static void -miSpriteSaveDoomedAreas (pWin, pObscured, dx, dy) - WindowPtr pWin; - RegionPtr pObscured; - int dx, dy; -{ - ScreenPtr pScreen; - miSpriteScreenPtr pScreenPriv; - BoxRec cursorBox; - - pScreen = pWin->drawable.pScreen; - - SCREEN_PROLOGUE (pScreen, SaveDoomedAreas); - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; - if (pScreenPriv->isUp) - { - cursorBox = pScreenPriv->saved; - - if (dx || dy) - { - cursorBox.x1 += dx; - cursorBox.y1 += dy; - cursorBox.x2 += dx; - cursorBox.y2 += dy; - } - if (RegionContainsRect(pObscured, &cursorBox) != rgnOUT) - miSpriteRemoveCursor (pScreen); - } - - (*pScreen->SaveDoomedAreas) (pWin, pObscured, dx, dy); - - SCREEN_EPILOGUE (pScreen, SaveDoomedAreas); -} - /* * miPointer interface routines */ @@ -606,9 +552,7 @@ miSpriteRealizeCursor (pScreen, pCursor) ScreenPtr pScreen; CursorPtr pCursor; { - miSpriteScreenPtr pScreenPriv; - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen); if (pCursor == pScreenPriv->pCursor) pScreenPriv->checkPixels = TRUE; return (*pScreenPriv->funcs->RealizeCursor) (pScreen, pCursor); @@ -619,9 +563,7 @@ miSpriteUnrealizeCursor (pScreen, pCursor) ScreenPtr pScreen; CursorPtr pCursor; { - miSpriteScreenPtr pScreenPriv; - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen); return (*pScreenPriv->funcs->UnrealizeCursor) (pScreen, pCursor); } @@ -632,9 +574,7 @@ miSpriteSetCursor (pScreen, pCursor, x, y) int x; int y; { - miSpriteScreenPtr pScreenPriv; - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen); if (!pCursor) { pScreenPriv->shouldBeUp = FALSE; @@ -732,9 +672,7 @@ miSpriteMoveCursor (pScreen, x, y) ScreenPtr pScreen; int x, y; { - miSpriteScreenPtr pScreenPriv; - - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen); miSpriteSetCursor (pScreen, pScreenPriv->pCursor, x, y); } @@ -746,10 +684,10 @@ static void miSpriteRemoveCursor (pScreen) ScreenPtr pScreen; { - miSpriteScreenPtr pScreenPriv; + miSpriteScreenPtr pScreenPriv; DamageDrawInternal (pScreen, TRUE); - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = GetSpriteScreen(pScreen); miSpriteIsUpFALSE (pScreen, pScreenPriv); pScreenPriv->pCacheWin = NullWindow; if (!(*pScreenPriv->funcs->RestoreUnderCursor) (pScreen, @@ -778,7 +716,7 @@ miSpriteRestoreCursor (pScreen) DamageDrawInternal (pScreen, TRUE); miSpriteComputeSaved (pScreen); - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + pScreenPriv = GetSpriteScreen(pScreen); pCursor = pScreenPriv->pCursor; x = pScreenPriv->x - (int)pCursor->bits->xhot; y = pScreenPriv->y - (int)pCursor->bits->yhot; @@ -808,12 +746,11 @@ static void miSpriteComputeSaved (pScreen) ScreenPtr pScreen; { - miSpriteScreenPtr pScreenPriv; int x, y, w, h; int wpad, hpad; CursorPtr pCursor; - pScreenPriv = (miSpriteScreenPtr) pScreen->devPrivates[miSpriteScreenIndex].ptr; + miSpriteScreenPtr pScreenPriv = GetSpriteScreen(pScreen); pCursor = pScreenPriv->pCursor; x = pScreenPriv->x - (int)pCursor->bits->xhot; y = pScreenPriv->y - (int)pCursor->bits->yhot; diff --git a/nx-X11/programs/Xserver/mi/mispritest.h b/nx-X11/programs/Xserver/mi/mispritest.h index 5075f05804..e8251ead22 100644 --- a/nx-X11/programs/Xserver/mi/mispritest.h +++ b/nx-X11/programs/Xserver/mi/mispritest.h @@ -57,9 +57,6 @@ typedef struct { /* window procedures */ CopyWindowProcPtr CopyWindow; - /* backing store procedures */ - SaveDoomedAreasProcPtr SaveDoomedAreas; - /* colormap procedures */ InstallColormapProcPtr InstallColormap; StoreColorsProcPtr StoreColors; diff --git a/nx-X11/programs/Xserver/mi/mivalidate.h b/nx-X11/programs/Xserver/mi/mivalidate.h index ef258c0f89..18700ac79f 100644 --- a/nx-X11/programs/Xserver/mi/mivalidate.h +++ b/nx-X11/programs/Xserver/mi/mivalidate.h @@ -40,8 +40,7 @@ typedef union _Validate { DDXPointRec oldAbsCorner; /* old window position */ RegionPtr borderVisible; /* visible region of border, */ /* non-null when size changes */ - Bool resized; /* unclipped winSize has changed - */ - /* don't call SaveDoomedAreas */ + Bool resized; /* unclipped winSize has changed */ } before; struct AfterValidate { RegionRec exposed; /* exposed regions, absolute pos */ diff --git a/nx-X11/programs/Xserver/mi/mivaltree.c b/nx-X11/programs/Xserver/mi/mivaltree.c index 21534cee05..247f139f96 100644 --- a/nx-X11/programs/Xserver/mi/mivaltree.c +++ b/nx-X11/programs/Xserver/mi/mivaltree.c @@ -217,7 +217,7 @@ miComputeClips ( RegionRec childUnion; Bool overlap; RegionPtr borderVisible; - Bool resized; + /* * Figure out the new visibility of this window. * The extent of the universe should be the same as the extent of @@ -372,7 +372,6 @@ miComputeClips ( } borderVisible = pParent->valdata->before.borderVisible; - resized = pParent->valdata->before.resized; RegionNull(&pParent->valdata->after.borderExposed); RegionNull(&pParent->valdata->after.exposed); @@ -502,18 +501,6 @@ miComputeClips ( universe, &pParent->clipList); } - /* - * One last thing: backing storage. We have to try to save what parts of - * the window are about to be obscured. We can just subtract the universe - * from the old clipList and get the areas that were in the old but aren't - * in the new and, hence, are about to be obscured. - */ - if (pParent->backStorage && !resized) - { - RegionSubtract(exposed, &pParent->clipList, universe); - (* pScreen->SaveDoomedAreas)(pParent, exposed, dx, dy); - } - /* HACK ALERT - copying contents of regions, instead of regions */ { RegionRec tmp; @@ -805,11 +792,6 @@ miValidateTree (pParent, pChild, kind) &totalClip, &pParent->clipList); /* fall through */ case VTMap: - if (pParent->backStorage) { - RegionSubtract(&exposed, &pParent->clipList, &totalClip); - (* pScreen->SaveDoomedAreas)(pParent, &exposed, 0, 0); - } - RegionCopy(&pParent->clipList, &totalClip); pParent->drawable.serialNumber = NEXT_SERIAL_NUMBER; break; diff --git a/nx-X11/programs/Xserver/mi/miwindow.c b/nx-X11/programs/Xserver/mi/miwindow.c index 2a583eda7b..01b3eae5d8 100644 --- a/nx-X11/programs/Xserver/mi/miwindow.c +++ b/nx-X11/programs/Xserver/mi/miwindow.c @@ -113,18 +113,6 @@ miClearToBackground(pWin, x, y, w, h, generateExposures) pScreen = pWin->drawable.pScreen; RegionInit(®, &box, 1); - if (pWin->backStorage) - { - /* - * If the window has backing-store on, call through the - * ClearToBackground vector to handle the special semantics - * (i.e. things backing store is to be cleared out and - * an Expose event is to be generated for those areas in backing - * store if generateExposures is TRUE). - */ - pBSReg = (* pScreen->ClearBackingStore)(pWin, x, y, w, h, - generateExposures); - } RegionIntersect(®, ®, &pWin->clipList); if (generateExposures) @@ -136,208 +124,6 @@ miClearToBackground(pWin, x, y, w, h, generateExposures) RegionDestroy(pBSReg); } -/* - * For SaveUnders using backing-store. The idea is that when a window is mapped - * with saveUnder set TRUE, any windows it obscures will have its backing - * store turned on setting the DIXsaveUnder bit, - * The backing-store code must be written to allow for this - */ - -/*- - *----------------------------------------------------------------------- - * miCheckSubSaveUnder -- - * Check all the inferiors of a window for coverage by saveUnder - * windows. Called from ChangeSaveUnder and CheckSaveUnder. - * This code is very inefficient. - * - * Results: - * TRUE if any windows need to have backing-store removed. - * - * Side Effects: - * Windows may have backing-store turned on or off. - * - *----------------------------------------------------------------------- - */ -static Bool -miCheckSubSaveUnder( - register WindowPtr pParent, /* Parent to check */ - WindowPtr pFirst, /* first reconfigured window */ - RegionPtr pRegion) /* Initial area obscured by saveUnder */ -{ - register WindowPtr pChild; /* Current child */ - register ScreenPtr pScreen; /* Screen to use */ - RegionRec SubRegion; /* Area of children obscured */ - Bool res = FALSE; /* result */ - Bool subInited=FALSE;/* SubRegion initialized */ - - pScreen = pParent->drawable.pScreen; - if ( (pChild = pParent->firstChild) ) - { - /* - * build region above first changed window - */ - - for (; pChild != pFirst; pChild = pChild->nextSib) - if (pChild->viewable && pChild->saveUnder) - RegionUnion(pRegion, pRegion, &pChild->borderSize); - - /* - * check region below and including first changed window - */ - - for (; pChild; pChild = pChild->nextSib) - { - if (pChild->viewable) - { - /* - * don't save under nephew/niece windows; - * use a separate region - */ - - if (pChild->firstChild) - { - if (!subInited) - { - RegionNull(&SubRegion); - subInited = TRUE; - } - RegionCopy(&SubRegion, pRegion); - res |= miCheckSubSaveUnder(pChild, pChild->firstChild, - &SubRegion); - } - else - { - res |= miCheckSubSaveUnder(pChild, pChild->firstChild, - pRegion); - } - - if (pChild->saveUnder) - RegionUnion(pRegion, pRegion, &pChild->borderSize); - } - } - - if (subInited) - RegionUninit(&SubRegion); - } - - /* - * Check the state of this window. DIX save unders are - * enabled for viewable windows with some client expressing - * exposure interest and which intersect the save under region - */ - - if (pParent->viewable && - ((pParent->eventMask | wOtherEventMasks(pParent)) & ExposureMask) && - RegionNotEmpty(&pParent->borderSize) && - RegionContainsRect(pRegion, RegionExtents( - &pParent->borderSize)) != rgnOUT) - { - if (!pParent->DIXsaveUnder) - { - pParent->DIXsaveUnder = TRUE; - (*pScreen->ChangeWindowAttributes) (pParent, CWBackingStore); - } - } - else - { - if (pParent->DIXsaveUnder) - { - res = TRUE; - pParent->DIXsaveUnder = FALSE; - } - } - return res; -} - - -/*- - *----------------------------------------------------------------------- - * miChangeSaveUnder -- - * Change the save-under state of a tree of windows. Called when - * a window with saveUnder TRUE is mapped/unmapped/reconfigured. - * - * Results: - * TRUE if any windows need to have backing-store removed (which - * means that PostChangeSaveUnder needs to be called later to - * finish the job). - * - * Side Effects: - * Windows may have backing-store turned on or off. - * - *----------------------------------------------------------------------- - */ -Bool -miChangeSaveUnder(pWin, first) - register WindowPtr pWin; - WindowPtr first; /* First window to check. - * Used when pWin was restacked */ -{ - RegionRec rgn; /* Area obscured by saveUnder windows */ - Bool res; - - if (!deltaSaveUndersViewable && !numSaveUndersViewable) - return FALSE; - numSaveUndersViewable += deltaSaveUndersViewable; - deltaSaveUndersViewable = 0; - RegionNull(&rgn); - res = miCheckSubSaveUnder (pWin->parent, - pWin->saveUnder ? first : pWin->nextSib, - &rgn); - RegionUninit(&rgn); - return res; -} - -/*- - *----------------------------------------------------------------------- - * miPostChangeSaveUnder -- - * Actually turn backing-store off for those windows that no longer - * need to have it on. - * - * Results: - * None. - * - * Side Effects: - * Backing-store and SAVE_UNDER_CHANGE_BIT are turned off for those - * windows affected. - * - *----------------------------------------------------------------------- - */ -void -miPostChangeSaveUnder(pWin, pFirst) - WindowPtr pWin; - WindowPtr pFirst; -{ - register WindowPtr pParent, pChild; - ChangeWindowAttributesProcPtr ChangeWindowAttributes; - - if (!(pParent = pWin->parent)) - return; - ChangeWindowAttributes = pParent->drawable.pScreen->ChangeWindowAttributes; - if (!pParent->DIXsaveUnder && - (pParent->backingStore == NotUseful) && pParent->backStorage) - (*ChangeWindowAttributes)(pParent, CWBackingStore); - if (!(pChild = pFirst)) - return; - while (1) - { - if (!pChild->DIXsaveUnder && - (pChild->backingStore == NotUseful) && pChild->backStorage) - (*ChangeWindowAttributes)(pChild, CWBackingStore); - if (pChild->firstChild) - { - pChild = pChild->firstChild; - continue; - } - while (!pChild->nextSib) - { - pChild = pChild->parent; - if (pChild == pParent) - return; - } - pChild = pChild->nextSib; - } -} - void miMarkWindow(pWin) register WindowPtr pWin; @@ -492,9 +278,6 @@ miMoveWindow(pWin, x, y, pNextSib, kind) Bool anyMarked = FALSE; register ScreenPtr pScreen; WindowPtr windowToValidate; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif WindowPtr pLayerWin; /* if this is a root window, can't be moved */ @@ -534,13 +317,6 @@ miMoveWindow(pWin, x, y, pNextSib, kind) anyMarked |= (*pScreen->MarkOverlappedWindows) (pWin, pLayerWin, (WindowPtr *)NULL); -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, windowToValidate); - } -#endif /* DO_SAVE_UNDERS */ - if (anyMarked) { (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, kind); @@ -549,10 +325,6 @@ miMoveWindow(pWin, x, y, pNextSib, kind) /* XXX need to retile border if ParentRelative origin */ (*pScreen->HandleExposures)(pLayerWin->parent); } -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, windowToValidate); -#endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, kind); } @@ -621,12 +393,8 @@ miSlideAndSizeWindow(pWin, x, y, w, h, pSib) RegionPtr destClip; /* portions of destination already written */ RegionPtr oldWinClip = NULL; /* old clip list for window */ RegionPtr borderVisible = NullRegion; /* visible area of the border */ - RegionPtr bsExposed = NullRegion; /* backing store exposures */ Bool shrunk = FALSE; /* shrunk in an inner dimension */ Bool moved = FALSE; /* window position changed */ -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif WindowPtr pLayerWin; /* if this is a root window, can't be resized */ @@ -725,9 +493,6 @@ miSlideAndSizeWindow(pWin, x, y, w, h, pSib) if (WasViewable) { pRegion = RegionCreate(NullBox, 1); - if (pWin->backStorage) - RegionCopy(pRegion, &pWin->clipList); - if (pLayerWin == pWin) anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pFirstChange, (WindowPtr *)NULL); @@ -741,13 +506,6 @@ miSlideAndSizeWindow(pWin, x, y, w, h, pSib) pWin->valdata->before.borderVisible = borderVisible; } -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pFirstChange); - } -#endif /* DO_SAVE_UNDERS */ - if (anyMarked) (*pScreen->ValidateTree)(pLayerWin->parent, pFirstChange, VTOther); /* @@ -759,21 +517,6 @@ miSlideAndSizeWindow(pWin, x, y, w, h, pSib) GravityTranslate (x, y, oldx, oldy, dw, dh, pWin->bitGravity, &nx, &ny); - if (pWin->backStorage && - ((pWin->backingStore == Always) || WasViewable)) - { - if (!WasViewable) - pRegion = &pWin->clipList; /* a convenient empty region */ - if (pWin->bitGravity == ForgetGravity) - bsExposed = (*pScreen->TranslateBackingStore) - (pWin, 0, 0, NullRegion, oldx, oldy); - else - { - bsExposed = (*pScreen->TranslateBackingStore) - (pWin, nx - x, ny - y, pRegion, oldx, oldy); - } - } - if (WasViewable) { /* avoid the border */ @@ -922,34 +665,12 @@ miSlideAndSizeWindow(pWin, x, y, w, h, pSib) RegionDestroy(pRegion); if (destClip) RegionDestroy(destClip); - if (bsExposed) - { - RegionPtr valExposed = NullRegion; - - if (pWin->valdata) - valExposed = &pWin->valdata->after.exposed; - (*pScreen->WindowExposures) (pWin, valExposed, bsExposed); - if (valExposed) - RegionEmpty(valExposed); - RegionDestroy(bsExposed); - } if (anyMarked) (*pScreen->HandleExposures)(pLayerWin->parent); -#ifdef DO_SAVE_UNDERS - if (dosave) - { - (*pScreen->PostChangeSaveUnder)(pLayerWin, pFirstChange); - } -#endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pFirstChange, VTOther); } - else if (bsExposed) - { - (*pScreen->WindowExposures) (pWin, NullRegion, bsExposed); - RegionDestroy(bsExposed); - } if (pWin->realized) WindowsRestructured (); } @@ -976,10 +697,7 @@ miSetShape(pWin) Bool WasViewable = (Bool)(pWin->viewable); register ScreenPtr pScreen = pWin->drawable.pScreen; Bool anyMarked = FALSE; - RegionPtr pOldClip = NULL, bsExposed; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif + RegionPtr pOldClip = NULL; WindowPtr pLayerWin; if (WasViewable) @@ -1008,74 +726,19 @@ miSetShape(pWin) if (WasViewable) { - if (pWin->backStorage) - { - pOldClip = RegionCreate(NullBox, 1); - RegionCopy(pOldClip, &pWin->clipList); - } - anyMarked |= (*pScreen->MarkOverlappedWindows)(pWin, pWin, (WindowPtr *)NULL); -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pLayerWin); - } -#endif /* DO_SAVE_UNDERS */ - if (anyMarked) (*pScreen->ValidateTree)(pLayerWin->parent, NullWindow, VTOther); - } - - if (pWin->backStorage && - ((pWin->backingStore == Always) || WasViewable)) - { - if (!WasViewable) - pOldClip = &pWin->clipList; /* a convenient empty region */ - bsExposed = (*pScreen->TranslateBackingStore) - (pWin, 0, 0, pOldClip, - pWin->drawable.x, pWin->drawable.y); - - /* - * Applies to NXAGENT_SERVER builds: - * - * We got a few, rare, segfaults here after having - * started using the backing store. It may be a - * different bug but miChangeSaveUnder() calls mi- - * CheckSubSaveUnder() that, in turn, can change - * the backing store attribute of the window. This - * means that we may try to destroy the region - * even if it was not created at the beginning of - * this function as, at the time, the backing store - * was off. miCheckSubSaveUnder() appear to get a - * pointer to the parent, so maybe doesn't change - * the attribute of the window itself. This is to - * be better investigated. - */ if (WasViewable && pOldClip) RegionDestroy(pOldClip); - if (bsExposed) - { - RegionPtr valExposed = NullRegion; - - if (pWin->valdata) - valExposed = &pWin->valdata->after.exposed; - (*pScreen->WindowExposures) (pWin, valExposed, bsExposed); - if (valExposed) - RegionEmpty(valExposed); - RegionDestroy(bsExposed); - } } if (WasViewable) { if (anyMarked) (*pScreen->HandleExposures)(pLayerWin->parent); -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, pLayerWin); -#endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, NullWindow, VTOther); } @@ -1097,9 +760,6 @@ miChangeBorderWidth(pWin, width) register ScreenPtr pScreen; Bool WasViewable = (Bool)(pWin->viewable); Bool HadBorder; -#ifdef DO_SAVE_UNDERS - Bool dosave = FALSE; -#endif WindowPtr pLayerWin; oldwidth = wBorderWidth (pWin); @@ -1132,22 +792,12 @@ miChangeBorderWidth(pWin, width) pWin->valdata->before.borderVisible = borderVisible; } } -#ifdef DO_SAVE_UNDERS - if (DO_SAVE_UNDERS(pWin)) - { - dosave = (*pScreen->ChangeSaveUnder)(pLayerWin, pWin->nextSib); - } -#endif /* DO_SAVE_UNDERS */ if (anyMarked) { (*pScreen->ValidateTree)(pLayerWin->parent, pLayerWin, VTOther); (*pScreen->HandleExposures)(pLayerWin->parent); } -#ifdef DO_SAVE_UNDERS - if (dosave) - (*pScreen->PostChangeSaveUnder)(pLayerWin, pWin->nextSib); -#endif /* DO_SAVE_UNDERS */ if (anyMarked && pScreen->PostValidateTree) (*pScreen->PostValidateTree)(pLayerWin->parent, pLayerWin, VTOther); diff --git a/nx-X11/programs/Xserver/miext/cw/cw.c b/nx-X11/programs/Xserver/miext/cw/cw.c index a45c34dff0..c03d7549d7 100644 --- a/nx-X11/programs/Xserver/miext/cw/cw.c +++ b/nx-X11/programs/Xserver/miext/cw/cw.c @@ -44,14 +44,13 @@ #define CW_ASSERT(x) do {} while (0) #endif -int cwGCIndex; -int cwScreenIndex; -int cwWindowIndex; +DevPrivateKeyRec cwGCKeyRec; +DevPrivateKeyRec cwScreenKeyRec; +DevPrivateKeyRec cwWindowKeyRec; #ifdef RENDER -int cwPictureIndex; +DevPrivateKeyRec cwPictureKeyRec; #endif static Bool cwDisabled[MAXSCREENS]; -static unsigned long cwGeneration = 0; extern GCOps cwGCOps; static Bool @@ -239,7 +238,7 @@ cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable) static void cwChangeGC(GCPtr pGC, unsigned long mask) { - cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr; + cwGCPtr pPriv = (cwGCPtr) dixLookupPrivate(&pGC->devPrivates, cwGCKey); FUNC_PROLOGUE(pGC, pPriv); @@ -251,7 +250,7 @@ cwChangeGC(GCPtr pGC, unsigned long mask) static void cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst) { - cwGCPtr pPriv = (cwGCPtr)(pGCDst)->devPrivates[cwGCIndex].ptr; + cwGCPtr pPriv = (cwGCPtr) dixLookupPrivate(&pGCDst->devPrivates, cwGCKey); FUNC_PROLOGUE(pGCDst, pPriv); @@ -263,7 +262,7 @@ cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst) static void cwDestroyGC(GCPtr pGC) { - cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr; + cwGCPtr pPriv = (cwGCPtr) dixLookupPrivate(&pGC->devPrivates, cwGCKey); FUNC_PROLOGUE(pGC, pPriv); @@ -277,7 +276,7 @@ cwDestroyGC(GCPtr pGC) static void cwChangeClip(GCPtr pGC, int type, void * pvalue, int nrects) { - cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr; + cwGCPtr pPriv = (cwGCPtr) dixLookupPrivate(&pGC->devPrivates, cwGCKey); FUNC_PROLOGUE(pGC, pPriv); @@ -289,7 +288,7 @@ cwChangeClip(GCPtr pGC, int type, void * pvalue, int nrects) static void cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc) { - cwGCPtr pPriv = (cwGCPtr)(pgcDst)->devPrivates[cwGCIndex].ptr; + cwGCPtr pPriv = (cwGCPtr) dixLookupPrivate(&pgcDst->devPrivates, cwGCKey); FUNC_PROLOGUE(pgcDst, pPriv); @@ -301,7 +300,7 @@ cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc) static void cwDestroyClip(GCPtr pGC) { - cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr; + cwGCPtr pPriv = (cwGCPtr) dixLookupPrivate(&pGC->devPrivates, cwGCKey);; FUNC_PROLOGUE(pGC, pPriv); @@ -623,32 +622,26 @@ miInitializeCompositeWrapper(ScreenPtr pScreen) if (cwDisabled[pScreen->myNum]) return; - if (cwGeneration != serverGeneration) - { - cwScreenIndex = AllocateScreenPrivateIndex(); - if (cwScreenIndex < 0) - return; - cwGCIndex = AllocateGCPrivateIndex(); - cwWindowIndex = AllocateWindowPrivateIndex(); -#ifdef RENDER - cwPictureIndex = AllocatePicturePrivateIndex(); -#endif - cwGeneration = serverGeneration; - } - if (!AllocateGCPrivate(pScreen, cwGCIndex, sizeof(cwGCRec))) + if (!dixRegisterPrivateKey(&cwScreenKeyRec, PRIVATE_SCREEN, 0)) + return; + + if (!dixRegisterPrivateKey(&cwGCKeyRec, PRIVATE_GC, sizeof(cwGCRec))) return; - if (!AllocateWindowPrivate(pScreen, cwWindowIndex, 0)) + + if (!dixRegisterPrivateKey(&cwWindowKeyRec, PRIVATE_WINDOW, 0)) return; + #ifdef RENDER - if (!AllocatePicturePrivate(pScreen, cwPictureIndex, 0)) + if (!dixRegisterPrivateKey(&cwPictureKeyRec, PRIVATE_PICTURE, 0)) return; #endif + pScreenPriv = (cwScreenPtr)malloc(sizeof(cwScreenRec)); if (!pScreenPriv) return; - pScreen->devPrivates[cwScreenIndex].ptr = (void *)pScreenPriv; - + dixSetPrivate(&pScreen->devPrivates, cwScreenKey, pScreenPriv); + SCREEN_EPILOGUE(pScreen, CloseScreen, cwCloseScreen); SCREEN_EPILOGUE(pScreen, GetImage, cwGetImage); SCREEN_EPILOGUE(pScreen, GetSpans, cwGetSpans); @@ -680,7 +673,8 @@ cwCloseScreen (ScreenPtr pScreen) PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); #endif - pScreenPriv = (cwScreenPtr)pScreen->devPrivates[cwScreenIndex].ptr; + pScreenPriv = (cwScreenPtr) dixLookupPrivate(&pScreen->devPrivates, + cwScreenKey); pScreen->CloseScreen = pScreenPriv->CloseScreen; pScreen->GetImage = pScreenPriv->GetImage; diff --git a/nx-X11/programs/Xserver/miext/cw/cw.h b/nx-X11/programs/Xserver/miext/cw/cw.h index b8792661f0..8a0ee58086 100644 --- a/nx-X11/programs/Xserver/miext/cw/cw.h +++ b/nx-X11/programs/Xserver/miext/cw/cw.h @@ -27,6 +27,7 @@ #include "gcstruct.h" #include "picturestr.h" +#include "privates.h" /* * One of these structures is allocated per GC that gets used with a window with @@ -44,33 +45,42 @@ typedef struct { GCFuncs *wrapFuncs; /* wrapped funcs */ } cwGCRec, *cwGCPtr; -extern int cwGCIndex; +extern DevPrivateKeyRec cwGCKeyRec; -#define getCwGC(pGC) ((cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr) -#define setCwGC(pGC,p) ((pGC)->devPrivates[cwGCIndex].ptr = (void *) (p)) +#define cwGCKey (&cwGCKeyRec) + +#define getCwGC(pGC) ((cwGCPtr)dixLookupPrivate(&(pGC)->devPrivates, cwGCKey)) +#define setCwGC(pGC,p) dixSetPrivate(&(pGC)->devPrivates, cwGCKey, p) /* * One of these structures is allocated per Picture that gets used with a * window with a backing pixmap */ +#ifdef RENDER typedef struct { PicturePtr pBackingPicture; unsigned long serialNumber; unsigned long stateChanges; } cwPictureRec, *cwPicturePtr; -#define getCwPicture(pPicture) \ - (pPicture->pDrawable ? (cwPicturePtr)(pPicture)->devPrivates[cwPictureIndex].ptr : 0) -#define setCwPicture(pPicture,p) ((pPicture)->devPrivates[cwPictureIndex].ptr = (void *) (p)) +extern DevPrivateKeyRec cwPictureKeyRec; + +#define cwPictureKey (&cwPictureKeyRec) -extern int cwPictureIndex; +#define getCwPicture(pPicture) (pPicture->pDrawable ? \ + (cwPicturePtr)dixLookupPrivate(&(pPicture)->devPrivates, cwPictureKey) : 0) +#define setCwPicture(pPicture,p) dixSetPrivate(&(pPicture)->devPrivates, cwPictureKey, p) +#endif /* RENDER */ -extern int cwWindowIndex; +extern DevPrivateKeyRec cwWindowKeyRec; -#define cwWindowPrivate(pWindow) ((pWindow)->devPrivates[cwWindowIndex].ptr) -#define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow)) -#define setCwPixmap(pWindow,pPixmap) (cwWindowPrivate(pWindow) = (void *) (pPixmap)) +#define cwWindowKey (&cwWindowKeyRec) + +#define cwWindowPrivate(pWin) dixLookupPrivate(&(pWin)->devPrivates, cwWindowKey) +#define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow)) +#define setCwPixmap(pWindow,pPixmap) \ + dixSetPrivate(&(pWindow)->devPrivates, cwWindowKey, pPixmap) #define cwDrawableIsRedirWindow(pDraw) \ ((pDraw)->type == DRAWABLE_WINDOW && \ @@ -112,10 +122,12 @@ typedef struct { #endif } cwScreenRec, *cwScreenPtr; -extern int cwScreenIndex; +extern DevPrivateKeyRec cwScreenKeyRec; + +#define cwScreenKey (&cwScreenKeyRec) -#define getCwScreen(pScreen) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr) -#define setCwScreen(pScreen,p) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr = (p)) +#define getCwScreen(pScreen) ((cwScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, cwScreenKey)) +#define setCwScreen(pScreen,p) dixSetPrivate(&(pScreen)->devPrivates, cwScreenKey, p) #define CW_OFFSET_XYPOINTS(ppt, npt) do { \ DDXPointPtr _ppt = (DDXPointPtr)(ppt); \ diff --git a/nx-X11/programs/Xserver/miext/damage/damage.c b/nx-X11/programs/Xserver/miext/damage/damage.c index 9c9161d36b..7a98972920 100644 --- a/nx-X11/programs/Xserver/miext/damage/damage.c +++ b/nx-X11/programs/Xserver/miext/damage/damage.c @@ -72,10 +72,50 @@ #define DAMAGE_DEBUG(x) #endif -#define getPixmapDamageRef(pPixmap) \ - ((DamagePtr *) &(pPixmap->devPrivates[damagePixPrivateIndex].ptr)) +#define getPixmapDamageRef(pPixmap) ((DamagePtr *) \ + dixLookupPrivateAddr(&(pPixmap)->devPrivates, damagePixPrivateKey)) -#define pixmapDamage(pPixmap) damagePixPriv(pPixmap) +#define pixmapDamage(pPixmap) damagePixPriv(pPixmap) + +static DevPrivateKeyRec damageScrPrivateKeyRec; + +#define damageScrPrivateKey (&damageScrPrivateKeyRec) +static DevPrivateKeyRec damagePixPrivateKeyRec; + +#define damagePixPrivateKey (&damagePixPrivateKeyRec) +static DevPrivateKeyRec damageGCPrivateKeyRec; + +#define damageGCPrivateKey (&damageGCPrivateKeyRec) +static DevPrivateKeyRec damageWinPrivateKeyRec; + +#define damageWinPrivateKey (&damageWinPrivateKeyRec) + +#define damageGetScrPriv(pScr) ((DamageScrPrivPtr) \ + dixLookupPrivate(&(pScr)->devPrivates, damageScrPrivateKey)) + +#define damageScrPriv(pScr) \ + DamageScrPrivPtr pScrPriv = damageGetScrPriv(pScr) + +#define damageGetPixPriv(pPix) \ + dixLookupPrivate(&(pPix)->devPrivates, damagePixPrivateKey) + +#define damgeSetPixPriv(pPix,v) \ + dixSetPrivate(&(pPix)->devPrivates, damagePixPrivateKey, v) + +#define damagePixPriv(pPix) \ + DamagePtr pDamage = damageGetPixPriv(pPix) + +#define damageGetGCPriv(pGC) \ + dixLookupPrivate(&(pGC)->devPrivates, damageGCPrivateKey) + +#define damageGCPriv(pGC) \ + DamageGCPrivPtr pGCPriv = damageGetGCPriv(pGC) + +#define damageGetWinPriv(pWin) \ + ((DamagePtr)dixLookupPrivate(&(pWin)->devPrivates, damageWinPrivateKey)) + +#define damageSetWinPriv(pWin,d) \ + dixSetPrivate(&(pWin)->devPrivates, damageWinPrivateKey, d) static DamagePtr * getDrawableDamageRef (DrawablePtr pDrawable) @@ -115,8 +155,8 @@ getDrawableDamageRef (DrawablePtr pDrawable) #define windowDamage(pWin) drawableDamage(&(pWin)->drawable) #define winDamageRef(pWindow) \ - DamagePtr *pPrev = (DamagePtr *) \ - &(pWindow->devPrivates[damageWinPrivateIndex].ptr) + DamagePtr *pPrev = (DamagePtr *) \ + dixLookupPrivateAddr(&(pWindow)->devPrivates, damageWinPrivateKey) #if DAMAGE_DEBUG_ENABLE static void @@ -1652,27 +1692,8 @@ GCOps damageGCOps = { #ifdef NEED_LINEHELPER NULL, #endif - {NULL} /* devPrivate */ }; -static void -damageRestoreAreas (PixmapPtr pPixmap, - RegionPtr prgn, - int xorg, - int yorg, - WindowPtr pWindow) -{ - ScreenPtr pScreen = pWindow->drawable.pScreen; - damageScrPriv(pScreen); - - damageDamageRegion (&pWindow->drawable, prgn, FALSE, -1); - unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas); - (*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgn, - xorg, yorg, pWindow); - wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas, - damageRestoreAreas); -} - static void damageSetWindowPixmap (WindowPtr pWindow, PixmapPtr pPixmap) { @@ -1736,17 +1757,10 @@ damageCloseScreen (ScreenPtr pScreen) unwrap (pScrPriv, pScreen, PaintWindowBorder); unwrap (pScrPriv, pScreen, CopyWindow); unwrap (pScrPriv, pScreen, CloseScreen); - unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas); free (pScrPriv); return (*pScreen->CloseScreen) (pScreen); } -int damageScrPrivateIndex; -int damagePixPrivateIndex; -int damageGCPrivateIndex; -int damageWinPrivateIndex; -int damageGeneration; - Bool DamageSetup (ScreenPtr pScreen) { @@ -1755,30 +1769,20 @@ DamageSetup (ScreenPtr pScreen) PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); #endif - if (damageGeneration != serverGeneration) - { - damageScrPrivateIndex = AllocateScreenPrivateIndex (); - if (damageScrPrivateIndex == -1) - return FALSE; - damageGCPrivateIndex = AllocateGCPrivateIndex (); - if (damageGCPrivateIndex == -1) - return FALSE; - damagePixPrivateIndex = AllocatePixmapPrivateIndex (); - if (damagePixPrivateIndex == -1) - return FALSE; - damageWinPrivateIndex = AllocateWindowPrivateIndex (); - if (damageWinPrivateIndex == -1) - return FALSE; - damageGeneration = serverGeneration; - } - if (pScreen->devPrivates[damageScrPrivateIndex].ptr) + if (!dixRegisterPrivateKey(&damageScrPrivateKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + + if (dixLookupPrivate(&pScreen->devPrivates, damageScrPrivateKey)) return TRUE; - if (!AllocateGCPrivate (pScreen, damageGCPrivateIndex, sizeof (DamageGCPrivRec))) + if (!dixRegisterPrivateKey + (&damageGCPrivateKeyRec, PRIVATE_GC, sizeof(DamageGCPrivRec))) return FALSE; - if (!AllocatePixmapPrivate (pScreen, damagePixPrivateIndex, 0)) + + if (!dixRegisterPrivateKey(&damagePixPrivateKeyRec, PRIVATE_PIXMAP, 0)) return FALSE; - if (!AllocateWindowPrivate (pScreen, damageWinPrivateIndex, 0)) + + if (!dixRegisterPrivateKey(&damageWinPrivateKeyRec, PRIVATE_WINDOW, 0)) return FALSE; pScrPriv = (DamageScrPrivPtr) malloc (sizeof (DamageScrPrivRec)); @@ -1806,8 +1810,6 @@ DamageSetup (ScreenPtr pScreen) wrap (pScrPriv, pScreen, SetWindowPixmap, damageSetWindowPixmap); wrap (pScrPriv, pScreen, CopyWindow, damageCopyWindow); wrap (pScrPriv, pScreen, CloseScreen, damageCloseScreen); - wrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas, - damageRestoreAreas); #ifdef RENDER if (ps) { wrap (pScrPriv, ps, Glyphs, damageGlyphs); @@ -1815,7 +1817,7 @@ DamageSetup (ScreenPtr pScreen) } #endif - pScreen->devPrivates[damageScrPrivateIndex].ptr = (void *) pScrPriv; + dixSetPrivate(&pScreen->devPrivates, damageScrPrivateKey, pScrPriv); return TRUE; } diff --git a/nx-X11/programs/Xserver/miext/damage/damagestr.h b/nx-X11/programs/Xserver/miext/damage/damagestr.h index 5b671cd3fe..9f8dc421f7 100644 --- a/nx-X11/programs/Xserver/miext/damage/damagestr.h +++ b/nx-X11/programs/Xserver/miext/damage/damagestr.h @@ -31,6 +31,7 @@ #include "damage.h" #include "gcstruct.h" +#include "privates.h" #ifdef RENDER # include "picturestr.h" #endif @@ -71,7 +72,6 @@ typedef struct _damageScrPriv { CompositeProcPtr Composite; GlyphsProcPtr Glyphs; #endif - BSFuncRec BackingStoreFuncs; } DamageScrPrivRec, *DamageScrPrivPtr; typedef struct _damageGCPriv { @@ -79,36 +79,31 @@ typedef struct _damageGCPriv { GCFuncs *funcs; } DamageGCPrivRec, *DamageGCPrivPtr; -extern int damageScrPrivateIndex; -extern int damagePixPrivateIndex; -extern int damageGCPrivateIndex; -extern int damageWinPrivateIndex; - -#define damageGetScrPriv(pScr) \ - ((DamageScrPrivPtr) (pScr)->devPrivates[damageScrPrivateIndex].ptr) +#define damageGetScrPriv(pScr) ((DamageScrPrivPtr) \ + dixLookupPrivate(&(pScr)->devPrivates, damageScrPrivateKey)) #define damageScrPriv(pScr) \ DamageScrPrivPtr pScrPriv = damageGetScrPriv(pScr) #define damageGetPixPriv(pPix) \ - ((DamagePtr) (pPix)->devPrivates[damagePixPrivateIndex].ptr) + dixLookupPrivate(&(pPix)->devPrivates, damagePixPrivateKey) #define damgeSetPixPriv(pPix,v) \ - ((pPix)->devPrivates[damagePixPrivateIndex].ptr = (void * ) (v)) + dixSetPrivate(&(pPix)->devPrivates, damagePixPrivateKey, v) #define damagePixPriv(pPix) \ - DamagePtr pDamage = damageGetPixPriv(pPix) + DamagePtr pDamage = damageGetPixPriv(pPix) #define damageGetGCPriv(pGC) \ - ((DamageGCPrivPtr) (pGC)->devPrivates[damageGCPrivateIndex].ptr) + dixLookupPrivate(&(pGC)->devPrivates, damageGCPrivateKey) #define damageGCPriv(pGC) \ DamageGCPrivPtr pGCPriv = damageGetGCPriv(pGC) #define damageGetWinPriv(pWin) \ - ((DamagePtr) (pWin)->devPrivates[damageWinPrivateIndex].ptr) + ((DamagePtr)dixLookupPrivate(&(pWin)->devPrivates, damageWinPrivateKey)) #define damageSetWinPriv(pWin,d) \ - ((pWin)->devPrivates[damageWinPrivateIndex].ptr = (d)) + dixSetPrivate(&(pWin)->devPrivates, damageWinPrivateKey, d) #endif /* _DAMAGESTR_H_ */ diff --git a/nx-X11/programs/Xserver/os/utils.c b/nx-X11/programs/Xserver/os/utils.c index 0a1e3f7b26..5e9282eb46 100644 --- a/nx-X11/programs/Xserver/os/utils.c +++ b/nx-X11/programs/Xserver/os/utils.c @@ -625,7 +625,6 @@ void UseMsg(void) #ifdef XCSECURITY ErrorF("-sp file security policy file\n"); #endif - ErrorF("-su disable any save under support\n"); ErrorF("-t # mouse threshold (pixels)\n"); ErrorF("-terminate terminate at server reset\n"); ErrorF("-to # connection time out\n"); @@ -968,8 +967,6 @@ ProcessCommandLine(int argc, char *argv[]) else UseMsg(); } - else if ( strcmp( argv[i], "-su") == 0) - disableSaveUnders = TRUE; else if ( strcmp( argv[i], "-t") == 0) { if(++i < argc) diff --git a/nx-X11/programs/Xserver/randr/randr.c b/nx-X11/programs/Xserver/randr/randr.c index c742cf6e05..53d8a7b1fe 100644 --- a/nx-X11/programs/Xserver/randr/randr.c +++ b/nx-X11/programs/Xserver/randr/randr.c @@ -83,14 +83,9 @@ static int SProcRRDispatch(ClientPtr pClient); int RREventBase; int RRErrorBase; RESTYPE RRClientType, RREventType; /* resource types for event masks */ +DevPrivateKeyRec RRClientPrivateKeyRec; -#ifndef NXAGENT_SERVER -DevPrivateKey RRClientPrivateKey = &RRClientPrivateKey; -DevPrivateKey rrPrivKey = &rrPrivKey; -#else -int RRClientPrivateIndex; -int rrPrivIndex = -1; -#endif +DevPrivateKeyRec rrPrivKeyRec; static void RRClientCallback(CallbackListPtr *list, void *closure, void *data) @@ -294,10 +289,6 @@ Bool RRInit(void) { if (RRGeneration != serverGeneration) { -#ifdef NXAGENT_SERVER - if ((rrPrivIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; -#endif if (!RRModeInit()) return FALSE; if (!RRCrtcInit()) @@ -308,10 +299,8 @@ RRInit(void) return FALSE; RRGeneration = serverGeneration; } -#ifndef NXAGENT_SERVER if (!dixRegisterPrivateKey(&rrPrivKeyRec, PRIVATE_SCREEN, 0)) return FALSE; -#endif /* !defined(NXAGENT_SERVER) */ return TRUE; } @@ -435,18 +424,10 @@ RRExtensionInit(void) if (RRNScreens == 0) return; -#ifndef NXAGENT_SERVER if (!dixRegisterPrivateKey(&RRClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(RRClientRec) + screenInfo.numScreens * sizeof(RRTimesRec))) return; -#else /* !defined(NXAGENT_SERVER) */ - RRClientPrivateIndex = AllocateClientPrivateIndex(); - if (!AllocateClientPrivate(RRClientPrivateIndex, - sizeof(RRClientRec) + - screenInfo.numScreens * sizeof(RRTimesRec))) - return; -#endif /* !defined(NXAGENT_SERVER) */ if (!AddCallback(&ClientStateCallback, RRClientCallback, 0)) return; diff --git a/nx-X11/programs/Xserver/randr/randrstr.h b/nx-X11/programs/Xserver/randr/randrstr.h index 4b497f82dc..b99a1e5684 100644 --- a/nx-X11/programs/Xserver/randr/randrstr.h +++ b/nx-X11/programs/Xserver/randr/randrstr.h @@ -366,29 +366,14 @@ typedef struct _rrScrPriv { } rrScrPrivRec, *rrScrPrivPtr; -#ifndef NXAGENT_SERVER extern _X_EXPORT DevPrivateKeyRec rrPrivKeyRec; #define rrPrivKey (&rrPrivKeyRec) -extern DevPrivateKey rrPrivKey; -#else -extern int rrPrivIndex; -#endif - -#ifndef NXAGENT_SERVER #define rrGetScrPriv(pScr) ((rrScrPrivPtr)dixLookupPrivate(&(pScr)->devPrivates, rrPrivKey)) #define rrScrPriv(pScr) rrScrPrivPtr pScrPriv = rrGetScrPriv(pScr) #define SetRRScreen(s,p) dixSetPrivate(&(s)->devPrivates, rrPrivKey, p) -#else /* !defined(NXAGENT_SERVER) */ - -#define rrGetScrPriv(pScr) ((rrScrPrivPtr) (pScr)->devPrivates[rrPrivIndex].ptr) -#define rrScrPriv(pScr) rrScrPrivPtr pScrPriv = rrGetScrPriv(pScr) -#define SetRRScreen(s,p) ((s)->devPrivates[rrPrivIndex].ptr = (void *) (p)) - -#endif /* !defined(NXAGENT_SERVER) */ - /* * each window has a list of clients requesting * RRNotify events. Each client has a resource @@ -419,13 +404,9 @@ typedef struct _RRClient { } RRClientRec, *RRClientPtr; extern RESTYPE RRClientType, RREventType; /* resource types for event masks */ +extern DevPrivateKeyRec RRClientPrivateKeyRec; -#ifndef NXAGENT_SERVER -extern DevPrivateKey RRClientPrivateKey; -#else -extern int RRClientPrivateIndex; -#endif - +#define RRClientPrivateKey (&RRClientPrivateKeyRec) extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType, RRProviderType; #ifdef NXAGENT_SERVER @@ -448,16 +429,7 @@ extern _X_EXPORT RESTYPE RRCrtcType, RRModeType, RROutputType, RRProviderType; #endif -#ifndef NXAGENT_SERVER - -#define RRClientPrivateKey (&RRClientPrivateKeyRec) #define GetRRClient(pClient) ((RRClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RRClientPrivateKey)) - -#else /* !defined/NXAGENT_SERVER) */ - -#define GetRRClient(pClient) ((RRClientPtr) (pClient)->devPrivates[RRClientPrivateIndex].ptr) - -#endif /* !defined(NXAGENT_SERVER) */ #define rrClientPriv(pClient) RRClientPtr pRRClient = GetRRClient(pClient) /* Initialize the extension */ diff --git a/nx-X11/programs/Xserver/record/record.c b/nx-X11/programs/Xserver/record/record.c index c18b96e469..00816385e7 100644 --- a/nx-X11/programs/Xserver/record/record.c +++ b/nx-X11/programs/Xserver/record/record.c @@ -166,13 +166,15 @@ typedef struct { ProcFunctionPtr recordVector[256]; } RecordClientPrivateRec, *RecordClientPrivatePtr; -static int RecordClientPrivateIndex; +static DevPrivateKeyRec RecordClientPrivateKeyRec; + +#define RecordClientPrivateKey (&RecordClientPrivateKeyRec) /* RecordClientPrivatePtr RecordClientPrivate(ClientPtr) * gets the client private of the given client. Syntactic sugar. */ #define RecordClientPrivate(_pClient) (RecordClientPrivatePtr) \ - ((_pClient)->devPrivates[RecordClientPrivateIndex].ptr) + dixLookupPrivate(&(_pClient)->devPrivates, RecordClientPrivateKey) /***************************************************************************/ @@ -984,8 +986,8 @@ RecordInstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient) memcpy(pClientPriv->recordVector, pClient->requestVector, sizeof (pClientPriv->recordVector)); pClientPriv->originalVector = pClient->requestVector; - pClient->devPrivates[RecordClientPrivateIndex].ptr = - (void *)pClientPriv; + dixSetPrivate(&pClient->devPrivates, + RecordClientPrivateKey, pClientPriv); pClient->requestVector = pClientPriv->recordVector; } while ((pIter = RecordIterateSet(pRCAP->pRequestMajorOpSet, @@ -1098,7 +1100,8 @@ RecordUninstallHooks(RecordClientsAndProtocolPtr pRCAP, XID oneclient) if (!otherRCAPwantsProcVector) { /* nobody needs it, so free it */ pClient->requestVector = pClientPriv->originalVector; - pClient->devPrivates[RecordClientPrivateIndex].ptr = NULL; + dixSetPrivate(&pClient->devPrivates, + RecordClientPrivateKey, NULL); free(pClientPriv); } } /* end if this RCAP specifies any requests */ @@ -2949,8 +2952,7 @@ RecordExtensionInit(void) if (!RTContext) return; - RecordClientPrivateIndex = AllocateClientPrivateIndex(); - if (!AllocateClientPrivate(RecordClientPrivateIndex, 0)) + if (!dixRegisterPrivateKey(RecordClientPrivateKey, PRIVATE_CLIENT, 0)) return; ppAllContexts = NULL; diff --git a/nx-X11/programs/Xserver/render/animcur.c b/nx-X11/programs/Xserver/render/animcur.c index 7336cdeff4..6e45fb18c4 100644 --- a/nx-X11/programs/Xserver/render/animcur.c +++ b/nx-X11/programs/Xserver/render/animcur.c @@ -86,14 +86,15 @@ static CursorBits animCursorBits = { empty, empty, 2, 1, 1, 0, 0, 1 }; -int AnimCurScreenPrivateIndex = -1; -int AnimCurGeneration; -#define IsAnimCur(c) ((c)->bits == &animCursorBits) -#define GetAnimCur(c) ((AnimCurPtr) ((c) + 1)) -#define GetAnimCurScreen(s) ((AnimCurScreenPtr) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr)) -#define GetAnimCurScreenIfSet(s) ((AnimCurScreenPrivateIndex != -1) ? GetAnimCurScreen(s) : NULL) -#define SetAnimCurScreen(s,p) ((s)->devPrivates[AnimCurScreenPrivateIndex].ptr = (void *) (p)) +DevPrivateKeyRec AnimCurScreenPrivateKeyRec; + +#define AnimCurScreenPrivateKey (&AnimCurScreenPrivateKeyRec) + +#define IsAnimCur(c) ((c) && (c)->bits == &animCursorBits) +#define GetAnimCur(c) ((AnimCurPtr) ((((char *)(c) + CURSOR_REC_SIZE)))) +#define GetAnimCurScreen(s) ((AnimCurScreenPtr)dixLookupPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey)) +#define SetAnimCurScreen(s,p) dixSetPrivate(&(s)->devPrivates, AnimCurScreenPrivateKey, p) #define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func) #define Unwrap(as,s,elt) ((s)->elt = (as)->elt) @@ -127,8 +128,6 @@ AnimCurCloseScreen (ScreenPtr pScreen) SetAnimCurScreen(pScreen,0); ret = (*pScreen->CloseScreen) (pScreen); free (as); - if (screenInfo.numScreens <= 1) - AnimCurScreenPrivateIndex = -1; return ret; } @@ -321,17 +320,9 @@ AnimCurInit (ScreenPtr pScreen) { AnimCurScreenPtr as; - if (AnimCurGeneration != serverGeneration) - { - AnimCurScreenPrivateIndex = AllocateScreenPrivateIndex (); - if (AnimCurScreenPrivateIndex < 0) - return FALSE; - AnimCurGeneration = serverGeneration; - animCurState.pCursor = 0; - animCurState.pScreen = 0; - animCurState.elt = 0; - animCurState.time = 0; - } + if (!dixRegisterPrivateKey(&AnimCurScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + as = (AnimCurScreenPtr) malloc (sizeof (AnimCurScreenRec)); if (!as) return FALSE; @@ -357,18 +348,19 @@ AnimCursorCreate (CursorPtr *cursors, CARD32 *deltas, int ncursor, CursorPtr *pp AnimCurPtr ac; for (i = 0; i < screenInfo.numScreens; i++) - if (!GetAnimCurScreenIfSet (screenInfo.screens[i])) + if (!GetAnimCurScreen (screenInfo.screens[i])) return BadImplementation; for (i = 0; i < ncursor; i++) if (IsAnimCur (cursors[i])) return BadMatch; - pCursor = (CursorPtr) malloc (sizeof (CursorRec) + - sizeof (AnimCurRec) + - ncursor * sizeof (AnimCurElt)); + pCursor = (CursorPtr) calloc(CURSOR_REC_SIZE + + sizeof(AnimCurRec) + + ncursor * sizeof(AnimCurElt), 1); if (!pCursor) return BadAlloc; + dixInitPrivates(pCursor, pCursor + 1, PRIVATE_CURSOR); pCursor->bits = &animCursorBits; animCursorBits.refcnt++; pCursor->refcnt = 1; diff --git a/nx-X11/programs/Xserver/render/glyph.c b/nx-X11/programs/Xserver/render/glyph.c index 9c9a485eac..c57a23a522 100644 --- a/nx-X11/programs/Xserver/render/glyph.c +++ b/nx-X11/programs/Xserver/render/glyph.c @@ -94,50 +94,6 @@ FindGlyphHashSet (CARD32 filled) return 0; } -static int _GlyphSetPrivateAllocateIndex = 0; - -int -AllocateGlyphSetPrivateIndex (void) -{ - return _GlyphSetPrivateAllocateIndex++; -} - -void -ResetGlyphSetPrivateIndex (void) -{ - _GlyphSetPrivateAllocateIndex = 0; -} - -Bool -_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr) -{ - void **new; - - if (n > glyphSet->maxPrivate) { - if (glyphSet->devPrivates && - glyphSet->devPrivates != (void *)(&glyphSet[1])) { - new = (void **) realloc (glyphSet->devPrivates, - (n + 1) * sizeof (void *)); - if (!new) - return FALSE; - } else { - new = (void **) malloc ((n + 1) * sizeof (void *)); - if (!new) - return FALSE; - if (glyphSet->devPrivates) - memcpy (new, - glyphSet->devPrivates, - (glyphSet->maxPrivate + 1) * sizeof (void *)); - } - glyphSet->devPrivates = new; - /* Zero out new, uninitialize privates */ - while (++glyphSet->maxPrivate < n) - glyphSet->devPrivates[glyphSet->maxPrivate] = (void *)0; - } - glyphSet->devPrivates[n] = ptr; - return TRUE; -} - Bool GlyphInit (ScreenPtr pScreen) { @@ -263,7 +219,7 @@ FreeGlyph (GlyphPtr glyph, int format) gr->signature = 0; globalGlyphs[format].tableEntries--; } - free (glyph); + dixFreeObjectWithPrivates(glyph, PRIVATE_GLYPH); } } @@ -280,7 +236,7 @@ AddGlyph (GlyphSetPtr glyphSet, GlyphPtr glyph, Glyph id) gr = FindGlyphRef (&globalGlyphs[glyphSet->fdepth], hash, TRUE, glyph); if (gr->glyph && gr->glyph != DeletedGlyph) { - free (glyph); + dixFreeObjectWithPrivates(glyph, PRIVATE_GLYPH); glyph = gr->glyph; } else @@ -339,18 +295,21 @@ AllocateGlyph (xGlyphInfo *gi, int fdepth) { int size; GlyphPtr glyph; - size_t padded_width; + size_t padded_width; padded_width = PixmapBytePad (gi->width, glyphDepths[fdepth]); if (gi->height && padded_width > (UINT32_MAX - sizeof(GlyphRec))/gi->height) return 0; - size = gi->height * padded_width; - glyph = (GlyphPtr) malloc (size + sizeof (GlyphRec)); + size = gi->height * padded_width + dixPrivatesSize(PRIVATE_GLYPH); + glyph = (GlyphPtr) malloc (size); if (!glyph) return 0; glyph->refcnt = 0; glyph->size = size + sizeof (xGlyphInfo); glyph->info = *gi; + + dixInitPrivates(glyph, (char *) glyph + gi->height * padded_width, PRIVATE_GLYPH); + return glyph; } @@ -423,7 +382,6 @@ GlyphSetPtr AllocateGlyphSet (int fdepth, PictFormatPtr format) { GlyphSetPtr glyphSet; - int size; if (!globalGlyphs[fdepth].hashSet) { @@ -431,15 +389,9 @@ AllocateGlyphSet (int fdepth, PictFormatPtr format) return FALSE; } - size = (sizeof (GlyphSetRec) + - (sizeof (void *) * _GlyphSetPrivateAllocateIndex)); - glyphSet = malloc (size); + glyphSet = dixAllocateObjectWithPrivates(GlyphSetRec, PRIVATE_GLYPHSET); if (!glyphSet) return FALSE; - bzero((char *)glyphSet, size); - glyphSet->maxPrivate = _GlyphSetPrivateAllocateIndex - 1; - if (_GlyphSetPrivateAllocateIndex) - glyphSet->devPrivates = (void *)(&glyphSet[1]); if (!AllocateGlyphHash (&glyphSet->hash, &glyphHashSets[0])) { diff --git a/nx-X11/programs/Xserver/render/glyphstr.h b/nx-X11/programs/Xserver/render/glyphstr.h index 5c4ed4933b..b4e4784634 100644 --- a/nx-X11/programs/Xserver/render/glyphstr.h +++ b/nx-X11/programs/Xserver/render/glyphstr.h @@ -37,6 +37,7 @@ typedef struct _Glyph { CARD32 refcnt; + PrivateRec *devPrivates; CARD32 size; /* info + bitmap */ xGlyphInfo info; /* bits follow */ @@ -74,19 +75,15 @@ typedef struct _GlyphSet { int fdepth; GlyphHashRec hash; int maxPrivate; - void **devPrivates; + PrivateRec *devPrivates; } GlyphSetRec, *GlyphSetPtr; #endif /* NXAGENT_SERVER */ -#define GlyphSetGetPrivate(pGlyphSet,n) \ - ((n) > (pGlyphSet)->maxPrivate ? \ - (void *) 0 : \ - (pGlyphSet)->devPrivates[n]) +#define GlyphSetGetPrivate(pGlyphSet,k) \ + dixLookupPrivate(&(pGlyphSet)->devPrivates, k) -#define GlyphSetSetPrivate(pGlyphSet,n,ptr) \ - ((n) > (pGlyphSet)->maxPrivate ? \ - _GlyphSetSetNewPrivate(pGlyphSet, n, ptr) : \ - ((((pGlyphSet)->devPrivates[n] = (ptr)) != 0) || TRUE)) +#define GlyphSetSetPrivate(pGlyphSet,k,ptr) \ + dixSetPrivate(&(pGlyphSet)->devPrivates, k, ptr) typedef struct _GlyphList { INT16 xOff; @@ -106,9 +103,6 @@ AllocateGlyphSetPrivateIndex (void); void ResetGlyphSetPrivateIndex (void); -Bool -_GlyphSetSetNewPrivate (GlyphSetPtr glyphSet, int n, void * ptr); - Bool GlyphInit (ScreenPtr pScreen); diff --git a/nx-X11/programs/Xserver/render/picture.c b/nx-X11/programs/Xserver/render/picture.c index eba0429030..776ab79eae 100644 --- a/nx-X11/programs/Xserver/render/picture.c +++ b/nx-X11/programs/Xserver/render/picture.c @@ -43,65 +43,22 @@ #include "picturestr.h" #endif -int PictureScreenPrivateIndex = -1; -int PictureWindowPrivateIndex; -int PictureGeneration; +DevPrivateKeyRec PictureScreenPrivateKeyRec; +DevPrivateKeyRec PictureWindowPrivateKeyRec; +static int PictureGeneration; RESTYPE PictureType; RESTYPE PictFormatType; RESTYPE GlyphSetType; int PictureCmapPolicy = PictureCmapPolicyDefault; -/* Picture Private machinery */ - -static int picturePrivateCount; - -void -ResetPicturePrivateIndex (void) -{ - picturePrivateCount = 0; -} - -int -AllocatePicturePrivateIndex (void) +PictFormatPtr +PictureWindowFormat(WindowPtr pWindow) { - return picturePrivateCount++; + ScreenPtr pScreen = pWindow->drawable.pScreen; + return PictureMatchVisual(pScreen, pWindow->drawable.depth, + WindowGetVisual(pWindow)); } -Bool -AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount) -{ - PictureScreenPtr ps = GetPictureScreen(pScreen); - unsigned int oldamount; - - /* Round up sizes for proper alignment */ - amount = ((amount + (sizeof(long) - 1)) / sizeof(long)) * sizeof(long); - - if (index2 >= ps->PicturePrivateLen) - { - unsigned int *nsizes; - - nsizes = (unsigned int *)realloc(ps->PicturePrivateSizes, - (index2 + 1) * sizeof(unsigned int)); - if (!nsizes) - return FALSE; - while (ps->PicturePrivateLen <= index2) - { - nsizes[ps->PicturePrivateLen++] = 0; - ps->totalPictureSize += sizeof(DevUnion); - } - ps->PicturePrivateSizes = nsizes; - } - oldamount = ps->PicturePrivateSizes[index2]; - if (amount > oldamount) - { - ps->PicturePrivateSizes[index2] = amount; - ps->totalPictureSize += (amount - oldamount); - } - - return TRUE; -} - - Bool PictureDestroyWindow (WindowPtr pWindow) { @@ -138,8 +95,6 @@ PictureCloseScreen (ScreenPtr pScreen) if (ps->formats[n].type == PictTypeIndexed) (*ps->CloseIndexed) (pScreen, &ps->formats[n]); SetPictureScreen(pScreen, 0); - if (ps->PicturePrivateSizes) - free (ps->PicturePrivateSizes); free (ps->formats); free (ps); return ret; @@ -634,10 +589,6 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) GlyphSetType = CreateNewResourceType (FreeGlyphSet); if (!GlyphSetType) return FALSE; - PictureScreenPrivateIndex = AllocateScreenPrivateIndex(); - if (PictureScreenPrivateIndex < 0) - return FALSE; - PictureWindowPrivateIndex = AllocateWindowPrivateIndex(); PictureGeneration = serverGeneration; #ifdef XResExtension RegisterResourceName (PictureType, "PICTURE"); @@ -645,9 +596,12 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) RegisterResourceName (GlyphSetType, "GLYPHSET"); #endif } - if (!AllocateWindowPrivate (pScreen, PictureWindowPrivateIndex, 0)) + if (!dixRegisterPrivateKey(&PictureScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) return FALSE; - + + if (!dixRegisterPrivateKey(&PictureWindowPrivateKeyRec, PRIVATE_WINDOW, 0)) + return FALSE; + if (!formats) { formats = PictureCreateDefaultFormats (pScreen, &nformats); @@ -703,8 +657,6 @@ PictureInit (ScreenPtr pScreen, PictFormatPtr formats, int nformats) } ps->totalPictureSize = sizeof (PictureRec); - ps->PicturePrivateSizes = 0; - ps->PicturePrivateLen = 0; ps->formats = formats; ps->fallback = formats; @@ -771,37 +723,6 @@ SetPictureToDefaults (PicturePtr pPicture) } #ifndef NXAGENT_SERVER -PicturePtr -AllocatePicture (ScreenPtr pScreen) -{ - PictureScreenPtr ps = GetPictureScreen(pScreen); - PicturePtr pPicture; - char *ptr; - DevUnion *ppriv; - unsigned int *sizes; - unsigned int size; - int i; - - pPicture = (PicturePtr) malloc (ps->totalPictureSize); - if (!pPicture) - return 0; - ppriv = (DevUnion *)(pPicture + 1); - pPicture->devPrivates = ppriv; - sizes = ps->PicturePrivateSizes; - ptr = (char *)(ppriv + ps->PicturePrivateLen); - for (i = ps->PicturePrivateLen; --i >= 0; ppriv++, sizes++) - { - if ( (size = *sizes) ) - { - ppriv->ptr = (void *)ptr; - ptr += size; - } - else - ppriv->ptr = (void *)NULL; - } - return pPicture; -} - PicturePtr CreatePicture (Picture pid, DrawablePtr pDrawable, @@ -814,7 +735,8 @@ CreatePicture (Picture pid, PicturePtr pPicture; PictureScreenPtr ps = GetPictureScreen(pDrawable->pScreen); - pPicture = AllocatePicture (pDrawable->pScreen); + pPicture = dixAllocateScreenObjectWithPrivates(pDrawable->pScreen, + PictureRec, PRIVATE_PICTURE); if (!pPicture) { *error = BadAlloc; @@ -978,7 +900,11 @@ static void initGradient(SourcePictPtr pGradient, int stopCount, static PicturePtr createSourcePicture(void) { PicturePtr pPicture; - pPicture = (PicturePtr) malloc(sizeof(PictureRec)); + pPicture = dixAllocateScreenObjectWithPrivates(NULL, PictureRec, + PRIVATE_PICTURE); + if (!pPicture) + return 0; + pPicture->pDrawable = 0; pPicture->pFormat = 0; pPicture->pNext = 0; @@ -1630,9 +1556,9 @@ FreePicture (void * value, WindowPtr pWindow = (WindowPtr) pPicture->pDrawable; PicturePtr *pPrev; - for (pPrev = (PicturePtr *) &((pWindow)->devPrivates[PictureWindowPrivateIndex].ptr); - *pPrev; - pPrev = &(*pPrev)->pNext) + for (pPrev = (PicturePtr *) dixLookupPrivateAddr + (&pWindow->devPrivates, PictureWindowPrivateKey); + *pPrev; pPrev = &(*pPrev)->pNext) { if (*pPrev == pPicture) { @@ -1646,7 +1572,7 @@ FreePicture (void * value, (*pScreen->DestroyPixmap) ((PixmapPtr)pPicture->pDrawable); } } - free (pPicture); + dixFreeObjectWithPrivates(pPicture, PRIVATE_PICTURE); } return Success; } diff --git a/nx-X11/programs/Xserver/render/picture.h b/nx-X11/programs/Xserver/render/picture.h index 518e9fbb02..c5f32e2f5b 100644 --- a/nx-X11/programs/Xserver/render/picture.h +++ b/nx-X11/programs/Xserver/render/picture.h @@ -25,6 +25,8 @@ #ifndef _PICTURE_H_ #define _PICTURE_H_ +#include "privates.h" + typedef struct _DirectFormat *DirectFormatPtr; typedef struct _PictFormat *PictFormatPtr; typedef struct _Picture *PicturePtr; @@ -169,7 +171,6 @@ extern int PictureCmapPolicy; int PictureParseCmapPolicy (const char *name); extern int RenderErrBase; -extern int RenderClientPrivateIndex; /* Fixed point updates from Carl Worth, USC, Information Sciences Institute */ diff --git a/nx-X11/programs/Xserver/render/picturestr.h b/nx-X11/programs/Xserver/render/picturestr.h index f5c367bb42..85559c40fb 100644 --- a/nx-X11/programs/Xserver/render/picturestr.h +++ b/nx-X11/programs/Xserver/render/picturestr.h @@ -159,7 +159,7 @@ typedef struct _Picture { RegionPtr pCompositeClip; - DevUnion *devPrivates; + PrivateRec *devPrivates; PictTransform *transform; @@ -366,20 +366,23 @@ typedef struct _PictureScreen { AddTrianglesProcPtr AddTriangles; AddTrapsProcPtr AddTraps; - } PictureScreenRec, *PictureScreenPtr; -extern int PictureScreenPrivateIndex; -extern int PictureWindowPrivateIndex; +extern DevPrivateKeyRec PictureScreenPrivateKeyRec; +#define PictureScreenPrivateKey (&PictureScreenPrivateKeyRec) + +extern DevPrivateKeyRec PictureWindowPrivateKeyRec; +#define PictureWindowPrivateKey (&PictureWindowPrivateKeyRec) + extern RESTYPE PictureType; extern RESTYPE PictFormatType; extern RESTYPE GlyphSetType; -#define GetPictureScreen(s) ((PictureScreenPtr) ((s)->devPrivates[PictureScreenPrivateIndex].ptr)) -#define GetPictureScreenIfSet(s) ((PictureScreenPrivateIndex != -1) ? GetPictureScreen(s) : NULL) -#define SetPictureScreen(s,p) ((s)->devPrivates[PictureScreenPrivateIndex].ptr = (void *) (p)) -#define GetPictureWindow(w) ((PicturePtr) ((w)->devPrivates[PictureWindowPrivateIndex].ptr)) -#define SetPictureWindow(w,p) ((w)->devPrivates[PictureWindowPrivateIndex].ptr = (void *) (p)) +#define GetPictureScreen(s) ((PictureScreenPtr)dixLookupPrivate(&(s)->devPrivates, PictureScreenPrivateKey)) +#define GetPictureScreenIfSet(s) (dixPrivateKeyRegistered(PictureScreenPrivateKey) ? GetPictureScreen(s) : NULL) +#define SetPictureScreen(s,p) dixSetPrivate(&(s)->devPrivates, PictureScreenPrivateKey, p) +#define GetPictureWindow(w) ((PicturePtr)dixLookupPrivate(&(w)->devPrivates, PictureWindowPrivateKey)) +#define SetPictureWindow(w,p) dixSetPrivate(&(w)->devPrivates, PictureWindowPrivateKey, p) #define VERIFY_PICTURE(pPicture, pid, client, mode, err) {\ pPicture = SecurityLookupIDByType(client, pid, PictureType, mode);\ @@ -397,15 +400,6 @@ extern RESTYPE GlyphSetType; } \ } \ -void -ResetPicturePrivateIndex (void); - -int -AllocatePicturePrivateIndex (void); - -Bool -AllocatePicturePrivate (ScreenPtr pScreen, int index2, unsigned int amount); - Bool PictureDestroyWindow (WindowPtr pWindow); @@ -418,6 +412,9 @@ PictureStoreColors (ColormapPtr pColormap, int ndef, xColorItem *pdef); Bool PictureInitIndexedFormats (ScreenPtr pScreen); +PictFormatPtr +PictureWindowFormat(WindowPtr pWindow); + Bool PictureSetSubpixelOrder (ScreenPtr pScreen, int subpixel); diff --git a/nx-X11/programs/Xserver/render/render.c b/nx-X11/programs/Xserver/render/render.c index 3c1cbe53c3..1760a9ba6a 100644 --- a/nx-X11/programs/Xserver/render/render.c +++ b/nx-X11/programs/Xserver/render/render.c @@ -206,21 +206,20 @@ int (*SProcRenderVector[RenderNumberRequests])(ClientPtr) = { SProcRenderCreateConicalGradient }; -static void -RenderResetProc (ExtensionEntry *extEntry); - #if 0 static CARD8 RenderReqCode; #endif int RenderErrBase; -int RenderClientPrivateIndex; +static DevPrivateKeyRec RenderClientPrivateKeyRec; + +#define RenderClientPrivateKey (&RenderClientPrivateKeyRec) typedef struct _RenderClient { int major_version; int minor_version; } RenderClientRec, *RenderClientPtr; -#define GetRenderClient(pClient) ((RenderClientPtr) (pClient)->devPrivates[RenderClientPrivateIndex].ptr) +#define GetRenderClient(pClient) ((RenderClientPtr)dixLookupPrivate(&(pClient)->devPrivates, RenderClientPrivateKey)) static void RenderClientCallback (CallbackListPtr *list, @@ -244,16 +243,15 @@ RenderExtensionInit (void) return; if (!PictureFinishInit ()) return; - RenderClientPrivateIndex = AllocateClientPrivateIndex (); - if (!AllocateClientPrivate (RenderClientPrivateIndex, - sizeof (RenderClientRec))) + if (!dixRegisterPrivateKey + (&RenderClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(RenderClientRec))) return; if (!AddCallback (&ClientStateCallback, RenderClientCallback, 0)) return; extEntry = AddExtension (RENDER_NAME, 0, RenderNumberErrors, ProcRenderDispatch, SProcRenderDispatch, - RenderResetProc, StandardMinorOpcode); + NULL, StandardMinorOpcode); if (!extEntry) return; #if 0 @@ -262,13 +260,6 @@ RenderExtensionInit (void) RenderErrBase = extEntry->errorBase; } -static void -RenderResetProc (ExtensionEntry *extEntry) -{ - ResetPicturePrivateIndex(); - ResetGlyphSetPrivateIndex(); -} - #ifndef NXAGENT_SERVER static int ProcRenderQueryVersion (ClientPtr client) @@ -680,7 +671,7 @@ ProcRenderChangePicture (ClientPtr client) return BadLength; return ChangePicture (pPicture, stuff->mask, (XID *) (stuff + 1), - (DevUnion *) 0, client); + (PrivateRec *) 0, client); } static int diff --git a/nx-X11/programs/Xserver/xfixes/cursor.c b/nx-X11/programs/Xserver/xfixes/cursor.c index 152bda5006..cd5ed3001f 100644 --- a/nx-X11/programs/Xserver/xfixes/cursor.c +++ b/nx-X11/programs/Xserver/xfixes/cursor.c @@ -55,13 +55,15 @@ static RESTYPE CursorClientType; static RESTYPE CursorHideCountType; static RESTYPE CursorWindowType; -static int CursorScreenPrivateIndex = -1; -static int CursorGeneration; static CursorPtr CursorCurrent; static CursorPtr pInvisibleCursor = NULL; static void deleteCursorHideCountsForScreen (ScreenPtr pScreen); +static DevPrivateKeyRec CursorScreenPrivateKeyRec; + +#define CursorScreenPrivateKey (&CursorScreenPrivateKeyRec) + #define VERIFY_CURSOR(pCursor, cursor, client, access) { \ pCursor = (CursorPtr)SecurityLookupIDByType((client), (cursor), \ RT_CURSOR, (access)); \ @@ -113,9 +115,9 @@ typedef struct _CursorScreen { CursorHideCountPtr pCursorHideCounts; } CursorScreenRec, *CursorScreenPtr; -#define GetCursorScreen(s) ((CursorScreenPtr) ((s)->devPrivates[CursorScreenPrivateIndex].ptr)) -#define GetCursorScreenIfSet(s) ((CursorScreenPrivateIndex != -1) ? GetCursorScreen(s) : NULL) -#define SetCursorScreen(s,p) ((s)->devPrivates[CursorScreenPrivateIndex].ptr = (void *) (p)) +#define GetCursorScreen(s) ((CursorScreenPtr)dixLookupPrivate(&(s)->devPrivates, CursorScreenPrivateKey)) +#define GetCursorScreenIfSet(s) GetCursorScreen(s) +#define SetCursorScreen(s,p) dixSetPrivate(&(s)->devPrivates, CursorScreenPrivateKey, p) #define Wrap(as,s,elt,func) (((as)->elt = (s)->elt), (s)->elt = func) #define Unwrap(as,s,elt) ((s)->elt = (as)->elt) @@ -169,8 +171,6 @@ CursorCloseScreen (ScreenPtr pScreen) deleteCursorHideCountsForScreen(pScreen); ret = (*pScreen->CloseScreen) (pScreen); free (cs); - if (screenInfo.numScreens <= 1) - CursorScreenPrivateIndex = -1; return ret; } @@ -1002,13 +1002,9 @@ XFixesCursorInit (void) { int i; - if (CursorGeneration != serverGeneration) - { - CursorScreenPrivateIndex = AllocateScreenPrivateIndex (); - if (CursorScreenPrivateIndex < 0) - return FALSE; - CursorGeneration = serverGeneration; - } + if (!dixRegisterPrivateKey(&CursorScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) + return FALSE; + for (i = 0; i < screenInfo.numScreens; i++) { ScreenPtr pScreen = screenInfo.screens[i]; diff --git a/nx-X11/programs/Xserver/xfixes/xfixes.c b/nx-X11/programs/Xserver/xfixes/xfixes.c index fadaf73b2f..6a42766d3b 100644 --- a/nx-X11/programs/Xserver/xfixes/xfixes.c +++ b/nx-X11/programs/Xserver/xfixes/xfixes.c @@ -47,10 +47,13 @@ #include "xfixesint.h" #include "protocol-versions.h" -static unsigned char XFixesReqCode; +unsigned char XFixesReqCode; int XFixesEventBase; int XFixesErrorBase; -static int XFixesClientPrivateIndex; + +DevPrivateKeyRec XFixesClientPrivateKeyRec; + +#define XFixesClientPrivateKey (&XFixesClientPrivateKeyRec) static int ProcXFixesQueryVersion(ClientPtr client) @@ -232,10 +235,10 @@ XFixesExtensionInit(void) { ExtensionEntry *extEntry; - XFixesClientPrivateIndex = AllocateClientPrivateIndex (); - if (!AllocateClientPrivate (XFixesClientPrivateIndex, - sizeof (XFixesClientRec))) + if (!dixRegisterPrivateKey + (&XFixesClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XFixesClientRec))) return; + if (!AddCallback (&ClientStateCallback, XFixesClientCallback, 0)) return; diff --git a/nx-X11/programs/Xserver/xfixes/xfixesint.h b/nx-X11/programs/Xserver/xfixes/xfixesint.h index 6dc5d39c52..ed980e2ee0 100644 --- a/nx-X11/programs/Xserver/xfixes/xfixesint.h +++ b/nx-X11/programs/Xserver/xfixes/xfixesint.h @@ -58,14 +58,16 @@ #include "selection.h" #include "xfixes.h" -extern int XFixesEventBase; +extern unsigned char XFixesReqCode; +extern int XFixesEventBase; +extern DevPrivateKeyRec XFixesClientPrivateKeyRec; typedef struct _XFixesClient { CARD32 major_version; CARD32 minor_version; } XFixesClientRec, *XFixesClientPtr; -#define GetXFixesClient(pClient) ((XFixesClientPtr) (pClient)->devPrivates[XFixesClientPrivateIndex].ptr) +#define GetXFixesClient(pClient) ((XFixesClientPtr)dixLookupPrivate(&(pClient)->devPrivates, XFixesClientPrivateKey)) extern int (*ProcXFixesVector[XFixesNumberRequests])(ClientPtr); diff --git a/nx-X11/programs/Xserver/xkb/ddxFakeMtn.c b/nx-X11/programs/Xserver/xkb/ddxFakeMtn.c index 854a7b72f2..491e3d07bc 100644 --- a/nx-X11/programs/Xserver/xkb/ddxFakeMtn.c +++ b/nx-X11/programs/Xserver/xkb/ddxFakeMtn.c @@ -106,7 +106,7 @@ ScreenPtr pScreen, oldScreen; oldY= y; else oldY+= y; -#define GetScreenPrivate(s) ((miPointerScreenPtr) ((s)->devPrivates[miPointerScreenIndex].ptr)) +#define GetScreenPrivate(s) ((miPointerScreenPtr)dixLookupPrivate(&(s)->devPrivates, miPointerScreenKey)) (*(GetScreenPrivate(oldScreen))->screenFuncs->CursorOffScreen) (&pScreen, &oldX, &oldY); } diff --git a/nx-X11/programs/Xserver/xkb/xkb.c b/nx-X11/programs/Xserver/xkb/xkb.c index 2138497b73..3f2aa13e4b 100644 --- a/nx-X11/programs/Xserver/xkb/xkb.c +++ b/nx-X11/programs/Xserver/xkb/xkb.c @@ -6145,6 +6145,9 @@ XkbExtensionInit(void) { ExtensionEntry *extEntry; + if (!XkbInitPrivates()) + return; + if ((extEntry = AddExtension(XkbName, XkbNumberEvents, XkbNumberErrors, ProcXkbDispatch, SProcXkbDispatch, XkbResetProc, StandardMinorOpcode))) { diff --git a/nx-X11/programs/Xserver/xkb/xkbActions.c b/nx-X11/programs/Xserver/xkb/xkbActions.c index 2bb41b928d..9e5cdc16ef 100644 --- a/nx-X11/programs/Xserver/xkb/xkbActions.c +++ b/nx-X11/programs/Xserver/xkb/xkbActions.c @@ -39,46 +39,35 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "xkb.h" #include -static unsigned int _xkbServerGeneration; -static int xkbDevicePrivateIndex = -1; +DevPrivateKeyRec xkbDevicePrivateKeyRec; -static void -xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, - void * data) +void +xkbUnwrapProc(DeviceIntPtr device, DeviceHandleProc proc, void * data) { xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device); - ProcessInputProc tmp = device->public.processInputProc; - if(xkbPrivPtr->unwrapProc) - xkbPrivPtr->unwrapProc = NULL; - - UNWRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr); - proc(device,data); - WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, - tmp,xkbUnwrapProc); + ProcessInputProc backupproc; + + if (xkbPrivPtr->unwrapProc) + xkbPrivPtr->unwrapProc = NULL; + + UNWRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, backupproc); + proc(device, data); + COND_WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, backupproc, xkbUnwrapProc); } +Bool +XkbInitPrivates(void) +{ + return dixRegisterPrivateKey(&xkbDevicePrivateKeyRec, PRIVATE_DEVICE, + sizeof(xkbDeviceInfoRec)); +} void XkbSetExtension(DeviceIntPtr device, ProcessInputProc proc) { - xkbDeviceInfoPtr xkbPrivPtr; - - if (serverGeneration != _xkbServerGeneration) { - if ((xkbDevicePrivateIndex = AllocateDevicePrivateIndex()) == -1) - return; - _xkbServerGeneration = serverGeneration; - } - if (!AllocateDevicePrivate(device, xkbDevicePrivateIndex)) - return; - - xkbPrivPtr = (xkbDeviceInfoPtr) malloc(sizeof(xkbDeviceInfoRec)); - if (!xkbPrivPtr) - return; - xkbPrivPtr->unwrapProc = NULL; + xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(device); - device->devPrivates[xkbDevicePrivateIndex].ptr = xkbPrivPtr; - WRAP_PROCESS_INPUT_PROC(device,xkbPrivPtr, - proc,xkbUnwrapProc); + WRAP_PROCESS_INPUT_PROC(device, xkbPrivPtr, proc, xkbUnwrapProc); } #ifdef XINPUT @@ -866,6 +855,7 @@ int x,y; XkbStateRec old; unsigned mods,mask,oldCoreState = 0,oldCorePrevState = 0; xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); +ProcessInputProc backupproc; if ((filter->keycode!=0)&&(filter->keycode!=keycode)) return 1; @@ -914,10 +904,10 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); realMods = xkbi->device->key->modifierMap[ev.u.u.detail]; xkbi->device->key->modifierMap[ev.u.u.detail] = 0; - UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr); + UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc); xkbi->device->public.processInputProc(&ev,xkbi->device,1); - COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, - ProcessKeyboardEvent,xkbUnwrapProc); + COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, backupproc, + xkbUnwrapProc); xkbi->device->key->modifierMap[ev.u.u.detail] = realMods; if ( mask || mods ) { @@ -955,10 +945,10 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device); realMods = xkbi->device->key->modifierMap[ev.u.u.detail]; xkbi->device->key->modifierMap[ev.u.u.detail] = 0; - UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr); + UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc); xkbi->device->public.processInputProc(&ev,xkbi->device,1); - COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, - ProcessKeyboardEvent,xkbUnwrapProc); + COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr, backupproc, + xkbUnwrapProc); xkbi->device->key->modifierMap[ev.u.u.detail] = realMods; if ( mask || mods ) { @@ -1154,6 +1144,7 @@ Bool xiEvent; #endif xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); +ProcessInputProc backupproc; keyc= kbd->key; xkbi= keyc->xkbInfo; @@ -1296,10 +1287,10 @@ xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(dev); if (keyEvent) { realMods = keyc->modifierMap[key]; keyc->modifierMap[key] = 0; - UNWRAP_PROCESS_INPUT_PROC(dev,xkbPrivPtr); + UNWRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr, backupproc); dev->public.processInputProc(xE,dev,count); - COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr, - ProcessKeyboardEvent,xkbUnwrapProc); + COND_WRAP_PROCESS_INPUT_PROC(dev, xkbPrivPtr, backupproc, + xkbUnwrapProc); keyc->modifierMap[key] = realMods; } else CoreProcessPointerEvent(xE,dev,count);