Alexandre Julliard : user32: Scale monitor rectangles based on DPI awareness.
Alexandre Julliard
julliard at winehq.org
Thu Aug 23 16:37:03 CDT 2018
Module: wine
Branch: master
Commit: 92f5c6e410fe0dbcbfa4aae708e7afd9564efb21
URL: https://source.winehq.org/git/wine.git/?a=commit;h=92f5c6e410fe0dbcbfa4aae708e7afd9564efb21
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Aug 23 12:23:47 2018 +0200
user32: Scale monitor rectangles based on DPI awareness.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/sysparams.c | 26 +++++++++++++++++++++++++-
dlls/user32/win.h | 1 +
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c
index 10f90a2..b6679c5 100644
--- a/dlls/user32/sysparams.c
+++ b/dlls/user32/sysparams.c
@@ -3222,6 +3222,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.@)
*/
BOOL WINAPI SetProcessDpiAwarenessContext( DPI_AWARENESS_CONTEXT context )
@@ -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;
diff --git a/dlls/user32/win.h b/dlls/user32/win.h
index f9e11ff..226e3e9 100644
--- a/dlls/user32/win.h
+++ b/dlls/user32/win.h
@@ -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;
More information about the wine-cvs
mailing list