Module: wine Branch: master Commit: 6505403e58a67ac02b2587f442ac68184935f3f5 URL: https://gitlab.winehq.org/wine/wine/-/commit/6505403e58a67ac02b2587f442ac681...
Author: Zhiyi Zhang zzhang@codeweavers.com Date: Fri Mar 15 11:56:30 2024 +0800
win32u: Fix a possible condition that makes EnumDisplayMonitors() not reporting any monitors.
When there are two monitors and they are mirrored, both of them are considered primary. When the first primary monitor happens to be a clone, EnumDisplayMonitors() ends up not reporting any monitors because should_enumerate_monitor() returns FALSE and we break out the loop to enumerate primary monitors after that.
This is a regression from b59619d and my review comments. My indent was to break out of the loop after finding the *master* primary monitor, not cloned primary monitors, to avoid unnecessary iterations. However, the primary monitor count is small and it's cleaner this way so let's break when should_enumerate_monitor() returns TRUE.
---
dlls/win32u/sysparams.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 7cefb3822a3..d2f7396971b 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -3459,8 +3459,10 @@ BOOL WINAPI NtUserEnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc { if (!is_monitor_primary( monitor )) continue; if (should_enumerate_monitor( monitor, &origin, &limit, &enum_info[count].rect )) + { enum_info[count++].handle = monitor->handle; - break; + break; + } }
/* then non-primary monitors */