Skip to content

Commit

Permalink
review fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyoyuppe committed Nov 19, 2019
1 parent 6e3c7a7 commit 110df93
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/modules/fancyzones/lib/FancyZones.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,27 +593,28 @@ void FancyZones::UpdateZoneWindows() noexcept
bool duplicateDeviceIdFound = false;
} localScope;


auto enumDisplayMonitorsCallback = [](HMONITOR monitor, HDC, RECT *, LPARAM captured_ptr) -> BOOL
{
const auto doContinueEnumeration = TRUE;
MONITORINFOEX mi;
mi.cbSize = sizeof(mi);
if (GetMonitorInfo(monitor, &mi) == FALSE)
{
return doContinueEnumeration;
// We should always return TRUE to continue enumeration
return TRUE;
}
DISPLAY_DEVICE displayDevice = { sizeof(displayDevice) };

if (EnumDisplayDevices(mi.szDevice, 0, &displayDevice, 1))
{
if (WI_IsFlagSet(displayDevice.StateFlags, DISPLAY_DEVICE_MIRRORING_DRIVER))
{
return doContinueEnumeration;
return TRUE;
}
}
if (displayDevice.DeviceID[0] == L'\0')
{
return doContinueEnumeration;
return TRUE;
}

const auto capturedScope = reinterpret_cast<localScopeCapture *>(captured_ptr);
Expand All @@ -622,7 +623,7 @@ void FancyZones::UpdateZoneWindows() noexcept
std::array<wchar_t, 256> parsedId{};
if (!ParseDeviceId(displayDevice.DeviceID, parsedId.data(), size(parsedId)))
{
return doContinueEnumeration;
return TRUE;
}
// Get a generated part of the id, e.g. "5&25664547&0&UID4355" from "VSCBD34#5&25664547&0&UID4355"
std::wstring_view parsedIdView{parsedId.data(), wcslen(parsedId.data())};
Expand All @@ -634,7 +635,7 @@ void FancyZones::UpdateZoneWindows() noexcept
const auto [_, hasUniqueID] = capturedScope->discoveredDeviceIDs.emplace(generatedPartOfID);
capturedScope->duplicateDeviceIdFound = !hasUniqueID || capturedScope->duplicateDeviceIdFound;
}
return doContinueEnumeration;
return TRUE;
};
EnumDisplayMonitors(nullptr, nullptr, enumDisplayMonitorsCallback, reinterpret_cast<LPARAM>(&localScope));
std::vector<WmiMonitorID> wmiMonitorInfo;
Expand Down

0 comments on commit 110df93

Please sign in to comment.