[PATCH 6/7] Create separate private key for midispcur cursor bits

Keith Packard keithp at keithp.com
Wed May 12 14:45:10 PDT 2010


The CursorScreenKey array is supposed to be used by the DDX for cursor
private data, but midispcur was abusing it to hold cursor bits private
information. Create a separate set of privates for the dispcur cursor
bits information.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 mi/midispcur.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/mi/midispcur.c b/mi/midispcur.c
index 06bddec..acb4ce4 100644
--- a/mi/midispcur.c
+++ b/mi/midispcur.c
@@ -59,6 +59,9 @@ static DevPrivateKey miDCScreenKey = &miDCScreenKeyIndex;
 
 static Bool	miDCCloseScreen(int index, ScreenPtr pScreen);
 
+/* per bits per-screen private data */
+static int miDCCursorBitsKeyIndex[MAXSCREENS];
+
 /* per device per-screen private data */
 static int miDCSpriteKeyIndex[MAXSCREENS];
 static DevPrivateKey miDCSpriteKey = miDCSpriteKeyIndex;
@@ -80,6 +83,9 @@ typedef struct {
   (miDCBufferPtr)dixLookupPrivate(&dev->devPrivates, miDCSpriteKey + (screen)->myNum) : \
   (miDCBufferPtr)dixLookupPrivate(&dev->u.master->devPrivates, miDCSpriteKey + (screen)->myNum))
 
+#define MIDCBITS(screen) \
+    (miDCCursorBitsKeyIndex + (screen)->myNum)
+
 /* 
  * The core pointer buffer will point to the index of the virtual core pointer
  * in the pCursorBuffers array. 
@@ -174,7 +180,7 @@ static Bool
 miDCRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
 {
     if (pCursor->bits->refcnt <= 1)
-	dixSetPrivate(&pCursor->bits->devPrivates, CursorScreenKey(pScreen), NULL);
+	dixSetPrivate(&pCursor->bits->devPrivates, MIDCBITS(pScreen), NULL);
     return TRUE;
 }
 
@@ -272,7 +278,7 @@ miDCRealize (ScreenPtr pScreen, CursorPtr pCursor)
 	    free((pointer) pPriv);
 	    return NULL;
 	}
-	dixSetPrivate(&pCursor->bits->devPrivates, CursorScreenKey(pScreen), pPriv);
+	dixSetPrivate(&pCursor->bits->devPrivates, MIDCBITS(pScreen), pPriv);
 	return pPriv;
     }
     pPriv->pPicture = 0;
@@ -290,7 +296,7 @@ miDCRealize (ScreenPtr pScreen, CursorPtr pCursor)
 	free((pointer) pPriv);
 	return NULL;
     }
-    dixSetPrivate(&pCursor->bits->devPrivates, CursorScreenKey(pScreen), pPriv);
+    dixSetPrivate(&pCursor->bits->devPrivates, MIDCBITS(pScreen), pPriv);
 
     /* create the two sets of bits, clipping as appropriate */
 
@@ -335,7 +341,7 @@ miDCUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
     miDCCursorPtr   pPriv;
 
     pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
-					    CursorScreenKey(pScreen));
+					    MIDCBITS(pScreen));
     if (pPriv && (pCursor->bits->refcnt <= 1))
     {
 	if (pPriv->sourceBits)
@@ -347,7 +353,7 @@ miDCUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
 	    FreePicture (pPriv->pPicture, 0);
 #endif
 	free((pointer) pPriv);
-	dixSetPrivate(&pCursor->bits->devPrivates, CursorScreenKey(pScreen), NULL);
+	dixSetPrivate(&pCursor->bits->devPrivates, MIDCBITS(pScreen), NULL);
     }
     return TRUE;
 }
@@ -436,7 +442,7 @@ miDCPutUpCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
     WindowPtr	    pWin;
 
     pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
-					    CursorScreenKey(pScreen));
+					    MIDCBITS(pScreen));
     if (!pPriv)
     {
 	pPriv = miDCRealize(pScreen, pCursor);
@@ -680,7 +686,7 @@ miDCMoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor,
     PixmapPtr	    pTemp;
 
     pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates,
-					    CursorScreenKey(pScreen));
+					    MIDCBITS(pScreen));
     if (!pPriv)
     {
 	pPriv = miDCRealize(pScreen, pCursor);
-- 
1.7.1



More information about the xorg-devel mailing list