Module: wine Branch: master Commit: cda7027bc8b67da3ef316008fed1670f23b355d0 URL: https://gitlab.winehq.org/wine/wine/-/commit/cda7027bc8b67da3ef316008fed1670...
Author: Rémi Bernon rbernon@codeweavers.com Date: Thu May 23 22:51:36 2024 +0200
win32u: Get the thread DPI context instead of the awareness.
---
dlls/user32/sysparams.c | 10 +++++----- dlls/win32u/sysparams.c | 32 +++++++++++++------------------- dlls/win32u/win32u_private.h | 2 +- dlls/win32u/window.c | 2 +- include/ntuser.h | 2 +- 5 files changed, 21 insertions(+), 27 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 0248a4d905f..7208535186a 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -757,7 +757,7 @@ DPI_AWARENESS_CONTEXT WINAPI GetThreadDpiAwarenessContext(void) struct ntuser_thread_info *info = NtUserGetThreadInfo(); ULONG context;
- if (info->dpi_awareness) return ULongToHandle( info->dpi_awareness ); + if (info->dpi_context) return ULongToHandle( info->dpi_context );
context = NtUserGetProcessDpiAwarenessContext( GetCurrentProcess() ); return UlongToHandle( NTUSER_DPI_CONTEXT_GET_AWARENESS( context ) | 0x10 ); @@ -777,15 +777,15 @@ DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT SetLastError( ERROR_INVALID_PARAMETER ); return 0; } - if (!(prev = info->dpi_awareness)) + if (!(prev = info->dpi_context)) { ULONG process_ctx = NtUserGetProcessDpiAwarenessContext( GetCurrentProcess() ); prev = NTUSER_DPI_CONTEXT_GET_AWARENESS( process_ctx ) | 0x80000010; /* restore to process default */ } - if (((ULONG_PTR)context & ~(ULONG_PTR)0x33) == 0x80000000) info->dpi_awareness = 0; + if (((ULONG_PTR)context & ~(ULONG_PTR)0x33) == 0x80000000) info->dpi_context = 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; + info->dpi_context = 0x22; + else info->dpi_context = val | 0x10; return ULongToHandle( prev ); }
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 26ed8b1d1ac..f107f114af6 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -39,6 +39,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(system);
+static LONG dpi_context; /* process DPI awareness context */
static HKEY video_key, enum_key, control_key, config_key, volatile_base_key;
@@ -2160,18 +2161,13 @@ static DPI_AWARENESS get_awareness_from_dpi_awareness_context( DPI_AWARENESS_CON } }
-/********************************************************************** - * get_thread_dpi_awareness - */ -DPI_AWARENESS get_thread_dpi_awareness(void) +UINT get_thread_dpi_awareness_context(void) { struct ntuser_thread_info *info = NtUserGetThreadInfo(); - ULONG_PTR context = info->dpi_awareness; - - if (context == 0) /* process default */ - return NtUserGetProcessDpiAwarenessContext( NULL ) & 3; + UINT context;
- return get_awareness_from_dpi_awareness_context((DPI_AWARENESS_CONTEXT)context); + if (!(context = info->dpi_context)) context = ReadNoFence( &dpi_context ); + return context ? context : NTUSER_DPI_UNAWARE; }
DWORD get_process_layout(void) @@ -2184,7 +2180,7 @@ DWORD get_process_layout(void) */ UINT get_thread_dpi(void) { - switch (get_thread_dpi_awareness()) + switch (NTUSER_DPI_CONTEXT_GET_AWARENESS( get_thread_dpi_awareness_context() )) { case DPI_AWARENESS_UNAWARE: return USER_DEFAULT_SCREEN_DPI; case DPI_AWARENESS_SYSTEM_AWARE: return system_dpi; @@ -2195,7 +2191,8 @@ UINT get_thread_dpi(void) /* see GetDpiForSystem */ UINT get_system_dpi(void) { - if (get_thread_dpi_awareness() == DPI_AWARENESS_UNAWARE) return USER_DEFAULT_SCREEN_DPI; + DPI_AWARENESS awareness = NTUSER_DPI_CONTEXT_GET_AWARENESS( get_thread_dpi_awareness_context() ); + if (awareness == DPI_AWARENESS_UNAWARE) return USER_DEFAULT_SCREEN_DPI; return system_dpi; }
@@ -2210,15 +2207,15 @@ UINT set_thread_dpi_awareness_context( UINT context ) RtlSetLastWin32Error( ERROR_INVALID_PARAMETER ); return 0; } - if (!(prev = info->dpi_awareness)) + if (!(prev = info->dpi_context)) { prev = NtUserGetProcessDpiAwarenessContext( GetCurrentProcess() ) & 3; prev |= 0x80000010; /* restore to process default */ } - if (((ULONG_PTR)context & ~(ULONG_PTR)0x33) == 0x80000000) info->dpi_awareness = 0; + if (((ULONG_PTR)context & ~(ULONG_PTR)0x33) == 0x80000000) info->dpi_context = 0; else if (context == HandleToUlong( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ) || context == 0x22) - info->dpi_awareness = 0x22; - else info->dpi_awareness = val | 0x10; + info->dpi_context = 0x22; + else info->dpi_context = val | 0x10; return prev; }
@@ -3733,7 +3730,7 @@ BOOL WINAPI NtUserGetDpiForMonitor( HMONITOR monitor, UINT type, UINT *x, UINT * RtlSetLastWin32Error( ERROR_INVALID_ADDRESS ); return FALSE; } - switch (get_thread_dpi_awareness()) + switch (NTUSER_DPI_CONTEXT_GET_AWARENESS( get_thread_dpi_awareness_context() )) { case DPI_AWARENESS_UNAWARE: *x = *y = USER_DEFAULT_SCREEN_DPI; break; case DPI_AWARENESS_SYSTEM_AWARE: *x = *y = system_dpi; break; @@ -6226,9 +6223,6 @@ BOOL WINAPI NtUserSetSysColors( INT count, const INT *colors, const COLORREF *va return TRUE; }
- -static LONG dpi_context; - /*********************************************************************** * NtUserSetProcessDpiAwarenessContext (win32u.@) */ diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index 222db6fb5f7..aecd60bae63 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -175,7 +175,7 @@ extern UINT get_system_dpi(void); extern int get_system_metrics( int index ); extern UINT get_thread_dpi(void); extern UINT set_thread_dpi_awareness_context( UINT context ); -extern DPI_AWARENESS get_thread_dpi_awareness(void); +extern UINT get_thread_dpi_awareness_context(void); extern RECT get_virtual_screen_rect( UINT dpi ); extern BOOL is_exiting_thread( DWORD tid ); extern POINT map_dpi_point( POINT pt, UINT dpi_from, UINT dpi_to ); diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 321c81069c4..f7026654a50 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -4911,7 +4911,7 @@ static WND *create_window_handle( HWND parent, HWND owner, UNICODE_STRING *name, HINSTANCE instance, BOOL ansi, DWORD style, DWORD ex_style ) { - DPI_AWARENESS awareness = get_thread_dpi_awareness(); + DPI_AWARENESS awareness = NTUSER_DPI_CONTEXT_GET_AWARENESS( get_thread_dpi_awareness_context() ); HWND handle = 0, full_parent = 0, full_owner = 0; struct tagCLASS *class = NULL; int extra_bytes = 0; diff --git a/include/ntuser.h b/include/ntuser.h index 392ab21ec0d..b58413ac4db 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -83,7 +83,7 @@ struct ntuser_thread_info UINT receive_flags; /* currently received message flags */ UINT top_window; /* desktop window */ UINT msg_window; /* HWND_MESSAGE parent window */ - DPI_AWARENESS dpi_awareness; /* DPI awareness */ + UINT dpi_context; /* DPI awareness context */ UINT default_imc; /* default input context */ UINT64 client_imm; /* client IMM thread info */ UINT64 wmchar_data; /* client data for WM_CHAR mappings */