This saves calls to GetMonitorInfo() and return from EnumDisplayMonitors() immediately after the primary monitor is found.
Signed-off-by: Zhiyi Zhang zzhang@codeweavers.com --- dlls/user32/sysparams.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 7dc2a8df645..ab1c5af0c1b 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -371,6 +371,27 @@ RECT get_virtual_screen_rect(void) return info.virtual_rect; }
+static BOOL CALLBACK get_primary_monitor_proc( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp ) +{ + RECT *primary_rect = (RECT *)lp; + + if (!rect->top && !rect->left && rect->right && rect->bottom) + { + *primary_rect = *rect; + return FALSE; + } + + return TRUE; +} + +static RECT get_primary_monitor_rect(void) +{ + RECT rect = {0}; + + EnumDisplayMonitors( 0, NULL, get_primary_monitor_proc, (LPARAM)&rect ); + return rect; +} + static BOOL CALLBACK get_monitor_count_proc( HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM lp ) { INT *count = (INT *)lp; @@ -2510,6 +2531,7 @@ INT WINAPI GetSystemMetrics( INT index ) NONCLIENTMETRICSW ncm; MINIMIZEDMETRICS mm; ICONMETRICSW im; + RECT rect; UINT ret; HDC hdc;
@@ -2715,11 +2737,11 @@ INT WINAPI GetSystemMetrics( INT index ) case SM_MOUSEWHEELPRESENT: return 1; case SM_CXSCREEN: - get_monitors_info( &info ); - return info.primary_rect.right - info.primary_rect.left; + rect = get_primary_monitor_rect(); + return rect.right - rect.left; case SM_CYSCREEN: - get_monitors_info( &info ); - return info.primary_rect.bottom - info.primary_rect.top; + rect = get_primary_monitor_rect(); + return rect.bottom - rect.top; case SM_XVIRTUALSCREEN: get_monitors_info( &info ); return info.virtual_rect.left;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=90667
Your paranoid android.
=== debiant2 (32 bit report) ===
user32: menu.c:2337: Test failed: test 25