Module: wine Branch: master Commit: 803a5f0789740ab72ebfd2cc41aed8a9c3db6b56 URL: https://gitlab.winehq.org/wine/wine/-/commit/803a5f0789740ab72ebfd2cc41aed8a...
Author: Jacek Caban jacek@codeweavers.com Date: Fri Aug 26 11:49:36 2022 +0200
win32u: Move NtUserPerMonitorDPIPhysicalToLogicalPoint implementation from user32.
---
dlls/user32/sysparams.c | 50 ------------------------------------------------- dlls/user32/user32.spec | 2 +- dlls/win32u/syscall.c | 1 + dlls/win32u/sysparams.c | 17 +++++++++++++++++ dlls/win32u/win32u.spec | 2 +- dlls/wow64win/syscall.h | 1 + dlls/wow64win/user.c | 8 ++++++++ include/ntuser.h | 1 + 8 files changed, 30 insertions(+), 52 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 285d7828c63..3f87702f32d 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -669,36 +669,6 @@ BOOL WINAPI EnumDisplaySettingsExW( const WCHAR *device, DWORD mode, return NtUserEnumDisplaySettings( &str, mode, dev_mode, flags ); }
-/********************************************************************** - * get_win_monitor_dpi - */ -static UINT get_win_monitor_dpi( HWND hwnd ) -{ - /* FIXME: use the monitor DPI instead */ - return system_dpi; -} - -/********************************************************************** - * map_dpi_point - */ -static POINT map_dpi_point( POINT pt, UINT dpi_from, UINT dpi_to ) -{ - if (dpi_from && dpi_to && dpi_from != dpi_to) - { - pt.x = MulDiv( pt.x, dpi_to, dpi_from ); - pt.y = MulDiv( pt.y, dpi_to, dpi_from ); - } - return pt; -} - -/********************************************************************** - * point_phys_to_win_dpi - */ -static POINT point_phys_to_win_dpi( HWND hwnd, POINT pt ) -{ - return map_dpi_point( pt, get_win_monitor_dpi( hwnd ), GetDpiForWindow( hwnd )); -} - /********************************************************************** * SetProcessDpiAwarenessContext (USER32.@) */ @@ -871,26 +841,6 @@ DPI_AWARENESS_CONTEXT WINAPI SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT return ULongToHandle( prev ); }
-/********************************************************************** - * PhysicalToLogicalPointForPerMonitorDPI (USER32.@) - */ -BOOL WINAPI PhysicalToLogicalPointForPerMonitorDPI( HWND hwnd, POINT *pt ) -{ - DPI_AWARENESS_CONTEXT context; - RECT rect; - BOOL ret = FALSE; - - context = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ); - if (GetWindowRect( hwnd, &rect ) && - pt->x >= rect.left && pt->y >= rect.top && pt->x <= rect.right && pt->y <= rect.bottom) - { - *pt = point_phys_to_win_dpi( hwnd, *pt ); - ret = TRUE; - } - SetThreadDpiAwarenessContext( context ); - return ret; -} - /*********************************************************************** * MonitorFromRect (USER32.@) */ diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 3a822aa380d..1bf3ebdc90d 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -565,7 +565,7 @@ @ stdcall PeekMessageA(ptr long long long long) @ stdcall PeekMessageW(ptr long long long long) @ stdcall PhysicalToLogicalPoint(long ptr) -@ stdcall PhysicalToLogicalPointForPerMonitorDPI(long ptr) +@ stdcall PhysicalToLogicalPointForPerMonitorDPI(long ptr) NtUserPerMonitorDPIPhysicalToLogicalPoint @ stub PlaySoundEvent @ stdcall PostMessageA(long long long long) @ stdcall PostMessageW(long long long long) diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c index 7212f6df0b0..f9e608ed0b7 100644 --- a/dlls/win32u/syscall.c +++ b/dlls/win32u/syscall.c @@ -230,6 +230,7 @@ static void * const syscalls[] = NtUserOpenInputDesktop, NtUserOpenWindowStation, NtUserPeekMessage, + NtUserPerMonitorDPIPhysicalToLogicalPoint, NtUserPostMessage, NtUserPostThreadMessage, NtUserQueryInputContext, diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index defcaeb7f0e..848b14dbcb3 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -2461,6 +2461,23 @@ BOOL WINAPI NtUserLogicalToPerMonitorDPIPhysicalPoint( HWND hwnd, POINT *pt ) return TRUE; }
+/********************************************************************** + * NtUserPerMonitorDPIPhysicalToLogicalPoint (win32u.@) + */ +BOOL WINAPI NtUserPerMonitorDPIPhysicalToLogicalPoint( HWND hwnd, POINT *pt ) +{ + RECT rect; + BOOL ret = FALSE; + + if (get_window_rect( hwnd, &rect, 0 ) && + pt->x >= rect.left && pt->y >= rect.top && pt->x <= rect.right && pt->y <= rect.bottom) + { + *pt = point_phys_to_win_dpi( hwnd, *pt ); + ret = TRUE; + } + return ret; +} + /* retrieve the cached base keys for a given entry */ static BOOL get_base_keys( enum parameter_key index, HKEY *base_key, HKEY *volatile_key ) { diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index d1339af9dcc..df722586ded 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -1099,7 +1099,7 @@ @ stub NtUserPaintMenuBar @ stub NtUserPaintMonitor @ stdcall -syscall NtUserPeekMessage(ptr long long long long) -@ stub NtUserPerMonitorDPIPhysicalToLogicalPoint +@ stdcall -syscall NtUserPerMonitorDPIPhysicalToLogicalPoint(long ptr) @ stub NtUserPhysicalToLogicalDpiPointForWindow @ stub NtUserPhysicalToLogicalPoint @ stub NtUserPostKeyboardInputMessage diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h index fb0c2c7de7e..009a457fe6e 100644 --- a/dlls/wow64win/syscall.h +++ b/dlls/wow64win/syscall.h @@ -216,6 +216,7 @@ SYSCALL_ENTRY( NtUserOpenInputDesktop ) \ SYSCALL_ENTRY( NtUserOpenWindowStation ) \ SYSCALL_ENTRY( NtUserPeekMessage ) \ + SYSCALL_ENTRY( NtUserPerMonitorDPIPhysicalToLogicalPoint ) \ SYSCALL_ENTRY( NtUserPostMessage ) \ SYSCALL_ENTRY( NtUserPostThreadMessage ) \ SYSCALL_ENTRY( NtUserQueryInputContext ) \ diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index ca8a40000dd..041285fa37f 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -3100,6 +3100,14 @@ NTSTATUS WINAPI wow64_NtUserPeekMessage( UINT *args ) return TRUE; }
+NTSTATUS WINAPI wow64_NtUserPerMonitorDPIPhysicalToLogicalPoint( UINT *args ) +{ + HWND hwnd = get_handle( &args ); + POINT *pt = get_ptr( &args ); + + return NtUserPerMonitorDPIPhysicalToLogicalPoint( hwnd, pt ); +} + NTSTATUS WINAPI wow64_NtUserPostMessage( UINT *args ) { HWND hwnd = get_handle( &args ); diff --git a/include/ntuser.h b/include/ntuser.h index f1f263af7b7..f7fa18ee983 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -788,6 +788,7 @@ BOOL WINAPI NtUserOpenClipboard( HWND hwnd, ULONG unk ); HDESK WINAPI NtUserOpenDesktop( OBJECT_ATTRIBUTES *attr, DWORD flags, ACCESS_MASK access ); HDESK WINAPI NtUserOpenInputDesktop( DWORD flags, BOOL inherit, ACCESS_MASK access ); BOOL WINAPI NtUserPeekMessage( MSG *msg_out, HWND hwnd, UINT first, UINT last, UINT flags ); +BOOL WINAPI NtUserPerMonitorDPIPhysicalToLogicalPoint( HWND hwnd, POINT *pt ); BOOL WINAPI NtUserPostMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ); BOOL WINAPI NtUserPostThreadMessage( DWORD thread, UINT msg, WPARAM wparam, LPARAM lparam ); UINT_PTR WINAPI NtUserQueryInputContext( HIMC handle, UINT attr );