[PATCH 5/5] xwin: make MAXSCREENS run-time configurable

Tiago Vignatti tiago.vignatti at nokia.com
Thu Apr 8 08:06:37 PDT 2010


From: Jon TURNEY <jon.turney at dronecode.org.uk>

Change g_ScreenInfo, an array of winScreenInfo elements, from a
static array to a dynamically allocated one, now that MAXSCREENS
is not a compile-time constant

Use an instance of the XWin DDX-specific screen info structure to hold
the current default values, to simplify greatly the code for applying
options to all screens and remove all those loops over MAXSCREENS screens
in the command line option processing

Signed-off-by: Jon TURNEY <jon.turney at dronecode.org.uk>
Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
 hw/xwin/InitOutput.c |   19 +-
 hw/xwin/win.h        |    8 +-
 hw/xwin/winglobals.c |    3 +-
 hw/xwin/winprocarg.c |  633 +++++++++++++-------------------------------------
 hw/xwin/winvalargs.c |    2 +-
 5 files changed, 182 insertions(+), 483 deletions(-)

diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c
index 175cd9d..9a21d6c 100644
--- a/hw/xwin/InitOutput.c
+++ b/hw/xwin/InitOutput.c
@@ -64,7 +64,7 @@ typedef HRESULT (*SHGETFOLDERPATHPROC)(
  */
 
 extern int			g_iNumScreens;
-extern winScreenInfo		g_ScreenInfo[];
+extern winScreenInfo *         g_ScreenInfo;
 extern int			g_iLastScreen;
 extern char *			g_pszCommandLine;
 extern Bool			g_fSilentFatalError;
@@ -115,9 +115,6 @@ void
 OsVendorVErrorF (const char *pszFormat, va_list va_args);
 #endif
 
-void
-winInitializeDefaultScreens (void);
-
 static Bool
 winCheckDisplayNumber (void);
 
@@ -718,17 +715,17 @@ OsVendorInit (void)
   /* Add a default screen if no screens were specified */
   if (g_iNumScreens == 0)
     {
-      winDebug ("OsVendorInit - Creating bogus screen 0\n");
+      winDebug ("OsVendorInit - Creating default screen 0\n");
 
-      /* 
-       * We need to initialize default screens if no arguments
-       * were processed.  Otherwise, the default screens would
-       * already have been initialized by ddxProcessArgument ().
+      /*
+       * We need to initialize the default screen 0 if no arguments
+       * were processed.  Otherwise, the default screen has already
+       * been initialized by ddxProcessArgument ().
        */
-      winInitializeDefaultScreens ();
+      winInitializeDefaultScreens(1);
 
       /*
-       * Add a screen 0 using the defaults set by 
+       * Add a screen 0 using the defaults set by
        * winInitializeDefaultScreens () and any additional parameters
        * processed by ddxProcessArgument ().
        */
diff --git a/hw/xwin/win.h b/hw/xwin/win.h
index 5cda970..96ed47b 100644
--- a/hw/xwin/win.h
+++ b/hw/xwin/win.h
@@ -624,7 +624,7 @@ typedef struct {
  * Extern declares for general global variables
  */
 
-extern winScreenInfo		g_ScreenInfo[];
+extern winScreenInfo *         g_ScreenInfo;
 extern miPointerScreenFuncRec	g_winPointerCursorFuncs;
 extern DWORD			g_dwEvents;
 #ifdef HAS_DEVWINDOWS
@@ -1453,6 +1453,12 @@ Bool
 winInitCursor (ScreenPtr pScreen);
 
 /*
+ * winprocarg.c
+ */
+void
+winInitializeDefaultScreens(int maxscreens);
+
+/*
  * END DDX and DIX Function Prototypes
  */
 
diff --git a/hw/xwin/winglobals.c b/hw/xwin/winglobals.c
index 926ce69..4d4b899 100644
--- a/hw/xwin/winglobals.c
+++ b/hw/xwin/winglobals.c
@@ -41,7 +41,7 @@
  */
 
 int		g_iNumScreens = 0;
-winScreenInfo	g_ScreenInfo[MAXSCREENS];
+winScreenInfo * g_ScreenInfo = 0;
 int		g_iLastScreen = -1;
 #ifdef HAS_DEVWINDOWS
 int		g_fdMessageQueue = WIN_FD_INVALID;
@@ -57,7 +57,6 @@ DevPrivateKey	g_iPixmapPrivateKey = &g_iPixmapPrivateKeyIndex;
 static int	g_iWindowPrivateKeyIndex;
 DevPrivateKey	g_iWindowPrivateKey = &g_iWindowPrivateKeyIndex;
 unsigned long	g_ulServerGeneration = 0;
-Bool		g_fInitializedDefaultScreens = FALSE;
 DWORD		g_dwEnginesSupported = 0;
 HINSTANCE	g_hInstance = 0;
 HWND		g_hDlgDepthChange = NULL;
diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c
index 66da76f..ecea271 100755
--- a/hw/xwin/winprocarg.c
+++ b/hw/xwin/winprocarg.c
@@ -45,9 +45,8 @@ from The Open Group.
  */
 
 extern int			g_iNumScreens;
-extern winScreenInfo		g_ScreenInfo[];
+extern winScreenInfo *         g_ScreenInfo;
 extern int			g_iLastScreen;
-extern Bool			g_fInitializedDefaultScreens;
 #ifdef XWIN_CLIPBOARD
 extern Bool			g_fUnicodeClipboard;
 extern Bool			g_fClipboard;
@@ -129,25 +128,25 @@ winLogVersionInfo (void);
 void OsVendorVErrorF (const char *pszFormat, va_list va_args);
 #endif
 
-void
-winInitializeDefaultScreens (void);
-
 /*
  * Process arguments on the command line
  */
 
-void
-winInitializeDefaultScreens (void)
+
+static winScreenInfo defaultScreenInfo;
+
+static void
+winInitializeDefaultScreen(void)
 {
-  int                   i;
-  DWORD			dwWidth, dwHeight;
+  DWORD dwWidth, dwHeight;
+  static Bool fInitializedDefaultScreens = FALSE;
 
-  /* Bail out early if default screens have already been initialized */
-  if (g_fInitializedDefaultScreens)
+  /* Bail out early if default screen has already been initialized */
+  if (fInitializedDefaultScreens)
     return;
 
   /* Zero the memory used for storing the screen info */
-  ZeroMemory (g_ScreenInfo, MAXSCREENS * sizeof (winScreenInfo));
+  memset(&defaultScreenInfo, 0, sizeof(winScreenInfo));
 
   /* Get default width and height */
   /*
@@ -157,62 +156,90 @@ winInitializeDefaultScreens (void)
   dwWidth = GetSystemMetrics (SM_CXSCREEN);
   dwHeight = GetSystemMetrics (SM_CYSCREEN);
 
-  winErrorFVerb (2, "winInitializeDefaultScreens - w %d h %d\n",
-	  (int) dwWidth, (int) dwHeight);
+  winErrorFVerb (2, "winInitializeDefaultScreen - w %d h %d\n",(int) dwWidth, (int) dwHeight);
 
   /* Set a default DPI, if no parameter was passed */
   if (monitorResolution == 0)
     monitorResolution = WIN_DEFAULT_DPI;
 
-  for (i = 0; i < MAXSCREENS; ++i)
-    {
-      g_ScreenInfo[i].dwScreen = i;
-      g_ScreenInfo[i].dwWidth  = dwWidth;
-      g_ScreenInfo[i].dwHeight = dwHeight;
-      g_ScreenInfo[i].dwUserWidth  = dwWidth;
-      g_ScreenInfo[i].dwUserHeight = dwHeight;
-      g_ScreenInfo[i].fUserGaveHeightAndWidth
-	=  WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH;
-      g_ScreenInfo[i].fUserGavePosition = FALSE;
-      g_ScreenInfo[i].dwBPP = WIN_DEFAULT_BPP;
-      g_ScreenInfo[i].dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES;
+  defaultScreenInfo.dwWidth  = dwWidth;
+  defaultScreenInfo.dwHeight = dwHeight;
+  defaultScreenInfo.dwUserWidth  = dwWidth;
+  defaultScreenInfo.dwUserHeight = dwHeight;
+  defaultScreenInfo.fUserGaveHeightAndWidth = WIN_DEFAULT_USER_GAVE_HEIGHT_AND_WIDTH;
+  defaultScreenInfo.fUserGavePosition = FALSE;
+  defaultScreenInfo.dwBPP = WIN_DEFAULT_BPP;
+  defaultScreenInfo.dwClipUpdatesNBoxes = WIN_DEFAULT_CLIP_UPDATES_NBOXES;
 #ifdef XWIN_EMULATEPSEUDO
-      g_ScreenInfo[i].fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO;
+  defaultScreenInfo.fEmulatePseudo = WIN_DEFAULT_EMULATE_PSEUDO;
 #endif
-      g_ScreenInfo[i].dwRefreshRate = WIN_DEFAULT_REFRESH;
-      g_ScreenInfo[i].pfb = NULL;
-      g_ScreenInfo[i].fFullScreen = FALSE;
-      g_ScreenInfo[i].fDecoration = TRUE;
+  defaultScreenInfo.dwRefreshRate = WIN_DEFAULT_REFRESH;
+  defaultScreenInfo.pfb = NULL;
+  defaultScreenInfo.fFullScreen = FALSE;
+  defaultScreenInfo.fDecoration = TRUE;
 #ifdef XWIN_MULTIWINDOWEXTWM
-      g_ScreenInfo[i].fMWExtWM = FALSE;
-      g_ScreenInfo[i].fInternalWM = FALSE;
+  defaultScreenInfo.fMWExtWM = FALSE;
+  defaultScreenInfo.fInternalWM = FALSE;
 #endif
-      g_ScreenInfo[i].fRootless = FALSE;
+  defaultScreenInfo.fRootless = FALSE;
 #ifdef XWIN_MULTIWINDOW
-      g_ScreenInfo[i].fMultiWindow = FALSE;
+  defaultScreenInfo.fMultiWindow = FALSE;
 #endif
 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-      g_ScreenInfo[i].fMultiMonitorOverride = FALSE;
+  defaultScreenInfo.fMultiMonitorOverride = FALSE;
 #endif
-      g_ScreenInfo[i].fMultipleMonitors = FALSE;
-      g_ScreenInfo[i].fLessPointer = FALSE;
-      g_ScreenInfo[i].fScrollbars = FALSE;
-      g_ScreenInfo[i].fNoTrayIcon = FALSE;
-      g_ScreenInfo[i].iE3BTimeout = WIN_E3B_OFF;
-      g_ScreenInfo[i].dwWidth_mm = (dwWidth / WIN_DEFAULT_DPI)
-	* 25.4;
-      g_ScreenInfo[i].dwHeight_mm = (dwHeight / WIN_DEFAULT_DPI)
-	* 25.4;
-      g_ScreenInfo[i].fUseWinKillKey = WIN_DEFAULT_WIN_KILL;
-      g_ScreenInfo[i].fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL;
-      g_ScreenInfo[i].fIgnoreInput = FALSE;
-      g_ScreenInfo[i].fExplicitScreen = FALSE;
-    }
+  defaultScreenInfo.fMultipleMonitors = FALSE;
+  defaultScreenInfo.fLessPointer = FALSE;
+  defaultScreenInfo.fScrollbars = FALSE;
+  defaultScreenInfo.fNoTrayIcon = FALSE;
+  defaultScreenInfo.iE3BTimeout = WIN_E3B_OFF;
+  defaultScreenInfo.dwWidth_mm = (dwWidth / WIN_DEFAULT_DPI) * 25.4;
+  defaultScreenInfo.dwHeight_mm = (dwHeight / WIN_DEFAULT_DPI) * 25.4;
+  defaultScreenInfo.fUseWinKillKey = WIN_DEFAULT_WIN_KILL;
+  defaultScreenInfo.fUseUnixKillKey = WIN_DEFAULT_UNIX_KILL;
+  defaultScreenInfo.fIgnoreInput = FALSE;
+  defaultScreenInfo.fExplicitScreen = FALSE;
+
+  /* Note that the default screen has been initialized */
+  fInitializedDefaultScreens = TRUE;
+}
+
+static void
+winInitializeScreen(int i)
+{
+  winErrorFVerb (2, "winInitializeScreen - %d\n",i);
+
+  /* Copy the default screen info */
+  g_ScreenInfo[i] = defaultScreenInfo;
+
+  /* Set the screen number */
+  g_ScreenInfo[i].dwScreen = i;
+}
+
+void
+winInitializeDefaultScreens(int maxscreens)
+{
+  static int allocated_screens = 0;
+  int i;
+  winErrorFVerb (2, "winInitializeDefaultScreens - %i\n", maxscreens);
+
+  /* Initialize default screen values, if needed */
+  winInitializeDefaultScreen();
+
+  if (maxscreens > allocated_screens)
+    {
+      /* Reallocate the memory for DDX-specific screen info */
+      g_ScreenInfo = realloc(g_ScreenInfo, maxscreens * sizeof (winScreenInfo));
+
+      /* Set default values for any new screens */
+      for (i = allocated_screens; i < maxscreens ; i++)
+        winInitializeScreen(i);
 
-  /* Signal that the default screens have been initialized */
-  g_fInitializedDefaultScreens = TRUE;
+      /* Update MAXSCREENS */
+      SetMaxScreens(maxscreens);
 
-  winErrorFVerb (2, "winInitializeDefaultScreens - Returning\n");
+      allocated_screens = maxscreens;
+    }
 }
 
 /* See Porting Layer Definition - p. 57 */
@@ -244,6 +271,7 @@ int
 ddxProcessArgument (int argc, char *argv[], int i)
 {
   static Bool		s_fBeenHere = FALSE;
+  winScreenInfo        *screenInfoPtr = NULL;
 
   /* Initialize once */
   if (!s_fBeenHere)
@@ -262,7 +290,6 @@ ddxProcessArgument (int argc, char *argv[], int i)
       if (!IS_OPTION("-help") && !IS_OPTION("-h") && !IS_OPTION("--help") &&
           !IS_OPTION("-version") && !IS_OPTION("--version"))
 	{
-
           /* Log the version information */
           winLogVersionInfo ();
 
@@ -276,7 +303,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
 	   */
 	  winErrorFVerb (2, "ddxProcessArgument - Initializing default "
 			 "screens\n");
-	  winInitializeDefaultScreens ();
+         winInitializeDefaultScreens(1);
 	}
     }
 
@@ -331,14 +358,19 @@ ddxProcessArgument (int argc, char *argv[], int i)
       nScreenNum = atoi (argv[i + 1]);
 
       /* Validate the specified screen number */
-      if (nScreenNum < 0 || nScreenNum >= MAXSCREENS)
+      if (nScreenNum < 0)
         {
-          ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n",
-		  nScreenNum);
+          ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n", nScreenNum);
           UseMsg ();
 	  return 0;
         }
 
+      /* Update MAXSCREENS and initialize default values for any new screens */
+      if ((nScreenNum+1) > MAXSCREENS)
+        {
+          winInitializeDefaultScreens(nScreenNum+1);
+        }
+
 	  /* look for @m where m is monitor number */
 	  if (i + 2 < argc
 		  && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor)) 
@@ -513,6 +545,26 @@ ddxProcessArgument (int argc, char *argv[], int i)
       return iArgsProcessed;
     }
 
