diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c index 55d6d7e53a7..8b45704a9f8 100644 --- a/dlls/user32/sysparams.c +++ b/dlls/user32/sysparams.c @@ -4006,12 +4006,20 @@ static BOOL CALLBACK enum_mon_callback( HMONITOR monitor, HDC hdc, LPRECT rect, BOOL CDECL nulldrv_EnumDisplayMonitors( HDC hdc, RECT *rect, MONITORENUMPROC proc, LPARAM lp ) { + BOOL is_winstation_visible = FALSE; + USEROBJECTFLAGS flags; + HWINSTA winstation; RECT monitor_rect; DWORD i = 0; TRACE("(%p, %p, %p, 0x%lx)\n", hdc, rect, proc, lp); - if (update_monitor_cache()) + /* Report physical monitor information only if window station has visible display surfaces */ + winstation = GetProcessWindowStation(); + if (GetUserObjectInformationW( winstation, UOI_FLAGS, &flags, sizeof(flags), NULL )) + is_winstation_visible = flags.dwFlags & WSF_VISIBLE; + + if (is_winstation_visible && update_monitor_cache()) { while (TRUE) { diff --git a/dlls/user32/tests/monitor.c b/dlls/user32/tests/monitor.c index a587c7c6b16..a5be9021cbc 100644 --- a/dlls/user32/tests/monitor.c +++ b/dlls/user32/tests/monitor.c @@ -1560,6 +1560,7 @@ static void test_EnumDisplayMonitors(void) static const DWORD DESKTOP_ALL_ACCESS = 0x01ff; HWINSTA winstation, old_winstation; HDESK desktop, old_desktop; + USEROBJECTFLAGS flags; INT count, old_count; DWORD error; BOOL ret; @@ -1599,6 +1600,12 @@ static void test_EnumDisplayMonitors(void) ok(ret, "SetProcessWindowStation failed, error %#x.\n", GetLastError()); ok(winstation == GetProcessWindowStation(), "Expected %p, got %p.\n", GetProcessWindowStation(), winstation); + flags.fInherit = FALSE; + flags.fReserved = FALSE; + flags.dwFlags = WSF_VISIBLE; + ret = SetUserObjectInformationW(winstation, UOI_FLAGS, &flags, sizeof(flags)); + ok(ret, "SetUserObjectInformationW failed, error %#x.\n", GetLastError()); + desktop = CreateDesktopW(L"test_desktop", NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL); ok(!!desktop && desktop != old_desktop, "CreateDesktopW failed, error %#x.\n", GetLastError()); ret = SetThreadDesktop(desktop);