[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

@@ -103,34 +103,6 @@ namespace FancyZonesUtils
return fallbackColor;
}
}
inline void ParseDeviceId(PCWSTR deviceId, PWSTR parsedId, size_t size)
{
// 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
const std::wstring defaultDeviceId = L"FallbackDevice";
if (!deviceId)
{
StringCchCopy(parsedId, size, defaultDeviceId.c_str());
return;
}
wchar_t buffer[256];
StringCchCopy(buffer, 256, deviceId);
PWSTR pszStart = wcschr(buffer, L'#');
PWSTR pszEnd = wcsrchr(buffer, L'#');
if (pszStart && pszEnd && (pszStart != pszEnd))
{
pszStart++; // skip past the first #
*pszEnd = '\0';
StringCchCopy(parsedId, size, pszStart);
}
else
{
StringCchCopy(parsedId, size, defaultDeviceId.c_str());
}
}
inline BYTE OpacitySettingToAlpha(int opacity)
{
@@ -185,6 +157,8 @@ namespace FancyZonesUtils
return result;
}
std::wstring ParseDeviceId(const std::wstring& deviceId);
UINT GetDpiForMonitor(HMONITOR monitor) noexcept;
void OrderMonitors(std::vector<std::pair<HMONITOR, RECT>>& monitorInfo);
void SizeWindowToRect(HWND window, RECT rect) noexcept;