+
+  /*
+   * Is this parameter attached to a screen or global?
+   *
+   * If the parameter is for all screens, store it in
+   * the default screen info
+   *
+   * If the parameter is for a single screen, store it
+   * in the screen info for that screen
+   *
+   */
+  if (g_iLastScreen == -1)
+    {
+      screenInfoPtr = &defaultScreenInfo;
+    }
+  else
+    {
+      screenInfoPtr = &(g_ScreenInfo[g_iLastScreen]);
+    }
+
   /*
    * Look for the '-engine n' argument
    */
@@ -541,22 +593,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
 	  return 0;
 	}
 
-      /* Is this parameter attached to a screen or global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int		j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].dwEnginePreferred = dwEngine;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].dwEnginePreferred = dwEngine;
-	}
+      screenInfoPtr->dwEnginePreferred = dwEngine;
       
       /* Indicate that we have processed the argument */
       return 2;
@@ -567,30 +604,11 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-fullscreen"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-              if (!g_ScreenInfo[j].fMultiMonitorOverride)
-                g_ScreenInfo[j].fMultipleMonitors = FALSE;
-#endif
-	      g_ScreenInfo[j].fFullScreen = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-          if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
-            g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
+          if (!screenInfoPtr->fMultiMonitorOverride)
+            screenInfoPtr->fMultipleMonitors = FALSE;
 #endif
