[PATCH 1/7] Move each screen's screensaver data into ScreenRec.

Jamey Sharp jamey at minilop.net
Sun May 23 16:22:07 PDT 2010


Most references to the savedScreenInfo array already had the
corresponding screen pointer handy, which meant they usually looked like
"savedScreenInfo[pScreen->myNum]". Adding a field to ScreenRec instead
of keeping this information in a parallel array simplifies those
expressions, and eliminates a MAXSCREENS-sized array.

Since dix uses this data, a screen private entry isn't appropriate.

Signed-off-by: Jamey Sharp <jamey at minilop.net>
---
 Xext/panoramiX.c       |    5 ++-
 Xext/panoramiXprocs.c  |   12 ++++----
 Xext/saver.c           |   12 ++++----
 composite/compwindow.c |    2 +-
 dix/window.c           |   71 +++++++++++++++++++++++-------------------------
 include/scrnintstr.h   |   11 +++++++
 include/windowstr.h    |   13 +-------
 mi/mioverlay.c         |    2 +-
 8 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/Xext/panoramiX.c b/Xext/panoramiX.c
index edcbb49..594da0e 100644
--- a/Xext/panoramiX.c
+++ b/Xext/panoramiX.c
@@ -836,13 +836,14 @@ PanoramiXConsolidate(void)
     saver->type = XRT_WINDOW;
 
     for (i =  0; i < PanoramiXNumScreens; i++) {
+	ScreenPtr pScreen = screenInfo.screens[i];
 	root->info[i].id = WindowTable[i]->drawable.id;
 	root->u.win.class = InputOutput;
         root->u.win.root = TRUE;
-        saver->info[i].id = savedScreenInfo[i].wid;
+        saver->info[i].id = pScreen->screensaver.wid;
         saver->u.win.class = InputOutput;
         saver->u.win.root = TRUE;
-	defmap->info[i].id = (screenInfo.screens[i])->defColormap;
+	defmap->info[i].id = pScreen->defColormap;
     }
 
     AddResource(root->info[0].id, XRT_WINDOW, root);
diff --git a/Xext/panoramiXprocs.c b/Xext/panoramiXprocs.c
index 8752ca5..08ea3ec 100644
--- a/Xext/panoramiXprocs.c
+++ b/Xext/panoramiXprocs.c
@@ -130,7 +130,7 @@ int PanoramiXCreateWindow(ClientPtr client)
     orig_x = stuff->x;
     orig_y = stuff->y;
     parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id) ||
