Zhiyi Zhang : user32: Optimize getting monitor count with GetSystemMetrics().
Module: wine Branch: master Commit: d7cd5587df5c0dfc6a5b0b9586b0feee28ee0de8 URL: https://source.winehq.org/git/wine.git/?a=commit;h=d7cd5587df5c0dfc6a5b0b958... Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Tue May 18 17:11:02 2021 +0800 user32: Optimize getting monitor count with GetSystemMetrics(). This saves calls to GetMonitorInfo(). Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/user32/sysparams.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 0b4dbfc2d78..7dc2a8df645 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -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:
participants (1)
-
Alexandre Julliard