-	  g_ScreenInfo[g_iLastScreen].fFullScreen = TRUE;
-	}
+         screenInfoPtr->fFullScreen = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -601,22 +619,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-lesspointer"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].fLessPointer = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-          g_ScreenInfo[g_iLastScreen].fLessPointer = TRUE;
-	}
+      screenInfoPtr->fLessPointer = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -627,30 +630,11 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-nodecoration"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-              if (!g_ScreenInfo[j].fMultiMonitorOverride)
-                g_ScreenInfo[j].fMultipleMonitors = FALSE;
-#endif
-	      g_ScreenInfo[j].fDecoration = FALSE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-          if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
-            g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
+      if (!screenInfoPtr->fMultiMonitorOverride)
+        screenInfoPtr->fMultipleMonitors = FALSE;
 #endif
-	  g_ScreenInfo[g_iLastScreen].fDecoration = FALSE;
-	}
+      screenInfoPtr->fDecoration = FALSE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -662,26 +646,9 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-mwextwm"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-              if (!g_ScreenInfo[j].fMultiMonitorOverride)
-                g_ScreenInfo[j].fMultipleMonitors = TRUE;
-	      g_ScreenInfo[j].fMWExtWM = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-          if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
-            g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
-	  g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE;
-	}
+      if (!screenInfoPtr->fMultiMonitorOverride)
+        screenInfoPtr->fMultipleMonitors = TRUE;
+      screenInfoPtr->fMWExtWM = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -691,28 +658,10 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-internalwm"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      if (!g_ScreenInfo[j].fMultiMonitorOverride)
-	        g_ScreenInfo[j].fMultipleMonitors = TRUE;
-	      g_ScreenInfo[j].fMWExtWM = TRUE;
-	      g_ScreenInfo[j].fInternalWM = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
-	    g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
-	  g_ScreenInfo[g_iLastScreen].fMWExtWM = TRUE;
-	  g_ScreenInfo[g_iLastScreen].fInternalWM = TRUE;
-	}
+      if (!screenInfoPtr->fMultiMonitorOverride)
+        screenInfoPtr->fMultipleMonitors = TRUE;
+      screenInfoPtr->fMWExtWM = TRUE;
+      screenInfoPtr->fInternalWM = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -724,30 +673,11 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-rootless"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-              if (!g_ScreenInfo[j].fMultiMonitorOverride)
-                g_ScreenInfo[j].fMultipleMonitors = FALSE;
-#endif
-	      g_ScreenInfo[j].fRootless = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-          if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
-            g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
+      if (!screenInfoPtr->fMultiMonitorOverride)
+        screenInfoPtr->fMultipleMonitors = FALSE;
 #endif