-                   (stuff->parent == savedScreenInfo[0].wid);
+                   (stuff->parent == screenInfo.screens[0]->screensaver.wid);
     FOR_NSCREENS_BACKWARD(j) {
         stuff->wid = newWin->info[j].id;
         stuff->parent = parent->info[j].id;
@@ -329,7 +329,7 @@ int PanoramiXReparentWindow(ClientPtr client)
     x = stuff->x;
     y = stuff->y;
     parentIsRoot = (stuff->parent == WindowTable[0]->drawable.id) ||
-                   (stuff->parent == savedScreenInfo[0].wid);
+                   (stuff->parent == screenInfo.screens[0]->screensaver.wid);
     FOR_NSCREENS_BACKWARD(j) {
 	stuff->window = win->info[j].id;
 	stuff->parent = parent->info[j].id;
@@ -476,7 +476,7 @@ int PanoramiXConfigureWindow(ClientPtr client)
     }
 
     if(pWin->parent && ((pWin->parent == WindowTable[0]) ||
-                        (pWin->parent->drawable.id == savedScreenInfo[0].wid)))
+                        (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid)))
     {
 	if ((Mask)stuff->mask & CWX) {
 	    x_offset = 0;
@@ -563,7 +563,7 @@ int PanoramiXGetGeometry(ClientPtr client)
 	rep.x = pWin->origin.x - wBorderWidth (pWin);
 	rep.y = pWin->origin.y - wBorderWidth (pWin);
 	if((pWin->parent == WindowTable[0]) || 
-           (pWin->parent->drawable.id == savedScreenInfo[0].wid))
+           (pWin->parent->drawable.id == screenInfo.screens[0]->screensaver.wid))
         {
 	   rep.x += panoramiXdataPtr[0].x;
 	   rep.y += panoramiXdataPtr[0].y;
@@ -597,7 +597,7 @@ int PanoramiXTranslateCoords(ClientPtr client)
     rep.child = None;
 
     if((pWin == WindowTable[0]) || 
-       (pWin->drawable.id == savedScreenInfo[0].wid))
+       (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
     { 
 	x = stuff->srcX - panoramiXdataPtr[0].x;
 	y = stuff->srcY - panoramiXdataPtr[0].y;
@@ -635,7 +635,7 @@ int PanoramiXTranslateCoords(ClientPtr client)
     rep.dstX = x - pDst->drawable.x;
     rep.dstY = y - pDst->drawable.y;
     if((pDst == WindowTable[0]) || 
-       (pDst->drawable.id == savedScreenInfo[0].wid))
+       (pWin->drawable.id == screenInfo.screens[0]->screensaver.wid))
     {
 	rep.dstX += panoramiXdataPtr[0].x;
 	rep.dstY += panoramiXdataPtr[0].y;
diff --git a/Xext/saver.c b/Xext/saver.c
index fdcbac5..da61fbe 100644
--- a/Xext/saver.c
+++ b/Xext/saver.c
@@ -285,7 +285,7 @@ CheckScreenPrivate (ScreenPtr pScreen)
     {
 	free(pPriv);
 	SetScreenPrivate (pScreen, NULL);
-	savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL;
+	pScreen->screensaver.ExternalScreenSaver = NULL;
     }
 }
 
@@ -304,7 +304,7 @@ MakeScreenPrivate (ScreenPtr pScreen)
     pPriv->hasWindow = FALSE;
     pPriv->installedMap = None;
     SetScreenPrivate (pScreen, pPriv);
-    savedScreenInfo[pScreen->myNum].ExternalScreenSaver = ScreenSaverHandle;
+    pScreen->screensaver.ExternalScreenSaver = ScreenSaverHandle;
     return pPriv;
 }
 
@@ -504,7 +504,7 @@ SendScreenSaverNotify (ScreenPtr pScreen, int state, Bool forced)
 	ev.state = state;
 	ev.timestamp = currentTime.milliseconds;
 	ev.root = WindowTable[pScreen->myNum]->drawable.id;
-	ev.window = savedScreenInfo[pScreen->myNum].wid;
+	ev.window = pScreen->screensaver.wid;
 	ev.kind = kind;
 	ev.forced = forced;
 	WriteEventsToClient (pEv->client, 1, (xEvent *) &ev);
@@ -559,7 +559,7 @@ CreateSaverWindow (ScreenPtr pScreen)
     Colormap			wantMap;
     ColormapPtr			pCmap;
 
-    pSaver = &savedScreenInfo[pScreen->myNum];
+    pSaver = &pScreen->screensaver;
     if (pSaver->pWindow)
     {
 	pSaver->pWindow = NullWindow;
@@ -672,7 +672,7 @@ DestroySaverWindow (ScreenPtr pScreen)
     if (!pPriv || !pPriv->hasWindow)
 	return FALSE;
 
-    pSaver = &savedScreenInfo[pScreen->myNum];
+    pSaver = &pScreen->screensaver;
     if (pSaver->pWindow)
     {
 	pSaver->pWindow = NullWindow;
@@ -756,7 +756,7 @@ ProcScreenSaverQueryInfo (ClientPtr client)
     if (rc != Success)
 	return rc;
 
-    pSaver = &savedScreenInfo[pDraw->pScreen->myNum];
+    pSaver = &pDraw->pScreen->screensaver;
     pPriv = GetScreenPrivate (pDraw->pScreen);
 
     UpdateCurrentTime ();
diff --git a/composite/compwindow.c b/composite/compwindow.c
index f2f6ea3..3b16bf9 100644
--- a/composite/compwindow.c
+++ b/composite/compwindow.c
@@ -800,7 +800,7 @@ CompositeRealChildHead (WindowPtr pWin)
 
     if (!pWin->parent &&
 	(screenIsSaved == SCREEN_SAVER_ON) &&
-	(HasSaverWindow (pWin->drawable.pScreen->myNum))) {
+	(HasSaverWindow (pWin->drawable.pScreen))) {
 
 	/* First child is the screen saver; see if next child is the overlay */
 	pChildBefore = pWin->firstChild;
diff --git a/dix/window.c b/dix/window.c
index 00854c6..bdad749 100644
--- a/dix/window.c
+++ b/dix/window.c
@@ -151,12 +151,10 @@ WindowSeekDeviceCursor(WindowPtr pWin,
 
 int screenIsSaved = SCREEN_SAVER_OFF;
 
-ScreenSaverStuffRec savedScreenInfo[MAXSCREENS];
-
 static int FocusPrivatesKeyIndex;
 DevPrivateKey FocusPrivatesKey = &FocusPrivatesKeyIndex;
 
-static Bool TileScreenSaver(int i, int kind);
+static Bool TileScreenSaver(ScreenPtr pScreen, int kind);
 
 
 #define INPUTONLY_LEGAL_MASK (CWWinGravity | CWEventMask | \
@@ -363,9 +361,9 @@ CreateRootWindow(ScreenPtr pScreen)
     if (!pWin)
 	return FALSE;
 
-    savedScreenInfo[pScreen->myNum].pWindow = NULL;
-    savedScreenInfo[pScreen->myNum].wid = FakeClientID(0);
-    savedScreenInfo[pScreen->myNum].ExternalScreenSaver = NULL;
+    pScreen->screensaver.pWindow = NULL;
+    pScreen->screensaver.wid = FakeClientID(0);
+    pScreen->screensaver.ExternalScreenSaver = NULL;
     screenIsSaved = SCREEN_SAVER_OFF;
 
     WindowTable[pScreen->myNum] = pWin;
@@ -539,7 +537,7 @@ RealChildHead(WindowPtr pWin)
 
     if (!pWin->parent &&
 	(screenIsSaved == SCREEN_SAVER_ON) &&
-	(HasSaverWindow (pWin->drawable.pScreen->myNum)))
+	(HasSaverWindow (pWin->drawable.pScreen)))
 	return (pWin->firstChild);
     else
 	return (NullWindow);
@@ -3034,7 +3032,7 @@ NotClippedByChildren(WindowPtr pWin)
     pReg = REGION_CREATE(pScreen, NullBox, 1);
     if (pWin->parent ||
 	screenIsSaved != SCREEN_SAVER_ON ||
-	!HasSaverWindow (pWin->drawable.pScreen->myNum))
+	!HasSaverWindow (pWin->drawable.pScreen))
     {
 	REGION_INTERSECT(pScreen, pReg, &pWin->borderClip, &pWin->winSize);
     }
@@ -3152,33 +3150,33 @@ dixSaveScreens(ClientPtr client, int on, int mode)
     }
     for (i = 0; i < screenInfo.numScreens; i++)
     {
+	ScreenPtr pScreen = screenInfo.screens[i];
 	if (on == SCREEN_SAVER_FORCER)
-	   (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i], on);
-	if (savedScreenInfo[i].ExternalScreenSaver)
+	   (* pScreen->SaveScreen) (pScreen, on);
+	if (pScreen->screensaver.ExternalScreenSaver)
 	{
-	    if ((*savedScreenInfo[i].ExternalScreenSaver)
-		(screenInfo.screens[i], type, on == SCREEN_SAVER_FORCER))
+	    if ((*pScreen->screensaver.ExternalScreenSaver)
+		(pScreen, type, on == SCREEN_SAVER_FORCER))
 		continue;
 	}
 	if (type == screenIsSaved)
 	    continue;
 	switch (type) {
 	case SCREEN_SAVER_OFF:
-	    if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED)
+	    if (pScreen->screensaver.blanked == SCREEN_IS_BLANKED)
 	    {
-	       (* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i],
-						      what);
+	       (* pScreen->SaveScreen) (pScreen, what);
 	    }
-	    else if (HasSaverWindow (i))
+	    else if (HasSaverWindow (pScreen))
 	    {
-		savedScreenInfo[i].pWindow = NullWindow;
-		FreeResource(savedScreenInfo[i].wid, RT_NONE);
+		pScreen->screensaver.pWindow = NullWindow;
+		FreeResource(pScreen->screensaver.wid, RT_NONE);
 	    }
 	    break;
 	case SCREEN_SAVER_CYCLE:
-	    if (savedScreenInfo[i].blanked == SCREEN_IS_TILED)
+	    if (pScreen->screensaver.blanked == SCREEN_IS_TILED)
 	    {
-		WindowPtr pWin = savedScreenInfo[i].pWindow;
+		WindowPtr pWin = pScreen->screensaver.pWindow;
 		/* make it look like screen saver is off, so that
 		 * NotClippedByChildren will compute a clip list
 		 * for the root window, so miPaintWindow works
@@ -3202,35 +3200,33 @@ dixSaveScreens(ClientPtr client, int on, int mode)
 	     * Call the DDX saver in case it wants to do something
 	     * at cycle time
 	     */
-	    else if (savedScreenInfo[i].blanked == SCREEN_IS_BLANKED)
+	    else if (pScreen->screensaver.blanked == SCREEN_IS_BLANKED)
 	    {
-		(* screenInfo.screens[i]->SaveScreen) (screenInfo.screens[i],
-						       type);
+		(* pScreen->SaveScreen) (pScreen, type);
 	    }
 	    break;
 	case SCREEN_SAVER_ON:
 	    if (ScreenSaverBlanking != DontPreferBlanking)
 	    {
-		if ((* screenInfo.screens[i]->SaveScreen)
-		   (screenInfo.screens[i], what))
+		if ((* pScreen->SaveScreen) (pScreen, what))
 		{
-		   savedScreenInfo[i].blanked = SCREEN_IS_BLANKED;
+		   pScreen->screensaver.blanked = SCREEN_IS_BLANKED;
 		   continue;
 		}
 		if ((ScreenSaverAllowExposures != DontAllowExposures) &&
-		    TileScreenSaver(i, SCREEN_IS_BLACK))
+		    TileScreenSaver(pScreen, SCREEN_IS_BLACK))
 		{
-		    savedScreenInfo[i].blanked = SCREEN_IS_BLACK;
+		    pScreen->screensaver.blanked = SCREEN_IS_BLACK;
 		    continue;
 		}
 	    }
 	    if ((ScreenSaverAllowExposures != DontAllowExposures) &&
-		TileScreenSaver(i, SCREEN_IS_TILED))
+		TileScreenSaver(pScreen, SCREEN_IS_TILED))
 	    {
-		savedScreenInfo[i].blanked = SCREEN_IS_TILED;
+		pScreen->screensaver.blanked = SCREEN_IS_TILED;
 	    }
 	    else
-		savedScreenInfo[i].blanked = SCREEN_ISNT_SAVED;
+		pScreen->screensaver.blanked = SCREEN_ISNT_SAVED;
 	    break;
 	}
     }
