Added support for placing the main window with the @<monitor#>. Patch by

Mark Fisher, small changes by Alexander Gottwald
This commit is contained in:
Alexander Gottwald 2004-12-08 15:12:32 +00:00
parent 295ee7081f
commit f93471e17e
3 changed files with 134 additions and 3 deletions

View file

@ -1,3 +1,10 @@
2004-12-08 Alexander Gottwald <ago at freedesktop dot org>
* InitOutput.c:
* winprocarg.c:
Added support for placing the main window with the @<monitor#>.
Patch by Mark Fisher, small changes by Alexander Gottwald
2004-12-04 Earle Philhower
* InitOutput.c:

View file

@ -435,9 +435,15 @@ winUseMsg (void)
"\tSpecify an optional refresh rate to use in fullscreen mode\n"
"\twith a DirectDraw engine.\n");
ErrorF ("-screen scr_num [width height [x y]]\n"
ErrorF ("-screen scr_num [width height [x y] | [[WxH[+X+Y]][@m]] ]\n"
"\tEnable screen scr_num and optionally specify a width and\n"
"\theight and initial position for that screen.\n");
"\theight and initial position for that screen. Additionally\n"
"\ta monitor number can be specified to start the server on,\n"
"\tat which point, all coordinates become relative to that\n"
"\tmonitor. Examples:\n"
"\t -screen 0 800x600+100+100@2 ; 2nd monitor offset 100,100 size 800x600\n"
"\t -screen 0 1024x768@3 ; 3rd monitor size 1024x768\n"
"\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");
ErrorF ("-lesspointer\n"
"\tHide the windows mouse pointer when it is over an inactive\n"

View file

@ -52,6 +52,17 @@ extern Bool g_fNoHelpMessageBox;
extern Bool g_fSoftwareCursor;
extern Bool g_fSilentDupError;
/* globals required by callback function for monitor information */
struct GetMonitorInfoData {
int requestedMonitor;
int monitorNum;
Bool bUserSpecifiedMonitor;
Bool bMonitorSpecifiedExists;
int monitorOffsetX;
int monitorOffsetY;
int monitorHeight;
int monitorWidth;
};
/*
* Function prototypes
@ -70,6 +81,7 @@ void OsVendorVErrorF (const char *pszFormat, va_list va_args);
void
winInitializeDefaultScreens (void);
BOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM data);
/*
* Process arguments on the command line
@ -252,6 +264,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
int iArgsProcessed = 1;
int nScreenNum;
int iWidth, iHeight, iX, iY;
int iMonitor;
#if CYGDEBUG
winDebug ("ddxProcessArgument - screen - argc: %d i: %d\n",
@ -276,8 +289,40 @@ ddxProcessArgument (int argc, char *argv[], int i)
return 0;
}
/* look for @m where m is monitor number */
if (i + 2 < argc
&& 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor))
{
struct GetMonitorInfoData data;
memset(&data, 0, sizeof(data));
data.requestedMonitor = iMonitor;
EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) &data);
if (data.bMonitorSpecifiedExists == TRUE)
{
winErrorFVerb(2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
iArgsProcessed = 3;
g_ScreenInfo[nScreenNum].fUserGaveHeightAndWidth = FALSE;
g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
g_ScreenInfo[nScreenNum].dwWidth = data.monitorWidth;
g_ScreenInfo[nScreenNum].dwHeight = data.monitorHeight;
g_ScreenInfo[nScreenNum].dwUserWidth = data.monitorWidth;
g_ScreenInfo[nScreenNum].dwUserHeight = data.monitorHeight;
g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
}
else
{
/* monitor does not exist, error out */
ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
iMonitor);
UseMsg ();
exit (0);
return 0;
}
}
/* Look for 'WxD' or 'W D' */
if (i + 2 < argc
else if (i + 2 < argc
&& 2 == sscanf (argv[i + 2], "%dx%d",
(int *) &iWidth,
(int *) &iHeight))
@ -298,6 +343,58 @@ ddxProcessArgument (int argc, char *argv[], int i)
g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
g_ScreenInfo[nScreenNum].dwInitialX = iX;
g_ScreenInfo[nScreenNum].dwInitialY = iY;
/* look for WxD+X+Y@m where m is monitor number. take X,Y to be offsets from monitor's root position */
if (1 == sscanf (argv[i + 2], "%*dx%*d+%*d+%*d@%d",
(int *) &iMonitor))
{
struct GetMonitorInfoData data;
memset(&data, 0, sizeof(data));
data.requestedMonitor = iMonitor;
EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) &data);
if (data.bMonitorSpecifiedExists == TRUE)
{
g_ScreenInfo[nScreenNum].dwInitialX += data.monitorOffsetX;
g_ScreenInfo[nScreenNum].dwInitialY += data.monitorOffsetY;
}
else
{
/* monitor does not exist, error out */
ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
iMonitor);
UseMsg ();
exit (0);
return 0;
}
}
}
/* look for WxD@m where m is monitor number */
else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d",
(int *) &iMonitor))
{
struct GetMonitorInfoData data;
memset(&data, 0, sizeof(data));
data.requestedMonitor = iMonitor;
EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) &data);
if (data.bMonitorSpecifiedExists == TRUE)
{
winErrorFVerb (2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;
g_ScreenInfo[nScreenNum].dwInitialX = data.monitorOffsetX;
g_ScreenInfo[nScreenNum].dwInitialY = data.monitorOffsetY;
}
else
{
/* monitor does not exist, error out */
ErrorF ("ddxProcessArgument - screen - Invalid monitor number %d\n",
iMonitor);
UseMsg ();
exit (0);
return 0;
}
}
}
else if (i + 3 < argc
@ -1332,3 +1429,24 @@ winLogVersionInfo (void)
ErrorF ("Release: %s\n\n", VERSION_STRING);
ErrorF ("Contact: %s\n\n", VENDOR_CONTACT);
}
/*
* getMonitorInfo - callback function used to return information from the enumeration of monitors attached
*/
BOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data)
{
struct GetMonitorInfoData* data = (struct GetMonitorInfoData*)_data;
// only get data for monitor number specified in <data>
data->monitorNum++;
if (data->monitorNum == data->requestedMonitor)
{
data->bMonitorSpecifiedExists = TRUE;
data->monitorOffsetX = rect->left;
data->monitorOffsetY = rect->top;
data->monitorHeight = rect->bottom - rect->top;
data->monitorWidth = rect->right - rect->left;
return FALSE;
}
return TRUE;
}