diff options
-rw-r--r-- | dix/cursor.c | 14 | ||||
-rw-r--r-- | hw/darwin/iokit/xfIOKitCursor.c | 20 | ||||
-rw-r--r-- | hw/darwin/quartz/fullscreen/quartzCursor.c | 10 | ||||
-rw-r--r-- | hw/darwin/quartz/quartzCursor.c | 10 | ||||
-rw-r--r-- | hw/dmx/dmxcursor.c | 8 | ||||
-rw-r--r-- | hw/dmx/dmxcursor.h | 7 | ||||
-rw-r--r-- | hw/xfree86/modes/xf86Cursors.c | 5 | ||||
-rw-r--r-- | hw/xfree86/ramdac/xf86Cursor.c | 6 | ||||
-rw-r--r-- | hw/xfree86/ramdac/xf86HWCurs.c | 4 | ||||
-rw-r--r-- | hw/xgl/glx/xglx.c | 4 | ||||
-rw-r--r-- | hw/xnest/Cursor.c | 6 | ||||
-rw-r--r-- | hw/xnest/XNCursor.h | 9 | ||||
-rw-r--r-- | include/cursorstr.h | 6 | ||||
-rw-r--r-- | mi/midispcur.c | 17 |
14 files changed, 75 insertions, 51 deletions
diff --git a/dix/cursor.c b/dix/cursor.c index b188e3f98..324faa169 100644 --- a/dix/cursor.c +++ b/dix/cursor.c @@ -99,6 +99,7 @@ FreeCursorBits(CursorBitsPtr bits) CloseFont(this->font, (Font)0); xfree(this); } + dixFreePrivates(bits->devPrivates); xfree(bits); } } @@ -124,6 +125,7 @@ FreeCursor(pointer value, XID cid) pscr = screenInfo.screens[nscr]; (void)( *pscr->UnrealizeCursor)( pscr, pCurs); } + dixFreePrivates(pCurs->devPrivates); FreeCursorBits(pCurs->bits); xfree( pCurs); return(Success); @@ -192,9 +194,9 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits, bits->height = cm->height; bits->xhot = cm->xhot; bits->yhot = cm->yhot; + bits->devPrivates = NULL; bits->refcnt = -1; CheckForEmptyMask(bits); - pCurs->bits = bits; pCurs->refcnt = 1; #ifdef XFIXES @@ -210,10 +212,14 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits, pCurs->backGreen = backGreen; pCurs->backBlue = backBlue; + pCurs->devPrivates = NULL; + pCurs->id = cid; + /* security creation/labeling check */ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, DixCreateAccess, pCurs); if (rc != Success) { + dixFreePrivates(pCurs->devPrivates); FreeCursorBits(bits); xfree(pCurs); return rc; @@ -232,6 +238,7 @@ AllocARGBCursor(unsigned char *psrcbits, unsigned char *pmaskbits, pscr = screenInfo.screens[nscr]; ( *pscr->UnrealizeCursor)( pscr, pCurs); } + dixFreePrivates(pCurs->devPrivates); FreeCursorBits(bits); xfree(pCurs); return BadAlloc; @@ -394,10 +401,14 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, pCurs->backGreen = backGreen; pCurs->backBlue = backBlue; + pCurs->id = cid; + pCurs->devPrivates = NULL; + /* security creation/labeling check */ rc = XaceHook(XACE_RESOURCE_ACCESS, client, cid, RT_CURSOR, DixCreateAccess, pCurs); if (rc != Success) { + dixFreePrivates(pCurs->devPrivates); FreeCursorBits(bits); xfree(pCurs); return rc; @@ -416,6 +427,7 @@ AllocGlyphCursor(Font source, unsigned sourceChar, Font mask, unsigned maskChar, pscr = screenInfo.screens[nscr]; ( *pscr->UnrealizeCursor)( pscr, pCurs); } + dixFreePrivates(pCurs->devPrivates); FreeCursorBits(pCurs->bits); xfree(pCurs); return BadAlloc; diff --git a/hw/darwin/iokit/xfIOKitCursor.c b/hw/darwin/iokit/xfIOKitCursor.c index 224710114..3101a8932 100644 --- a/hw/darwin/iokit/xfIOKitCursor.c +++ b/hw/darwin/iokit/xfIOKitCursor.c @@ -202,7 +202,7 @@ XFIOKitRealizeCursor8( } // save the result - pCursor->devPriv[pScreen->myNum] = (pointer) newCursor; + dixSetPrivate(&pCursor->devPrivates, pScreen, newCursor); return TRUE; } @@ -285,7 +285,7 @@ XFIOKitRealizeCursor15( #endif // save the result - pCursor->devPriv[pScreen->myNum] = (pointer) newCursor; + dixSetPrivate(&pCursor->devPrivates, pScreen, newCursor); return TRUE; } @@ -369,7 +369,7 @@ XFIOKitRealizeCursor24( #endif // save the result - pCursor->devPriv[pScreen->myNum] = (pointer) newCursor; + dixSetPrivate(&pCursor->devPrivates, pScreen, newCursor); return TRUE; } @@ -422,7 +422,7 @@ XFIOKitUnrealizeCursor( !ScreenPriv->canHWCursor) { result = (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pScreen, pCursor); } else { - xfree( pCursor->devPriv[pScreen->myNum] ); + xfree(dixLookupPrivate(&pCursor->devPrivates, pScreen)); result = TRUE; } @@ -476,20 +476,20 @@ XFIOKitSetCursor( // change the cursor image in shared memory if (dfb->bitsPerPixel == 8) { - cursorPrivPtr newCursor = - (cursorPrivPtr) pCursor->devPriv[pScreen->myNum]; + cursorPrivPtr newCursor = dixLookupPrivate(&pCursor->devPrivates, + pScreen); memcpy(cshmem->cursor.bw8.image[0], newCursor->image, CURSORWIDTH*CURSORHEIGHT); memcpy(cshmem->cursor.bw8.mask[0], newCursor->mask, CURSORWIDTH*CURSORHEIGHT); } else if (dfb->bitsPerPixel == 16) { - unsigned short *newCursor = - (unsigned short *) pCursor->devPriv[pScreen->myNum]; + unsigned short *newCursor = dixLookupPrivate(&pCursor->devPrivates, + pScreen); memcpy(cshmem->cursor.rgb.image[0], newCursor, 2*CURSORWIDTH*CURSORHEIGHT); } else { - unsigned int *newCursor = - (unsigned int *) pCursor->devPriv[pScreen->myNum]; + unsigned int *newCursor = dixLookupPrivate(&pCursor->devPrivates, + pScreen); memcpy(cshmem->cursor.rgb24.image[0], newCursor, 4*CURSORWIDTH*CURSORHEIGHT); } diff --git a/hw/darwin/quartz/fullscreen/quartzCursor.c b/hw/darwin/quartz/fullscreen/quartzCursor.c index bee83b875..797149ef9 100644 --- a/hw/darwin/quartz/fullscreen/quartzCursor.c +++ b/hw/darwin/quartz/fullscreen/quartzCursor.c @@ -318,7 +318,7 @@ QuartzRealizeCursor( if (!qdCursor) return FALSE; // save the result - pCursor->devPriv[pScreen->myNum] = (pointer) qdCursor; + dixSetPrivate(&pCursor->devPrivates, pScreen, qdCursor); return TRUE; } @@ -345,13 +345,13 @@ QuartzUnrealizeCursor( (pScreen, pCursor); } } else { - CCrsrHandle oldCursor = (CCrsrHandle) pCursor->devPriv[pScreen->myNum]; - + CCrsrHandle oldCursor = dixLookupPrivate(&pCursor->devPrivates, + pScreen); if (currentCursor != oldCursor) { // This should only fail when quitting, in which case we just leak. FreeQDCursor(oldCursor); } - pCursor->devPriv[pScreen->myNum] = NULL; + dixSetPrivate(&pCursor->devPrivates, pScreen, NULL); return TRUE; } } @@ -391,7 +391,7 @@ QuartzSetCursor( (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y); ScreenPriv->qdCursorMode = TRUE; - CHANGE_QD_CURSOR(pCursor->devPriv[pScreen->myNum]); + CHANGE_QD_CURSOR(dixLookupPrivate(&pCursor->devPrivates, pScreen)); SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible); } else if (quartzRootless) { diff --git a/hw/darwin/quartz/quartzCursor.c b/hw/darwin/quartz/quartzCursor.c index a121ce17c..aa7ce2295 100644 --- a/hw/darwin/quartz/quartzCursor.c +++ b/hw/darwin/quartz/quartzCursor.c @@ -321,7 +321,7 @@ QuartzRealizeCursor( if (!qdCursor) return FALSE; // save the result - pCursor->devPriv[pScreen->myNum] = (pointer) qdCursor; + dixSetPrivate(&pCursor->devPrivates, pScreen, qdCursor); return TRUE; } @@ -348,13 +348,13 @@ QuartzUnrealizeCursor( (pScreen, pCursor); } } else { - CCrsrHandle oldCursor = (CCrsrHandle) pCursor->devPriv[pScreen->myNum]; - + CCrsrHandle oldCursor = dixLookupPrivate(&pCursor->devPrivates, + pScreen); if (currentCursor != oldCursor) { // This should only fail when quitting, in which case we just leak. FreeQDCursor(oldCursor); } - pCursor->devPriv[pScreen->myNum] = NULL; + dixSetPrivate(&pCursor->devPrivates, pScreen, NULL); return TRUE; } } @@ -394,7 +394,7 @@ QuartzSetCursor( (*ScreenPriv->spriteFuncs->SetCursor)(pScreen, 0, x, y); ScreenPriv->qdCursorMode = TRUE; - CHANGE_QD_CURSOR(pCursor->devPriv[pScreen->myNum]); + CHANGE_QD_CURSOR(dixLookupPrivate(&pCursor->devPrivates, pScreen)); SHOW_QD_CURSOR(pScreen, ScreenPriv->qdCursorVisible); } else if (quartzRootless) { diff --git a/hw/dmx/dmxcursor.c b/hw/dmx/dmxcursor.c index 1ad199d58..8a801169c 100644 --- a/hw/dmx/dmxcursor.c +++ b/hw/dmx/dmxcursor.c @@ -662,8 +662,8 @@ static Bool _dmxRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) DMXDBG2("_dmxRealizeCursor(%d,%p)\n", pScreen->myNum, pCursor); - pCursor->devPriv[pScreen->myNum] = xalloc(sizeof(*pCursorPriv)); - if (!pCursor->devPriv[pScreen->myNum]) + DMX_SET_CURSOR_PRIV(pCursor, pScreen, xalloc(sizeof(*pCursorPriv))); + if (!DMX_GET_CURSOR_PRIV(pCursor, pScreen)) return FALSE; pCursorPriv = DMX_GET_CURSOR_PRIV(pCursor, pScreen); @@ -700,9 +700,9 @@ static Bool _dmxUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) if (dmxScreen->beDisplay) { if (dmxBEFreeCursor(pScreen, pCursor)) - xfree(pCursor->devPriv[pScreen->myNum]); + xfree(DMX_GET_CURSOR_PRIV(pCursor, pScreen)); } - pCursor->devPriv[pScreen->myNum] = NULL; + DMX_SET_CURSOR_PRIV(pCursor, pScreen, NULL); return TRUE; } diff --git a/hw/dmx/dmxcursor.h b/hw/dmx/dmxcursor.h index 7b70c6250..d909bd01e 100644 --- a/hw/dmx/dmxcursor.h +++ b/hw/dmx/dmxcursor.h @@ -63,7 +63,10 @@ extern void dmxHideCursor(DMXScreenInfo *dmxScreen); extern void dmxBECreateCursor(ScreenPtr pScreen, CursorPtr pCursor); extern Bool dmxBEFreeCursor(ScreenPtr pScreen, CursorPtr pCursor); -#define DMX_GET_CURSOR_PRIV(_pCursor, _pScreen) \ - (dmxCursorPrivPtr)(_pCursor)->devPriv[(_pScreen)->myNum] +#define DMX_GET_CURSOR_PRIV(_pCursor, _pScreen) \ + ((dmxCursorPrivPtr)dixLookupPrivate(&(_pCursor)->devPrivates, _pScreen)) + +#define DMX_SET_CURSOR_PRIV(_pCursor, _pScreen, v) \ + dixSetPrivate(&(_pCursor)->devPrivates, _pScreen, v) #endif /* DMXCURSOR_H */ diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c index b5101642b..acf34c1d1 100644 --- a/hw/xfree86/modes/xf86Cursors.c +++ b/hw/xfree86/modes/xf86Cursors.c @@ -226,7 +226,8 @@ xf86_set_cursor_colors (ScrnInfoPtr scrn, int bg, int fg) xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); CursorPtr cursor = xf86_config->cursor; int c; - CARD8 *bits = cursor ? cursor->devPriv[screen->myNum] : NULL; + CARD8 *bits = cursor ? dixLookupPrivate(&cursor->devPrivates, + screen) : NULL; /* Save ARGB versions of these colors */ xf86_config->cursor_fg = (CARD32) fg | 0xff000000; @@ -612,7 +613,7 @@ xf86_reload_cursors (ScreenPtr screen) else #endif (*cursor_info->LoadCursorImage)(cursor_info->pScrn, - cursor->devPriv[screen->myNum]); + dixLookupPrivate(&cursor->devPrivates, screen)); (*cursor_info->SetCursorPosition)(cursor_info->pScrn, x, y); (*cursor_info->ShowCursor)(cursor_info->pScrn); diff --git a/hw/xfree86/ramdac/xf86Cursor.c b/hw/xfree86/ramdac/xf86Cursor.c index 1c2d6a869..5b1ce5e1f 100644 --- a/hw/xfree86/ramdac/xf86Cursor.c +++ b/hw/xfree86/ramdac/xf86Cursor.c @@ -251,7 +251,7 @@ xf86CursorRealizeCursor(ScreenPtr pScreen, CursorPtr pCurs) &pScreen->devPrivates, xf86CursorScreenKey); if (pCurs->refcnt <= 1) - pCurs->devPriv[pScreen->myNum] = NULL; + dixSetPrivate(&pCurs->devPrivates, pScreen, NULL); return (*ScreenPriv->spriteFuncs->RealizeCursor)(pScreen, pCurs); } @@ -263,8 +263,8 @@ xf86CursorUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCurs) &pScreen->devPrivates, xf86CursorScreenKey); if (pCurs->refcnt <= 1) { - xfree(pCurs->devPriv[pScreen->myNum]); - pCurs->devPriv[pScreen->myNum] = NULL; + xfree(dixLookupPrivate(&pCurs->devPrivates, pScreen)); + dixSetPrivate(&pCurs->devPrivates, pScreen, NULL); } return (*ScreenPriv->spriteFuncs->UnrealizeCursor)(pScreen, pCurs); diff --git a/hw/xfree86/ramdac/xf86HWCurs.c b/hw/xfree86/ramdac/xf86HWCurs.c index 0a753be3f..d10e283d7 100644 --- a/hw/xfree86/ramdac/xf86HWCurs.c +++ b/hw/xfree86/ramdac/xf86HWCurs.c @@ -123,7 +123,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) return; } - bits = pCurs->devPriv[pScreen->myNum]; + bits = (unsigned char *)dixLookupPrivate(&pCurs->devPrivates, pScreen); x -= infoPtr->pScrn->frameX0 + ScreenPriv->HotX; y -= infoPtr->pScrn->frameY0 + ScreenPriv->HotY; @@ -133,7 +133,7 @@ xf86SetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y) #endif if (!bits) { bits = (*infoPtr->RealizeCursor)(infoPtr, pCurs); - pCurs->devPriv[pScreen->myNum] = bits; + dixSetPrivate(&pCurs->devPrivates, pScreen, bits); } if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN)) diff --git a/hw/xgl/glx/xglx.c b/hw/xgl/glx/xglx.c index 657afc075..d7f0ed3f9 100644 --- a/hw/xgl/glx/xglx.c +++ b/hw/xgl/glx/xglx.c @@ -121,10 +121,10 @@ typedef struct _xglxCursor { } xglxCursorRec, *xglxCursorPtr; #define XGLX_GET_CURSOR_PRIV(pCursor, pScreen) \ - ((xglxCursorPtr) (pCursor)->devPriv[(pScreen)->myNum]) + ((xglxCursorPtr)dixLookupPrivate(&(pCursor)->devPrivates, pScreen)) #define XGLX_SET_CURSOR_PRIV(pCursor, pScreen, v) \ - ((pCursor)->devPriv[(pScreen)->myNum] = (pointer) v) + dixSetPrivate(&(pCursor)->devPrivates, pScreen, v) #define XGLX_CURSOR_PRIV(pCursor, pScreen) \ xglxCursorPtr pCursorPriv = XGLX_GET_CURSOR_PRIV (pCursor, pScreen) diff --git a/hw/xnest/Cursor.c b/hw/xnest/Cursor.c index 134276e7b..138698068 100644 --- a/hw/xnest/Cursor.c +++ b/hw/xnest/Cursor.c @@ -104,8 +104,8 @@ xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) bg_color.green = pCursor->backGreen; bg_color.blue = pCursor->backBlue; - pCursor->devPriv[pScreen->myNum] = (pointer)xalloc(sizeof(xnestPrivCursor)); - xnestCursorPriv(pCursor, pScreen)->cursor = + xnestSetCursorPriv(pCursor, pScreen, xalloc(sizeof(xnestPrivCursor))); + xnestCursor(pCursor, pScreen) = XCreatePixmapCursor(xnestDisplay, source, mask, &fg_color, &bg_color, pCursor->bits->xhot, pCursor->bits->yhot); @@ -119,7 +119,7 @@ Bool xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor) { XFreeCursor(xnestDisplay, xnestCursor(pCursor, pScreen)); - xfree(xnestCursorPriv(pCursor, pScreen)); + xfree(xnestGetCursorPriv(pCursor, pScreen)); return True; } diff --git a/hw/xnest/XNCursor.h b/hw/xnest/XNCursor.h index ffec9eb0a..9705f6bea 100644 --- a/hw/xnest/XNCursor.h +++ b/hw/xnest/XNCursor.h @@ -19,11 +19,14 @@ typedef struct { Cursor cursor; } xnestPrivCursor; -#define xnestCursorPriv(pCursor, pScreen) \ - ((xnestPrivCursor *)((pCursor)->devPriv[pScreen->myNum])) +#define xnestGetCursorPriv(pCursor, pScreen) \ + ((xnestPrivCursor *)dixLookupPrivate(&(pCursor)->devPrivates, pScreen)) + +#define xnestSetCursorPriv(pCursor, pScreen, v) \ + dixSetPrivate(&(pCursor)->devPrivates, pScreen, v) #define xnestCursor(pCursor, pScreen) \ - (xnestCursorPriv(pCursor, pScreen)->cursor) + (xnestGetCursorPriv(pCursor, pScreen)->cursor) Bool xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); Bool xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor); diff --git a/include/cursorstr.h b/include/cursorstr.h index b7beaa0c5..bca35969b 100644 --- a/include/cursorstr.h +++ b/include/cursorstr.h @@ -49,6 +49,7 @@ SOFTWARE. #define CURSORSTRUCT_H #include "cursor.h" +#include "privates.h" /* * device-independent cursor storage */ @@ -63,7 +64,7 @@ typedef struct _CursorBits { Bool emptyMask; /* all zeros mask */ unsigned short width, height, xhot, yhot; /* metrics */ int refcnt; /* can be shared */ - pointer devPriv[MAXSCREENS]; /* set by pScr->RealizeCursor*/ + PrivateRec *devPrivates; /* set by pScr->RealizeCursor*/ #ifdef ARGB_CURSOR CARD32 *argb; /* full-color alpha blended */ #endif @@ -74,7 +75,8 @@ typedef struct _Cursor { unsigned short foreRed, foreGreen, foreBlue; /* device-independent color */ unsigned short backRed, backGreen, backBlue; /* device-independent color */ int refcnt; - pointer devPriv[MAXSCREENS]; /* set by pScr->RealizeCursor*/ + PrivateRec *devPrivates; /* set by pScr->RealizeCursor*/ + XID id; #ifdef XFIXES CARD32 serialNumber; Atom name; diff --git a/mi/midispcur.c b/mi/midispcur.c index 8b782925a..f974c0845 100644 --- a/mi/midispcur.c +++ b/mi/midispcur.c @@ -190,7 +190,7 @@ miDCRealizeCursor (pScreen, pCursor) CursorPtr pCursor; { if (pCursor->bits->refcnt <= 1) - pCursor->bits->devPriv[pScreen->myNum] = (pointer)NULL; + dixSetPrivate(&pCursor->bits->devPrivates, pScreen, NULL); return TRUE; } @@ -290,7 +290,7 @@ miDCRealize ( xfree ((pointer) pPriv); return (miDCCursorPtr)NULL; } - pCursor->bits->devPriv[pScreen->myNum] = (pointer) pPriv; + dixSetPrivate(&pCursor->bits->devPrivates, pScreen, pPriv); return pPriv; } pPriv->pPicture = 0; @@ -308,7 +308,7 @@ miDCRealize ( xfree ((pointer) pPriv); return (miDCCursorPtr)NULL; } - pCursor->bits->devPriv[pScreen->myNum] = (pointer) pPriv; + dixSetPrivate(&pCursor->bits->devPrivates, pScreen, pPriv); /* create the two sets of bits, clipping as appropriate */ @@ -354,7 +354,8 @@ miDCUnrealizeCursor (pScreen, pCursor) { miDCCursorPtr pPriv; - pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum]; + pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates, + pScreen); if (pPriv && (pCursor->bits->refcnt <= 1)) { if (pPriv->sourceBits) @@ -366,7 +367,7 @@ miDCUnrealizeCursor (pScreen, pCursor) FreePicture (pPriv->pPicture, 0); #endif xfree ((pointer) pPriv); - pCursor->bits->devPriv[pScreen->myNum] = (pointer)NULL; + dixSetPrivate(&pCursor->bits->devPrivates, pScreen, NULL); } return TRUE; } @@ -461,7 +462,8 @@ miDCPutUpCursor (pScreen, pCursor, x, y, source, mask) miDCCursorPtr pPriv; WindowPtr pWin; - pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum]; + pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates, + pScreen); if (!pPriv) { pPriv = miDCRealize(pScreen, pCursor); @@ -711,7 +713,8 @@ miDCMoveCursor (pScreen, pCursor, x, y, w, h, dx, dy, source, mask) XID gcval = FALSE; PixmapPtr pTemp; - pPriv = (miDCCursorPtr) pCursor->bits->devPriv[pScreen->myNum]; + pPriv = (miDCCursorPtr)dixLookupPrivate(&pCursor->bits->devPrivates, + pScreen); if (!pPriv) { pPriv = miDCRealize(pScreen, pCursor); |