diff --git a/hw/kdrive/ephyr/ephyrdriext.c b/hw/kdrive/ephyr/ephyrdriext.c index e3d0cfbb4..b6be47f5e 100644 --- a/hw/kdrive/ephyr/ephyrdriext.c +++ b/hw/kdrive/ephyr/ephyrdriext.c @@ -44,6 +44,7 @@ #include #include #include "misc.h" +#include "privates.h" #include "dixstruct.h" #include "extnsionst.h" #include "colormapst.h" @@ -118,14 +119,13 @@ static Bool findWindowPairFromLocal (WindowPtr a_local, static unsigned char DRIReqCode = 0; -static int ephyrDRIGeneration=-1 ; -static int ephyrDRIWindowIndex=-1 ; -static int ephyrDRIScreenIndex=-1 ; +static DevPrivateKey ephyrDRIWindowKey = &ephyrDRIWindowKey; +static DevPrivateKey ephyrDRIScreenKey = &ephyrDRIScreenKey; -#define GET_EPHYR_DRI_WINDOW_PRIV(win) \ - ((EphyrDRIWindowPrivPtr)((win)->devPrivates[ephyrDRIWindowIndex].ptr)) -#define GET_EPHYR_DRI_SCREEN_PRIV(screen) \ - ((EphyrDRIScreenPrivPtr)((screen)->devPrivates[ephyrDRIScreenIndex].ptr)) +#define GET_EPHYR_DRI_WINDOW_PRIV(win) ((EphyrDRIWindowPrivPtr) \ + dixLookupPrivate(&(win)->devPrivates, ephyrDRIWindowKey)) +#define GET_EPHYR_DRI_SCREEN_PRIV(screen) ((EphyrDRIScreenPrivPtr) \ + dixLookupPrivate(&(screen)->devPrivates, ephyrDRIScreenKey)) Bool @@ -164,28 +164,18 @@ ephyrDRIExtensionInit (ScreenPtr a_screen) EPHYR_LOG_ERROR ("failed to register DRI extension\n") ; goto out ; } - if (ephyrDRIGeneration != serverGeneration) { - ephyrDRIScreenIndex = AllocateScreenPrivateIndex () ; - if (ephyrDRIScreenIndex < 0) { - EPHYR_LOG_ERROR ("failed to allocate screen priv index\n") ; - goto out ; - } - } screen_priv = xcalloc (1, sizeof (EphyrDRIScreenPrivRec)) ; if (!screen_priv) { EPHYR_LOG_ERROR ("failed to allocate screen_priv\n") ; goto out ; } - a_screen->devPrivates[ephyrDRIScreenIndex].ptr = screen_priv; + dixSetPrivate(&a_screen->devPrivates, ephyrDRIScreenKey, screen_priv); if (!ephyrDRIScreenInit (a_screen)) { EPHYR_LOG_ERROR ("ephyrDRIScreenInit() failed\n") ; goto out ; } EphyrMirrorHostVisuals (a_screen) ; - if (ephyrDRIGeneration != serverGeneration) { - ephyrDRIGeneration = serverGeneration ; - } is_ok=TRUE ; out: EPHYR_LOG ("leave\n") ; @@ -203,17 +193,6 @@ ephyrDRIScreenInit (ScreenPtr a_screen) screen_priv=GET_EPHYR_DRI_SCREEN_PRIV (a_screen) ; EPHYR_RETURN_VAL_IF_FAIL (screen_priv, FALSE) ; - if (ephyrDRIGeneration != serverGeneration) { - ephyrDRIWindowIndex = AllocateWindowPrivateIndex () ; - if (ephyrDRIWindowIndex < 0) { - EPHYR_LOG_ERROR ("failed to allocate window priv index\n") ; - goto out ; - } - } - if (!AllocateWindowPrivate (a_screen, ephyrDRIWindowIndex, 0)) { - EPHYR_LOG_ERROR ("failed to allocate window privates\n") ; - goto out ; - } screen_priv->CreateWindow = a_screen->CreateWindow ; screen_priv->DestroyWindow = a_screen->DestroyWindow ; screen_priv->MoveWindow = a_screen->MoveWindow ; @@ -254,7 +233,7 @@ ephyrDRICreateWindow (WindowPtr a_win) screen->CreateWindow = ephyrDRICreateWindow ; if (is_ok) { - a_win->devPrivates[ephyrDRIWindowIndex].ptr = NULL ; + dixSetPrivate(&a_win->devPrivates, ephyrDRIWindowKey, NULL); } return is_ok ; } @@ -285,7 +264,7 @@ ephyrDRIDestroyWindow (WindowPtr a_win) if (win_priv) { destroyHostPeerWindow (a_win) ; xfree (win_priv) ; - a_win->devPrivates[ephyrDRIWindowIndex].ptr = NULL ; + dixSetPrivate(&a_win->devPrivates, ephyrDRIWindowKey, NULL); EPHYR_LOG ("destroyed the remote peer window\n") ; } } @@ -1088,7 +1067,7 @@ ProcXF86DRICreateDrawable (ClientPtr client) EPHYR_LOG_ERROR ("failed to allocate window private\n") ; return BadAlloc ; } - window->devPrivates[ephyrDRIWindowIndex].ptr = win_priv ; + dixSetPrivate(&window->devPrivates, ephyrDRIWindowKey, win_priv); EPHYR_LOG ("paired window '%#x' with remote '%d'\n", (unsigned int)window, remote_win) ; } diff --git a/hw/kdrive/src/kdrive.c b/hw/kdrive/src/kdrive.c index 5376f19db..50148c49c 100644 --- a/hw/kdrive/src/kdrive.c +++ b/hw/kdrive/src/kdrive.c @@ -29,6 +29,7 @@ #endif #include #include +#include "privates.h" #ifdef RANDR #include #endif @@ -66,8 +67,8 @@ KdDepths kdDepths[] = { #define KD_DEFAULT_BUTTONS 5 -int kdScreenPrivateIndex; -unsigned long kdGeneration; +DevPrivateKey kdScreenPrivateKey = &kdScreenPrivateKey; +unsigned long kdGeneration; Bool kdVideoTest; unsigned long kdVideoTestTime; @@ -751,10 +752,8 @@ KdAllocatePrivates (ScreenPtr pScreen) KdPrivScreenPtr pScreenPriv; if (kdGeneration != serverGeneration) - { - kdScreenPrivateIndex = AllocateScreenPrivateIndex(); - kdGeneration = serverGeneration; - } + kdGeneration = serverGeneration; + pScreenPriv = (KdPrivScreenPtr) xalloc(sizeof (*pScreenPriv)); if (!pScreenPriv) return FALSE; @@ -1401,8 +1400,8 @@ KdInitOutput (ScreenInfo *pScreenInfo, } #ifdef DPMSExtension -void -DPMSSet(int level) +int +DPMSSet(ClientPtr client, int level) { } diff --git a/hw/kdrive/src/kxv.c b/hw/kdrive/src/kxv.c index b6ff4f831..0b8d1c4e0 100644 --- a/hw/kdrive/src/kxv.c +++ b/hw/kdrive/src/kxv.c @@ -106,9 +106,10 @@ static Bool KdXVInitAdaptors(ScreenPtr, KdVideoAdaptorPtr*, int); DevPrivateKey KdXVWindowKey = &KdXVWindowKey; DevPrivateKey KdXvScreenKey = &KdXvScreenKey; +static unsigned long KdXVGeneration = 0; static unsigned long PortResource = 0; -int (*XvGetScreenKeyProc)(void) = XvGetScreenKey; +DevPrivateKey (*XvGetScreenKeyProc)(void) = XvGetScreenKey; unsigned long (*XvGetRTPortProc)(void) = XvGetRTPort; int (*XvScreenInitProc)(ScreenPtr) = XvScreenInit; @@ -191,12 +192,15 @@ KdXVScreenInit( /* fprintf(stderr,"KdXVScreenInit initializing %d adaptors\n",num); */ + if (KdXVGeneration != serverGeneration) + KdXVGeneration = serverGeneration; + if(!XvGetScreenKeyProc || !XvGetRTPortProc || !XvScreenInitProc) return FALSE; if(Success != (*XvScreenInitProc)(pScreen)) return FALSE; - KdXvScreenIndex = (*XvGetScreenKeyProc)(); + KdXvScreenKey = (*XvGetScreenKeyProc)(); PortResource = (*XvGetRTPortProc)(); pxvs = GET_XV_SCREEN(pScreen); @@ -1106,7 +1110,7 @@ KdXVClipNotify(WindowPtr pWin, int dx, int dy) pPriv->pDraw = NULL; if(!pPrev) - dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, winPriv->next); + dixSetPrivate(&pWin->devPrivates, KdXVWindowKey, WinPriv->next); else pPrev->next = WinPriv->next; tmp = WinPriv; diff --git a/hw/xquartz/darwin.c b/hw/xquartz/darwin.c index ab4dc0dfd..d932bcd74 100644 --- a/hw/xquartz/darwin.c +++ b/hw/xquartz/darwin.c @@ -88,7 +88,7 @@ FILE *debug_log_fp = NULL; * X server shared global variables */ int darwinScreensFound = 0; -int darwinScreenIndex = 0; +DevPrivateKey darwinScreenKey = &darwinScreenKey; io_connect_t darwinParamConnect = 0; int darwinEventReadFD = -1; int darwinEventWriteFD = -1; @@ -613,7 +613,6 @@ DarwinAdjustScreenOrigins(ScreenInfo *pScreenInfo) void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv ) { int i; - static unsigned long generation = 0; pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER; pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT; @@ -625,12 +624,6 @@ void InitOutput( ScreenInfo *pScreenInfo, int argc, char **argv ) for (i = 0; i < NUMFORMATS; i++) pScreenInfo->formats[i] = formats[i]; - // Allocate private storage for each screen's Darwin specific info - if (generation != serverGeneration) { - darwinScreenIndex = AllocateScreenPrivateIndex(); - generation = serverGeneration; - } - // Discover screens and do mode specific initialization QuartzInitOutput(argc, argv);