@@ -3252,8 +3248,9 @@ SaveScreens(int on, int mode)
 }
 
 static Bool
-TileScreenSaver(int i, int kind)
+TileScreenSaver(ScreenPtr pScreen, int kind)
 {
+    int i = pScreen->myNum;
     int j;
     int result;
     XID attributes[3];
@@ -3330,12 +3327,12 @@ TileScreenSaver(int i, int kind)
 	}
     }
 
-    pWin = savedScreenInfo[i].pWindow =
-	 CreateWindow(savedScreenInfo[i].wid,
+    pWin = pScreen->screensaver.pWindow =
+	 CreateWindow(pScreen->screensaver.wid,
 	      WindowTable[i],
 	      -RANDOM_WIDTH, -RANDOM_WIDTH,
-	      (unsigned short)screenInfo.screens[i]->width + RANDOM_WIDTH,
-	      (unsigned short)screenInfo.screens[i]->height + RANDOM_WIDTH,
+	      (unsigned short)pScreen->width + RANDOM_WIDTH,
+	      (unsigned short)pScreen->height + RANDOM_WIDTH,
 	      0, InputOutput, mask, attributes, 0, serverClient,
 	      wVisual (WindowTable[i]), &result);
 
@@ -3346,7 +3343,7 @@ TileScreenSaver(int i, int kind)
 	return FALSE;
 
     if (!AddResource(pWin->drawable.id, RT_WINDOW,
-		     (pointer)savedScreenInfo[i].pWindow))
+		     (pointer)pScreen->screensaver.pWindow))
 	return FALSE;
 
     if (mask & CWBackPixmap)
