Allocate per-screen device/cursor-bits private keys in midispcur
midispcur was abusing the CursorScreenKey to index the cursor_bits privates, it also had a MAXSCREENS array of keys to index device privates. Switch both of these to the new dixCreatePrivateKey API and store a pointer to that in the screen private. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Jamey Sharp <jamey@minilop.net>
This commit is contained in:
		
							parent
							
								
									34db537907
								
							
						
					
					
						commit
						ab07e2b8ed
					
				|  | @ -59,14 +59,7 @@ static DevPrivateKeyRec miDCScreenKeyRec; | ||||||
| 
 | 
 | ||||||
| static Bool	miDCCloseScreen(int index, ScreenPtr pScreen); | static Bool	miDCCloseScreen(int index, ScreenPtr pScreen); | ||||||
| 
 | 
 | ||||||
| /* per bits per-screen private data */ | /* per device private data */ | ||||||
| static DevPrivateKeyRec miDCCursorBitsKeyRec[MAXSCREENS]; |  | ||||||
| #define miDCCursorBitsKey(screen)	(&miDCCursorBitsKeyRec[(screen)->myNum]) |  | ||||||
| 
 |  | ||||||
| /* per device per-screen private data */ |  | ||||||
| static DevPrivateKeyRec miDCDeviceKeyRec[MAXSCREENS]; |  | ||||||
| #define miDCDeviceKey(screen)		(&miDCDeviceKeyRec[(screen)->myNum]) |  | ||||||
| 
 |  | ||||||
| typedef struct { | typedef struct { | ||||||
|     GCPtr	    pSourceGC, pMaskGC; |     GCPtr	    pSourceGC, pMaskGC; | ||||||
|     GCPtr	    pSaveGC, pRestoreGC; |     GCPtr	    pSaveGC, pRestoreGC; | ||||||
|  | @ -86,9 +79,15 @@ typedef struct { | ||||||
|  * in the pCursorBuffers array.  |  * in the pCursorBuffers array.  | ||||||
|  */ |  */ | ||||||
| typedef struct { | typedef struct { | ||||||
|     CloseScreenProcPtr CloseScreen; |     CloseScreenProcPtr	CloseScreen; | ||||||
|  |     DevPrivateKey	device_key; | ||||||
|  |     DevPrivateKey	cursor_bits_key; | ||||||
| } miDCScreenRec, *miDCScreenPtr; | } miDCScreenRec, *miDCScreenPtr; | ||||||
| 
 | 
 | ||||||
|  | #define miGetDCScreen(s)	((miDCScreenPtr)(dixLookupPrivate(&(s)->devPrivates, miDCScreenKey))) | ||||||
|  | #define miDCDeviceKey(s) 	(miGetDCScreen(s)->device_key) | ||||||
|  | #define miDCCursorBitsKey(s)	(miGetDCScreen(s)->cursor_bits_key) | ||||||
|  | 
 | ||||||
| /* per-cursor per-screen private data */ | /* per-cursor per-screen private data */ | ||||||
| typedef struct { | typedef struct { | ||||||
|     PixmapPtr		sourceBits;	    /* source bits */ |     PixmapPtr		sourceBits;	    /* source bits */ | ||||||
|  | @ -106,16 +105,16 @@ miDCInitialize (ScreenPtr pScreen, miPointerScreenFuncPtr screenFuncs) | ||||||
|     if (!dixRegisterPrivateKey(&miDCScreenKeyRec, PRIVATE_SCREEN, 0)) |     if (!dixRegisterPrivateKey(&miDCScreenKeyRec, PRIVATE_SCREEN, 0)) | ||||||
| 	return FALSE; | 	return FALSE; | ||||||
| 
 | 
 | ||||||
|     if (!dixRegisterPrivateKey(&miDCDeviceKeyRec[pScreen->myNum], PRIVATE_DEVICE, 0)) |  | ||||||
| 	return FALSE; |  | ||||||
| 
 |  | ||||||
|     if (!dixRegisterPrivateKey(&miDCCursorBitsKeyRec[pScreen->myNum], PRIVATE_CURSOR_BITS, 0)) |  | ||||||
| 	return FALSE; |  | ||||||
| 
 |  | ||||||
|     pScreenPriv = malloc(sizeof (miDCScreenRec)); |     pScreenPriv = malloc(sizeof (miDCScreenRec)); | ||||||
|     if (!pScreenPriv) |     if (!pScreenPriv) | ||||||
| 	return FALSE; | 	return FALSE; | ||||||
| 
 | 
 | ||||||
|  |     pScreenPriv->cursor_bits_key = dixCreatePrivateKey(PRIVATE_CURSOR_BITS, 0); | ||||||
|  |     pScreenPriv->device_key = dixCreatePrivateKey(PRIVATE_DEVICE, 0); | ||||||
|  |     if (!pScreenPriv->cursor_bits_key || !pScreenPriv->device_key) { | ||||||
|  | 	free(pScreenPriv); | ||||||
|  | 	return FALSE; | ||||||
|  |     } | ||||||
|     pScreenPriv->CloseScreen = pScreen->CloseScreen; |     pScreenPriv->CloseScreen = pScreen->CloseScreen; | ||||||
|     pScreen->CloseScreen = miDCCloseScreen; |     pScreen->CloseScreen = miDCCloseScreen; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue