mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
[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:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user