diff --git a/include/scrnintstr.h b/include/scrnintstr.h
index 6f1936c..6076b87 100644
--- a/include/scrnintstr.h
+++ b/include/scrnintstr.h
@@ -82,6 +82,16 @@ typedef struct _Depth {
     VisualID		*vids;    /* block of visual ids for this depth */
   } DepthRec;
 
+typedef struct _ScreenSaverStuff {
+    WindowPtr pWindow;
+    XID       wid;
+    char      blanked;
+    Bool      (*ExternalScreenSaver)(
+	ScreenPtr	/*pScreen*/,
+	int		/*xstate*/,
+	Bool		/*force*/);
+} ScreenSaverStuffRec;
+
 
 /*
  *  There is a typedef for each screen function pointer so that code that
@@ -467,6 +477,7 @@ typedef struct _Screen {
     pointer		devPrivate;
     short       	numVisuals;
     VisualPtr		visuals;
+    ScreenSaverStuffRec screensaver;
 
     /* Random screen procedures */
 
diff --git a/include/windowstr.h b/include/windowstr.h
index 96bee9b..29b95fc 100644
--- a/include/windowstr.h
+++ b/include/windowstr.h
@@ -204,24 +204,15 @@ extern _X_EXPORT Mask	DontPropagateMasks[];
 
 #define HasBorder(w)	((w)->borderWidth || wClipShape(w))
 
