Xwin: make screens structures run-time adjustable

Change g_ScreenInfo, an array of winScreenInfo elements, from a
static array of MAXSCREENS elements, to a dynamically allocated one

Fix up the validation that -screen option screen numbers are
contiguous from zero (which possibly didn't work correctly before
anyhow)

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Jamey Sharp<jamey@minilop.net>
Reviewed-by: Tiago Vignatti <tiago.vignatti@nokia.com>
This commit is contained in:
Jon TURNEY 2010-04-16 18:13:50 +01:00 committed by Tiago Vignatti
parent d8454ae488
commit a7d398e545
5 changed files with 23 additions and 21 deletions

View File

@ -64,7 +64,7 @@ typedef HRESULT (*SHGETFOLDERPATHPROC)(
*/ */
extern int g_iNumScreens; extern int g_iNumScreens;
extern winScreenInfo g_ScreenInfo[]; extern winScreenInfo * g_ScreenInfo;
extern char * g_pszCommandLine; extern char * g_pszCommandLine;
extern Bool g_fSilentFatalError; extern Bool g_fSilentFatalError;

View File

@ -622,7 +622,7 @@ typedef struct {
* Extern declares for general global variables * Extern declares for general global variables
*/ */
extern winScreenInfo g_ScreenInfo[]; extern winScreenInfo * g_ScreenInfo;
extern miPointerScreenFuncRec g_winPointerCursorFuncs; extern miPointerScreenFuncRec g_winPointerCursorFuncs;
extern DWORD g_dwEvents; extern DWORD g_dwEvents;
#ifdef HAS_DEVWINDOWS #ifdef HAS_DEVWINDOWS

View File

@ -41,7 +41,7 @@
*/ */
int g_iNumScreens = 0; int g_iNumScreens = 0;
winScreenInfo g_ScreenInfo[MAXSCREENS]; winScreenInfo * g_ScreenInfo = 0;
#ifdef HAS_DEVWINDOWS #ifdef HAS_DEVWINDOWS
int g_fdMessageQueue = WIN_FD_INVALID; int g_fdMessageQueue = WIN_FD_INVALID;
#endif #endif

View File

@ -45,7 +45,7 @@ from The Open Group.
*/ */
extern int g_iNumScreens; extern int g_iNumScreens;
extern winScreenInfo g_ScreenInfo[]; extern winScreenInfo * g_ScreenInfo;
#ifdef XWIN_CLIPBOARD #ifdef XWIN_CLIPBOARD
extern Bool g_fUnicodeClipboard; extern Bool g_fUnicodeClipboard;
extern Bool g_fClipboard; extern Bool g_fClipboard;
@ -227,6 +227,9 @@ winInitializeScreens(int maxscreens)
if (maxscreens > g_iNumScreens) if (maxscreens > g_iNumScreens)
{ {
/* Reallocate the memory for DDX-specific screen info */
g_ScreenInfo = realloc(g_ScreenInfo, maxscreens * sizeof (winScreenInfo));
/* Set default values for any new screens */ /* Set default values for any new screens */
for (i = g_iNumScreens; i < maxscreens ; i++) for (i = g_iNumScreens; i < maxscreens ; i++)
winInitializeScreen(i); winInitializeScreen(i);
@ -353,7 +356,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
nScreenNum = atoi (argv[i + 1]); nScreenNum = atoi (argv[i + 1]);
/* Validate the specified screen number */ /* Validate the specified screen number */
if (nScreenNum < 0 || nScreenNum >= MAXSCREENS) if (nScreenNum < 0)
{ {
ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n", ErrorF ("ddxProcessArgument - screen - Invalid screen number %d\n",
nScreenNum); nScreenNum);

View File

@ -40,17 +40,24 @@
*/ */
extern int g_iNumScreens; extern int g_iNumScreens;
extern winScreenInfo g_ScreenInfo[]; extern winScreenInfo * g_ScreenInfo;
extern Bool g_fXdmcpEnabled; extern Bool g_fXdmcpEnabled;
/* /*
* Prototypes * Verify all screens have been explicitly specified
*/ */
static BOOL
isEveryScreenExplicit(void)
{
int i;
Bool for (i = 0; i < g_iNumScreens; i++)
winValidateArgs (void); if (!g_ScreenInfo[i].fExplicitScreen)
return FALSE;
return TRUE;
}
/* /*
* winValidateArgs - Look for invalid argument combinations * winValidateArgs - Look for invalid argument combinations
@ -62,6 +69,7 @@ winValidateArgs (void)
int i; int i;
int iMaxConsecutiveScreen = 0; int iMaxConsecutiveScreen = 0;
BOOL fHasNormalScreen0 = FALSE; BOOL fHasNormalScreen0 = FALSE;
BOOL fImplicitScreenFound = FALSE;
/* /*
* Check for a malformed set of -screen parameters. * Check for a malformed set of -screen parameters.
@ -70,23 +78,14 @@ winValidateArgs (void)
* XWin -screen 0 -screen 2 * XWin -screen 0 -screen 2
* XWin -screen 1 -screen 2 * XWin -screen 1 -screen 2
*/ */
for (i = 0; i < MAXSCREENS; i++) if (!isEveryScreenExplicit())
{
if (g_ScreenInfo[i].fExplicitScreen)
iMaxConsecutiveScreen = i + 1;
}
winErrorFVerb (2, "winValidateArgs - g_iNumScreens: %d "
"iMaxConsecutiveScreen: %d\n",
g_iNumScreens, iMaxConsecutiveScreen);
if (g_iNumScreens < iMaxConsecutiveScreen)
{ {
ErrorF ("winValidateArgs - Malformed set of screen parameter(s). " ErrorF ("winValidateArgs - Malformed set of screen parameter(s). "
"Screens must be specified consecutively starting with " "Screens must be specified consecutively starting with "
"screen 0. That is, you cannot have only a screen 1, nor " "screen 0. That is, you cannot have only a screen 1, nor "
"could you have screen 0 and screen 2. You instead must " "could you have screen 0 and screen 2. You instead must "
"have screen 0, or screen 0 and screen 1, respectively. Of " "have screen 0, or screen 0 and screen 1, respectively. "
"you can specify as many screens as you want from 0 up to " "You can specify as many screens as you want.\n");
"%d.\n", MAXSCREENS - 1);
return FALSE; return FALSE;
} }