-	  g_ScreenInfo[g_iLastScreen].fRootless = TRUE;
-	}
+      screenInfoPtr->fRootless = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -759,30 +689,11 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-multiwindow"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-              if (!g_ScreenInfo[j].fMultiMonitorOverride)
-                g_ScreenInfo[j].fMultipleMonitors = TRUE;
-#endif
-	      g_ScreenInfo[j].fMultiWindow = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-          if (!g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride)
-            g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
+      if (!screenInfoPtr->fMultiMonitorOverride)
+        screenInfoPtr->fMultipleMonitors = TRUE;
 #endif
-	  g_ScreenInfo[g_iLastScreen].fMultiWindow = TRUE;
-	}
+      screenInfoPtr->fMultiWindow = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -795,28 +706,10 @@ ddxProcessArgument (int argc, char *argv[], int i)
   if (IS_OPTION ("-multiplemonitors")
       || IS_OPTION ("-multimonitors"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-              g_ScreenInfo[j].fMultiMonitorOverride = TRUE;
-#endif
-	      g_ScreenInfo[j].fMultipleMonitors = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-          g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE;
+      screenInfoPtr->fMultiMonitorOverride = TRUE;
 #endif
-	  g_ScreenInfo[g_iLastScreen].fMultipleMonitors = TRUE;
-	}
+      screenInfoPtr->fMultipleMonitors = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -828,28 +721,10 @@ ddxProcessArgument (int argc, char *argv[], int i)
   if (IS_OPTION ("-nomultiplemonitors")
       || IS_OPTION ("-nomultimonitors"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-#if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-              g_ScreenInfo[j].fMultiMonitorOverride = TRUE;
-#endif
-	      g_ScreenInfo[j].fMultipleMonitors = FALSE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
 #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM)
-          g_ScreenInfo[g_iLastScreen].fMultiMonitorOverride = TRUE;
+      screenInfoPtr->fMultiMonitorOverride = TRUE;
 #endif
-	  g_ScreenInfo[g_iLastScreen].fMultipleMonitors = FALSE;
-	}
+      screenInfoPtr->fMultipleMonitors = FALSE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -861,22 +736,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-scrollbars"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].fScrollbars = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].fScrollbars = TRUE;
-	}
+      screenInfoPtr->fScrollbars = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -914,22 +774,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-ignoreinput"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].fIgnoreInput = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].fIgnoreInput = TRUE;
-	}
+      screenInfoPtr->fIgnoreInput = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -962,22 +807,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
 	  iE3BTimeout = WIN_DEFAULT_E3B_TIME;
 	}
 
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].iE3BTimeout = iE3BTimeout;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].iE3BTimeout = iE3BTimeout;
-	}
+      screenInfoPtr->iE3BTimeout = iE3BTimeout;
 
       /* Indicate that we have processed this argument */
       return iArgsProcessed;