-typedef struct _ScreenSaverStuff {
-    WindowPtr pWindow;
-    XID       wid;
-    char      blanked;
-    Bool      (*ExternalScreenSaver)(
-	ScreenPtr	/*pScreen*/,
-	int		/*xstate*/,
-	Bool		/*force*/);
-} ScreenSaverStuffRec, *ScreenSaverStuffPtr;
+typedef struct _ScreenSaverStuff *ScreenSaverStuffPtr;
 
 #define SCREEN_IS_BLANKED   0
 #define SCREEN_ISNT_SAVED   1
 #define SCREEN_IS_TILED     2
 #define SCREEN_IS_BLACK	    3
 
-#define HasSaverWindow(i)   (savedScreenInfo[i].pWindow != NullWindow)
+#define HasSaverWindow(pScreen)   (pScreen->screensaver.pWindow != NullWindow)
 
 extern _X_EXPORT int screenIsSaved;
-extern _X_EXPORT ScreenSaverStuffRec savedScreenInfo[MAXSCREENS];
 
 #endif /* WINDOWSTRUCT_H */
diff --git a/mi/mioverlay.c b/mi/mioverlay.c
index 2de7682..053da69 100644
--- a/mi/mioverlay.c
+++ b/mi/mioverlay.c
@@ -1738,7 +1738,7 @@ miOverlayComputeCompositeClip(GCPtr pGC, WindowPtr pWin)
 	pregWin = REGION_CREATE(pScreen, NullBox, 1);
 	freeTmpClip = TRUE;
 	if (pWin->parent || (screenIsSaved != SCREEN_SAVER_ON) ||
-		!HasSaverWindow (pScreen->myNum))
+		!HasSaverWindow (pScreen))
 	{
             REGION_INTERSECT(pScreen,pregWin,&pTree->borderClip,&pWin->winSize);
 	}
-- 
1.7.0



More information about the xorg-devel mailing list