summaryrefslogtreecommitdiff
path: root/miext
diff options
context:
space:
mode:
Diffstat (limited to 'miext')
-rw-r--r--miext/cw/cw.c53
-rw-r--r--miext/cw/cw.h29
-rwxr-xr-xmiext/damage/damage.c44
-rwxr-xr-xmiext/damage/damagestr.h15
-rw-r--r--miext/rootless/Makefile.am19
-rw-r--r--miext/rootless/accel/Makefile.am25
-rw-r--r--miext/rootless/accel/rlAccel.c13
-rw-r--r--miext/rootless/accel/rlBlt.c44
-rw-r--r--miext/rootless/accel/rlFill.c6
-rw-r--r--miext/rootless/rootless.h3
-rw-r--r--miext/rootless/rootlessCommon.c81
-rw-r--r--miext/rootless/rootlessCommon.h42
-rw-r--r--miext/rootless/rootlessConfig.h4
-rw-r--r--miext/rootless/rootlessGC.c60
-rw-r--r--miext/rootless/rootlessScreen.c98
-rw-r--r--miext/rootless/rootlessValTree.c12
-rw-r--r--miext/rootless/rootlessWindow.c213
-rw-r--r--miext/rootless/rootlessWindow.h3
-rw-r--r--miext/rootless/safeAlpha/Makefile.am8
-rw-r--r--miext/rootless/safeAlpha/safeAlphaPicture.c109
-rw-r--r--miext/shadow/shadow.c15
-rw-r--r--miext/shadow/shadow.h5
22 files changed, 615 insertions, 286 deletions
diff --git a/miext/cw/cw.c b/miext/cw/cw.c
index bd49f3f0d..efb046948 100644
--- a/miext/cw/cw.c
+++ b/miext/cw/cw.c
@@ -43,13 +43,12 @@
#define CW_ASSERT(x) do {} while (0)
#endif
-int cwGCIndex;
-int cwScreenIndex;
-int cwWindowIndex;
+DevPrivateKey cwGCKey = &cwGCKey;
+DevPrivateKey cwScreenKey = &cwScreenKey;
+DevPrivateKey cwWindowKey = &cwWindowKey;
#ifdef RENDER
-int cwPictureIndex;
+DevPrivateKey cwPictureKey = &cwPictureKey;
#endif
-static unsigned long cwGeneration = 0;
extern GCOps cwGCOps;
static Bool
@@ -123,7 +122,7 @@ cwCreateBackingGC(GCPtr pGC, DrawablePtr pDrawable)
pBackingDrawable = cwGetBackingDrawable(pDrawable, &x_off, &y_off);
pPriv->pBackingGC = CreateGC(pBackingDrawable, GCGraphicsExposures,
- &noexpose, &status);
+ &noexpose, &status, (XID)0, serverClient);
if (status != Success)
return FALSE;
@@ -237,7 +236,7 @@ cwValidateGC(GCPtr pGC, unsigned long stateChanges, DrawablePtr pDrawable)
static void
cwChangeGC(GCPtr pGC, unsigned long mask)
{
- cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGC->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGC, pPriv);
@@ -249,7 +248,7 @@ cwChangeGC(GCPtr pGC, unsigned long mask)
static void
cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
{
- cwGCPtr pPriv = (cwGCPtr)(pGCDst)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGCDst->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGCDst, pPriv);
@@ -261,7 +260,7 @@ cwCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst)
static void
cwDestroyGC(GCPtr pGC)
{
- cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGC->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGC, pPriv);
@@ -275,7 +274,7 @@ cwDestroyGC(GCPtr pGC)
static void
cwChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
{
- cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGC->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGC, pPriv);
@@ -287,7 +286,7 @@ cwChangeClip(GCPtr pGC, int type, pointer pvalue, int nrects)
static void
cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
{
- cwGCPtr pPriv = (cwGCPtr)(pgcDst)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pgcDst->devPrivates, cwGCKey);
FUNC_PROLOGUE(pgcDst, pPriv);
@@ -299,7 +298,7 @@ cwCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
static void
cwDestroyClip(GCPtr pGC)
{
- cwGCPtr pPriv = (cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr;
+ cwGCPtr pPriv = (cwGCPtr)dixLookupPrivate(&pGC->devPrivates, cwGCKey);
FUNC_PROLOGUE(pGC, pPriv);
@@ -478,34 +477,14 @@ miInitializeCompositeWrapper(ScreenPtr pScreen)
Bool has_render = GetPictureScreenIfSet(pScreen) != NULL;
#endif
- if (cwGeneration != serverGeneration)
- {
- cwScreenIndex = AllocateScreenPrivateIndex();
- if (cwScreenIndex < 0)
- return;
- cwGCIndex = AllocateGCPrivateIndex();
- cwWindowIndex = AllocateWindowPrivateIndex();
-#ifdef RENDER
- if (has_render)
- cwPictureIndex = AllocatePicturePrivateIndex();
-#endif
- cwGeneration = serverGeneration;
- }
- if (!AllocateGCPrivate(pScreen, cwGCIndex, sizeof(cwGCRec)))
- return;
- if (!AllocateWindowPrivate(pScreen, cwWindowIndex, 0))
+ if (!dixRequestPrivate(cwGCKey, sizeof(cwGCRec)))
return;
-#ifdef RENDER
- if (has_render) {
- if (!AllocatePicturePrivate(pScreen, cwPictureIndex, 0))
- return;
- }
-#endif
+
pScreenPriv = (cwScreenPtr)xalloc(sizeof(cwScreenRec));
if (!pScreenPriv)
return;
- pScreen->devPrivates[cwScreenIndex].ptr = (pointer)pScreenPriv;
+ dixSetPrivate(&pScreen->devPrivates, cwScreenKey, pScreenPriv);
SCREEN_EPILOGUE(pScreen, CloseScreen, cwCloseScreen);
SCREEN_EPILOGUE(pScreen, GetImage, cwGetImage);
@@ -530,8 +509,8 @@ cwCloseScreen (int i, ScreenPtr pScreen)
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
- pScreenPriv = (cwScreenPtr)pScreen->devPrivates[cwScreenIndex].ptr;
-
+ pScreenPriv = (cwScreenPtr)dixLookupPrivate(&pScreen->devPrivates,
+ cwScreenKey);
pScreen->CloseScreen = pScreenPriv->CloseScreen;
pScreen->GetImage = pScreenPriv->GetImage;
pScreen->GetSpans = pScreenPriv->GetSpans;
diff --git a/miext/cw/cw.h b/miext/cw/cw.h
index a83949dc9..145f3492c 100644
--- a/miext/cw/cw.h
+++ b/miext/cw/cw.h
@@ -26,6 +26,7 @@
#include "gcstruct.h"
#include "picturestr.h"
+#include "privates.h"
/*
* One of these structures is allocated per GC that gets used with a window with
@@ -43,10 +44,10 @@ typedef struct {
GCFuncs *wrapFuncs; /* wrapped funcs */
} cwGCRec, *cwGCPtr;
-extern int cwGCIndex;
+extern DevPrivateKey cwGCKey;
-#define getCwGC(pGC) ((cwGCPtr)(pGC)->devPrivates[cwGCIndex].ptr)
-#define setCwGC(pGC,p) ((pGC)->devPrivates[cwGCIndex].ptr = (pointer) (p))
+#define getCwGC(pGC) ((cwGCPtr)dixLookupPrivate(&(pGC)->devPrivates, cwGCKey))
+#define setCwGC(pGC,p) dixSetPrivate(&(pGC)->devPrivates, cwGCKey, p)
/*
* One of these structures is allocated per Picture that gets used with a
@@ -59,17 +60,17 @@ typedef struct {
unsigned long stateChanges;
} cwPictureRec, *cwPicturePtr;
-#define getCwPicture(pPicture) \
- (pPicture->pDrawable ? (cwPicturePtr)(pPicture)->devPrivates[cwPictureIndex].ptr : 0)
-#define setCwPicture(pPicture,p) ((pPicture)->devPrivates[cwPictureIndex].ptr = (pointer) (p))
+#define getCwPicture(pPicture) (pPicture->pDrawable ? \
+ (cwPicturePtr)dixLookupPrivate(&(pPicture)->devPrivates, cwPictureKey) : 0)
+#define setCwPicture(pPicture,p) dixSetPrivate(&(pPicture)->devPrivates, cwPictureKey, p)
-extern int cwPictureIndex;
+extern DevPrivateKey cwPictureKey;
+extern DevPrivateKey cwWindowKey;
-extern int cwWindowIndex;
-
-#define cwWindowPrivate(pWindow) ((pWindow)->devPrivates[cwWindowIndex].ptr)
+#define cwWindowPrivate(pWin) dixLookupPrivate(&(pWin)->devPrivates, cwWindowKey)
#define getCwPixmap(pWindow) ((PixmapPtr) cwWindowPrivate(pWindow))
-#define setCwPixmap(pWindow,pPixmap) (cwWindowPrivate(pWindow) = (pointer) (pPixmap))
+#define setCwPixmap(pWindow,pPixmap) \
+ dixSetPrivate(&(pWindow)->devPrivates, cwWindowKey, pPixmap)
#define cwDrawableIsRedirWindow(pDraw) \
((pDraw)->type == DRAWABLE_WINDOW && \
@@ -109,10 +110,10 @@ typedef struct {
#endif
} cwScreenRec, *cwScreenPtr;
-extern int cwScreenIndex;
+extern DevPrivateKey cwScreenKey;
-#define getCwScreen(pScreen) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr)
-#define setCwScreen(pScreen,p) ((cwScreenPtr)(pScreen)->devPrivates[cwScreenIndex].ptr = (p))
+#define getCwScreen(pScreen) ((cwScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, cwScreenKey))
+#define setCwScreen(pScreen,p) dixSetPrivate(&(pScreen)->devPrivates, cwScreenKey, p)
#define CW_OFFSET_XYPOINTS(ppt, npt) do { \
DDXPointPtr _ppt = (DDXPointPtr)(ppt); \
diff --git a/miext/damage/damage.c b/miext/damage/damage.c
index 17425aeb2..56864c56d 100755
--- a/miext/damage/damage.c
+++ b/miext/damage/damage.c
@@ -65,16 +65,15 @@
#define DAMAGE_DEBUG(x)
#endif
-#define getPixmapDamageRef(pPixmap) \
- ((DamagePtr *) &(pPixmap->devPrivates[damagePixPrivateIndex].ptr))
+#define getPixmapDamageRef(pPixmap) ((DamagePtr *) \
+ dixLookupPrivateAddr(&(pPixmap)->devPrivates, damagePixPrivateKey))
#define pixmapDamage(pPixmap) damagePixPriv(pPixmap)
-static int damageScrPrivateIndex;
-static int damagePixPrivateIndex;
-static int damageGCPrivateIndex;
-static int damageWinPrivateIndex;
-static int damageGeneration;
+static DevPrivateKey damageScrPrivateKey = &damageScrPrivateKey;
+static DevPrivateKey damagePixPrivateKey = &damagePixPrivateKey;
+static DevPrivateKey damageGCPrivateKey = &damageGCPrivateKey;
+static DevPrivateKey damageWinPrivateKey = &damageWinPrivateKey;
static DamagePtr *
getDrawableDamageRef (DrawablePtr pDrawable)
@@ -115,7 +114,7 @@ getDrawableDamageRef (DrawablePtr pDrawable)
#define winDamageRef(pWindow) \
DamagePtr *pPrev = (DamagePtr *) \
- &(pWindow->devPrivates[damageWinPrivateIndex].ptr)
+ dixLookupPrivateAddr(&(pWindow)->devPrivates, damageWinPrivateKey)
static void
DamageReportDamage (DamagePtr pDamage, RegionPtr pDamageRegion)
@@ -243,9 +242,6 @@ damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip,
if (pDamage->pDrawable->type == DRAWABLE_WINDOW &&
!((WindowPtr) (pDamage->pDrawable))->realized)
{
-#if 0
- DAMAGE_DEBUG (("damage while window unrealized\n"));
-#endif
continue;
}
@@ -1748,30 +1744,10 @@ DamageSetup (ScreenPtr pScreen)
PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
#endif
- if (damageGeneration != serverGeneration)
- {
- damageScrPrivateIndex = AllocateScreenPrivateIndex ();
- if (damageScrPrivateIndex == -1)
- return FALSE;
- damageGCPrivateIndex = AllocateGCPrivateIndex ();
- if (damageGCPrivateIndex == -1)
- return FALSE;
- damagePixPrivateIndex = AllocatePixmapPrivateIndex ();
- if (damagePixPrivateIndex == -1)
- return FALSE;
- damageWinPrivateIndex = AllocateWindowPrivateIndex ();
- if (damageWinPrivateIndex == -1)
- return FALSE;
- damageGeneration = serverGeneration;
- }
- if (pScreen->devPrivates[damageScrPrivateIndex].ptr)
+ if (dixLookupPrivate(&pScreen->devPrivates, damageScrPrivateKey))
return TRUE;
- if (!AllocateGCPrivate (pScreen, damageGCPrivateIndex, sizeof (DamageGCPrivRec)))
- return FALSE;
- if (!AllocatePixmapPrivate (pScreen, damagePixPrivateIndex, 0))
- return FALSE;
- if (!AllocateWindowPrivate (pScreen, damageWinPrivateIndex, 0))
+ if (!dixRequestPrivate(damageGCPrivateKey, sizeof(DamageGCPrivRec)))
return FALSE;
pScrPriv = (DamageScrPrivPtr) xalloc (sizeof (DamageScrPrivRec));
@@ -1794,7 +1770,7 @@ DamageSetup (ScreenPtr pScreen)
}
#endif
- pScreen->devPrivates[damageScrPrivateIndex].ptr = (pointer) pScrPriv;
+ dixSetPrivate(&pScreen->devPrivates, damageScrPrivateKey, pScrPriv);
return TRUE;
}
diff --git a/miext/damage/damagestr.h b/miext/damage/damagestr.h
index e603f02a4..2f6d53844 100755
--- a/miext/damage/damagestr.h
+++ b/miext/damage/damagestr.h
@@ -29,6 +29,7 @@
#include "damage.h"
#include "gcstruct.h"
+#include "privates.h"
#ifdef RENDER
# include "picturestr.h"
#endif
@@ -78,31 +79,31 @@ typedef struct _damageGCPriv {
} DamageGCPrivRec, *DamageGCPrivPtr;
/* XXX should move these into damage.c, damageScrPrivateIndex is static */
-#define damageGetScrPriv(pScr) \
- ((DamageScrPrivPtr) (pScr)->devPrivates[damageScrPrivateIndex].ptr)
+#define damageGetScrPriv(pScr) ((DamageScrPrivPtr) \
+ dixLookupPrivate(&(pScr)->devPrivates, damageScrPrivateKey))
#define damageScrPriv(pScr) \
DamageScrPrivPtr pScrPriv = damageGetScrPriv(pScr)
#define damageGetPixPriv(pPix) \
- ((DamagePtr) (pPix)->devPrivates[damagePixPrivateIndex].ptr)
+ dixLookupPrivate(&(pPix)->devPrivates, damagePixPrivateKey)
#define damgeSetPixPriv(pPix,v) \
- ((pPix)->devPrivates[damagePixPrivateIndex].ptr = (pointer ) (v))
+ dixSetPrivate(&(pPix)->devPrivates, damagePixPrivateKey, v)
#define damagePixPriv(pPix) \
DamagePtr pDamage = damageGetPixPriv(pPix)
#define damageGetGCPriv(pGC) \
- ((DamageGCPrivPtr) (pGC)->devPrivates[damageGCPrivateIndex].ptr)
+ dixLookupPrivate(&(pGC)->devPrivates, damageGCPrivateKey)
#define damageGCPriv(pGC) \
DamageGCPrivPtr pGCPriv = damageGetGCPriv(pGC)
#define damageGetWinPriv(pWin) \
- ((DamagePtr) (pWin)->devPrivates[damageWinPrivateIndex].ptr)
+ ((DamagePtr)dixLookupPrivate(&(pWin)->devPrivates, damageWinPrivateKey))
#define damageSetWinPriv(pWin,d) \
- ((pWin)->devPrivates[damageWinPrivateIndex].ptr = (d))
+ dixSetPrivate(&(pWin)->devPrivates, damageWinPrivateKey, d)
#endif /* _DAMAGESTR_H_ */
diff --git a/miext/rootless/Makefile.am b/miext/rootless/Makefile.am
index 8dae6d237..aa8528e6a 100644
--- a/miext/rootless/Makefile.am
+++ b/miext/rootless/Makefile.am
@@ -1,22 +1,19 @@
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- $(XORG_CFLAGS)
-
-INCLUDES = -I$(top_srcdir)/hw/xfree86/os-support
+AM_CFLAGS = $(DIX_CFLAGS) $(XSERVER_CFLAGS)
+AM_CPPFLAGS = -I$(top_srcdir)/hw/xfree86/os-support
SUBDIRS = safeAlpha accel
noinst_LTLIBRARIES = librootless.la
librootless_la_SOURCES = \
rootlessCommon.c \
- rootlessCommon.h \
- rootlessConfig.h \
rootlessGC.c \
- rootless.h \
rootlessScreen.c \
rootlessValTree.c \
- rootlessWindow.c \
- rootlessWindow.h
+ rootlessWindow.c
EXTRA_DIST = \
- README.txt
+ README.txt \
+ rootless.h \
+ rootlessCommon.h \
+ rootlessConfig.h \
+ rootlessWindow.h
diff --git a/miext/rootless/accel/Makefile.am b/miext/rootless/accel/Makefile.am
index c49d5fb47..ca41653b7 100644
--- a/miext/rootless/accel/Makefile.am
+++ b/miext/rootless/accel/Makefile.am
@@ -1,18 +1,15 @@
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- $(XORG_CFLAGS)
-
-INCLUDES = -I$(srcdir)/.. -I$(top_srcdir)/hw/xfree86/os-support
-
+AM_CFLAGS = $(DIX_CFLAGS) $(XSERVER_CFLAGS)
+AM_CPPFLAGS = -I$(srcdir)/.. -I$(top_srcdir)/hw/xfree86/os-support
noinst_LTLIBRARIES = librlAccel.la
-librlAccel_la_SOURCES = rlAccel.c \
- rlBlt.c \
- rlCopy.c \
- rlFill.c \
- rlFillRect.c \
- rlFillSpans.c \
- rlGlyph.c \
- rlSolid.c
+librlAccel_la_SOURCES = \
+ rlAccel.c \
+ rlBlt.c \
+ rlCopy.c \
+ rlFill.c \
+ rlFillRect.c \
+ rlFillSpans.c \
+ rlGlyph.c \
+ rlSolid.c
EXTRA_DIST = rlAccel.h
diff --git a/miext/rootless/accel/rlAccel.c b/miext/rootless/accel/rlAccel.c
index d62bee740..a14412416 100644
--- a/miext/rootless/accel/rlAccel.c
+++ b/miext/rootless/accel/rlAccel.c
@@ -46,10 +46,10 @@ typedef struct _rlAccelScreenRec {
CloseScreenProcPtr CloseScreen;
} rlAccelScreenRec, *rlAccelScreenPtr;
-static int rlAccelScreenPrivateIndex = -1;
+static DevPrivateKey rlAccelScreenPrivateKey = &rlAccelScreenPrivateKey;
-#define RLACCELREC(pScreen) \
- ((rlAccelScreenRec *)(pScreen)->devPrivates[rlAccelScreenPrivateIndex].ptr)
+#define RLACCELREC(pScreen) ((rlAccelScreenRec *) \
+ dixLookupPrivate(&(pScreen)->devPrivates, rlAccelScreenPrivateKey))
/* This is mostly identical to fbGCOps. */
static GCOps rlAccelOps = {
@@ -128,15 +128,8 @@ rlCloseScreen (int iScreen, ScreenPtr pScreen)
Bool
RootlessAccelInit(ScreenPtr pScreen)
{
- static unsigned long rlAccelGeneration = 0;
rlAccelScreenRec *s;
- if (rlAccelGeneration != serverGeneration) {
- rlAccelScreenPrivateIndex = AllocateScreenPrivateIndex();
- if (rlAccelScreenPrivateIndex == -1) return FALSE;
- rlAccelGeneration = serverGeneration;
- }
-
s = xalloc(sizeof(rlAccelScreenRec));
if (!s) return FALSE;
RLACCELREC(pScreen) = s;
diff --git a/miext/rootless/accel/rlBlt.c b/miext/rootless/accel/rlBlt.c
index 2cf72eb22..b5fe74085 100644
--- a/miext/rootless/accel/rlBlt.c
+++ b/miext/rootless/accel/rlBlt.c
@@ -32,10 +32,22 @@
#endif
#include <stddef.h> /* For NULL */
+#include <string.h>
#include "fb.h"
#include "rootlessCommon.h"
#include "rlAccel.h"
+#define InitializeShifts(sx,dx,ls,rs) { \
+ if (sx != dx) { \
+ if (sx > dx) { \
+ ls = sx - dx; \
+ rs = FB_UNIT - ls; \
+ } else { \
+ rs = dx - sx; \
+ ls = FB_UNIT - rs; \
+ } \
+ } \
+}
void
rlBlt (FbBits *srcLine,
@@ -74,6 +86,29 @@ rlBlt (FbBits *srcLine,
return;
}
#endif
+
+ if (alu == GXcopy && pm == FB_ALLONES && !reverse &&
+ !(srcX & 7) && !(dstX & 7) && !(width & 7)) {
+ int i;
+ CARD8 *src = (CARD8 *) srcLine;
+ CARD8 *dst = (CARD8 *) dstLine;
+
+ srcStride *= sizeof(FbBits);
+ dstStride *= sizeof(FbBits);
+ width >>= 3;
+ src += (srcX >> 3);
+ dst += (dstX >> 3);
+
+ if (!upsidedown)
+ for (i = 0; i < height; i++)
+ memcpy(dst + i * dstStride, src + i * srcStride, width);
+ else
+ for (i = height - 1; i >= 0; i--)
+ memcpy(dst + i * dstStride, src + i * srcStride, width);
+
+ return;
+ }
+
FbInitializeMergeRop(alu, pm);
destInvarient = FbDestInvarientMergeRop();
if (upsidedown)
@@ -325,9 +360,12 @@ rlBlt (FbBits *srcLine,
bits1 = *src++;
if (startmask)
{
- bits = FbScrLeft(bits1, leftShift);
- bits1 = *src++;
- bits |= FbScrRight(bits1, rightShift);
+ bits = FbScrLeft(bits1, leftShift);
+ if (FbScrLeft(startmask, rightShift))
+ {
+ bits1 = *src++;
+ bits |= FbScrRight(bits1, rightShift);
+ }
FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
dst++;
}
diff --git a/miext/rootless/accel/rlFill.c b/miext/rootless/accel/rlFill.c
index 0d0d01251..a80c7769f 100644
--- a/miext/rootless/accel/rlFill.c
+++ b/miext/rootless/accel/rlFill.c
@@ -89,7 +89,7 @@ rlFill (DrawablePtr pDrawable,
dstBpp,
(pGC->patOrg.x + pDrawable->x + dstXoff),
- pGC->patOrg.y + pDrawable->y + dstYoff - y);
+ pGC->patOrg.y + pDrawable->y - y);
}
else
{
@@ -126,7 +126,7 @@ rlFill (DrawablePtr pDrawable,
fgand, fgxor,
bgand, bgxor,
pGC->patOrg.x + pDrawable->x + dstXoff,
- pGC->patOrg.y + pDrawable->y + dstYoff - y);
+ pGC->patOrg.y + pDrawable->y - y);
}
break;
}
@@ -154,7 +154,7 @@ rlFill (DrawablePtr pDrawable,
pPriv->pm,
dstBpp,
(pGC->patOrg.x + pDrawable->x + dstXoff) * dstBpp,
- pGC->patOrg.y + pDrawable->y + dstYoff - y);
+ pGC->patOrg.y + pDrawable->y - y);
break;
}
}
diff --git a/miext/rootless/rootless.h b/miext/rootless/rootless.h
index d9fdb6adb..5224dca2b 100644
--- a/miext/rootless/rootless.h
+++ b/miext/rootless/rootless.h
@@ -66,7 +66,6 @@ typedef struct _RootlessWindowRec {
int bytesPerRow;
PixmapPtr pixmap;
- PixmapPtr oldPixmap;
#ifdef ROOTLESS_TRACK_DAMAGE
RegionRec damage;
@@ -74,6 +73,8 @@ typedef struct _RootlessWindowRec {
unsigned int is_drawing :1; // Currently drawing?
unsigned int is_reorder_pending :1;
+ unsigned int is_offscreen :1;
+ unsigned int is_obscured :1;
} RootlessWindowRec, *RootlessWindowPtr;
diff --git a/miext/rootless/rootlessCommon.c b/miext/rootless/rootlessCommon.c
index 9cbb7fa1b..97c92d309 100644
--- a/miext/rootless/rootlessCommon.c
+++ b/miext/rootless/rootlessCommon.c
@@ -37,6 +37,7 @@
#include <limits.h> /* For CHAR_BIT */
#include "rootlessCommon.h"
+#include "colormapst.h"
unsigned int rootless_CopyBytes_threshold = 0;
unsigned int rootless_FillBytes_threshold = 0;
@@ -98,6 +99,41 @@ IsFramedWindow(WindowPtr pWin)
return (top && WINREC(top));
}
+Bool
+RootlessResolveColormap (ScreenPtr pScreen, int first_color,
+ int n_colors, uint32_t *colors)
+{
+ int last, i;
+ ColormapPtr map;
+
+ map = RootlessGetColormap (pScreen);
+ if (map == NULL || map->class != PseudoColor) return FALSE;
+
+ last = MIN (map->pVisual->ColormapEntries, first_color + n_colors);
+ for (i = MAX (0, first_color); i < last; i++) {
+ Entry *ent = map->red + i;
+ uint16_t red, green, blue;
+
+ if (!ent->refcnt) continue;
+ if (ent->fShared) {
+ red = ent->co.shco.red->color;
+ green = ent->co.shco.green->color;
+ blue = ent->co.shco.blue->color;
+ } else {
+ red = ent->co.local.red;
+ green = ent->co.local.green;
+ blue = ent->co.local.blue;
+ }
+
+ colors[i - first_color] = (0xFF000000UL
+ | ((uint32_t) red & 0xff00) << 8
+ | (green & 0xff00)
+ | (blue >> 8));
+ }
+
+ return TRUE;
+}
+
/*
* RootlessStartDrawing
@@ -136,8 +172,24 @@ void RootlessStartDrawing(WindowPtr pWindow)
winRec->is_drawing = TRUE;
}
- winRec->oldPixmap = pScreen->GetWindowPixmap(pWindow);
- pScreen->SetWindowPixmap(pWindow, winRec->pixmap);
+ PixmapPtr curPixmap = pScreen->GetWindowPixmap(pWindow);
+ if (curPixmap == winRec->pixmap)
+ {
+ RL_DEBUG_MSG("Window %p already has winRec->pixmap %p; not pushing\n", pWindow, winRec->pixmap);
+ }
+ else
+ {
+ PixmapPtr oldPixmap = dixLookupPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey);
+ if (oldPixmap != NULL)
+ {
+ if (oldPixmap == curPixmap)
+ RL_DEBUG_MSG("Window %p's curPixmap %p is the same as its oldPixmap; strange\n", pWindow, curPixmap);
+ else
+ RL_DEBUG_MSG("Window %p's existing oldPixmap %p being lost!\n", pWindow, oldPixmap);
+ }
+ dixSetPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey, curPixmap);
+ pScreen->SetWindowPixmap(pWindow, winRec->pixmap);
+ }
}
@@ -146,6 +198,29 @@ void RootlessStartDrawing(WindowPtr pWindow)
* Stop drawing to a window's backing buffer. If flush is true,
* damaged regions are flushed to the screen.
*/
+static int RestorePreDrawingPixmapVisitor(WindowPtr pWindow, pointer data)
+{
+ RootlessWindowRec *winRec = (RootlessWindowRec*)data;
+ ScreenPtr pScreen = pWindow->drawable.pScreen;
+ PixmapPtr exPixmap = pScreen->GetWindowPixmap(pWindow);
+ PixmapPtr oldPixmap = dixLookupPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey);
+ if (oldPixmap == NULL)
+ {
+ if (exPixmap == winRec->pixmap)
+ RL_DEBUG_MSG("Window %p appears to be in drawing mode (ex-pixmap %p equals winRec->pixmap, which is being freed) but has no oldPixmap!\n", pWindow, exPixmap);
+ }
+ else
+ {
+ if (exPixmap != winRec->pixmap)
+ RL_DEBUG_MSG("Window %p appears to be in drawing mode (oldPixmap %p) but ex-pixmap %p not winRec->pixmap %p!\n", pWindow, oldPixmap, exPixmap, winRec->pixmap);
+ if (oldPixmap == winRec->pixmap)
+ RL_DEBUG_MSG("Window %p's oldPixmap %p is winRec->pixmap, which has just been freed!\n", pWindow, oldPixmap);
+ pScreen->SetWindowPixmap(pWindow, oldPixmap);
+ dixSetPrivate(&pWindow->devPrivates, rootlessWindowOldPixmapPrivateKey, NULL);
+ }
+ return WT_WALKCHILDREN;
+}
+
void RootlessStopDrawing(WindowPtr pWindow, Bool flush)
{
ScreenPtr pScreen = pWindow->drawable.pScreen;
@@ -162,7 +237,7 @@ void RootlessStopDrawing(WindowPtr pWindow, Bool flush)
SCREENREC(pScreen)->imp->StopDrawing(winRec->wid, flush);
FreeScratchPixmapHeader(winRec->pixmap);
- pScreen->SetWindowPixmap(pWindow, winRec->oldPixmap);
+ TraverseTree(top, RestorePreDrawingPixmapVisitor, (pointer)winRec);
winRec->pixmap = NULL;
winRec->is_drawing = FALSE;
diff --git a/miext/rootless/rootlessCommon.h b/miext/rootless/rootlessCommon.h
index 66b930d36..9e4a14a04 100644
--- a/miext/rootless/rootlessCommon.h
+++ b/miext/rootless/rootlessCommon.h
@@ -32,12 +32,17 @@
#include <dix-config.h>
#endif
+#include <stdint.h>
#ifndef _ROOTLESSCOMMON_H
#define _ROOTLESSCOMMON_H
#include "rootless.h"
#include "fb.h"
+#ifdef SHAPE
+#include "scrnintstr.h"
+#endif /* SHAPE */
+
#ifdef RENDER
#include "picturestr.h"
#endif
@@ -52,9 +57,10 @@
// Global variables
-extern int rootlessGCPrivateIndex;
-extern int rootlessScreenPrivateIndex;
-extern int rootlessWindowPrivateIndex;
+extern DevPrivateKey rootlessGCPrivateKey;
+extern DevPrivateKey rootlessScreenPrivateKey;
+extern DevPrivateKey rootlessWindowPrivateKey;
+extern DevPrivateKey rootlessWindowOldPixmapPrivateKey;
// RootlessGCRec: private per-gc data
@@ -102,13 +108,20 @@ typedef struct _RootlessScreenRec {
GlyphsProcPtr Glyphs;
#endif
+ InstallColormapProcPtr InstallColormap;
+ UninstallColormapProcPtr UninstallColormap;
+ StoreColorsProcPtr StoreColors;
+
void *pixmap_data;
unsigned int pixmap_data_size;
+ ColormapPtr colormap;
+
void *redisplay_timer;
unsigned int redisplay_timer_set :1;
unsigned int redisplay_queued :1;
unsigned int redisplay_expired :1;
+ unsigned int colormap_changed :1;
} RootlessScreenRec, *RootlessScreenPtr;
@@ -131,12 +144,17 @@ typedef struct _RootlessScreenRec {
// Accessors for screen and window privates
-#define SCREENREC(pScreen) \
- ((RootlessScreenRec *)(pScreen)->devPrivates[rootlessScreenPrivateIndex].ptr)
+#define SCREENREC(pScreen) ((RootlessScreenRec *) \
+ dixLookupPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey))
-#define WINREC(pWin) \
- ((RootlessWindowRec *)(pWin)->devPrivates[rootlessWindowPrivateIndex].ptr)
+#define SETSCREENREC(pScreen, v) \
+ dixSetPrivate(&(pScreen)->devPrivates, rootlessScreenPrivateKey, v)
+#define WINREC(pWin) ((RootlessWindowRec *) \
+ dixLookupPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey))
+
+#define SETWINREC(pWin, v) \
+ dixSetPrivate(&(pWin)->devPrivates, rootlessWindowPrivateKey, v)
// Call a rootless implementation function.
// Many rootless implementation functions are allowed to be NULL.
@@ -249,6 +267,16 @@ void RootlessRedisplayScreen(ScreenPtr pScreen);
void RootlessQueueRedisplay(ScreenPtr pScreen);
+/* Return the colormap currently installed on the given screen. */
+ColormapPtr RootlessGetColormap (ScreenPtr pScreen);
+
+/* Convert colormap to ARGB. */
+Bool RootlessResolveColormap (ScreenPtr pScreen, int first_color,
+ int n_colors, uint32_t *colors);
+
+void RootlessFlushWindowColormap (WindowPtr pWin);
+void RootlessFlushScreenColormaps (ScreenPtr pScreen);
+
// Move a window to its proper location on the screen.
void RootlessRepositionWindow(WindowPtr pWin);
diff --git a/miext/rootless/rootlessConfig.h b/miext/rootless/rootlessConfig.h
index 3e326bf06..ab0187e83 100644
--- a/miext/rootless/rootlessConfig.h
+++ b/miext/rootless/rootlessConfig.h
@@ -34,7 +34,7 @@
#ifndef _ROOTLESSCONFIG_H
#define _ROOTLESSCONFIG_H
-#ifdef __DARWIN__
+#ifdef __APPLE__
# define ROOTLESS_ACCEL TRUE
# define ROOTLESS_GLOBAL_COORDS TRUE
@@ -48,7 +48,7 @@
alpha for 16bpp. */
# define RootlessAlphaMask(bpp) ((bpp) == 32 ? 0xFF000000 : 0)
-#endif /* __DARWIN__ */
+#endif /* __APPLE__ */
#if defined(__CYGWIN__) || defined(WIN32)
diff --git a/miext/rootless/rootlessGC.c b/miext/rootless/rootlessGC.c
index b26f52c54..c80b11f1d 100644
--- a/miext/rootless/rootlessGC.c
+++ b/miext/rootless/rootlessGC.c
@@ -276,11 +276,11 @@ RootlessCreateGC(GCPtr pGC)
Bool result;
SCREEN_UNWRAP(pGC->pScreen, CreateGC);
- s = (RootlessScreenRec *) pGC->pScreen->
- devPrivates[rootlessScreenPrivateIndex].ptr;
+ s = SCREENREC(pGC->pScreen);
result = s->CreateGC(pGC);
- gcrec = (RootlessGCRec *) pGC->devPrivates[rootlessGCPrivateIndex].ptr;
+ gcrec = (RootlessGCRec *)
+ dixLookupPrivate(&pGC->devPrivates, rootlessGCPrivateKey);
gcrec->originalOps = NULL; // don't wrap ops yet
gcrec->originalFuncs = pGC->funcs;
pGC->funcs = &rootlessGCFuncs;
@@ -302,7 +302,7 @@ RootlessCreateGC(GCPtr pGC)
// does not assume ops have been wrapped
#define GCFUNC_UNWRAP(pGC) \
RootlessGCRec *gcrec = (RootlessGCRec *) \
- (pGC)->devPrivates[rootlessGCPrivateIndex].ptr; \
+ dixLookupPrivate(&(pGC)->devPrivates, rootlessGCPrivateKey); \
(pGC)->funcs = gcrec->originalFuncs; \
if (gcrec->originalOps) { \
(pGC)->ops = gcrec->originalOps; \
@@ -399,7 +399,7 @@ static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
// assumes both funcs and ops are wrapped
#define GCOP_UNWRAP(pGC) \
RootlessGCRec *gcrec = (RootlessGCRec *) \
- (pGC)->devPrivates[rootlessGCPrivateIndex].ptr; \
+ dixLookupPrivate(&(pGC)->devPrivates, rootlessGCPrivateKey); \
GCFuncs *saveFuncs = pGC->funcs; \
(pGC)->funcs = gcrec->originalFuncs; \
(pGC)->ops = gcrec->originalOps;
@@ -413,10 +413,12 @@ static void RootlessCopyClip(GCPtr pgcDst, GCPtr pgcSrc)
#define GC_IS_ROOT(pDst) ((pDst)->type == DRAWABLE_WINDOW \
&& IsRoot ((WindowPtr) (pDst)))
-#define GC_SKIP_ROOT(pDst) \
+#define GC_SKIP_ROOT(pDst, pGC) \
do { \
- if (GC_IS_ROOT (pDst)) \
+ if (GC_IS_ROOT (pDst)) { \
+ GCOP_WRAP(pGC); \
return; \
+ } \
} while (0)
@@ -426,7 +428,7 @@ RootlessFillSpans(DrawablePtr dst, GCPtr pGC, int nInit,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("fill spans start ");
if (nInit <= 0) {
@@ -482,7 +484,7 @@ RootlessSetSpans(DrawablePtr dst, GCPtr pGC, char *pSrc,
int nspans, int sorted)
{
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("set spans start ");
if (nspans <= 0) {
@@ -533,7 +535,7 @@ RootlessPutImage(DrawablePtr dst, GCPtr pGC,
BoxRec box;
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("put image start ");
RootlessStartDrawing((WindowPtr) dst);
@@ -565,7 +567,10 @@ RootlessCopyArea(DrawablePtr pSrc, DrawablePtr dst, GCPtr pGC,
GCOP_UNWRAP(pGC);
if (GC_IS_ROOT(dst) || GC_IS_ROOT(pSrc))
+ {
+ GCOP_WRAP(pGC);
return NULL; /* nothing exposed */
+ }
RL_DEBUG_MSG("copy area start (src 0x%x, dst 0x%x)", pSrc, dst);
@@ -615,7 +620,10 @@ static RegionPtr RootlessCopyPlane(DrawablePtr pSrc, DrawablePtr dst,
GCOP_UNWRAP(pGC);
if (GC_IS_ROOT(dst) || GC_IS_ROOT(pSrc))
+ {
+ GCOP_WRAP(pGC);
return NULL; /* nothing exposed */
+ }
RL_DEBUG_MSG("copy plane start ");
@@ -652,7 +660,7 @@ static void RootlessPolyPoint(DrawablePtr dst, GCPtr pGC,
int mode, int npt, DDXPointPtr pptInit)
{
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("polypoint start ");
RootlessStartDrawing((WindowPtr) dst);
@@ -746,7 +754,7 @@ static void RootlessPolylines(DrawablePtr dst, GCPtr pGC,
int mode, int npt, DDXPointPtr pptInit)
{
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("poly lines start ");
RootlessStartDrawing((WindowPtr) dst);
@@ -821,7 +829,7 @@ static void RootlessPolySegment(DrawablePtr dst, GCPtr pGC,
int nseg, xSegment *pSeg)
{
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("poly segment start (win 0x%x)", dst);
RootlessStartDrawing((WindowPtr) dst);
@@ -892,7 +900,7 @@ static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC,
int nRects, xRectangle *pRects)
{
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("poly rectangle start ");
RootlessStartDrawing((WindowPtr) dst);
@@ -953,7 +961,7 @@ static void RootlessPolyRectangle(DrawablePtr dst, GCPtr pGC,
static void RootlessPolyArc(DrawablePtr dst, GCPtr pGC, int narcs, xArc *parcs)
{
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("poly arc start ");
RootlessStartDrawing((WindowPtr) dst);
@@ -1009,7 +1017,7 @@ static void RootlessFillPolygon(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("fill poly start (win 0x%x, fillStyle 0x%x)", dst,
pGC->fillStyle);
@@ -1083,7 +1091,7 @@ static void RootlessPolyFillRect(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("fill rect start (win 0x%x, fillStyle 0x%x)", dst,
pGC->fillStyle);
@@ -1138,7 +1146,7 @@ static void RootlessPolyFillArc(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("fill arc start ");
if (narcsInit > 0) {
@@ -1193,7 +1201,7 @@ static void RootlessImageText8(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("imagetext8 start ");
if (count > 0) {
@@ -1247,7 +1255,10 @@ static int RootlessPolyText8(DrawablePtr dst, GCPtr pGC,
GCOP_UNWRAP(pGC);
if (GC_IS_ROOT(dst))
+ {
+ GCOP_WRAP(pGC);
return 0;
+ }
RL_DEBUG_MSG("polytext8 start ");
@@ -1285,7 +1296,7 @@ static void RootlessImageText16(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("imagetext16 start ");
if (count > 0) {
@@ -1339,7 +1350,10 @@ static int RootlessPolyText16(DrawablePtr dst, GCPtr pGC,
GCOP_UNWRAP(pGC);
if (GC_IS_ROOT(dst))
+ {
+ GCOP_WRAP(pGC);
return 0;
+ }
RL_DEBUG_MSG("polytext16 start ");
@@ -1378,7 +1392,7 @@ static void RootlessImageGlyphBlt(DrawablePtr dst, GCPtr pGC,
{
GC_SAVE(pGC);
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("imageglyph start ");
if (nglyphInit > 0) {
@@ -1439,7 +1453,7 @@ static void RootlessPolyGlyphBlt(DrawablePtr dst, GCPtr pGC,
CharInfoPtr *ppci, pointer pglyphBase)
{
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("polyglyph start ");
RootlessStartDrawing((WindowPtr) dst);
@@ -1485,7 +1499,7 @@ RootlessPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr dst,
BoxRec box;
GCOP_UNWRAP(pGC);
- GC_SKIP_ROOT(dst);
+ GC_SKIP_ROOT(dst, pGC);
RL_DEBUG_MSG("push pixels start ");
RootlessStartDrawing((WindowPtr) dst);
diff --git a/miext/rootless/rootlessScreen.c b/miext/rootless/rootlessScreen.c
index 489d3fb23..5031858dd 100644
--- a/miext/rootless/rootlessScreen.c
+++ b/miext/rootless/rootlessScreen.c
@@ -42,6 +42,7 @@
#include "propertyst.h"
#include "mivalidate.h"
#include "picturestr.h"
+#include "colormapst.h"
#include <sys/types.h>
#include <sys/stat.h>
@@ -61,9 +62,10 @@ extern int RootlessMiValidateTree(WindowPtr pRoot, WindowPtr pChild,
extern Bool RootlessCreateGC(GCPtr pGC);
// Initialize globals
-int rootlessGCPrivateIndex = -1;
-int rootlessScreenPrivateIndex = -1;
-int rootlessWindowPrivateIndex = -1;
+DevPrivateKey rootlessGCPrivateKey = &rootlessGCPrivateKey;
+DevPrivateKey rootlessScreenPrivateKey = &rootlessScreenPrivateKey;
+DevPrivateKey rootlessWindowPrivateKey = &rootlessWindowPrivateKey;
+DevPrivateKey rootlessWindowOldPixmapPrivateKey = &rootlessWindowOldPixmapPrivateKey;
/*
@@ -469,6 +471,67 @@ RootlessMarkOverlappedWindows(WindowPtr pWin, WindowPtr pFirst,
return result;
}
+ColormapPtr
+RootlessGetColormap (ScreenPtr pScreen)
+{
+ RootlessScreenRec *s = SCREENREC (pScreen);
+
+ return s->colormap;
+}
+
+static void
+RootlessInstallColormap (ColormapPtr pMap)
+{
+ ScreenPtr pScreen = pMap->pScreen;
+ RootlessScreenRec *s = SCREENREC (pScreen);
+
+ SCREEN_UNWRAP(pScreen, InstallColormap);
+
+ if (s->colormap != pMap) {
+ s->colormap = pMap;
+ s->colormap_changed = TRUE;
+ RootlessQueueRedisplay (pScreen);
+ }
+
+ pScreen->InstallColormap (pMap);
+
+ SCREEN_WRAP (pScreen, InstallColormap);
+}
+
+static void
+RootlessUninstallColormap (ColormapPtr pMap)
+{
+ ScreenPtr pScreen = pMap->pScreen;
+ RootlessScreenRec *s = SCREENREC (pScreen);
+
+ SCREEN_UNWRAP(pScreen, UninstallColormap);
+
+ if (s->colormap == pMap)
+ s->colormap = NULL;
+
+ pScreen->UninstallColormap (pMap);
+
+ SCREEN_WRAP(pScreen, UninstallColormap);
+}
+
+static void
+RootlessStoreColors (ColormapPtr pMap, int ndef, xColorItem *pdef)
+{
+ ScreenPtr pScreen = pMap->pScreen;
+ RootlessScreenRec *s = SCREENREC (pScreen);
+
+ SCREEN_UNWRAP(pScreen, StoreColors);
+
+ if (s->colormap == pMap && ndef > 0) {
+ s->colormap_changed = TRUE;
+ RootlessQueueRedisplay (pScreen);
+ }
+
+ pScreen->StoreColors (pMap, ndef, pdef);
+
+ SCREEN_WRAP(pScreen, StoreColors);
+}
+
static CARD32
RootlessRedisplayCallback(OsTimerPtr timer, CARD32 time, void *arg)
@@ -547,28 +610,14 @@ static Bool
RootlessAllocatePrivates(ScreenPtr pScreen)
{
RootlessScreenRec *s;
- static unsigned long rootlessGeneration = 0;
-
- if (rootlessGeneration != serverGeneration) {
- rootlessScreenPrivateIndex = AllocateScreenPrivateIndex();
- if (rootlessScreenPrivateIndex == -1) return FALSE;
- rootlessGCPrivateIndex = AllocateGCPrivateIndex();
- if (rootlessGCPrivateIndex == -1) return FALSE;
- rootlessWindowPrivateIndex = AllocateWindowPrivateIndex();
- if (rootlessWindowPrivateIndex == -1) return FALSE;
- rootlessGeneration = serverGeneration;
- }
// no allocation needed for screen privates
- if (!AllocateGCPrivate(pScreen, rootlessGCPrivateIndex,
- sizeof(RootlessGCRec)))
- return FALSE;
- if (!AllocateWindowPrivate(pScreen, rootlessWindowPrivateIndex, 0))
+ if (!dixRequestPrivate(rootlessGCPrivateKey, sizeof(RootlessGCRec)))
return FALSE;
s = xalloc(sizeof(RootlessScreenRec));
if (! s) return FALSE;
- SCREENREC(pScreen) = s;
+ SETSCREENREC(pScreen, s);
s->pixmap_data = NULL;
s->pixmap_data_size = 0;
@@ -583,8 +632,7 @@ RootlessAllocatePrivates(ScreenPtr pScreen)
static void
RootlessWrap(ScreenPtr pScreen)
{
- RootlessScreenRec *s = (RootlessScreenRec*)
- pScreen->devPrivates[rootlessScreenPrivateIndex].ptr;
+ RootlessScreenRec *s = SCREENREC(pScreen);
#define WRAP(a) \
if (pScreen->a) { \
@@ -614,6 +662,9 @@ RootlessWrap(ScreenPtr pScreen)
WRAP(MarkOverlappedWindows);
WRAP(ValidateTree);
WRAP(ChangeWindowAttributes);
+ WRAP(InstallColormap);
+ WRAP(UninstallColormap);
+ WRAP(StoreColors);
#ifdef SHAPE
WRAP(SetShape);
@@ -648,10 +699,11 @@ Bool RootlessInit(ScreenPtr pScreen, RootlessFrameProcsPtr procs)
if (!RootlessAllocatePrivates(pScreen))
return FALSE;
- s = (RootlessScreenRec*)
- pScreen->devPrivates[rootlessScreenPrivateIndex].ptr;
+ s = SCREENREC(pScreen);
s->imp = procs;
+ s->colormap = NULL;
+ s->redisplay_expired = FALSE;
RootlessWrap(pScreen);
diff --git a/miext/rootless/rootlessValTree.c b/miext/rootless/rootlessValTree.c
index 9fab7866b..4f16530cc 100644
--- a/miext/rootless/rootlessValTree.c
+++ b/miext/rootless/rootlessValTree.c
@@ -482,6 +482,18 @@ RootlessComputeClips (pParent, pScreen, universe, kind, exposed)
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)
+ {
+ REGION_SUBTRACT( pScreen, exposed, &pParent->clipList, universe);
+ (* pScreen->SaveDoomedAreas)(pParent, exposed, dx, dy);
+ }
+
/* HACK ALERT - copying contents of regions, instead of regions */
{
RegionRec tmp;
diff --git a/miext/rootless/rootlessWindow.c b/miext/rootless/rootlessWindow.c
index 4a3c0f6ae..b95339888 100644
--- a/miext/rootless/rootlessWindow.c
+++ b/miext/rootless/rootlessWindow.c
@@ -36,13 +36,23 @@
#include <stddef.h> /* For NULL */
#include <limits.h> /* For CHAR_BIT */
#include <assert.h>
+#ifdef __APPLE__
+//#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include "mi.h"
+#include "pixmapstr.h"
+#include "windowstr.h"
+#include <Xplugin.h>
+//#include <X11/extensions/applewm.h>
+extern int darwinMainScreenX, darwinMainScreenY;
+#endif
+#include "fb.h"
+
+#define AppleWMNumWindowLevels 5
#include "rootlessCommon.h"
#include "rootlessWindow.h"
-#include "fb.h"
-
-
#ifdef ROOTLESS_GLOBAL_COORDS
#define SCREEN_TO_GLOBAL_X \
(dixScreenOrigins[pScreen->myNum].x + rootlessGlobalOffsetX)
@@ -53,6 +63,127 @@
#define SCREEN_TO_GLOBAL_Y 0
#endif
+#define DEFINE_ATOM_HELPER(func,atom_name) \
+ static Atom func (void) { \
+ static unsigned int generation; \
+ static Atom atom; \
+ if (generation != serverGeneration) { \
+ generation = serverGeneration; \
+ atom = MakeAtom (atom_name, strlen (atom_name), TRUE); \
+ } \
+ return atom; \
+ }
+
+DEFINE_ATOM_HELPER (xa_native_screen_origin, "_NATIVE_SCREEN_ORIGIN")
+DEFINE_ATOM_HELPER (xa_native_window_id, "_NATIVE_WINDOW_ID")
+DEFINE_ATOM_HELPER (xa_apple_no_order_in, "_APPLE_NO_ORDER_IN")
+
+static Bool no_configure_window;
+static Bool windows_hidden;
+// TODO - abstract xp functions
+
+static const int normal_window_levels[AppleWMNumWindowLevels+1] = {
+ 0, 3, 4, 5, LONG_MIN + 30, LONG_MIN + 29,
+};
+static const int rooted_window_levels[AppleWMNumWindowLevels+1] = {
+ 202, 203, 204, 205, 201, 200
+};
+
+static inline int
+configure_window (xp_window_id id, unsigned int mask,
+ const xp_window_changes *values)
+{
+ if (!no_configure_window)
+ return xp_configure_window (id, mask, values);
+ else
+ return XP_Success;
+}
+
+/*static inline unsigned long
+current_time_in_seconds (void)
+{
+ unsigned long t = 0;
+
+ t += currentTime.milliseconds / 1000;
+ t += currentTime.months * 4294967;
+
+ return t;
+ } */
+
+static inline Bool
+rootlessHasRoot (ScreenPtr pScreen)
+{
+ return WINREC (WindowTable[pScreen->myNum]) != NULL;
+}
+
+void
+RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state)
+{
+ WindowPtr pWin;
+ RootlessWindowRec *winRec;
+
+ pWin = xprGetXWindow (id);
+ if (pWin == NULL) return;
+
+ winRec = WINREC (pWin);
+ if (winRec == NULL) return;
+
+ winRec->is_offscreen = ((state & XP_WINDOW_STATE_OFFSCREEN) != 0);
+ winRec->is_obscured = ((state & XP_WINDOW_STATE_OBSCURED) != 0);
+ // pWin->rootlessUnhittable = winRec->is_offscreen;
+}
+
+void
+RootlessNativeWindowMoved (WindowPtr pWin)
+{
+ xp_box bounds;
+ int sx, sy;
+ XID vlist[2];
+ Mask mask;
+ ClientPtr client;
+ RootlessWindowRec *winRec = WINREC(pWin);
+
+ if (xp_get_window_bounds (winRec->wid, &bounds) != Success) return;
+
+ sx = dixScreenOrigins[pWin->drawable.pScreen->myNum].x + darwinMainScreenX;
+ sy = dixScreenOrigins[pWin->drawable.pScreen->myNum].y + darwinMainScreenY;
+
+ /* Fake up a ConfigureWindow packet to resize the window to the current bounds. */
+
+ vlist[0] = (INT16) bounds.x1 - sx;
+ vlist[1] = (INT16) bounds.y1 - sy;
+ mask = CWX | CWY;
+
+ /* pretend we're the owner of the window! */
+ client = LookupClient (pWin->drawable.id, NullClient);
+
+ /* Don't want to do anything to the physical window (avoids
+ notification-response feedback loops) */
+
+ no_configure_window = TRUE;
+ ConfigureWindow (pWin, mask, vlist, client);
+ no_configure_window = FALSE;
+}
+
+/* Updates the _NATIVE_SCREEN_ORIGIN property on the given root window. */
+static void
+set_screen_origin (WindowPtr pWin)
+{
+ long data[2];
+
+ if (!IsRoot (pWin))
+ return;
+
+ /* FIXME: move this to an extension? */
+
+ data[0] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].x
+ + darwinMainScreenX);
+ data[1] = (dixScreenOrigins[pWin->drawable.pScreen->myNum].y
+ + darwinMainScreenY);
+
+ ChangeWindowProperty (pWin, xa_native_screen_origin (), XA_INTEGER,
+ 32, PropModeReplace, 2, data, TRUE);
+}
/*
* RootlessCreateWindow
@@ -66,7 +197,8 @@ RootlessCreateWindow(WindowPtr pWin)
Bool result;
RegionRec saveRoot;
- WINREC(pWin) = NULL;
+ SETWINREC(pWin, NULL);
+ dixSetPrivate(&pWin->devPrivates, rootlessWindowOldPixmapPrivateKey, NULL);
SCREEN_UNWRAP(pWin->drawable.pScreen, CreateWindow);
@@ -107,7 +239,7 @@ RootlessDestroyFrame(WindowPtr pWin, RootlessWindowPtr winRec)
#endif
xfree(winRec);
- WINREC(pWin) = NULL;
+ SETWINREC(pWin, NULL);
}
@@ -314,6 +446,12 @@ RootlessInitializeFrame(WindowPtr pWin, RootlessWindowRec *winRec)
}
+Bool
+RootlessColormapCallback (void *data, int first_color, int n_colors, uint32_t *colors)
+{
+ return RootlessResolveColormap (data, first_color, n_colors, colors);
+}
+
/*
* RootlessEnsureFrame
* Make sure the given window is framed. If the window doesn't have a
@@ -351,7 +489,7 @@ RootlessEnsureFrame(WindowPtr pWin)
winRec->pixmap = NULL;
winRec->wid = NULL;
- WINREC(pWin) = winRec;
+ SETWINREC(pWin, winRec);
#ifdef SHAPE
// Set the frame's shape if the window is shaped
@@ -368,10 +506,13 @@ RootlessEnsureFrame(WindowPtr pWin)
{
RL_DEBUG_MSG("implementation failed to create frame!\n");
xfree(winRec);
- WINREC(pWin) = NULL;
+ SETWINREC(pWin, NULL);
return NULL;
}
+ if (pWin->drawable.depth == 8)
+ RootlessFlushWindowColormap(pWin);
+
#ifdef SHAPE
if (pShape != NULL)
REGION_UNINIT(pScreen, &shape);
@@ -565,7 +706,6 @@ RootlessRestackWindow(WindowPtr pWin, WindowPtr pOldNextSib)
RL_DEBUG_MSG("restackwindow end\n");
}
-
/*
* Specialized window copy procedures
*/
@@ -706,13 +846,13 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
top = TopLevelParent(pWin);
if (top == NULL) {
RL_DEBUG_MSG("no parent\n");
- return;
+ goto out;
}
winRec = WINREC(top);
if (winRec == NULL) {
RL_DEBUG_MSG("not framed\n");
- return;
+ goto out;
}
/* Move region to window local coords */
@@ -735,6 +875,7 @@ RootlessCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
RootlessDamageRegion(pWin, prgnSrc);
}
+out:
REGION_UNINIT(pScreen, &rgnDst);
fbValidateDrawable(&pWin->drawable);
@@ -1296,8 +1437,8 @@ RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent)
/* Switch the frame record from one to the other. */
- WINREC(pWin) = NULL;
- WINREC(pTopWin) = winRec;
+ SETWINREC(pWin, NULL);
+ SETWINREC(pTopWin, winRec);
RootlessInitializeFrame(pTopWin, winRec);
RootlessReshapeFrame(pTopWin);
@@ -1324,6 +1465,26 @@ out:
}
}
+
+void
+RootlessFlushWindowColormap (WindowPtr pWin)
+{
+ RootlessWindowRec *winRec = WINREC (pWin);
+ xp_window_changes wc;
+
+ if (winRec == NULL)
+ return;
+
+ RootlessStopDrawing (pWin, FALSE);
+
+ /* This is how we tell xp that the colormap may have changed. */
+
+ wc.colormap = RootlessColormapCallback;
+ wc.colormap_data = pWin->drawable.pScreen;
+
+ configure_window (winRec->wid, XP_COLORMAP, &wc);
+}
+
/*
* RootlessChangeBorderWidth
* FIXME: untested!
@@ -1385,20 +1546,20 @@ RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width)
void
RootlessOrderAllWindows (void)
{
- int i;
- WindowPtr pWin;
-
- RL_DEBUG_MSG("RootlessOrderAllWindows() ");
- for (i = 0; i < screenInfo.numScreens; i++) {
- if (screenInfo.screens[i] == NULL) continue;
- pWin = WindowTable[i];
- if (pWin == NULL) continue;
+ int i;
+ WindowPtr pWin;
+
+ RL_DEBUG_MSG("RootlessOrderAllWindows() ");
+ for (i = 0; i < screenInfo.numScreens; i++) {
+ if (screenInfo.screens[i] == NULL) continue;
+ pWin = WindowTable[i];
+ if (pWin == NULL) continue;
- for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib) {
- if (!pWin->realized) continue;
- if (RootlessEnsureFrame(pWin) == NULL) continue;
- RootlessReorderWindow (pWin);
+ for (pWin = pWin->firstChild; pWin != NULL; pWin = pWin->nextSib) {
+ if (!pWin->realized) continue;
+ if (RootlessEnsureFrame(pWin) == NULL) continue;
+ RootlessReorderWindow (pWin);
+ }
}
- }
- RL_DEBUG_MSG("RootlessOrderAllWindows() done");
+ RL_DEBUG_MSG("RootlessOrderAllWindows() done");
}
diff --git a/miext/rootless/rootlessWindow.h b/miext/rootless/rootlessWindow.h
index 9573068b4..055589e79 100644
--- a/miext/rootless/rootlessWindow.h
+++ b/miext/rootless/rootlessWindow.h
@@ -36,6 +36,7 @@
#include "rootlessCommon.h"
+#include <Xplugin.h>
Bool RootlessCreateWindow(WindowPtr pWin);
Bool RootlessDestroyWindow(WindowPtr pWin);
@@ -55,5 +56,7 @@ void RootlessResizeWindow(WindowPtr pWin, int x, int y,
unsigned int w, unsigned int h, WindowPtr pSib);
void RootlessReparentWindow(WindowPtr pWin, WindowPtr pPriorParent);
void RootlessChangeBorderWidth(WindowPtr pWin, unsigned int width);
+void RootlessNativeWindowMoved (WindowPtr pWin);
+void RootlessNativeWindowStateChanged (xp_window_id id, unsigned int state);
#endif
diff --git a/miext/rootless/safeAlpha/Makefile.am b/miext/rootless/safeAlpha/Makefile.am
index 823fb777d..a22afb6a2 100644
--- a/miext/rootless/safeAlpha/Makefile.am
+++ b/miext/rootless/safeAlpha/Makefile.am
@@ -1,9 +1,5 @@
-AM_CFLAGS = \
- $(DIX_CFLAGS) \
- $(XORG_CFLAGS)
-
-INCLUDES = -I$(srcdir)/.. -I$(top_srcdir)/hw/xfree86/os-support
-
+AM_CFLAGS = $(DIX_CFLAGS) $(XSERVER_CFLAGS)
+AM_CPPFLAGS = -I$(srcdir)/.. -I$(top_srcdir)/hw/xfree86/os-support
noinst_LTLIBRARIES = libsafeAlpha.la
libsafeAlpha_la_SOURCES = safeAlphaPicture.c
diff --git a/miext/rootless/safeAlpha/safeAlphaPicture.c b/miext/rootless/safeAlpha/safeAlphaPicture.c
index 57f1ae187..8f6631531 100644
--- a/miext/rootless/safeAlpha/safeAlphaPicture.c
+++ b/miext/rootless/safeAlpha/safeAlphaPicture.c
@@ -46,6 +46,7 @@
#include "fbpict.h"
#include "safeAlpha.h"
#include "rootlessCommon.h"
+# define mod(a,b) ((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
/* Optimized version of fbCompositeSolidMask_nx8x8888 */
void
@@ -133,68 +134,78 @@ SafeAlphaCompositeSolidMask_nx8x8888(
void
SafeAlphaComposite (CARD8 op,
- PicturePtr pSrc,
- PicturePtr pMask,
- PicturePtr pDst,
- INT16 xSrc,
- INT16 ySrc,
- INT16 xMask,
- INT16 yMask,
- INT16 xDst,
- INT16 yDst,
- CARD16 width,
- CARD16 height)
+ PicturePtr pSrc,
+ PicturePtr pMask,
+ PicturePtr pDst,
+ INT16 xSrc,
+ INT16 ySrc,
+ INT16 xMask,
+ INT16 yMask,
+ INT16 xDst,
+ INT16 yDst,
+ CARD16 width,
+ CARD16 height)
{
- int oldDepth = pDst->pDrawable->depth;
- int oldFormat = pDst->format;
+ if (!pSrc) {
+ ErrorF("SafeAlphaComposite: pSrc must not be null!\n");
+ return;
+ }
+
+ if (!pDst) {
+ ErrorF("SafeAlphaComposite: pDst must not be null!\n");
+ return;
+ }
+
+ int oldDepth = pDst->pDrawable->depth;
+ int oldFormat = pDst->format;
- /*
- * We can use the more optimized fbpict code, but it sets bits above
- * the depth to zero. Temporarily adjust destination depth if needed.
- */
- if (pDst->pDrawable->type == DRAWABLE_WINDOW
- && pDst->pDrawable->depth == 24
- && pDst->pDrawable->bitsPerPixel == 32)
+ /*
+ * We can use the more optimized fbpict code, but it sets bits above
+ * the depth to zero. Temporarily adjust destination depth if needed.
+ */
+ if (pDst->pDrawable->type == DRAWABLE_WINDOW
+ && pDst->pDrawable->depth == 24
+ && pDst->pDrawable->bitsPerPixel == 32)
{
- pDst->pDrawable->depth = 32;
+ pDst->pDrawable->depth = 32;
}
- /* For rootless preserve the alpha in x8r8g8b8 which really is
- * a8r8g8b8
- */
- if (oldFormat == PICT_x8r8g8b8)
+ /* For rootless preserve the alpha in x8r8g8b8 which really is
+ * a8r8g8b8
+ */
+ if (oldFormat == PICT_x8r8g8b8)
{
- pDst->format = PICT_a8r8g8b8;
+ pDst->format = PICT_a8r8g8b8;
}
- if (pSrc && pMask && pSrc->pDrawable && pMask->pDrawable &&
- !pSrc->transform && !pMask->transform &&
- !pSrc->alphaMap && !pMask->alphaMap &&
- !pMask->repeat && !pMask->componentAlpha && !pDst->alphaMap &&
- pMask->format == PICT_a8 &&
- pSrc->repeatType == RepeatNormal &&
- pSrc->pDrawable->width == 1 &&
- pSrc->pDrawable->height == 1 &&
- (pDst->format == PICT_a8r8g8b8 ||
- pDst->format == PICT_x8r8g8b8 ||
- pDst->format == PICT_a8b8g8r8 ||
- pDst->format == PICT_x8b8g8r8))
+ if (pSrc->pDrawable && pMask && pMask->pDrawable &&
+ !pSrc->transform && !pMask->transform &&
+ !pSrc->alphaMap && !pMask->alphaMap &&
+ !pMask->repeat && !pMask->componentAlpha && !pDst->alphaMap &&
+ pMask->format == PICT_a8 &&
+ pSrc->repeatType == RepeatNormal &&
+ pSrc->pDrawable->width == 1 &&
+ pSrc->pDrawable->height == 1 &&
+ (pDst->format == PICT_a8r8g8b8 ||
+ pDst->format == PICT_x8r8g8b8 ||
+ pDst->format == PICT_a8b8g8r8 ||
+ pDst->format == PICT_x8b8g8r8))
{
- fbWalkCompositeRegion (op, pSrc, pMask, pDst,
- xSrc, ySrc, xMask, yMask, xDst, yDst,
- width, height,
- TRUE /* srcRepeat */,
- FALSE /* maskRepeat */,
- SafeAlphaCompositeSolidMask_nx8x8888);
+ fbWalkCompositeRegion (op, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst,
+ width, height,
+ TRUE /* srcRepeat */,
+ FALSE /* maskRepeat */,
+ SafeAlphaCompositeSolidMask_nx8x8888);
}
- else
+ else
{
- fbComposite (op, pSrc, pMask, pDst,
- xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
+ fbComposite (op, pSrc, pMask, pDst,
+ xSrc, ySrc, xMask, yMask, xDst, yDst, width, height);
}
- pDst->pDrawable->depth = oldDepth;
- pDst->format = oldFormat;
+ pDst->pDrawable->depth = oldDepth;
+ pDst->format = oldFormat;
}
#endif /* RENDER */
diff --git a/miext/shadow/shadow.c b/miext/shadow/shadow.c
index 8aa192f62..ef0df4091 100644
--- a/miext/shadow/shadow.c
+++ b/miext/shadow/shadow.c
@@ -36,8 +36,7 @@
#include "gcstruct.h"
#include "shadow.h"
-int shadowScrPrivateIndex;
-int shadowGeneration;
+DevPrivateKey shadowScrPrivateKey = &shadowScrPrivateKey;
#define wrap(priv, real, mem) {\
priv->mem = real->mem; \
@@ -116,7 +115,8 @@ static void
shadowReportFunc(DamagePtr pDamage, RegionPtr pRegion, void *closure)
{
ScreenPtr pScreen = closure;
- shadowBufPtr pBuf = pScreen->devPrivates[shadowScrPrivateIndex].ptr;
+ shadowBufPtr pBuf = (shadowBufPtr)
+ dixLookupPrivate(&pScreen->devPrivates, shadowScrPrivateKey);
/* Register the damaged region, use DamageReportNone below when we
* want to break BC below... */
@@ -138,13 +138,6 @@ shadowSetup(ScreenPtr pScreen)
if (!DamageSetup(pScreen))
return FALSE;
- if (shadowGeneration != serverGeneration) {
- shadowScrPrivateIndex = AllocateScreenPrivateIndex();
- if (shadowScrPrivateIndex == -1)
- return FALSE;
- shadowGeneration = serverGeneration;
- }
-
pBuf = (shadowBufPtr) xalloc(sizeof(shadowBufRec));
if (!pBuf)
return FALSE;
@@ -175,7 +168,7 @@ shadowSetup(ScreenPtr pScreen)
REGION_NULL(pScreen, &pBuf->damage); /* bc */
#endif
- pScreen->devPrivates[shadowScrPrivateIndex].ptr = (pointer) pBuf;
+ dixSetPrivate(&pScreen->devPrivates, shadowScrPrivateKey, pBuf);
return TRUE;
}
diff --git a/miext/shadow/shadow.h b/miext/shadow/shadow.h
index 8986809f4..2e45df2b5 100644
--- a/miext/shadow/shadow.h
+++ b/miext/shadow/shadow.h
@@ -74,9 +74,10 @@ typedef struct _shadowBuf {
#define SHADOW_REFLECT_Y 32
#define SHADOW_REFLECT_ALL (SHADOW_REFLECT_X|SHADOW_REFLECT_Y)
-extern int shadowScrPrivateIndex;
+extern DevPrivateKey shadowScrPrivateKey;
-#define shadowGetBuf(pScr) ((shadowBufPtr) (pScr)->devPrivates[shadowScrPrivateIndex].ptr)
+#define shadowGetBuf(pScr) ((shadowBufPtr) \
+ dixLookupPrivate(&(pScr)->devPrivates, shadowScrPrivateKey))
#define shadowBuf(pScr) shadowBufPtr pBuf = shadowGetBuf(pScr)
#define shadowDamage(pBuf) DamageRegion(pBuf->pDamage)