Commit 165f552c authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Add more allowed values in GetAwarenessFromDpiAwarenessContext() and…

user32: Add more allowed values in GetAwarenessFromDpiAwarenessContext() and IsValidDpiAwarenessContext(). Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 9fa96f54
......@@ -2999,8 +2999,9 @@ BOOL WINAPI SetProcessDpiAwarenessInternal( DPI_AWARENESS awareness )
*/
BOOL WINAPI AreDpiAwarenessContextsEqual( DPI_AWARENESS_CONTEXT ctx1, DPI_AWARENESS_CONTEXT ctx2 )
{
if (!IsValidDpiAwarenessContext( ctx1 )) return FALSE;
return ctx1 == ctx2;
DPI_AWARENESS aware1 = GetAwarenessFromDpiAwarenessContext( ctx1 );
DPI_AWARENESS aware2 = GetAwarenessFromDpiAwarenessContext( ctx2 );
return aware1 != DPI_AWARENESS_INVALID && aware1 == aware2;
}
/***********************************************************************
......@@ -3008,11 +3009,22 @@ BOOL WINAPI AreDpiAwarenessContextsEqual( DPI_AWARENESS_CONTEXT ctx1, DPI_AWAREN
*/
DPI_AWARENESS WINAPI GetAwarenessFromDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
{
if (context == DPI_AWARENESS_CONTEXT_UNAWARE) return DPI_AWARENESS_UNAWARE;
if (context == DPI_AWARENESS_CONTEXT_SYSTEM_AWARE) return DPI_AWARENESS_SYSTEM_AWARE;
if (context == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE) return DPI_AWARENESS_PER_MONITOR_AWARE;
if (context == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2) return DPI_AWARENESS_PER_MONITOR_AWARE;
return DPI_AWARENESS_INVALID;
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;
}
}
/***********************************************************************
......@@ -3020,10 +3032,7 @@ DPI_AWARENESS WINAPI GetAwarenessFromDpiAwarenessContext( DPI_AWARENESS_CONTEXT
*/
BOOL WINAPI IsValidDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
{
return (context == DPI_AWARENESS_CONTEXT_UNAWARE ||
context == DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ||
context == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ||
context == DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
return GetAwarenessFromDpiAwarenessContext( context ) != DPI_AWARENESS_INVALID;
}
/***********************************************************************
......
......@@ -48,6 +48,7 @@ static DPI_AWARENESS_CONTEXT (WINAPI *pGetThreadDpiAwarenessContext)(void);
static DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT);
static DPI_AWARENESS_CONTEXT (WINAPI *pGetWindowDpiAwarenessContext)(HWND);
static DPI_AWARENESS (WINAPI *pGetAwarenessFromDpiAwarenessContext)(DPI_AWARENESS_CONTEXT);
static BOOL (WINAPI *pIsValidDpiAwarenessContext)(DPI_AWARENESS_CONTEXT);
static BOOL strict;
static int dpi, real_dpi;
......@@ -3006,6 +3007,7 @@ static void test_dpi_aware(void)
{
DPI_AWARENESS awareness;
DPI_AWARENESS_CONTEXT context;
ULONG_PTR i;
context = pGetThreadDpiAwarenessContext();
awareness = pGetAwarenessFromDpiAwarenessContext( context );
......@@ -3074,6 +3076,53 @@ static void test_dpi_aware(void)
context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE );
awareness = pGetAwarenessFromDpiAwarenessContext( context );
ok( awareness == DPI_AWARENESS_PER_MONITOR_AWARE, "wrong awareness %u\n", awareness );
for (i = 0; i < 0x100; i++)
{
awareness = pGetAwarenessFromDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)i );
switch (i)
{
case 0x10:
case 0x11:
case 0x12:
ok( awareness == (i & ~0x10), "%lx: wrong value %u\n", i, awareness );
ok( pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)i ), "%lx: not valid\n", i );
break;
default:
ok( awareness == DPI_AWARENESS_INVALID, "%lx: wrong value %u\n", i, awareness );
ok( !pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)i ), "%lx: valid\n", i );
break;
}
awareness = pGetAwarenessFromDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)(i | 0x80000000) );
switch (i)
{
case 0x10:
case 0x11:
case 0x12:
ok( awareness == (i & ~0x10), "%lx: wrong value %u\n", i | 0x80000000, awareness );
ok( pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)(i | 0x80000000) ),
"%lx: not valid\n", i | 0x80000000 );
break;
default:
ok( awareness == DPI_AWARENESS_INVALID, "%lx: wrong value %u\n", i | 0x80000000, awareness );
ok( !pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)(i | 0x80000000) ),
"%lx: valid\n", i | 0x80000000 );
break;
}
awareness = pGetAwarenessFromDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i );
switch (~i)
{
case (ULONG_PTR)DPI_AWARENESS_CONTEXT_UNAWARE:
case (ULONG_PTR)DPI_AWARENESS_CONTEXT_SYSTEM_AWARE:
case (ULONG_PTR)DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE:
ok( awareness == i, "%lx: wrong value %u\n", ~i, awareness );
ok( pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i ), "%lx: not valid\n", ~i );
break;
default:
ok( awareness == DPI_AWARENESS_INVALID, "%lx: wrong value %u\n", ~i, awareness );
ok( !pIsValidDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)~i ), "%lx: valid\n", ~i );
break;
}
}
}
else win_skip( "SetProcessDPIAware not supported\n" );
......@@ -3165,6 +3214,7 @@ START_TEST(sysparams)
pSetThreadDpiAwarenessContext = (void*)GetProcAddress(hdll, "SetThreadDpiAwarenessContext");
pGetWindowDpiAwarenessContext = (void*)GetProcAddress(hdll, "GetWindowDpiAwarenessContext");
pGetAwarenessFromDpiAwarenessContext = (void*)GetProcAddress(hdll, "GetAwarenessFromDpiAwarenessContext");
pIsValidDpiAwarenessContext = (void*)GetProcAddress(hdll, "IsValidDpiAwarenessContext");
hInstance = GetModuleHandleA( NULL );
hdc = GetDC(0);
......
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