xfree86: use own dev-privates key for per-screen cursor
Since it's storing an locally defined (ddx-internal) data, it's better not to abuse some globally defined key for this. It just happened to work before, since CursorScreenKey is only used by DDX (and there's only one DDX per executable) and they currently (!) have the same size (pointer) - but that's a fragile programming style, so clean it up. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net> Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1342>
This commit is contained in:
		
							parent
							
								
									49d139344d
								
							
						
					
					
						commit
						6557286084
					
				| 
						 | 
				
			
			@ -301,7 +301,8 @@ xf86_set_cursor_colors(ScrnInfoPtr scrn, int bg, int fg)
 | 
			
		|||
    CursorPtr cursor = xf86CurrentCursor(screen);
 | 
			
		||||
    int c;
 | 
			
		||||
    CARD8 *bits = cursor ?
 | 
			
		||||
        dixLookupScreenPrivate(&cursor->devPrivates, CursorScreenKey, screen)
 | 
			
		||||
        dixLookupScreenPrivate(&cursor->devPrivates,
 | 
			
		||||
                               &xf86ScreenCursorBitsKeyRec, screen)
 | 
			
		||||
        : NULL;
 | 
			
		||||
 | 
			
		||||
    /* Save ARGB versions of these colors */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,4 +48,6 @@ extern _X_EXPORT DevPrivateKeyRec xf86CursorScreenKeyRec;
 | 
			
		|||
 | 
			
		||||
#define xf86CursorScreenKey (&xf86CursorScreenKeyRec)
 | 
			
		||||
 | 
			
		||||
extern DevScreenPrivateKeyRec xf86ScreenCursorBitsKeyRec;
 | 
			
		||||
 | 
			
		||||
#endif                          /* _XF86CURSORPRIV_H */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,6 +18,7 @@
 | 
			
		|||
#include "inputstr.h"
 | 
			
		||||
 | 
			
		||||
DevPrivateKeyRec xf86CursorScreenKeyRec;
 | 
			
		||||
DevScreenPrivateKeyRec xf86ScreenCursorBitsKeyRec;
 | 
			
		||||
 | 
			
		||||
/* sprite functions */
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -68,6 +69,10 @@ xf86InitCursor(ScreenPtr pScreen, xf86CursorInfoPtr infoPtr)
 | 
			
		|||
    if (!ScreenPriv)
 | 
			
		||||
        return FALSE;
 | 
			
		||||
 | 
			
		||||
    if (!dixRegisterScreenPrivateKey(&xf86ScreenCursorBitsKeyRec, pScreen,
 | 
			
		||||
                                     PRIVATE_CURSOR, 0))
 | 
			
		||||
        return FALSE;
 | 
			
		||||
 | 
			
		||||
    dixSetPrivate(&pScreen->devPrivates, xf86CursorScreenKey, ScreenPriv);
 | 
			
		||||
 | 
			
		||||
    ScreenPriv->SWCursor = TRUE;
 | 
			
		||||
| 
						 | 
				
			
			@ -273,8 +278,8 @@ xf86CursorRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs)
 | 
			
		|||
                                               xf86CursorScreenKey);
 | 
			
		||||
 | 
			
		||||
    if (CursorRefCount(pCurs) <= 1)
 | 
			
		||||
        dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen,
 | 
			
		||||
                            NULL);
 | 
			
		||||
        dixSetScreenPrivate(&pCurs->devPrivates, &xf86ScreenCursorBitsKeyRec,
 | 
			
		||||
                            pScreen, NULL);
 | 
			
		||||
 | 
			
		||||
    return (*ScreenPriv->spriteFuncs->RealizeCursor) (pDev, pScreen, pCurs);
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -288,9 +293,9 @@ xf86CursorUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCurs)
 | 
			
		|||
 | 
			
		||||
    if (CursorRefCount(pCurs) <= 1) {
 | 
			
		||||
        free(dixLookupScreenPrivate
 | 
			
		||||
             (&pCurs->devPrivates, CursorScreenKey, pScreen));
 | 
			
		||||
        dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen,
 | 
			
		||||
                            NULL);
 | 
			
		||||
             (&pCurs->devPrivates, &xf86ScreenCursorBitsKeyRec, pScreen));
 | 
			
		||||
        dixSetScreenPrivate(&pCurs->devPrivates, &xf86ScreenCursorBitsKeyRec,
 | 
			
		||||
                            pScreen, NULL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return (*ScreenPriv->spriteFuncs->UnrealizeCursor) (pDev, pScreen, pCurs);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -197,15 +197,15 @@ xf86ScreenSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Hot plugged GPU's do not have a CursorScreenKey, force sw cursor.
 | 
			
		||||
     * Hot plugged GPU's do not have a xf86ScreenCursorBitsKeyRec, force sw cursor.
 | 
			
		||||
     * This check can be removed once dix/privates.c gets relocation code for
 | 
			
		||||
     * PRIVATE_CURSOR. Also see the related comment in AddGPUScreen().
 | 
			
		||||
     */
 | 
			
		||||
    if (!_dixGetScreenPrivateKey(CursorScreenKey, pScreen))
 | 
			
		||||
    if (!_dixGetScreenPrivateKey(&xf86ScreenCursorBitsKeyRec, pScreen))
 | 
			
		||||
        return FALSE;
 | 
			
		||||
 | 
			
		||||
    bits =
 | 
			
		||||
        dixLookupScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen);
 | 
			
		||||
    bits = dixLookupScreenPrivate(&pCurs->devPrivates,
 | 
			
		||||
                                  &xf86ScreenCursorBitsKeyRec, pScreen);
 | 
			
		||||
 | 
			
		||||
    x -= infoPtr->pScrn->frameX0;
 | 
			
		||||
    y -= infoPtr->pScrn->frameY0;
 | 
			
		||||
| 
						 | 
				
			
			@ -213,8 +213,8 @@ xf86ScreenSetCursor(ScreenPtr pScreen, CursorPtr pCurs, int x, int y)
 | 
			
		|||
    if (!pCurs->bits->argb || !xf86DriverHasLoadCursorARGB(infoPtr))
 | 
			
		||||
        if (!bits) {
 | 
			
		||||
            bits = (*infoPtr->RealizeCursor) (infoPtr, pCurs);
 | 
			
		||||
            dixSetScreenPrivate(&pCurs->devPrivates, CursorScreenKey, pScreen,
 | 
			
		||||
                                bits);
 | 
			
		||||
            dixSetScreenPrivate(&pCurs->devPrivates,
 | 
			
		||||
                                &xf86ScreenCursorBitsKeyRec, pScreen, bits);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    if (!(infoPtr->Flags & HARDWARE_CURSOR_UPDATE_UNHIDDEN))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue