From 8b7ed3630729e77766cc524d27540eac72f3b02a Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 19 Apr 2018 10:46:43 +0200 Subject: [PATCH] user32: Add partial stub for GetDpiForMonitorInternal(). Signed-off-by: Alexandre Julliard --- .../ext-ms-win-rtcore-ntuser-dpi-l1-1-0.spec | 2 +- .../ext-ms-win-rtcore-ntuser-dpi-l1-2-0.spec | 2 +- dlls/shcore/main.c | 12 ++----- dlls/user32/sysparams.c | 32 ++++++++++++++----- dlls/user32/user32.spec | 1 + include/winuser.h | 1 + 6 files changed, 30 insertions(+), 20 deletions(-) diff --git a/dlls/ext-ms-win-rtcore-ntuser-dpi-l1-1-0/ext-ms-win-rtcore-ntuser-dpi-l1-1-0.spec b/dlls/ext-ms-win-rtcore-ntuser-dpi-l1-1-0/ext-ms-win-rtcore-ntuser-dpi-l1-1-0.spec index ca1fe1cb524..336d8cec493 100644 --- a/dlls/ext-ms-win-rtcore-ntuser-dpi-l1-1-0/ext-ms-win-rtcore-ntuser-dpi-l1-1-0.spec +++ b/dlls/ext-ms-win-rtcore-ntuser-dpi-l1-1-0/ext-ms-win-rtcore-ntuser-dpi-l1-1-0.spec @@ -1,3 +1,3 @@ -@ stub GetDpiForMonitorInternal +@ stdcall GetDpiForMonitorInternal(long long ptr ptr) user32.GetDpiForMonitorInternal @ stdcall GetProcessDpiAwarenessInternal(long ptr) user32.GetProcessDpiAwarenessInternal @ stdcall SetProcessDpiAwarenessInternal(long) user32.SetProcessDpiAwarenessInternal diff --git a/dlls/ext-ms-win-rtcore-ntuser-dpi-l1-2-0/ext-ms-win-rtcore-ntuser-dpi-l1-2-0.spec b/dlls/ext-ms-win-rtcore-ntuser-dpi-l1-2-0/ext-ms-win-rtcore-ntuser-dpi-l1-2-0.spec index 67c40ab2a70..cd546c22c5b 100644 --- a/dlls/ext-ms-win-rtcore-ntuser-dpi-l1-2-0/ext-ms-win-rtcore-ntuser-dpi-l1-2-0.spec +++ b/dlls/ext-ms-win-rtcore-ntuser-dpi-l1-2-0/ext-ms-win-rtcore-ntuser-dpi-l1-2-0.spec @@ -1 +1 @@ -@ stub GetDpiForMonitorInternal +@ stdcall GetDpiForMonitorInternal(long long ptr ptr) user32.GetDpiForMonitorInternal diff --git a/dlls/shcore/main.c b/dlls/shcore/main.c index 17d4b6827cc..07918bcac7b 100644 --- a/dlls/shcore/main.c +++ b/dlls/shcore/main.c @@ -58,14 +58,6 @@ HRESULT WINAPI SetProcessDpiAwareness(PROCESS_DPI_AWARENESS value) HRESULT WINAPI GetDpiForMonitor(HMONITOR monitor, MONITOR_DPI_TYPE type, UINT *x, UINT *y) { - HDC hDC; - - FIXME("(%p, %u, %p, %p): semi-stub\n", monitor, type, x, y); - - hDC = GetDC(0); - if (x) *x = GetDeviceCaps(hDC, LOGPIXELSX); - if (y) *y = GetDeviceCaps(hDC, LOGPIXELSY); - ReleaseDC(0, hDC); - - return S_OK; + if (GetDpiForMonitorInternal( monitor, type, x, y )) return S_OK; + return HRESULT_FROM_WIN32( GetLastError() ); } diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 425acaecc97..8c5dd0add22 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -630,11 +630,17 @@ static UINT get_system_dpi(void) static const WCHAR dpi_key_name[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p','\0'}; static const WCHAR def_dpi_key_name[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s','\0'}; static const WCHAR dpi_value_name[] = {'L','o','g','P','i','x','e','l','s','\0'}; - DWORD dpi; + static UINT system_dpi; + UINT dpi; - if ((dpi = get_reg_dword( HKEY_CURRENT_USER, dpi_key_name, dpi_value_name ))) return dpi; - if ((dpi = get_reg_dword( HKEY_CURRENT_CONFIG, def_dpi_key_name, dpi_value_name ))) return dpi; - return USER_DEFAULT_SCREEN_DPI; + if (!system_dpi) + { + if (!(dpi = get_reg_dword( HKEY_CURRENT_USER, dpi_key_name, dpi_value_name )) && + !(dpi = get_reg_dword( HKEY_CURRENT_CONFIG, def_dpi_key_name, dpi_value_name ))) + dpi = USER_DEFAULT_SCREEN_DPI; + system_dpi = dpi; + } + return system_dpi; } HDC get_display_dc(void) @@ -3284,12 +3290,22 @@ BOOL WINAPI IsProcessDPIAware(void) */ UINT WINAPI GetDpiForSystem(void) { - static int display_dpi; - if (!IsProcessDPIAware()) return USER_DEFAULT_SCREEN_DPI; + return get_system_dpi(); +} - if (!display_dpi) display_dpi = get_system_dpi(); - return display_dpi; +/*********************************************************************** + * GetDpiForMonitorInternal (USER32.@) + */ +BOOL WINAPI GetDpiForMonitorInternal( HMONITOR monitor, UINT type, UINT *x, UINT *y ) +{ + UINT dpi = get_system_dpi(); + + WARN( "(%p, %u, %p, %p): semi-stub\n", monitor, type, x, y ); + + if (x) *x = dpi; + if (y) *y = dpi; + return TRUE; } /*********************************************************************** diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 8d9058bab7b..8556502fda4 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -296,6 +296,7 @@ @ stdcall GetDlgItemTextA(long long ptr long) @ stdcall GetDlgItemTextW(long long ptr long) @ stdcall GetDoubleClickTime() +@ stdcall GetDpiForMonitorInternal(long long ptr ptr) @ stdcall GetDpiForSystem() @ stdcall GetDpiForWindow(long) @ stdcall GetFocus() diff --git a/include/winuser.h b/include/winuser.h index 86cdbf6a15d..c2055e96207 100644 --- a/include/winuser.h +++ b/include/winuser.h @@ -3678,6 +3678,7 @@ WINUSERAPI UINT WINAPI GetDlgItemTextA(HWND,INT,LPSTR,INT); WINUSERAPI UINT WINAPI GetDlgItemTextW(HWND,INT,LPWSTR,INT); #define GetDlgItemText WINELIB_NAME_AW(GetDlgItemText) WINUSERAPI UINT WINAPI GetDoubleClickTime(void); +WINUSERAPI BOOL WINAPI GetDpiForMonitorInternal(HMONITOR,UINT,UINT*,UINT*); WINUSERAPI UINT WINAPI GetDpiForWindow(HWND); WINUSERAPI UINT WINAPI GetDpiForSystem(void); WINUSERAPI HWND WINAPI GetFocus(void);