Commit 478814ed authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Implement Get/SetThreadDpiAwarenessContext().

parent c440af11
...@@ -3042,12 +3042,31 @@ UINT WINAPI GetDpiForWindow( HWND hwnd ) ...@@ -3042,12 +3042,31 @@ UINT WINAPI GetDpiForWindow( HWND hwnd )
} }
/********************************************************************** /**********************************************************************
* GetThreadDpiAwarenessContext (USER32.@)
*/
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 */
}
/**********************************************************************
* SetThreadDpiAwarenessContext (USER32.@) * SetThreadDpiAwarenessContext (USER32.@)
*/ */
DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT context ) DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
{ {
FIXME("(%p): stub\n", context); DPI_AWARENESS_CONTEXT prev = GetThreadDpiAwarenessContext();
return NULL;
if (!IsValidDpiAwarenessContext( context ))
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
get_user_thread_info()->dpi_awareness = context;
return prev;
} }
/********************************************************************** /**********************************************************************
......
...@@ -42,6 +42,9 @@ static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR, LPDEVMODEA, HWND, DWORD, ...@@ -42,6 +42,9 @@ static LONG (WINAPI *pChangeDisplaySettingsExA)(LPCSTR, LPDEVMODEA, HWND, DWORD,
static BOOL (WINAPI *pIsProcessDPIAware)(void); static BOOL (WINAPI *pIsProcessDPIAware)(void);
static BOOL (WINAPI *pSetProcessDPIAware)(void); static BOOL (WINAPI *pSetProcessDPIAware)(void);
static BOOL (WINAPI *pSetProcessDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); static BOOL (WINAPI *pSetProcessDpiAwarenessContext)(DPI_AWARENESS_CONTEXT);
static DPI_AWARENESS_CONTEXT (WINAPI *pGetThreadDpiAwarenessContext)(void);
static DPI_AWARENESS_CONTEXT (WINAPI *pSetThreadDpiAwarenessContext)(DPI_AWARENESS_CONTEXT);
static DPI_AWARENESS (WINAPI *pGetAwarenessFromDpiAwarenessContext)(DPI_AWARENESS_CONTEXT);
static BOOL strict; static BOOL strict;
static int dpi, real_dpi; static int dpi, real_dpi;
...@@ -2998,6 +3001,13 @@ static void test_dpi_aware(void) ...@@ -2998,6 +3001,13 @@ static void test_dpi_aware(void)
if (pSetProcessDpiAwarenessContext) if (pSetProcessDpiAwarenessContext)
{ {
DPI_AWARENESS awareness;
DPI_AWARENESS_CONTEXT context;
context = pGetThreadDpiAwarenessContext();
awareness = pGetAwarenessFromDpiAwarenessContext( context );
todo_wine
ok( awareness == DPI_AWARENESS_UNAWARE, "wrong awareness %u\n", awareness );
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
ret = pSetProcessDpiAwarenessContext( NULL ); ret = pSetProcessDpiAwarenessContext( NULL );
ok( !ret, "got %d\n", ret ); ok( !ret, "got %d\n", ret );
...@@ -3018,7 +3028,34 @@ static void test_dpi_aware(void) ...@@ -3018,7 +3028,34 @@ static void test_dpi_aware(void)
ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() ); ok( GetLastError() == ERROR_ACCESS_DENIED, "wrong error %u\n", GetLastError() );
ret = pIsProcessDPIAware(); ret = pIsProcessDPIAware();
ok(ret, "got %d\n", ret); ok(ret, "got %d\n", ret);
} context = pGetThreadDpiAwarenessContext();
awareness = pGetAwarenessFromDpiAwarenessContext( context );
ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong awareness %u\n", awareness );
SetLastError( 0xdeadbeef );
context = pSetThreadDpiAwarenessContext( 0 );
ok( !context, "got %p\n", context );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
SetLastError( 0xdeadbeef );
context = pSetThreadDpiAwarenessContext( (DPI_AWARENESS_CONTEXT)-5 );
ok( !context, "got %p\n", context );
ok( GetLastError() == ERROR_INVALID_PARAMETER, "wrong error %u\n", GetLastError() );
context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_UNAWARE );
awareness = pGetAwarenessFromDpiAwarenessContext( context );
ok( awareness == DPI_AWARENESS_SYSTEM_AWARE, "wrong awareness %u\n", awareness );
context = pGetThreadDpiAwarenessContext();
awareness = pGetAwarenessFromDpiAwarenessContext( context );
ok( awareness == DPI_AWARENESS_UNAWARE, "wrong awareness %u\n", awareness );
context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
awareness = pGetAwarenessFromDpiAwarenessContext( context );
ok( awareness == DPI_AWARENESS_UNAWARE, "wrong awareness %u\n", awareness );
context = pGetThreadDpiAwarenessContext();
awareness = pGetAwarenessFromDpiAwarenessContext( context );
ok( awareness == DPI_AWARENESS_PER_MONITOR_AWARE, "wrong awareness %u\n", awareness );
context = pSetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_SYSTEM_AWARE );
awareness = pGetAwarenessFromDpiAwarenessContext( context );
ok( awareness == DPI_AWARENESS_PER_MONITOR_AWARE, "wrong awareness %u\n", awareness );
}
else win_skip( "SetProcessDPIAware not supported\n" );
ret = pSetProcessDPIAware(); ret = pSetProcessDPIAware();
ok(ret, "got %d\n", ret); ok(ret, "got %d\n", ret);
...@@ -3045,6 +3082,9 @@ START_TEST(sysparams) ...@@ -3045,6 +3082,9 @@ START_TEST(sysparams)
pIsProcessDPIAware = (void*)GetProcAddress(hdll, "IsProcessDPIAware"); pIsProcessDPIAware = (void*)GetProcAddress(hdll, "IsProcessDPIAware");
pSetProcessDPIAware = (void*)GetProcAddress(hdll, "SetProcessDPIAware"); pSetProcessDPIAware = (void*)GetProcAddress(hdll, "SetProcessDPIAware");
pSetProcessDpiAwarenessContext = (void*)GetProcAddress(hdll, "SetProcessDpiAwarenessContext"); pSetProcessDpiAwarenessContext = (void*)GetProcAddress(hdll, "SetProcessDpiAwarenessContext");
pGetThreadDpiAwarenessContext = (void*)GetProcAddress(hdll, "GetThreadDpiAwarenessContext");
pSetThreadDpiAwarenessContext = (void*)GetProcAddress(hdll, "SetThreadDpiAwarenessContext");
pGetAwarenessFromDpiAwarenessContext = (void*)GetProcAddress(hdll, "GetAwarenessFromDpiAwarenessContext");
hInstance = GetModuleHandleA( NULL ); hInstance = GetModuleHandleA( NULL );
hdc = GetDC(0); hdc = GetDC(0);
......
...@@ -379,6 +379,7 @@ ...@@ -379,6 +379,7 @@
@ stdcall GetTabbedTextExtentW(long wstr long long ptr) @ stdcall GetTabbedTextExtentW(long wstr long long ptr)
@ stdcall GetTaskmanWindow () @ stdcall GetTaskmanWindow ()
@ stdcall GetThreadDesktop(long) @ stdcall GetThreadDesktop(long)
@ stdcall GetThreadDpiAwarenessContext()
@ stdcall GetTitleBarInfo(long ptr) @ stdcall GetTitleBarInfo(long ptr)
@ stdcall GetTopWindow(long) @ stdcall GetTopWindow(long)
@ stdcall GetTouchInputInfo(long long ptr long) @ stdcall GetTouchInputInfo(long long ptr long)
......
...@@ -169,6 +169,7 @@ struct wm_char_mapping_data ...@@ -169,6 +169,7 @@ struct wm_char_mapping_data
/* no attempt is made to keep the layout compatible with the Windows one */ /* no attempt is made to keep the layout compatible with the Windows one */
struct user_thread_info struct user_thread_info
{ {
DPI_AWARENESS_CONTEXT dpi_awareness; /* DPI awareness context */
HANDLE server_queue; /* Handle to server-side queue */ HANDLE server_queue; /* Handle to server-side queue */
DWORD wake_mask; /* Current queue wake mask */ DWORD wake_mask; /* Current queue wake mask */
DWORD changed_mask; /* Current queue changed mask */ DWORD changed_mask; /* Current queue changed mask */
......
...@@ -3766,6 +3766,7 @@ WINUSERAPI DWORD WINAPI GetTabbedTextExtentW(HDC,LPCWSTR,INT,INT,const INT ...@@ -3766,6 +3766,7 @@ WINUSERAPI DWORD WINAPI GetTabbedTextExtentW(HDC,LPCWSTR,INT,INT,const INT
#define GetTabbedTextExtent WINELIB_NAME_AW(GetTabbedTextExtent) #define GetTabbedTextExtent WINELIB_NAME_AW(GetTabbedTextExtent)
WINUSERAPI BOOL WINAPI GetTitleBarInfo(HWND,PTITLEBARINFO); WINUSERAPI BOOL WINAPI GetTitleBarInfo(HWND,PTITLEBARINFO);
WINUSERAPI HDESK WINAPI GetThreadDesktop(DWORD); WINUSERAPI HDESK WINAPI GetThreadDesktop(DWORD);
WINUSERAPI DPI_AWARENESS_CONTEXT WINAPI GetThreadDpiAwarenessContext(void);
WINUSERAPI HWND WINAPI GetTopWindow(HWND); WINUSERAPI HWND WINAPI GetTopWindow(HWND);
WINUSERAPI BOOL WINAPI GetTouchInputInfo(HTOUCHINPUT,UINT,TOUCHINPUT*,int); WINUSERAPI BOOL WINAPI GetTouchInputInfo(HTOUCHINPUT,UINT,TOUCHINPUT*,int);
WINUSERAPI BOOL WINAPI GetUpdateRect(HWND,LPRECT,BOOL); WINUSERAPI BOOL WINAPI GetUpdateRect(HWND,LPRECT,BOOL);
......
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