hw/xwin: Make QueryMonitor() slightly less insane
Make QueryMonitor() slightly less insane, making it return TRUE if the
specified monitor exists, rather than always returning TRUE (which we
are uselessly checking, and then also checking if the specified monitor
exists)
(Note that EnumDisplayMonitors() doesn't seem to have meaningful way to
return errors, see 5940580f
)
Also: Spamming the long UseMsg() after "Invalid monitor number" isn't very
helpful.
Also: If we are exiting in ddxProcessArgument() due to an error in
options, use a non-zero exit status.
This commit is contained in:
parent
8f7e4b56d2
commit
b078e03410
|
@ -981,8 +981,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[])
|
|||
for (iMonitor = 1; ; iMonitor++)
|
||||
{
|
||||
struct GetMonitorInfoData data;
|
||||
QueryMonitor(iMonitor, &data);
|
||||
if (data.bMonitorSpecifiedExists)
|
||||
if (QueryMonitor(iMonitor, &data))
|
||||
{
|
||||
MONITORINFO mi;
|
||||
mi.cbSize = sizeof(MONITORINFO);
|
||||
|
|
|
@ -39,7 +39,7 @@ from The Open Group.
|
|||
*/
|
||||
|
||||
static
|
||||
wBOOL CALLBACK
|
||||
WINBOOL CALLBACK
|
||||
getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data)
|
||||
{
|
||||
struct GetMonitorInfoData *data = (struct GetMonitorInfoData *) _data;
|
||||
|
@ -70,5 +70,5 @@ QueryMonitor(int i, struct GetMonitorInfoData *data)
|
|||
/* query information */
|
||||
EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
|
||||
|
||||
return TRUE;
|
||||
return data->bMonitorSpecifiedExists;
|
||||
}
|
||||
|
|
|
@ -309,11 +309,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
|||
if (i + 2 < argc && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor)) {
|
||||
struct GetMonitorInfoData data;
|
||||
|
||||
if (!QueryMonitor(iMonitor, &data)) {
|
||||
ErrorF
|
||||
("ddxProcessArgument - screen - Querying monitors failed\n");
|
||||
}
|
||||
else if (data.bMonitorSpecifiedExists == TRUE) {
|
||||
if (QueryMonitor(iMonitor, &data)) {
|
||||
winErrorFVerb(2,
|
||||
"ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n",
|
||||
iMonitor);
|
||||
|
@ -334,8 +330,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
|||
ErrorF
|
||||
("ddxProcessArgument - screen - Invalid monitor number %d\n",
|
||||
iMonitor);
|
||||
UseMsg();
|
||||
exit(0);
|
||||
exit(1);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -366,11 +361,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
|||
(int *) &iMonitor)) {
|
||||
struct GetMonitorInfoData data;
|
||||
|
||||
if (!QueryMonitor(iMonitor, &data)) {
|
||||
ErrorF
|
||||
("ddxProcessArgument - screen - Querying monitors failed\n");
|
||||
}
|
||||
else if (data.bMonitorSpecifiedExists == TRUE) {
|
||||
if (QueryMonitor(iMonitor, &data)) {
|
||||
g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
|
||||
g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle;
|
||||
g_ScreenInfo[nScreenNum].dwInitialX +=
|
||||
|
@ -383,11 +374,9 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
|||
ErrorF
|
||||
("ddxProcessArgument - screen - Invalid monitor number %d\n",
|
||||
iMonitor);
|
||||
UseMsg();
|
||||
exit(0);
|
||||
exit(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,11 +384,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
|||
else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d", (int *) &iMonitor)) {
|
||||
struct GetMonitorInfoData data;
|
||||
|
||||
if (!QueryMonitor(iMonitor, &data)) {
|
||||
ErrorF
|
||||
("ddxProcessArgument - screen - Querying monitors failed\n");
|
||||
}
|
||||
else if (data.bMonitorSpecifiedExists == TRUE) {
|
||||
if (QueryMonitor(iMonitor, &data)) {
|
||||
winErrorFVerb(2,
|
||||
"ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n",
|
||||
iMonitor);
|
||||
|
@ -414,11 +399,9 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
|||
ErrorF
|
||||
("ddxProcessArgument - screen - Invalid monitor number %d\n",
|
||||
iMonitor);
|
||||
UseMsg();
|
||||
exit(0);
|
||||
exit(1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (i + 3 < argc && 1 == sscanf(argv[i + 2], "%d", (int *) &iWidth)
|
||||
|
|
|
@ -238,7 +238,6 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
struct GetMonitorInfoData data;
|
||||
|
||||
if (QueryMonitor(s_pScreenInfo->iMonitor, &data)) {
|
||||
if (data.bMonitorSpecifiedExists == TRUE) {
|
||||
dwWidth = data.monitorWidth;
|
||||
dwHeight = data.monitorHeight;
|
||||
/*
|
||||
|
@ -250,7 +249,6 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
ErrorF("Monitor number %d no longer exists!\n",
|
||||
s_pScreenInfo->iMonitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue