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++)
|
for (iMonitor = 1; ; iMonitor++)
|
||||||
{
|
{
|
||||||
struct GetMonitorInfoData data;
|
struct GetMonitorInfoData data;
|
||||||
QueryMonitor(iMonitor, &data);
|
if (QueryMonitor(iMonitor, &data))
|
||||||
if (data.bMonitorSpecifiedExists)
|
|
||||||
{
|
{
|
||||||
MONITORINFO mi;
|
MONITORINFO mi;
|
||||||
mi.cbSize = sizeof(MONITORINFO);
|
mi.cbSize = sizeof(MONITORINFO);
|
||||||
|
|
|
@ -39,7 +39,7 @@ from The Open Group.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static
|
static
|
||||||
wBOOL CALLBACK
|
WINBOOL CALLBACK
|
||||||
getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data)
|
getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data)
|
||||||
{
|
{
|
||||||
struct GetMonitorInfoData *data = (struct GetMonitorInfoData *) _data;
|
struct GetMonitorInfoData *data = (struct GetMonitorInfoData *) _data;
|
||||||
|
@ -70,5 +70,5 @@ QueryMonitor(int i, struct GetMonitorInfoData *data)
|
||||||
/* query information */
|
/* query information */
|
||||||
EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
|
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)) {
|
if (i + 2 < argc && 1 == sscanf(argv[i + 2], "@%d", (int *) &iMonitor)) {
|
||||||
struct GetMonitorInfoData data;
|
struct GetMonitorInfoData data;
|
||||||
|
|
||||||
if (!QueryMonitor(iMonitor, &data)) {
|
if (QueryMonitor(iMonitor, &data)) {
|
||||||
ErrorF
|
|
||||||
("ddxProcessArgument - screen - Querying monitors failed\n");
|
|
||||||
}
|
|
||||||
else if (data.bMonitorSpecifiedExists == TRUE) {
|
|
||||||
winErrorFVerb(2,
|
winErrorFVerb(2,
|
||||||
"ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n",
|
"ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n",
|
||||||
iMonitor);
|
iMonitor);
|
||||||
|
@ -334,8 +330,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
||||||
ErrorF
|
ErrorF
|
||||||
("ddxProcessArgument - screen - Invalid monitor number %d\n",
|
("ddxProcessArgument - screen - Invalid monitor number %d\n",
|
||||||
iMonitor);
|
iMonitor);
|
||||||
UseMsg();
|
exit(1);
|
||||||
exit(0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,11 +361,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
||||||
(int *) &iMonitor)) {
|
(int *) &iMonitor)) {
|
||||||
struct GetMonitorInfoData data;
|
struct GetMonitorInfoData data;
|
||||||
|
|
||||||
if (!QueryMonitor(iMonitor, &data)) {
|
if (QueryMonitor(iMonitor, &data)) {
|
||||||
ErrorF
|
|
||||||
("ddxProcessArgument - screen - Querying monitors failed\n");
|
|
||||||
}
|
|
||||||
else if (data.bMonitorSpecifiedExists == TRUE) {
|
|
||||||
g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
|
g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
|
||||||
g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle;
|
g_ScreenInfo[nScreenNum].hMonitor = data.monitorHandle;
|
||||||
g_ScreenInfo[nScreenNum].dwInitialX +=
|
g_ScreenInfo[nScreenNum].dwInitialX +=
|
||||||
|
@ -383,11 +374,9 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
||||||
ErrorF
|
ErrorF
|
||||||
("ddxProcessArgument - screen - Invalid monitor number %d\n",
|
("ddxProcessArgument - screen - Invalid monitor number %d\n",
|
||||||
iMonitor);
|
iMonitor);
|
||||||
UseMsg();
|
exit(1);
|
||||||
exit(0);
|
|
||||||
return 0;
|
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)) {
|
else if (1 == sscanf(argv[i + 2], "%*dx%*d@%d", (int *) &iMonitor)) {
|
||||||
struct GetMonitorInfoData data;
|
struct GetMonitorInfoData data;
|
||||||
|
|
||||||
if (!QueryMonitor(iMonitor, &data)) {
|
if (QueryMonitor(iMonitor, &data)) {
|
||||||
ErrorF
|
|
||||||
("ddxProcessArgument - screen - Querying monitors failed\n");
|
|
||||||
}
|
|
||||||
else if (data.bMonitorSpecifiedExists == TRUE) {
|
|
||||||
winErrorFVerb(2,
|
winErrorFVerb(2,
|
||||||
"ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n",
|
"ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n",
|
||||||
iMonitor);
|
iMonitor);
|
||||||
|
@ -414,11 +399,9 @@ ddxProcessArgument(int argc, char *argv[], int i)
|
||||||
ErrorF
|
ErrorF
|
||||||
("ddxProcessArgument - screen - Invalid monitor number %d\n",
|
("ddxProcessArgument - screen - Invalid monitor number %d\n",
|
||||||
iMonitor);
|
iMonitor);
|
||||||
UseMsg();
|
exit(1);
|
||||||
exit(0);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (i + 3 < argc && 1 == sscanf(argv[i + 2], "%d", (int *) &iWidth)
|
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;
|
struct GetMonitorInfoData data;
|
||||||
|
|
||||||
if (QueryMonitor(s_pScreenInfo->iMonitor, &data)) {
|
if (QueryMonitor(s_pScreenInfo->iMonitor, &data)) {
|
||||||
if (data.bMonitorSpecifiedExists == TRUE) {
|
|
||||||
dwWidth = data.monitorWidth;
|
dwWidth = data.monitorWidth;
|
||||||
dwHeight = data.monitorHeight;
|
dwHeight = data.monitorHeight;
|
||||||
/*
|
/*
|
||||||
|
@ -250,7 +249,6 @@ winWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
ErrorF("Monitor number %d no longer exists!\n",
|
ErrorF("Monitor number %d no longer exists!\n",
|
||||||
s_pScreenInfo->iMonitor);
|
s_pScreenInfo->iMonitor);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user