forked from Mirrors/wine-wine
user32: Support returning to the process default in SetThreadDpiAwarenessContext().
Signed-off-by: Alexandre Julliard <julliard@winehq.org>oldstable
parent
165f552c34
commit
da2551f874
|
@ -2942,19 +2942,22 @@ BOOL WINAPI EnumDisplaySettingsExW(LPCWSTR lpszDeviceName, DWORD iModeNum,
|
|||
}
|
||||
|
||||
|
||||
static DPI_AWARENESS_CONTEXT dpi_awareness;
|
||||
static DPI_AWARENESS dpi_awareness;
|
||||
|
||||
/**********************************************************************
|
||||
* SetProcessDpiAwarenessContext (USER32.@)
|
||||
*/
|
||||
BOOL WINAPI SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
|
||||
{
|
||||
if (!IsValidDpiAwarenessContext( context ))
|
||||
DPI_AWARENESS val = GetAwarenessFromDpiAwarenessContext( context );
|
||||
|
||||
if (val == DPI_AWARENESS_INVALID)
|
||||
{
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
return FALSE;
|
||||
}
|
||||
if (InterlockedCompareExchangePointer( (void **)&dpi_awareness, context, NULL ))
|
||||
val |= 0x10; /* avoid 0 value */
|
||||
if (InterlockedCompareExchange( &dpi_awareness, val, 0 ))
|
||||
{
|
||||
SetLastError( ERROR_ACCESS_DENIED );
|
||||
return FALSE;
|
||||
|
@ -2973,7 +2976,7 @@ BOOL WINAPI GetProcessDpiAwarenessInternal( HANDLE process, DPI_AWARENESS *aware
|
|||
WARN( "not supported on other process %p\n", process );
|
||||
*awareness = DPI_AWARENESS_UNAWARE;
|
||||
}
|
||||
else *awareness = GetAwarenessFromDpiAwarenessContext( dpi_awareness );
|
||||
else *awareness = dpi_awareness & 3;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -3041,7 +3044,7 @@ BOOL WINAPI IsValidDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
|
|||
BOOL WINAPI SetProcessDPIAware(void)
|
||||
{
|
||||
TRACE("\n");
|
||||
InterlockedCompareExchangePointer( (void **)&dpi_awareness, DPI_AWARENESS_CONTEXT_SYSTEM_AWARE, NULL );
|
||||
InterlockedCompareExchange( &dpi_awareness, 0x11, 0 );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -3050,8 +3053,7 @@ BOOL WINAPI SetProcessDPIAware(void)
|
|||
*/
|
||||
BOOL WINAPI IsProcessDPIAware(void)
|
||||
{
|
||||
/* FIXME: should default to FALSE when not set */
|
||||
return dpi_awareness != DPI_AWARENESS_CONTEXT_UNAWARE;
|
||||
return GetAwarenessFromDpiAwarenessContext( GetThreadDpiAwarenessContext() ) != DPI_AWARENESS_UNAWARE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -3088,9 +3090,9 @@ DPI_AWARENESS_CONTEXT WINAPI GetThreadDpiAwarenessContext(void)
|
|||
{
|
||||
struct user_thread_info *info = get_user_thread_info();
|
||||
|
||||
if (info->dpi_awareness) return info->dpi_awareness;
|
||||
if (dpi_awareness) return dpi_awareness;
|
||||
return DPI_AWARENESS_CONTEXT_SYSTEM_AWARE; /* FIXME: should default to unaware */
|
||||
if (info->dpi_awareness) return ULongToHandle( info->dpi_awareness );
|
||||
if (dpi_awareness) return ULongToHandle( dpi_awareness );
|
||||
return (DPI_AWARENESS_CONTEXT)(0x10 | DPI_AWARENESS_SYSTEM_AWARE); /* FIXME: should default to unaware */
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
@ -3098,15 +3100,23 @@ DPI_AWARENESS_CONTEXT WINAPI GetThreadDpiAwarenessContext(void)
|
|||
*/
|
||||
DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
|
||||
{
|
||||
DPI_AWARENESS_CONTEXT prev = GetThreadDpiAwarenessContext();
|
||||
struct user_thread_info *info = get_user_thread_info();
|
||||
DPI_AWARENESS prev, val = GetAwarenessFromDpiAwarenessContext( context );
|
||||
|
||||
if (!IsValidDpiAwarenessContext( context ))
|
||||
if (val == DPI_AWARENESS_INVALID)
|
||||
{
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
return 0;
|
||||
}
|
||||
get_user_thread_info()->dpi_awareness = context;
|
||||
return prev;
|
||||
if (!(prev = info->dpi_awareness))
|
||||
{
|
||||
prev = dpi_awareness;
|
||||
if (!prev) prev = 0x10 | DPI_AWARENESS_UNAWARE;
|
||||
prev |= 0x80000000; /* restore to process default */
|
||||
}
|
||||
if (((ULONG_PTR)context & ~(ULONG_PTR)0x13) == 0x80000000) info->dpi_awareness = 0;
|
||||
else info->dpi_awareness = val | 0x10;
|
||||
return ULongToHandle( prev );
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
|
|
|
@ -3010,9 +3010,13 @@ static void test_dpi_aware(void)
|
|||
ULONG_PTR i;
|
||||
|
||||
context = pGetThreadDpiAwarenessContext();
|
||||
todo_wine
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x10, "wrong context %p\n", context );
|
||||
awareness = pGetAwarenessFromDpiAwarenessContext( context );
|
||||
todo_wine
|
||||
ok( awareness == DPI_AWARENESS_UNAWARE, "wrong awareness %u\n", awareness );
|
||||
todo_wine
|
||||
ok( !pIsProcessDPIAware(), "already aware\n" );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pSetProcessDpiAwarenessContext( NULL );
|
||||
ok( !ret, "got %d\n", ret );
|
||||
|
@ -3023,6 +3027,7 @@ static void test_dpi_aware(void)
|
|||
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
|
||||
ret = pSetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE );
|
||||
ok( ret, "got %d\n", ret );
|
||||
ok( pIsProcessDPIAware(), "not aware\n" );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pSetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE );
|
||||
ok( !ret, "got %d\n", ret );
|
||||
|
@ -3051,6 +3056,7 @@ static void test_dpi_aware(void)
|
|||
ret = pIsProcessDPIAware();
|
||||
ok(ret, "got %d\n", ret);
|
||||
context = pGetThreadDpiAwarenessContext();
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x11, "wrong context %p\n", context );
|
||||
awareness = pGetAwarenessFromDpiAwarenessContext( context );
|
||||
ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong awareness %u\n", awareness );
|
||||
SetLastError( 0xdeadbeef );
|
||||
|
@ -3062,20 +3068,43 @@ static void test_dpi_aware(void)
|
|||
ok( !context, "got %p\n", context );
|
||||
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
|
||||
context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_UNAWARE );
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x80000011, "wrong context %p\n", context );
|
||||
awareness = pGetAwarenessFromDpiAwarenessContext( context );
|
||||
ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong awareness %u\n", awareness );
|
||||
ok( !pIsProcessDPIAware(), "still aware\n" );
|
||||
context = pGetThreadDpiAwarenessContext();
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x10, "wrong context %p\n", context );
|
||||
awareness = pGetAwarenessFromDpiAwarenessContext( context );
|
||||
ok( awareness == DPI_AWARENESS_UNAWARE, "wrong awareness %u\n", awareness );
|
||||
context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x10, "wrong context %p\n", context );
|
||||
awareness = pGetAwarenessFromDpiAwarenessContext( context );
|
||||
ok( awareness == DPI_AWARENESS_UNAWARE, "wrong awareness %u\n", awareness );
|
||||
context = pGetThreadDpiAwarenessContext();
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x12, "wrong context %p\n", context );
|
||||
awareness = pGetAwarenessFromDpiAwarenessContext( context );
|
||||
ok( awareness == DPI_AWARENESS_PER_MONITOR_AWARE, "wrong awareness %u\n", awareness );
|
||||
context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE );
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x12, "wrong context %p\n", context );
|
||||
awareness = pGetAwarenessFromDpiAwarenessContext( context );
|
||||
ok( awareness == DPI_AWARENESS_PER_MONITOR_AWARE, "wrong awareness %u\n", awareness );
|
||||
ok( pIsProcessDPIAware(), "not aware\n" );
|
||||
context = pGetThreadDpiAwarenessContext();
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x11, "wrong context %p\n", context );
|
||||
context = pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)0x80000010 );
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x11, "wrong context %p\n", context );
|
||||
context = pGetThreadDpiAwarenessContext();
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x11, "wrong context %p\n", context );
|
||||
context = pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)0x80000011 );
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x80000011, "wrong context %p\n", context );
|
||||
context = pGetThreadDpiAwarenessContext();
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x11, "wrong context %p\n", context );
|
||||
context = pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)0x12 );
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x80000011, "wrong context %p\n", context );
|
||||
context = pSetThreadDpiAwarenessContext( context );
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x12, "wrong context %p\n", context );
|
||||
context = pGetThreadDpiAwarenessContext();
|
||||
ok( context == (DPI_AWARENESS_CONTEXT)0x11, "wrong context %p\n", context );
|
||||
for (i = 0; i < 0x100; i++)
|
||||
{
|
||||
awareness = pGetAwarenessFromDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)i );
|
||||
|
@ -3124,7 +3153,7 @@ static void test_dpi_aware(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
else win_skip( "SetProcessDPIAware not supported\n" );
|
||||
else win_skip( "SetProcessDpiAwarenessContext not supported\n" );
|
||||
|
||||
ret = pSetProcessDPIAware();
|
||||
ok(ret, "got %d\n", ret);
|
||||
|
|
|
@ -169,7 +169,7 @@ struct wm_char_mapping_data
|
|||
/* no attempt is made to keep the layout compatible with the Windows one */
|
||||
struct user_thread_info
|
||||
{
|
||||
DPI_AWARENESS_CONTEXT dpi_awareness; /* DPI awareness context */
|
||||
DPI_AWARENESS dpi_awareness; /* DPI awareness */
|
||||
HANDLE server_queue; /* Handle to server-side queue */
|
||||
DWORD wake_mask; /* Current queue wake mask */
|
||||
DWORD changed_mask; /* Current queue changed mask */
|
||||
|
|
Loading…
Reference in New Issue