diff --git a/hw/xwin/ChangeLog b/hw/xwin/ChangeLog index b0704c790..79d200433 100644 --- a/hw/xwin/ChangeLog +++ b/hw/xwin/ChangeLog @@ -1,3 +1,10 @@ +2004-12-14 Alexander Gottwald + + * InitOutput.c: + * winprocarg.c: + EnumDisplayMonitors is not available on Window NT4 and 95. Resolve + the function dynamicly + 2004-12-08 Alexander Gottwald * InitOutput.c: diff --git a/hw/xwin/InitOutput.c b/hw/xwin/InitOutput.c index 99c141c9c..2224b0635 100644 --- a/hw/xwin/InitOutput.c +++ b/hw/xwin/InitOutput.c @@ -752,7 +752,7 @@ winUseMsg (void) "\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" + "\tmonitor (Not for Windows NT4 and 95). 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"); diff --git a/hw/xwin/winprocarg.c b/hw/xwin/winprocarg.c index c789e03ed..9bd51fa6b 100755 --- a/hw/xwin/winprocarg.c +++ b/hw/xwin/winprocarg.c @@ -67,6 +67,44 @@ struct GetMonitorInfoData { int monitorWidth; }; +typedef wBOOL (*ENUMDISPLAYMONITORSPROC)(HDC,LPCRECT,MONITORENUMPROC,LPARAM); +ENUMDISPLAYMONITORSPROC _EnumDisplayMonitors; + +wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _data); + +Bool QueryMonitor(int index, struct GetMonitorInfoData *data) +{ + /* Load EnumDisplayMonitors from DLL */ + HMODULE user32; + FARPROC func; + user32 = LoadLibrary("user32.dll"); + if (user32 == NULL) + { + winW32Error(2, "Could not open user32.dll"); + return FALSE; + } + func = GetProcAddress(user32, "EnumDisplayMonitors"); + if (func == NULL) + { + winW32Error(2, "Could not resolve EnumDisplayMonitors: "); + return FALSE; + } + _EnumDisplayMonitors = (ENUMDISPLAYMONITORSPROC)func; + + /* prepare data */ + if (data == NULL) + return FALSE; + memset(data, 0, sizeof(*data)); + data->requestedMonitor = index; + + /* query information */ + _EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data); + + /* cleanup */ + FreeLibrary(user32); + return TRUE; +} + /* * Function prototypes */ @@ -84,8 +122,6 @@ void OsVendorVErrorF (const char *pszFormat, va_list va_args); void winInitializeDefaultScreens (void); -wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM data); - /* * Process arguments on the command line */ @@ -298,10 +334,11 @@ ddxProcessArgument (int argc, char *argv[], int i) && 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) + if (!QueryMonitor(iMonitor, &data)) + { + ErrorF ("ddxProcessArgument - screen - " + "Querying monitors is not supported on NT4 and Win95\n"); + } else if (data.bMonitorSpecifiedExists == TRUE) { winErrorFVerb(2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor); iArgsProcessed = 3; @@ -353,10 +390,11 @@ ddxProcessArgument (int argc, char *argv[], int i) (int *) &iMonitor)) { struct GetMonitorInfoData data; - memset(&data, 0, sizeof(data)); - data.requestedMonitor = iMonitor; - EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) &data); - if (data.bMonitorSpecifiedExists == TRUE) + if (!QueryMonitor(iMonitor, &data)) + { + ErrorF ("ddxProcessArgument - screen - " + "Querying monitors is not supported on NT4 and Win95\n"); + } else if (data.bMonitorSpecifiedExists == TRUE) { g_ScreenInfo[nScreenNum].dwInitialX += data.monitorOffsetX; g_ScreenInfo[nScreenNum].dwInitialY += data.monitorOffsetY; @@ -379,10 +417,11 @@ ddxProcessArgument (int argc, char *argv[], int i) (int *) &iMonitor)) { struct GetMonitorInfoData data; - memset(&data, 0, sizeof(data)); - data.requestedMonitor = iMonitor; - EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) &data); - if (data.bMonitorSpecifiedExists == TRUE) + if (!QueryMonitor(iMonitor, &data)) + { + ErrorF ("ddxProcessArgument - screen - " + "Querying monitors is not supported on NT4 and Win95\n"); + } else if (data.bMonitorSpecifiedExists == TRUE) { winErrorFVerb (2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor); g_ScreenInfo[nScreenNum].fUserGavePosition = TRUE;