@@ -1000,23 +830,8 @@ ddxProcessArgument (int argc, char *argv[], int i)
       /* Grab the argument */
       dwBPP = atoi (argv[i]);
 
-      /* Is this parameter attached to a screen or global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int		j;
+      screenInfoPtr->dwBPP = dwBPP;
 
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].dwBPP = dwBPP;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].dwBPP = dwBPP;
-	}
-      
       /* Indicate that we have processed the argument */
       return 2;
     }
@@ -1038,23 +853,8 @@ ddxProcessArgument (int argc, char *argv[], int i)
       /* Grab the argument */
       dwRefreshRate = atoi (argv[i]);
 
-      /* Is this parameter attached to a screen or global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int		j;
+      screenInfoPtr->dwRefreshRate = dwRefreshRate;
 
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].dwRefreshRate = dwRefreshRate;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].dwRefreshRate = dwRefreshRate;
-	}
-      
       /* Indicate that we have processed the argument */
       return 2;
     }
@@ -1076,23 +876,8 @@ ddxProcessArgument (int argc, char *argv[], int i)
       /* Grab the argument */
       dwNumBoxes = atoi (argv[i]);
 
-      /* Is this parameter attached to a screen or global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int		j;
+      screenInfoPtr->dwClipUpdatesNBoxes = dwNumBoxes;
 
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].dwClipUpdatesNBoxes = dwNumBoxes;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].dwClipUpdatesNBoxes = dwNumBoxes;
-	}
-      
       /* Indicate that we have processed the argument */
       return 2;
     }
