On Thu, Apr 08, 2010 at 11:23:21PM +0200, ext Keith Packard wrote:
> 
> Yeah, for things which are created after the ScreenRec is allocated, it
> makes sense to just allocate them right in the ScreenRec.
> 
> For things which are in the xfree86 DDX and are allocated before the
> ScreenRec, those can be in ScrnInfo.
> 
> If there are things outside the xfree86 DDX which are allocated before
> the ScreenRec, we'd need a third plan.
> 

that what Keith said summarizes pretty well indeed.

I thought a bit and started a draft of a patch what we can make this stuff
"maxscreensless". And what seemed to be the hard part is actually there: I
brought all global definitions inside AddScreen, reallocating them (well, I'll
have do the same with WindowTable there). See the attached.

Now it seems the rest is bit trivial then, don't? I meant, like Keith and
Aaron said, is just a matter to add a new struct member in both ScreenRec and
ScrnInfo. 


Who tries? :)

                            Tiago
diff --git a/dix/dispatch.c b/dix/dispatch.c
index 982c808..bf064f7 100644
--- a/dix/dispatch.c
+++ b/dix/dispatch.c
@@ -3975,6 +3975,44 @@ static int indexForScanlinePad[ 65 ] = {
 	 3		/* 64 bits per scanline pad unit */
 };
 
+static void
+ReallocGlobals (void)
+{
+    DDXPointRec         *dixScreenOriginsNew;
+    int                 *cursorScreenDevPrivNew;
+    ScreenSaverStuffRec *savedScreenInfoNew;
+    ScreenPtr           *screensNew;
+
+    if (serverGeneration == 1) {
+
+	if (screenInfo.numScreens) {
+	    dixScreenOriginsNew = xrealloc(dixScreenOrigins,
+            (screenInfo.numScreens + 1) * sizeof(DDXPointRec));
+	    cursorScreenDevPrivNew = xrealloc(cursorScreenDevPriv,
+            (screenInfo.numScreens + 1) * sizeof(int));
+	    savedScreenInfoNew = xrealloc(savedScreenInfo,
+            (screenInfo.numScreens + 1) * sizeof(ScreenSaverStuffRec));
+	    screensNew = xrealloc(screenInfo.screens,
+            (screenInfo.numScreens + 1) * sizeof(struct _Screen));
+	}
+	else {
+	    dixScreenOriginsNew = xalloc(sizeof(DDXPointRec));
+	    cursorScreenDevPrivNew = xalloc(sizeof(int));
+	    savedScreenInfoNew = xalloc(sizeof(ScreenSaverStuffRec));
+	    screensNew = xalloc(sizeof(struct _Screen));
+	}
+	dixScreenOrigins = dixScreenOriginsNew;
+	cursorScreenDevPriv = cursorScreenDevPrivNew;
+	savedScreenInfo = savedScreenInfoNew;
+	screenInfo.screens = screensNew;
+
+	/* Initialize DevPrivates as 0 is fundamental. TODO: justify why */
+	cursorScreenDevPriv[screenInfo.numScreens] = 0;
+    }
+
+    MAXSCREENSALLOC_FATAL(WindowTable);
+}
+
 /*
 	grow the array of screenRecs if necessary.
 	call the device-supplied initialization procedure
@@ -4056,6 +4094,9 @@ AddScreen(
        multiple screens.
     */
     pScreen->rgf = ~0L;  /* there are no scratch GCs yet*/
+
+    ReallocGlobals();
+
     WindowTable[i] = NullWindow;
     screenInfo.screens[i] = pScreen;
     screenInfo.numScreens++;
diff --git a/dix/main.c b/dix/main.c
index edd66a1..b9b6f64 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -148,16 +148,6 @@ void SetMaxScreens(int maxscreens)
     MAXSCREENS = maxscreens > 0 ? maxscreens : MAXSCREENSDEFAULT;
 }
 
-static void InitGlobals(void)
-{
-    if (!MAXSCREENS) SetMaxScreens(MAXSCREENSDEFAULT);
-
-    MAXSCREENSALLOC_FATAL(dixScreenOrigins);
-    MAXSCREENSALLOC_FATAL(cursorScreenDevPriv);
-    MAXSCREENSALLOC_FATAL(savedScreenInfo);
-    MAXSCREENSALLOC_FATAL(screenInfo.screens);
-}
-
 #ifdef XQUARTZ
 #include <pthread.h>
 
@@ -189,8 +179,6 @@ int main(int argc, char *argv[], char *envp[])
 
     ProcessCommandLine(argc, argv);
 
-    InitGlobals();
-
     alwaysCheckForInput[0] = 0;
     alwaysCheckForInput[1] = 1;
     while(1)
@@ -233,10 +221,6 @@ int main(int argc, char *argv[], char *envp[])
 	screenInfo.arraySize = MAXSCREENS;
 	screenInfo.numScreens = 0;
 
-	MAXSCREENSALLOC(WindowTable);
-	if (!WindowTable)
-	    FatalError("couldn't create root window table");
-
 	InitAtoms();
 	InitEvents();
 	InitSelections();
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to