user32: Scale monitor rectangles based on DPI awareness.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
7068a85604
commit
92f5c6e410
|
@ -3221,6 +3221,21 @@ UINT get_thread_dpi(void)
|
|||
}
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* map_dpi_rect
|
||||
*/
|
||||
RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to )
|
||||
{
|
||||
if (dpi_from && dpi_to && dpi_from != dpi_to)
|
||||
{
|
||||
rect.left = MulDiv( rect.left, dpi_to, dpi_from );
|
||||
rect.top = MulDiv( rect.top, dpi_to, dpi_from );
|
||||
rect.right = MulDiv( rect.right, dpi_to, dpi_from );
|
||||
rect.bottom = MulDiv( rect.bottom, dpi_to, dpi_from );
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* SetProcessDpiAwarenessContext (USER32.@)
|
||||
*/
|
||||
|
@ -3586,13 +3601,22 @@ BOOL WINAPI GetMonitorInfoA( HMONITOR monitor, LPMONITORINFO info )
|
|||
BOOL WINAPI GetMonitorInfoW( HMONITOR monitor, LPMONITORINFO info )
|
||||
{
|
||||
BOOL ret;
|
||||
UINT dpi_from, dpi_to;
|
||||
|
||||
if (info->cbSize != sizeof(MONITORINFOEXW) && info->cbSize != sizeof(MONITORINFO)) return FALSE;
|
||||
|
||||
ret = USER_Driver->pGetMonitorInfo( monitor, info );
|
||||
if (ret)
|
||||
{
|
||||
if ((dpi_to = get_thread_dpi()))
|
||||
{
|
||||
dpi_from = get_monitor_dpi( monitor );
|
||||
info->rcMonitor = map_dpi_rect( info->rcMonitor, dpi_from, dpi_to );
|
||||
info->rcWork = map_dpi_rect( info->rcWork, dpi_from, dpi_to );
|
||||
}
|
||||
TRACE( "flags %04x, monitor %s, work %s\n", info->dwFlags,
|
||||
wine_dbgstr_rect(&info->rcMonitor), wine_dbgstr_rect(&info->rcWork));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -3634,7 +3658,7 @@ __ASM_GLOBAL_FUNC( enum_mon_callback_wrapper,
|
|||
static BOOL CALLBACK enum_mon_callback( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp )
|
||||
{
|
||||
struct enum_mon_data *data = (struct enum_mon_data *)lp;
|
||||
RECT monrect = *rect;
|
||||
RECT monrect = map_dpi_rect( *rect, get_monitor_dpi( monitor ), get_thread_dpi() );
|
||||
|
||||
OffsetRect( &monrect, -data->origin.x, -data->origin.y );
|
||||
if (!IntersectRect( &monrect, &monrect, &data->limit )) return TRUE;
|
||||
|
|
|
@ -131,6 +131,7 @@ extern void WINPOS_SysCommandSizeMove( HWND hwnd, WPARAM wParam ) DECLSPEC_HIDDE
|
|||
extern UINT get_monitor_dpi( HMONITOR monitor ) DECLSPEC_HIDDEN;
|
||||
extern UINT get_win_monitor_dpi( HWND hwnd ) DECLSPEC_HIDDEN;
|
||||
extern UINT get_thread_dpi(void) DECLSPEC_HIDDEN;
|
||||
extern RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to ) 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;
|
||||
|
|
Loading…
Reference in New Issue