@@ -1103,22 +888,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-emulatepseudo"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].fEmulatePseudo = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-          g_ScreenInfo[g_iLastScreen].fEmulatePseudo = TRUE;
-	}
+      screenInfoPtr->fEmulatePseudo = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -1130,22 +900,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-nowinkill"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].fUseWinKillKey = FALSE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].fUseWinKillKey = FALSE;
-	}
+      screenInfoPtr->fUseWinKillKey = FALSE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -1156,22 +911,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-winkill"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].fUseWinKillKey = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].fUseWinKillKey = TRUE;
-	}
+      screenInfoPtr->fUseWinKillKey = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -1182,22 +922,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-nounixkill"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].fUseUnixKillKey = FALSE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = FALSE;
-	}
+      screenInfoPtr->fUseUnixKillKey = FALSE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -1208,22 +933,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-unixkill"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].fUseUnixKillKey = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].fUseUnixKillKey = TRUE;
-	}
+      screenInfoPtr->fUseUnixKillKey = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -1234,22 +944,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-notrayicon"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].fNoTrayIcon = TRUE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].fNoTrayIcon = TRUE;
-	}
+      screenInfoPtr->fNoTrayIcon = TRUE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -1260,22 +955,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
    */
   if (IS_OPTION ("-trayicon"))
     {
-      /* Is this parameter attached to a screen or is it global? */
-      if (-1 == g_iLastScreen)
-	{
-	  int			j;
-
-	  /* Parameter is for all screens */
-	  for (j = 0; j < MAXSCREENS; j++)
-	    {
-	      g_ScreenInfo[j].fNoTrayIcon = FALSE;
-	    }
-	}
-      else
-	{
-	  /* Parameter is for a single screen */
-	  g_ScreenInfo[g_iLastScreen].fNoTrayIcon = FALSE;
-	}
+      screenInfoPtr->fNoTrayIcon = FALSE;
 
       /* Indicate that we have processed this argument */
       return 1;
@@ -1464,6 +1144,23 @@ ddxProcessArgument (int argc, char *argv[], int i)
       g_fSilentDupError = TRUE;
       return 1;
     }
+
+  /*
+   * Look for the '-maxscreen' argument
+   */
+  if (IS_OPTION ("-maxscreens"))
+    {
+      if (++i < argc)
+        {
+          int maxscreens = atoi(argv[i]);
+
+          if (maxscreens > 0)
+            winInitializeDefaultScreens(maxscreens);
+        }
+
+      return 0; /* Let DIX parse this again */
+    }
+
   return 0;
 }
 
diff --git a/hw/xwin/winvalargs.c b/hw/xwin/winvalargs.c
index 038e097..47b0d80 100755
--- a/hw/xwin/winvalargs.c
+++ b/hw/xwin/winvalargs.c
@@ -40,7 +40,7 @@
  */
 
 extern int			g_iNumScreens;
-extern winScreenInfo		g_ScreenInfo[];
+extern winScreenInfo *         g_ScreenInfo;
 extern Bool			g_fXdmcpEnabled;
 
 
-- 
1.6.0.4



More information about the xorg-devel mailing list