[FancyZones] Screen enumeration improvement (#6908)

* Improvements in enumeration of available screens (work areas)

* Minor code style improvement

* Address PR comments

* Store map of display device name to device index

* Address PR comments

* Update comment

* Break when suitable device is found
This commit is contained in:
vldmr11080
2020-10-13 17:22:25 +02:00
committed by GitHub
parent dde19380e9
commit 954705e3a0
7 changed files with 85 additions and 77 deletions

View File

@@ -40,6 +40,30 @@ namespace
namespace FancyZonesUtils
{
std::wstring ParseDeviceId(const std::wstring& deviceId)
{
// We're interested in the unique part between the first and last #'s
// Example input: \\?\DISPLAY#DELA026#5&10a58c63&0&UID16777488#{e6f07b5f-ee97-4a90-b076-33f57bf4eaa7}
// Example output: DELA026#5&10a58c63&0&UID16777488
static const std::wstring defaultDeviceId = L"FallbackDevice";
if (deviceId.empty())
{
return defaultDeviceId;
}
size_t start = deviceId.find(L'#');
size_t end = deviceId.rfind(L'#');
if (start != std::wstring::npos && end != std::wstring::npos && start != end)
{
size_t size = end - (start + 1);
return deviceId.substr(start + 1, size);
}
else
{
return defaultDeviceId;
}
}
typedef BOOL(WINAPI* GetDpiForMonitorInternalFunc)(HMONITOR, UINT, UINT*, UINT*);
UINT GetDpiForMonitor(HMONITOR monitor) noexcept
{