Commit d7cd5587 authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

user32: Optimize getting monitor count with GetSystemMetrics().

This saves calls to GetMonitorInfo(). Signed-off-by: 's avatarZhiyi Zhang <zzhang@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 573d451b
......@@ -371,6 +371,22 @@ RECT get_virtual_screen_rect(void)
return info.virtual_rect;
}
static BOOL CALLBACK get_monitor_count_proc( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp )
{
INT *count = (INT *)lp;
++(*count);
return TRUE;
}
static INT get_monitor_count(void)
{
INT count = 0;
EnumDisplayMonitors( 0, NULL, get_monitor_count_proc, (LPARAM)&count );
return count;
}
static BOOL get_primary_adapter(WCHAR *name)
{
DISPLAY_DEVICEW dd;
......@@ -2717,8 +2733,7 @@ INT WINAPI GetSystemMetrics( INT index )
get_monitors_info( &info );
return info.virtual_rect.bottom - info.virtual_rect.top;
case SM_CMONITORS:
get_monitors_info( &info );
return info.count;
return get_monitor_count();
case SM_SAMEDISPLAYFORMAT:
return 1;
case SM_IMMENABLED:
......
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