Commit 4c71db15 authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Set the process DPI awareness from the manifest.

parent bd0cd09e
......@@ -212,6 +212,62 @@ static const WCHAR *get_default_desktop(void)
/***********************************************************************
* dpiaware_init
*
* Initialize the DPI awareness style.
*/
static void dpiaware_init(void)
{
WCHAR buffer[256];
static const WCHAR dpiAwareW[] = {'d','p','i','A','w','a','r','e',0};
static const WCHAR dpiAwarenessW[] = {'d','p','i','A','w','a','r','e','n','e','s','s',0};
static const WCHAR namespace2005W[] = {'h','t','t','p',':','/','/','s','c','h','e','m','a','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','S','M','I','/','2','0','0','5','/','W','i','n','d','o','w','s','S','e','t','t','i','n','g','s',0};
static const WCHAR namespace2016W[] = {'h','t','t','p',':','/','/','s','c','h','e','m','a','s','.','m','i','c','r','o','s','o','f','t','.','c','o','m','/','S','M','I','/','2','0','1','6','/','W','i','n','d','o','w','s','S','e','t','t','i','n','g','s',0};
if (QueryActCtxSettingsW( 0, NULL, namespace2016W, dpiAwarenessW, buffer, ARRAY_SIZE(buffer), NULL ))
{
static const WCHAR unawareW[] = {'u','n','a','w','a','r','e',0};
static const WCHAR systemW[] = {'s','y','s','t','e','m',0};
static const WCHAR permonW[] = {'p','e','r','m','o','n','i','t','o','r',0};
static const WCHAR permonv2W[] = {'p','e','r','m','o','n','i','t','o','r','v','2',0};
static const WCHAR spacesW[] = {' ','\t','\r','\n',0};
static const WCHAR * const types[] = { unawareW, systemW, permonW, permonv2W };
WCHAR *p, *start = buffer, *end;
ULONG_PTR i;
TRACE( "got dpiAwareness=%s\n", debugstr_w(buffer) );
for (start = buffer; *start; start = end)
{
start += strspnW( start, spacesW );
if (!(end = strchrW( start, ',' ))) end = start + strlenW(start);
else *end++ = 0;
if ((p = strpbrkW( start, spacesW ))) *p = 0;
for (i = 0; i < ARRAY_SIZE(types); i++)
{
if (strcmpiW( start, types[i] )) continue;
SetProcessDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i );
return;
}
}
}
else if (QueryActCtxSettingsW( 0, NULL, namespace2005W, dpiAwareW, buffer, ARRAY_SIZE(buffer), NULL ))
{
static const WCHAR trueW[] = {'t','r','u','e',0};
static const WCHAR truepmW[] = {'t','r','u','e','/','p','m',0};
static const WCHAR permonW[] = {'p','e','r',' ','m','o','n','i','t','o','r',0};
TRACE( "got dpiAware=%s\n", debugstr_w(buffer) );
if (!strcmpiW( buffer, trueW ))
SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE );
else if (!strcmpiW( buffer, truepmW ) || !strcmpiW( buffer, permonW ))
SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
else
SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_UNAWARE );
}
}
/***********************************************************************
* winstation_init
*
* Connect to the process window station and desktop.
......@@ -272,6 +328,7 @@ static void winstation_init(void)
*/
static BOOL process_attach(void)
{
dpiaware_init();
winstation_init();
/* Initialize system colors and metrics */
......
......@@ -32,6 +32,8 @@
#define GET_WORD(ptr) (*(const WORD *)(ptr))
#define GET_DWORD(ptr) (*(const DWORD *)(ptr))
#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
#define WM_SYSTIMER 0x0118
#define WM_POPUPSYSTEMMENU 0x0313
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment