Commit 3570b091 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move DPI mapping from EnumDisplayMonitors.

parent 7aab49d7
...@@ -327,7 +327,7 @@ RECT get_virtual_screen_rect(void) ...@@ -327,7 +327,7 @@ RECT get_virtual_screen_rect(void)
{ {
RECT rect = {0}; RECT rect = {0};
EnumDisplayMonitors( 0, NULL, get_virtual_screen_proc, (LPARAM)&rect ); NtUserEnumDisplayMonitors( 0, NULL, get_virtual_screen_proc, (LPARAM)&rect );
return rect; return rect;
} }
...@@ -348,7 +348,7 @@ RECT get_primary_monitor_rect(void) ...@@ -348,7 +348,7 @@ RECT get_primary_monitor_rect(void)
{ {
RECT rect = {0}; RECT rect = {0};
EnumDisplayMonitors( 0, NULL, get_primary_monitor_proc, (LPARAM)&rect ); NtUserEnumDisplayMonitors( 0, NULL, get_primary_monitor_proc, (LPARAM)&rect );
return rect; return rect;
} }
...@@ -364,7 +364,7 @@ static INT get_monitor_count(void) ...@@ -364,7 +364,7 @@ static INT get_monitor_count(void)
{ {
INT count = 0; INT count = 0;
EnumDisplayMonitors( 0, NULL, get_monitor_count_proc, (LPARAM)&count ); NtUserEnumDisplayMonitors( 0, NULL, get_monitor_count_proc, (LPARAM)&count );
return count; return count;
} }
...@@ -1747,7 +1747,7 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam, ...@@ -1747,7 +1747,7 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
if (!spi_loaded[spi_idx]) if (!spi_loaded[spi_idx])
{ {
work_area = get_primary_monitor_rect(); work_area = get_primary_monitor_rect();
EnumDisplayMonitors( 0, NULL, enum_monitors, (LPARAM)&work_area ); NtUserEnumDisplayMonitors( 0, NULL, enum_monitors, (LPARAM)&work_area );
spi_loaded[spi_idx] = TRUE; spi_loaded[spi_idx] = TRUE;
} }
*(RECT*)pvParam = work_area; *(RECT*)pvParam = work_area;
...@@ -3469,7 +3469,7 @@ HMONITOR WINAPI MonitorFromRect( const RECT *rect, DWORD flags ) ...@@ -3469,7 +3469,7 @@ HMONITOR WINAPI MonitorFromRect( const RECT *rect, DWORD flags )
info.rect.bottom = info.rect.top + 1; info.rect.bottom = info.rect.top + 1;
} }
if (!EnumDisplayMonitors( 0, NULL, monitor_enum, (LPARAM)&info )) return 0; if (!NtUserEnumDisplayMonitors( 0, NULL, monitor_enum, (LPARAM)&info )) return 0;
if (!info.ret) if (!info.ret)
{ {
if (flags & MONITOR_DEFAULTTOPRIMARY) info.ret = info.primary; if (flags & MONITOR_DEFAULTTOPRIMARY) info.ret = info.primary;
...@@ -3546,13 +3546,6 @@ BOOL WINAPI GetMonitorInfoW( HMONITOR monitor, LPMONITORINFO info ) ...@@ -3546,13 +3546,6 @@ BOOL WINAPI GetMonitorInfoW( HMONITOR monitor, LPMONITORINFO info )
return NtUserCallTwoParam( HandleToUlong(monitor), (ULONG_PTR)info, NtUserGetMonitorInfo ); return NtUserCallTwoParam( HandleToUlong(monitor), (ULONG_PTR)info, NtUserGetMonitorInfo );
} }
struct enum_mon_data
{
LPARAM lparam;
POINT origin;
RECT limit;
};
#ifdef __i386__ #ifdef __i386__
/* Some apps pass a non-stdcall callback to EnumDisplayMonitors, /* Some apps pass a non-stdcall callback to EnumDisplayMonitors,
* so we need a small assembly wrapper to call it. * so we need a small assembly wrapper to call it.
...@@ -3580,45 +3573,15 @@ __ASM_GLOBAL_FUNC( enum_mon_callback_wrapper, ...@@ -3580,45 +3573,15 @@ __ASM_GLOBAL_FUNC( enum_mon_callback_wrapper,
BOOL WINAPI User32CallEnumDisplayMonitor( struct enum_display_monitor_params *params, ULONG size ) BOOL WINAPI User32CallEnumDisplayMonitor( struct enum_display_monitor_params *params, ULONG size )
{ {
struct enum_mon_data *data = (struct enum_mon_data *)params->lparam;
RECT monrect = map_dpi_rect( params->rect, get_monitor_dpi( params->monitor ), get_thread_dpi() );
/* FIXME: move DPI conversion and rect filtering to win32u */
OffsetRect( &monrect, -data->origin.x, -data->origin.y );
if (!IntersectRect( &monrect, &monrect, &data->limit )) return TRUE;
#ifdef __i386__ #ifdef __i386__
return enum_mon_callback_wrapper( params->proc, params->monitor, params->hdc, return enum_mon_callback_wrapper( params->proc, params->monitor, params->hdc,
&monrect, data->lparam ); &params->rect, params->lparam );
#else #else
return params->proc( params->monitor, params->hdc, &monrect, data->lparam ); return params->proc( params->monitor, params->hdc, &params->rect, params->lparam );
#endif #endif
} }
/*********************************************************************** /***********************************************************************
* EnumDisplayMonitors (USER32.@)
*/
BOOL WINAPI EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
{
struct enum_mon_data data;
data.lparam = lp;
if (hdc)
{
if (!GetDCOrgEx( hdc, &data.origin )) return FALSE;
if (GetClipBox( hdc, &data.limit ) == ERROR) return FALSE;
}
else
{
data.origin.x = data.origin.y = 0;
data.limit.left = data.limit.top = INT_MIN;
data.limit.right = data.limit.bottom = INT_MAX;
}
if (rect && !IntersectRect( &data.limit, &data.limit, rect )) return TRUE;
return NtUserEnumDisplayMonitors( hdc, rect, proc, (LPARAM)&data );
}
/***********************************************************************
* EnumDisplayDevicesA (USER32.@) * EnumDisplayDevicesA (USER32.@)
*/ */
BOOL WINAPI EnumDisplayDevicesA( LPCSTR device, DWORD index, DISPLAY_DEVICEA *info, DWORD flags ) BOOL WINAPI EnumDisplayDevicesA( LPCSTR device, DWORD index, DISPLAY_DEVICEA *info, DWORD flags )
......
...@@ -223,7 +223,7 @@ ...@@ -223,7 +223,7 @@
@ stub EnumDisplayDeviceModesW @ stub EnumDisplayDeviceModesW
@ stdcall EnumDisplayDevicesA(str long ptr long) @ stdcall EnumDisplayDevicesA(str long ptr long)
@ stdcall EnumDisplayDevicesW(wstr long ptr long) @ stdcall EnumDisplayDevicesW(wstr long ptr long)
@ stdcall EnumDisplayMonitors(long ptr ptr long) @ stdcall EnumDisplayMonitors(long ptr ptr long) NtUserEnumDisplayMonitors
@ stdcall EnumDisplaySettingsA(str long ptr) @ stdcall EnumDisplaySettingsA(str long ptr)
@ stdcall EnumDisplaySettingsExA(str long ptr long) @ stdcall EnumDisplaySettingsExA(str long ptr long)
@ stdcall EnumDisplaySettingsExW(wstr long ptr long) @ stdcall EnumDisplaySettingsExW(wstr long ptr long)
......
...@@ -1741,8 +1741,27 @@ BOOL WINAPI NtUserEnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc ...@@ -1741,8 +1741,27 @@ BOOL WINAPI NtUserEnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc
struct enum_display_monitor_params params; struct enum_display_monitor_params params;
struct monitor *monitor; struct monitor *monitor;
unsigned int count = 0, i; unsigned int count = 0, i;
POINT origin;
RECT limit;
BOOL ret = TRUE; BOOL ret = TRUE;
if (hdc)
{
DC *dc;
if (!(dc = get_dc_ptr( hdc ))) return FALSE;
origin.x = dc->attr->vis_rect.left;
origin.y = dc->attr->vis_rect.top;
release_dc_ptr( dc );
if (NtGdiGetAppClipBox( hdc, &limit ) == ERROR) return FALSE;
}
else
{
origin.x = origin.y = 0;
limit.left = limit.top = INT_MIN;
limit.right = limit.bottom = INT_MAX;
}
if (rect && !intersect_rect( &limit, &limit, rect )) return TRUE;
if (!lock_display_devices()) return FALSE; if (!lock_display_devices()) return FALSE;
count = list_count( &monitors ); count = list_count( &monitors );
...@@ -1756,9 +1775,17 @@ BOOL WINAPI NtUserEnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc ...@@ -1756,9 +1775,17 @@ BOOL WINAPI NtUserEnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc
count = 0; count = 0;
LIST_FOR_EACH_ENTRY(monitor, &monitors, struct monitor, entry) LIST_FOR_EACH_ENTRY(monitor, &monitors, struct monitor, entry)
{ {
RECT monrect;
if (!(monitor->dev.state_flags & DISPLAY_DEVICE_ACTIVE)) continue; if (!(monitor->dev.state_flags & DISPLAY_DEVICE_ACTIVE)) continue;
monrect = map_dpi_rect( monitor->rc_monitor, get_monitor_dpi( monitor->handle ),
get_thread_dpi() );
offset_rect( &monrect, -origin.x, -origin.y );
if (!intersect_rect( &monrect, &monrect, &limit )) continue;
enum_info[count].handle = monitor->handle; enum_info[count].handle = monitor->handle;
enum_info[count].rect = monitor->rc_monitor; enum_info[count].rect = monrect;
count++; count++;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment