hw/xwin: Stop pretending we work on NT4

We already link directly to some functions not available in NT4, so stop
pretending we will work on NT4 and link directly to EnumDisplayMonitors()
and SHGetFolderPath()

Also remove mentions of NT4 & Win95 from error messages

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
This commit is contained in:
Jon TURNEY 2011-07-03 19:10:52 +01:00
parent f6529a05a2
commit 3ead1d810b
3 changed files with 11 additions and 57 deletions

View File

@ -588,34 +588,17 @@ winFixupPaths (void)
} }
if (getenv("HOME") == NULL) if (getenv("HOME") == NULL)
{ {
HMODULE shfolder;
SHGETFOLDERPATHPROC shgetfolderpath = NULL;
char buffer[MAX_PATH + 5]; char buffer[MAX_PATH + 5];
strncpy(buffer, "HOME=", 5); strncpy(buffer, "HOME=", 5);
/* Try to load SHGetFolderPath from shfolder.dll and shell32.dll */
shfolder = LoadLibrary("shfolder.dll");
/* fallback to shell32.dll */
if (shfolder == NULL)
shfolder = LoadLibrary("shell32.dll");
/* resolve SHGetFolderPath */
if (shfolder != NULL)
shgetfolderpath = (SHGETFOLDERPATHPROC)GetProcAddress(shfolder, "SHGetFolderPathA");
/* query appdata directory */ /* query appdata directory */
if (shgetfolderpath && if (SHGetFolderPathA(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0, buffer + 5) == 0)
shgetfolderpath(NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE, NULL, 0,
buffer + 5) == 0)
{ {
putenv(buffer); putenv(buffer);
} else } else
{ {
winMsg (X_ERROR, "Can not determine HOME directory\n"); winMsg (X_ERROR, "Can not determine HOME directory\n");
} }
if (shfolder != NULL)
FreeLibrary(shfolder);
} }
if (!g_fLogFileChanged) { if (!g_fLogFileChanged) {
static char buffer[MAX_PATH]; static char buffer[MAX_PATH];
@ -825,7 +808,7 @@ winUseMsg (void)
"\theight and initial position for that screen. Additionally\n" "\theight and initial position for that screen. Additionally\n"
"\ta monitor number can be specified to start the server on,\n" "\ta monitor number can be specified to start the server on,\n"
"\tat which point, all coordinates become relative to that\n" "\tat which point, all coordinates become relative to that\n"
"\tmonitor (Not for Windows NT4 and 95). Examples:\n" "\tmonitor. Examples:\n"
"\t -screen 0 800x600+100+100@2 ; 2nd monitor offset 100,100 size 800x600\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 1024x768@3 ; 3rd monitor size 1024x768\n"
"\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n"); "\t -screen 0 @1 ; on 1st monitor using its full resolution (the default)\n");

View File

@ -53,30 +53,8 @@ wBOOL CALLBACK getMonitorInfo(HMONITOR hMonitor, HDC hdc, LPRECT rect, LPARAM _d
return TRUE; return TRUE;
} }
typedef WINAPI 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) 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 */ /* prepare data */
if (data == NULL) if (data == NULL)
return FALSE; return FALSE;
@ -84,9 +62,5 @@ Bool QueryMonitor(int index, struct GetMonitorInfoData *data)
data->requestedMonitor = index; data->requestedMonitor = index;
/* query information */ /* query information */
_EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data); return EnumDisplayMonitors(NULL, NULL, getMonitorInfo, (LPARAM) data);
/* cleanup */
FreeLibrary(user32);
return TRUE;
} }

View File

@ -326,8 +326,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
struct GetMonitorInfoData data; struct GetMonitorInfoData data;
if (!QueryMonitor(iMonitor, &data)) if (!QueryMonitor(iMonitor, &data))
{ {
ErrorF ("ddxProcessArgument - screen - " ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
"Querying monitors is not supported on NT4 and Win95\n");
} else if (data.bMonitorSpecifiedExists == TRUE) } else if (data.bMonitorSpecifiedExists == TRUE)
{ {
winErrorFVerb(2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor); winErrorFVerb(2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);
@ -383,8 +382,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
struct GetMonitorInfoData data; struct GetMonitorInfoData data;
if (!QueryMonitor(iMonitor, &data)) if (!QueryMonitor(iMonitor, &data))
{ {
ErrorF ("ddxProcessArgument - screen - " ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
"Querying monitors is not supported on NT4 and Win95\n");
} else if (data.bMonitorSpecifiedExists == TRUE) } else if (data.bMonitorSpecifiedExists == TRUE)
{ {
g_ScreenInfo[nScreenNum].iMonitor = iMonitor; g_ScreenInfo[nScreenNum].iMonitor = iMonitor;
@ -411,8 +409,7 @@ ddxProcessArgument (int argc, char *argv[], int i)
struct GetMonitorInfoData data; struct GetMonitorInfoData data;
if (!QueryMonitor(iMonitor, &data)) if (!QueryMonitor(iMonitor, &data))
{ {
ErrorF ("ddxProcessArgument - screen - " ErrorF ("ddxProcessArgument - screen - Querying monitors failed\n");
"Querying monitors is not supported on NT4 and Win95\n");
} else if (data.bMonitorSpecifiedExists == TRUE) } else if (data.bMonitorSpecifiedExists == TRUE)
{ {
winErrorFVerb (2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor); winErrorFVerb (2, "ddxProcessArgument - screen - Found Valid ``@Monitor'' = %d arg\n", iMonitor);