user32: Scale window dimensions in SetWindowPos() based on DPI awareness.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
110443acef
commit
4233caa7b8
|
@ -1643,6 +1643,23 @@ static void dump_winpos_flags(UINT flags)
|
||||||
TRACE("\n");
|
TRACE("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* map_dpi_winpos
|
||||||
|
*/
|
||||||
|
static void map_dpi_winpos( WINDOWPOS *winpos )
|
||||||
|
{
|
||||||
|
UINT dpi_from = get_thread_dpi();
|
||||||
|
UINT dpi_to = GetDpiForWindow( winpos->hwnd );
|
||||||
|
|
||||||
|
if (!dpi_from) dpi_from = get_win_monitor_dpi( winpos->hwnd );
|
||||||
|
if (dpi_from == dpi_to) return;
|
||||||
|
winpos->x = MulDiv( winpos->x, dpi_to, dpi_from );
|
||||||
|
winpos->y = MulDiv( winpos->y, dpi_to, dpi_from );
|
||||||
|
winpos->cx = MulDiv( winpos->cx, dpi_to, dpi_from );
|
||||||
|
winpos->cy = MulDiv( winpos->cy, dpi_to, dpi_from );
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* SWP_DoWinPosChanging
|
* SWP_DoWinPosChanging
|
||||||
*/
|
*/
|
||||||
|
@ -1691,10 +1708,9 @@ static BOOL SWP_DoWinPosChanging( WINDOWPOS *pWinpos, RECT *old_window_rect, REC
|
||||||
}
|
}
|
||||||
pWinpos->flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
|
pWinpos->flags |= SWP_NOCLIENTMOVE | SWP_NOCLIENTSIZE;
|
||||||
|
|
||||||
TRACE( "hwnd %p, after %p, swp %d,%d %dx%d flags %08x\n",
|
TRACE( "hwnd %p, after %p, swp %d,%d %dx%d flags %08x current %s style %08x new %s\n",
|
||||||
pWinpos->hwnd, pWinpos->hwndInsertAfter, pWinpos->x, pWinpos->y,
|
pWinpos->hwnd, pWinpos->hwndInsertAfter, pWinpos->x, pWinpos->y,
|
||||||
pWinpos->cx, pWinpos->cy, pWinpos->flags );
|
pWinpos->cx, pWinpos->cy, pWinpos->flags,
|
||||||
TRACE( "current %s style %08x new %s\n",
|
|
||||||
wine_dbgstr_rect( old_window_rect ), wndPtr->dwStyle,
|
wine_dbgstr_rect( old_window_rect ), wndPtr->dwStyle,
|
||||||
wine_dbgstr_rect( new_window_rect ));
|
wine_dbgstr_rect( new_window_rect ));
|
||||||
|
|
||||||
|
@ -2216,6 +2232,8 @@ BOOL USER_SetWindowPos( WINDOWPOS * winpos, int parent_x, int parent_y )
|
||||||
{
|
{
|
||||||
RECT old_window_rect, old_client_rect, new_window_rect, new_client_rect, valid_rects[2];
|
RECT old_window_rect, old_client_rect, new_window_rect, new_client_rect, valid_rects[2];
|
||||||
UINT orig_flags;
|
UINT orig_flags;
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
DPI_AWARENESS_CONTEXT context;
|
||||||
|
|
||||||
orig_flags = winpos->flags;
|
orig_flags = winpos->flags;
|
||||||
|
|
||||||
|
@ -2256,11 +2274,13 @@ BOOL USER_SetWindowPos( WINDOWPOS * winpos, int parent_x, int parent_y )
|
||||||
else if (winpos->cy > 32767) winpos->cy = 32767;
|
else if (winpos->cy > 32767) winpos->cy = 32767;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context = SetThreadDpiAwarenessContext( GetWindowDpiAwarenessContext( winpos->hwnd ));
|
||||||
|
|
||||||
if (!SWP_DoWinPosChanging( winpos, &old_window_rect, &old_client_rect,
|
if (!SWP_DoWinPosChanging( winpos, &old_window_rect, &old_client_rect,
|
||||||
&new_window_rect, &new_client_rect )) return FALSE;
|
&new_window_rect, &new_client_rect )) goto done;
|
||||||
|
|
||||||
/* Fix redundant flags */
|
/* Fix redundant flags */
|
||||||
if (!fixup_flags( winpos, &old_window_rect, parent_x, parent_y )) return FALSE;
|
if (!fixup_flags( winpos, &old_window_rect, parent_x, parent_y )) goto done;
|
||||||
|
|
||||||
if((winpos->flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) != SWP_NOZORDER)
|
if((winpos->flags & (SWP_NOZORDER | SWP_HIDEWINDOW | SWP_SHOWWINDOW)) != SWP_NOZORDER)
|
||||||
{
|
{
|
||||||
|
@ -2275,8 +2295,7 @@ BOOL USER_SetWindowPos( WINDOWPOS * winpos, int parent_x, int parent_y )
|
||||||
|
|
||||||
if (!set_window_pos( winpos->hwnd, winpos->hwndInsertAfter, winpos->flags,
|
if (!set_window_pos( winpos->hwnd, winpos->hwndInsertAfter, winpos->flags,
|
||||||
&new_window_rect, &new_client_rect, valid_rects ))
|
&new_window_rect, &new_client_rect, valid_rects ))
|
||||||
return FALSE;
|
goto done;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if( winpos->flags & SWP_HIDEWINDOW )
|
if( winpos->flags & SWP_HIDEWINDOW )
|
||||||
|
@ -2329,7 +2348,10 @@ BOOL USER_SetWindowPos( WINDOWPOS * winpos, int parent_x, int parent_y )
|
||||||
winpos->cy = new_window_rect.bottom - new_window_rect.top;
|
winpos->cy = new_window_rect.bottom - new_window_rect.top;
|
||||||
SendMessageW( winpos->hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)winpos );
|
SendMessageW( winpos->hwnd, WM_WINDOWPOSCHANGED, 0, (LPARAM)winpos );
|
||||||
}
|
}
|
||||||
return TRUE;
|
ret = TRUE;
|
||||||
|
done:
|
||||||
|
SetThreadDpiAwarenessContext( context );
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -2358,6 +2380,8 @@ BOOL WINAPI SetWindowPos( HWND hwnd, HWND hwndInsertAfter,
|
||||||
winpos.cy = cy;
|
winpos.cy = cy;
|
||||||
winpos.flags = flags;
|
winpos.flags = flags;
|
||||||
|
|
||||||
|
map_dpi_winpos( &winpos );
|
||||||
|
|
||||||
if (WIN_IsCurrentThread( hwnd ))
|
if (WIN_IsCurrentThread( hwnd ))
|
||||||
return USER_SetWindowPos( &winpos, 0, 0 );
|
return USER_SetWindowPos( &winpos, 0, 0 );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue