sys_sdl_win.c: Sys_SetDPIAware: call SetProcessDPIAwareness / SetProcessDPIAware

git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@1119 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
Eric Wasylishen 2014-10-16 23:01:43 +00:00
parent 5438f83b08
commit f244f82c64

View file

@ -173,10 +173,43 @@ static void Sys_GetBasedir (char *argv0, char *dst, size_t dstsize)
}
}
typedef enum { dpi_unaware = 0, dpi_system_aware = 1, dpi_monitor_aware = 2 } dpi_awareness;
typedef BOOL(*SetProcessDPIAwareFunc)();
typedef HRESULT(*SetProcessDPIAwarenessFunc)(dpi_awareness value);
void Sys_SetDPIAware (void)
{
HMODULE hUser32, hShcore;
SetProcessDPIAwarenessFunc setDPIAwareness;
SetProcessDPIAwareFunc setDPIAware;
/* Neither SDL 1.2 nor SDL 2.0.3 can handle the OS scaling our window.
(e.g. https://bugzilla.libsdl.org/show_bug.cgi?id=2713)
Call SetProcessDpiAwareness/SetProcessDPIAware to opt out of scaling.
*/
hShcore = LoadLibraryA ("Shcore.dll");
hUser32 = LoadLibraryA ("user32.dll");
setDPIAwareness = (SetProcessDPIAwarenessFunc) GetProcAddress(hShcore, "SetProcessDpiAwareness");
setDPIAware = (SetProcessDPIAwareFunc) GetProcAddress (hUser32, "SetProcessDPIAware");
if (setDPIAwareness) /* Windows 8.1+ */
setDPIAwareness (dpi_monitor_aware);
else if (setDPIAware) /* Windows Vista-8.0 */
setDPIAware ();
if (hShcore)
FreeLibrary (hShcore);
if (hUser32)
FreeLibrary (hUser32);
}
void Sys_Init (void)
{
OSVERSIONINFO vinfo;
Sys_SetDPIAware ();
memset (cwd, 0, sizeof(cwd));
Sys_GetBasedir(NULL, cwd, sizeof(cwd));
host_parms->basedir = cwd;