Alexandre Julliard : user32: Set the process DPI awareness from the manifest.
Alexandre Julliard
julliard at winehq.org
Fri Mar 30 12:32:36 CDT 2018
Module: wine
Branch: master
Commit: 4c71db15ca72f099d5237857a3e9eb03764c7f1b
URL: https://source.winehq.org/git/wine.git/?a=commit;h=4c71db15ca72f099d5237857a3e9eb03764c7f1b
Author: Alexandre Julliard <julliard at winehq.org>
Date: Fri Mar 30 16:45:22 2018 +0200
user32: Set the process DPI awareness from the manifest.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/user_main.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
dlls/user32/user_private.h | 2 ++
2 files changed, 59 insertions(+)
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c
index 74a7617..057c7aa 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -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 */
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
index 7e4f699..5d54cb1 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -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
More information about the wine-cvs
mailing list