diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index a971062235f..9d7c256a308 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -3244,6 +3244,16 @@ POINT point_win_to_thread_dpi( HWND hwnd, POINT pt ) return map_dpi_point( pt, GetDpiForWindow( hwnd ), dpi ); } +/********************************************************************** + * point_thread_to_win_dpi + */ +POINT point_thread_to_win_dpi( HWND hwnd, POINT pt ) +{ + UINT dpi = get_thread_dpi(); + if (!dpi) dpi = get_win_monitor_dpi( hwnd ); + return map_dpi_point( pt, dpi, GetDpiForWindow( hwnd )); +} + /********************************************************************** * map_dpi_rect */ @@ -3269,6 +3279,16 @@ RECT rect_win_to_thread_dpi( HWND hwnd, RECT rect ) return map_dpi_rect( rect, GetDpiForWindow( hwnd ), dpi ); } +/********************************************************************** + * rect_thread_to_win_dpi + */ +RECT rect_thread_to_win_dpi( HWND hwnd, RECT rect ) +{ + UINT dpi = get_thread_dpi(); + if (!dpi) dpi = get_win_monitor_dpi( hwnd ); + return map_dpi_rect( rect, dpi, GetDpiForWindow( hwnd ) ); +} + /********************************************************************** * SetProcessDpiAwarenessContext (USER32.@) */ diff --git a/dlls/user32/win.h b/dlls/user32/win.h index b912ef88541..f30b00430bd 100644 --- a/dlls/user32/win.h +++ b/dlls/user32/win.h @@ -133,8 +133,11 @@ extern UINT get_win_monitor_dpi( HWND hwnd ) DECLSPEC_HIDDEN; extern UINT get_thread_dpi(void) DECLSPEC_HIDDEN; extern POINT map_dpi_point( POINT pt, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN; extern POINT point_win_to_thread_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; +extern POINT point_thread_to_win_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; extern RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN; extern RECT rect_win_to_thread_dpi( HWND hwnd, RECT rect ) DECLSPEC_HIDDEN; +extern RECT rect_thread_to_win_dpi( HWND hwnd, RECT rect ) DECLSPEC_HIDDEN; + extern BOOL set_window_pos( HWND hwnd, HWND insert_after, UINT swp_flags, const RECT *window_rect, const RECT *client_rect, const RECT *valid_rects ) DECLSPEC_HIDDEN; diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index 1dd9c12ba47..98eec62fab7 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -1342,9 +1342,9 @@ BOOL WINAPI GetWindowPlacement( HWND hwnd, WINDOWPLACEMENT *wndpl ) wndpl->flags = WPF_RESTORETOMAXIMIZED; else wndpl->flags = 0; - wndpl->ptMinPosition = pWnd->min_pos; - wndpl->ptMaxPosition = pWnd->max_pos; - wndpl->rcNormalPosition = pWnd->normal_rect; + wndpl->ptMinPosition = EMPTYPOINT(pWnd->min_pos) ? pWnd->min_pos : point_win_to_thread_dpi( hwnd, pWnd->min_pos ); + wndpl->ptMaxPosition = EMPTYPOINT(pWnd->max_pos) ? pWnd->max_pos : point_win_to_thread_dpi( hwnd, pWnd->max_pos ); + wndpl->rcNormalPosition = rect_win_to_thread_dpi( hwnd, pWnd->normal_rect ); WIN_ReleasePtr( pWnd ); TRACE( "%p: returning min %d,%d max %d,%d normal %s\n", @@ -1419,9 +1419,9 @@ static BOOL WINPOS_SetPlacement( HWND hwnd, const WINDOWPLACEMENT *wndpl, UINT f if (!pWnd || pWnd == WND_OTHER_PROCESS || pWnd == WND_DESKTOP) return FALSE; - if( flags & PLACE_MIN ) pWnd->min_pos = wp.ptMinPosition; - if( flags & PLACE_MAX ) pWnd->max_pos = wp.ptMaxPosition; - if( flags & PLACE_RECT) pWnd->normal_rect = wp.rcNormalPosition; + if (flags & PLACE_MIN) pWnd->min_pos = point_thread_to_win_dpi( hwnd, wp.ptMinPosition ); + if (flags & PLACE_MAX) pWnd->max_pos = point_thread_to_win_dpi( hwnd, wp.ptMaxPosition ); + if (flags & PLACE_RECT) pWnd->normal_rect = rect_thread_to_win_dpi( hwnd, wp.rcNormalPosition ); style = pWnd->dwStyle;