From: Fabian Maurer dark.shadow4@web.de
--- dlls/win32u/sysparams.c | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 5dcf42ff7f5..5e48a09522c 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -2187,6 +2187,27 @@ UINT get_win_monitor_dpi( HWND hwnd ) return system_dpi; }
+/* see GetAwarenessFromDpiAwarenessContext */ +static DPI_AWARENESS get_awareness_from_dpi_awareness_context( DPI_AWARENESS_CONTEXT context ) +{ + switch ((ULONG_PTR)context) + { + case 0x10: + case 0x11: + case 0x12: + case 0x80000010: + case 0x80000011: + case 0x80000012: + return (ULONG_PTR)context & 3; + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE: + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE: + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE: + return ~(ULONG_PTR)context; + default: + return DPI_AWARENESS_INVALID; + } +} + /********************************************************************** * get_thread_dpi_awareness */ @@ -2240,27 +2261,6 @@ UINT get_system_dpi(void) return system_dpi; }
-/* see GetAwarenessFromDpiAwarenessContext */ -static DPI_AWARENESS get_awareness_from_dpi_awareness_context( DPI_AWARENESS_CONTEXT context ) -{ - switch ((ULONG_PTR)context) - { - case 0x10: - case 0x11: - case 0x12: - case 0x80000010: - case 0x80000011: - case 0x80000012: - return (ULONG_PTR)context & 3; - case (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE: - case (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE: - case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE: - return ~(ULONG_PTR)context; - default: - return DPI_AWARENESS_INVALID; - } -} - /********************************************************************** * SetThreadDpiAwarenessContext (win32u.so) */
From: Fabian Maurer dark.shadow4@web.de
--- dlls/win32u/sysparams.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 5e48a09522c..7dc807bb909 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -2216,24 +2216,10 @@ DPI_AWARENESS get_thread_dpi_awareness(void) struct ntuser_thread_info *info = NtUserGetThreadInfo(); ULONG_PTR context = info->dpi_awareness;
- switch (context) - { - case 0: /* process default */ + if (context == 0) /* process default */ return NtUserGetProcessDpiAwarenessContext( NULL ) & 3; - case 0x10: - case 0x11: - case 0x12: - case 0x80000010: - case 0x80000011: - case 0x80000012: - return context & 3; - case (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE: - case (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE: - case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE: - return ~context; - default: - return DPI_AWARENESS_INVALID; - } + + return get_awareness_from_dpi_awareness_context((DPI_AWARENESS_CONTEXT)context); }
DWORD get_process_layout(void)
From: Fabian Maurer dark.shadow4@web.de
--- dlls/user32/tests/sysparams.c | 52 +++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+)
diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c index 16756ecb06a..68fe455a002 100644 --- a/dlls/user32/tests/sysparams.c +++ b/dlls/user32/tests/sysparams.c @@ -3778,6 +3778,55 @@ static void test_dpi_aware(void) test_metrics_for_dpi( 192 ); }
+static void test_ThreadDpiAwarenessContext(ULONG_PTR flags) +{ + int i; + DPI_AWARENESS_CONTEXT context, last_context; + DPI_AWARENESS awareness; + BOOL ret = pGetProcessDpiAwarenessInternal(GetCurrentProcess(), &awareness); + + struct awareness_context_thread + { + ULONG_PTR context; + ULONG_PTR result_get; + ULONG_PTR result_set; + BOOL todo_get; + BOOL todo_set; + } awareness_contexts[] = { + { 0x10 | flags, 0x10 | flags, 0x10 | flags }, + { 0x11 | flags, 0x11 | flags, 0x11 | flags }, + { 0x12, 0x12, 0x12 }, + { 0x22, 0x22, 0x22, TRUE, TRUE }, + { 0x80000010 | flags, 0x10 | awareness | flags, 0x80000010 | awareness | flags }, + { 0x80000011 | flags, 0x10 | awareness | flags, 0x80000010 | awareness | flags }, + { 0x80000012, 0x10 | awareness | flags, 0x80000010 | awareness | flags }, + { 0x80000022, 0x10 | awareness | flags, 0x80000010 | awareness | flags, FALSE, TRUE }, + { (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE, 0x10 | flags, 0x10 | flags }, + { (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE, 0x11 | flags, 0x11 | flags }, + { (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, 0x12, 0x12 }, + { (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, 0x22, 0x22, TRUE, TRUE }, + { 0x12, 0x12 }, /* Only for last_result test */ + }; + + ok(ret, "GetProcessDpiAwarenessInternal failed\n"); + + for (i = 0; i < ARRAY_SIZE(awareness_contexts); i++) + { + struct awareness_context_thread *item = &awareness_contexts[i]; + last_context = pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)item->context ); + ok(last_context != 0, "Failed to set context %p\n", (DPI_AWARENESS_CONTEXT)item->context ); + if (i != 0) + { + struct awareness_context_thread *last = &awareness_contexts[i - 1]; + todo_wine_if(awareness_contexts[i - 1].todo_set) + ok( last_context == (DPI_AWARENESS_CONTEXT)last->result_set, "For context %p - after set expected %p, got %p\n", (DPI_AWARENESS_CONTEXT)last->context, (DPI_AWARENESS_CONTEXT)last->result_set, last_context ); + } + context = pGetThreadDpiAwarenessContext(); + todo_wine_if(item->todo_get) + ok( context == (DPI_AWARENESS_CONTEXT)item->result_get, "For context %p - after get expected %p, got %p\n", (DPI_AWARENESS_CONTEXT)item->context, (DPI_AWARENESS_CONTEXT)item->result_get, context ); + } +} + static void test_dpi_context(void) { DPI_AWARENESS awareness; @@ -3923,6 +3972,9 @@ static void test_dpi_context(void) context = pGetThreadDpiAwarenessContext(); todo_wine ok( context == (DPI_AWARENESS_CONTEXT)(0x11 | flags), "wrong context %p\n", context ); + + test_ThreadDpiAwarenessContext(flags); + for (i = 0; i < 0x100; i++) { awareness = pGetAwarenessFromDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)i );
From: Fabian Maurer dark.shadow4@web.de
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56360 --- dlls/user32/sysparams.c | 4 +++- dlls/user32/tests/sysparams.c | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index ec8dc11af17..d30bed44b31 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -747,7 +747,9 @@ DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT prev = NtUserGetProcessDpiAwarenessContext( GetCurrentProcess() ) & 3; prev |= 0x80000010; /* restore to process default */ } - if (((ULONG_PTR)context & ~(ULONG_PTR)0x13) == 0x80000000) info->dpi_awareness = 0; + if (((ULONG_PTR)context & ~(ULONG_PTR)0x33) == 0x80000000) info->dpi_awareness = 0; + else if (context == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 || context == (DPI_AWARENESS_CONTEXT)0x22) + info->dpi_awareness = 0x22; else info->dpi_awareness = val | 0x10; return ULongToHandle( prev ); } diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c index 68fe455a002..a3d3785c689 100644 --- a/dlls/user32/tests/sysparams.c +++ b/dlls/user32/tests/sysparams.c @@ -3796,15 +3796,15 @@ static void test_ThreadDpiAwarenessContext(ULONG_PTR flags) { 0x10 | flags, 0x10 | flags, 0x10 | flags }, { 0x11 | flags, 0x11 | flags, 0x11 | flags }, { 0x12, 0x12, 0x12 }, - { 0x22, 0x22, 0x22, TRUE, TRUE }, + { 0x22, 0x22, 0x22}, { 0x80000010 | flags, 0x10 | awareness | flags, 0x80000010 | awareness | flags }, { 0x80000011 | flags, 0x10 | awareness | flags, 0x80000010 | awareness | flags }, { 0x80000012, 0x10 | awareness | flags, 0x80000010 | awareness | flags }, - { 0x80000022, 0x10 | awareness | flags, 0x80000010 | awareness | flags, FALSE, TRUE }, + { 0x80000022, 0x10 | awareness | flags, 0x80000010 | awareness | flags }, { (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE, 0x10 | flags, 0x10 | flags }, { (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE, 0x11 | flags, 0x11 | flags }, { (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, 0x12, 0x12 }, - { (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, 0x22, 0x22, TRUE, TRUE }, + { (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, 0x22, 0x22 }, { 0x12, 0x12 }, /* Only for last_result test */ };
From: Fabian Maurer dark.shadow4@web.de
--- dlls/user32/tests/sysparams.c | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c index a3d3785c689..3b8613160dc 100644 --- a/dlls/user32/tests/sysparams.c +++ b/dlls/user32/tests/sysparams.c @@ -49,6 +49,7 @@ static BOOL (WINAPI *pAdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT); static BOOL (WINAPI *pLogicalToPhysicalPointForPerMonitorDPI)(HWND,POINT*); static BOOL (WINAPI *pPhysicalToLogicalPointForPerMonitorDPI)(HWND,POINT*); static LONG (WINAPI *pGetAutoRotationState)(PAR_STATE); +static BOOL (WINAPI *pAreDpiAwarenessContextsEqual)(DPI_AWARENESS_CONTEXT,DPI_AWARENESS_CONTEXT);
static BOOL strict; static int dpi, real_dpi; @@ -3827,6 +3828,54 @@ static void test_ThreadDpiAwarenessContext(ULONG_PTR flags) } }
+static void test_AreDpiAwarenessContextsEqual(ULONG_PTR flags) +{ + int i, j; + ULONG_PTR contexts[] = { + 0x10 | flags, + 0x11 | flags, + 0x12, + 0x22, + 0x80000010 | flags, + 0x80000011 | flags, + 0x80000012, + 0x80000022, + (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE, + (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE, + (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE, + (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, + }; + struct awareness_context_equal + { + BOOL equal; + BOOL todo; + } tests[ARRAY_SIZE(contexts)][ARRAY_SIZE(contexts)] = { + { { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 } }, + { { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 } }, + { { 0 }, { 0 }, { 1 }, { 0, TRUE }, { 0 }, { 0 }, { 1 }, { 0, TRUE }, { 0 }, { 0 }, { 1 }, { 0, TRUE } }, + { { 0 }, { 0 }, { 0, TRUE }, { 1 }, { 0 }, { 0 }, { 0, TRUE }, { 1 }, { 0 }, { 0 }, { 0, TRUE }, { 1 } }, + { { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 } }, + { { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 } }, + { { 0 }, { 0 }, { 1 }, { 0, TRUE }, { 0 }, { 0 }, { 1 }, { 0, TRUE }, { 0 }, { 0 }, { 1 }, { 0, TRUE } }, + { { 0 }, { 0 }, { 0, TRUE }, { 1 }, { 0 }, { 0 }, { 0, TRUE }, { 1 }, { 0 }, { 0 }, { 0, TRUE }, { 1 } }, + { { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 } }, + { { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 } }, + { { 0 }, { 0 }, { 1 }, { 0, TRUE }, { 0 }, { 0 }, { 1 }, { 0, TRUE }, { 0 }, { 0 }, { 1 }, { 0, TRUE } }, + { { 0 }, { 0 }, { 0 , TRUE}, { 1 }, { 0 }, { 0 }, { 0, TRUE }, { 1 }, { 0 }, { 0 }, { 0, TRUE }, { 1 } }, + }; + + for (i = 0; i < ARRAY_SIZE(contexts); i++) + { + for (j = 0; j < ARRAY_SIZE(contexts); j++) + { + struct awareness_context_equal *result = &tests[i][j]; + BOOL equal = pAreDpiAwarenessContextsEqual((DPI_AWARENESS_CONTEXT)contexts[i], (DPI_AWARENESS_CONTEXT)contexts[j]); + todo_wine_if(result->todo) + ok(equal == result->equal, "(%d, %d) (%p == %p) - Expected equal to be %d but got %d\n", i, j, (DPI_AWARENESS_CONTEXT)contexts[i], (DPI_AWARENESS_CONTEXT)contexts[j], result->equal, equal); + } + } +} + static void test_dpi_context(void) { DPI_AWARENESS awareness; @@ -3974,6 +4023,7 @@ static void test_dpi_context(void) ok( context == (DPI_AWARENESS_CONTEXT)(0x11 | flags), "wrong context %p\n", context );
test_ThreadDpiAwarenessContext(flags); + test_AreDpiAwarenessContextsEqual(flags);
for (i = 0; i < 0x100; i++) { @@ -4269,6 +4319,7 @@ START_TEST(sysparams) pLogicalToPhysicalPointForPerMonitorDPI = (void*)GetProcAddress(hdll, "LogicalToPhysicalPointForPerMonitorDPI"); pPhysicalToLogicalPointForPerMonitorDPI = (void*)GetProcAddress(hdll, "PhysicalToLogicalPointForPerMonitorDPI"); pGetAutoRotationState = (void*)GetProcAddress(hdll, "GetAutoRotationState"); + pAreDpiAwarenessContextsEqual = (void*)GetProcAddress(hdll, "AreDpiAwarenessContextsEqual");
hInstance = GetModuleHandleA( NULL ); hdc = GetDC(0);
From: Fabian Maurer dark.shadow4@web.de
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56360 --- dlls/user32/sysparams.c | 11 +++++++++-- dlls/user32/tests/sysparams.c | 12 ++++++------ 2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index d30bed44b31..9fa37a292d1 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -636,13 +636,20 @@ BOOL WINAPI SetProcessDpiAwarenessInternal( DPI_AWARENESS awareness ) return SetProcessDpiAwarenessContext( contexts[awareness] ); }
+static ULONG_PTR map_awareness_context( DPI_AWARENESS_CONTEXT ctx ) +{ + if (ctx == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 || ctx == (DPI_AWARENESS_CONTEXT)0x22 || ctx == (DPI_AWARENESS_CONTEXT)0x80000022) + return 0x22; + return GetAwarenessFromDpiAwarenessContext(ctx); +} + /*********************************************************************** * AreDpiAwarenessContextsEqual (USER32.@) */ BOOL WINAPI AreDpiAwarenessContextsEqual( DPI_AWARENESS_CONTEXT ctx1, DPI_AWARENESS_CONTEXT ctx2 ) { - DPI_AWARENESS aware1 = GetAwarenessFromDpiAwarenessContext( ctx1 ); - DPI_AWARENESS aware2 = GetAwarenessFromDpiAwarenessContext( ctx2 ); + DPI_AWARENESS aware1 = map_awareness_context( ctx1 ); + DPI_AWARENESS aware2 = map_awareness_context( ctx2 ); return aware1 != DPI_AWARENESS_INVALID && aware1 == aware2; }
diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c index 3b8613160dc..9a1d7928a27 100644 --- a/dlls/user32/tests/sysparams.c +++ b/dlls/user32/tests/sysparams.c @@ -3852,16 +3852,16 @@ static void test_AreDpiAwarenessContextsEqual(ULONG_PTR flags) } tests[ARRAY_SIZE(contexts)][ARRAY_SIZE(contexts)] = { { { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 } }, { { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 } }, - { { 0 }, { 0 }, { 1 }, { 0, TRUE }, { 0 }, { 0 }, { 1 }, { 0, TRUE }, { 0 }, { 0 }, { 1 }, { 0, TRUE } }, - { { 0 }, { 0 }, { 0, TRUE }, { 1 }, { 0 }, { 0 }, { 0, TRUE }, { 1 }, { 0 }, { 0 }, { 0, TRUE }, { 1 } }, + { { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 } }, + { { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 } }, { { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 } }, { { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 } }, - { { 0 }, { 0 }, { 1 }, { 0, TRUE }, { 0 }, { 0 }, { 1 }, { 0, TRUE }, { 0 }, { 0 }, { 1 }, { 0, TRUE } }, - { { 0 }, { 0 }, { 0, TRUE }, { 1 }, { 0 }, { 0 }, { 0, TRUE }, { 1 }, { 0 }, { 0 }, { 0, TRUE }, { 1 } }, + { { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 } }, + { { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 } }, { { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 } }, { { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 } }, - { { 0 }, { 0 }, { 1 }, { 0, TRUE }, { 0 }, { 0 }, { 1 }, { 0, TRUE }, { 0 }, { 0 }, { 1 }, { 0, TRUE } }, - { { 0 }, { 0 }, { 0 , TRUE}, { 1 }, { 0 }, { 0 }, { 0, TRUE }, { 1 }, { 0 }, { 0 }, { 0, TRUE }, { 1 } }, + { { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 } }, + { { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 } }, };
for (i = 0; i < ARRAY_SIZE(contexts); i++)
From: Fabian Maurer dark.shadow4@web.de
--- dlls/user32/sysparams.c | 2 ++ dlls/win32u/sysparams.c | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 9fa37a292d1..a3f768ff66d 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -655,6 +655,7 @@ BOOL WINAPI AreDpiAwarenessContextsEqual( DPI_AWARENESS_CONTEXT ctx1, DPI_AWAREN
/*********************************************************************** * GetAwarenessFromDpiAwarenessContext (USER32.@) + * copied into win32u, make sure to keep that in sync */ DPI_AWARENESS WINAPI GetAwarenessFromDpiAwarenessContext( DPI_AWARENESS_CONTEXT context ) { @@ -738,6 +739,7 @@ DPI_AWARENESS_CONTEXT WINAPI GetThreadDpiAwarenessContext(void)
/********************************************************************** * SetThreadDpiAwarenessContext (USER32.@) + * copied into win32u, make sure to keep that in sync */ DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT context ) { diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 7dc807bb909..a31d586a5b6 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -2187,7 +2187,7 @@ UINT get_win_monitor_dpi( HWND hwnd ) return system_dpi; }
-/* see GetAwarenessFromDpiAwarenessContext */ +/* copied from user32 GetAwarenessFromDpiAwarenessContext, make sure to keep that in sync */ static DPI_AWARENESS get_awareness_from_dpi_awareness_context( DPI_AWARENESS_CONTEXT context ) { switch ((ULONG_PTR)context) @@ -2195,14 +2195,18 @@ static DPI_AWARENESS get_awareness_from_dpi_awareness_context( DPI_AWARENESS_CON case 0x10: case 0x11: case 0x12: + case 0x22: case 0x80000010: case 0x80000011: case 0x80000012: + case 0x80000022: return (ULONG_PTR)context & 3; case (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE: case (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE: case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE: return ~(ULONG_PTR)context; + case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2: + return ~(ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE; default: return DPI_AWARENESS_INVALID; } @@ -2249,6 +2253,7 @@ UINT get_system_dpi(void)
/********************************************************************** * SetThreadDpiAwarenessContext (win32u.so) + * copied from user32, make sure to keep that in sync */ DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT context ) { @@ -2265,7 +2270,9 @@ DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT prev = NtUserGetProcessDpiAwarenessContext( GetCurrentProcess() ) & 3; prev |= 0x80000010; /* restore to process default */ } - if (((ULONG_PTR)context & ~(ULONG_PTR)0x13) == 0x80000000) info->dpi_awareness = 0; + if (((ULONG_PTR)context & ~(ULONG_PTR)0x33) == 0x80000000) info->dpi_awareness = 0; + else if (context == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 || context == (DPI_AWARENESS_CONTEXT)0x22) + info->dpi_awareness = 0x22; else info->dpi_awareness = val | 0x10; return ULongToHandle( prev ); }
Alexandre Julliard (@julliard) commented about dlls/user32/tests/sysparams.c:
BOOL equal;
BOOL todo;
- } tests[ARRAY_SIZE(contexts)][ARRAY_SIZE(contexts)] = {
{ { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 } },
{ { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 } },
{ { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 } },
{ { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 } },
{ { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 } },
{ { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 } },
{ { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 } },
{ { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 } },
{ { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 } },
{ { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 } },
{ { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 } },
{ { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 }, { 0 }, { 0 }, { 0 }, { 1 } },
- };
That's not manageable. The expected results should be computed, not enumerated in a table.