mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 06:29:44 +08:00
Remove resolution from unique identifier
This commit is contained in:
parent
fd866ce71f
commit
5a36651217
@ -613,7 +613,7 @@ void FancyZones::AddZoneWindow(HMONITOR monitor, PCWSTR deviceId) noexcept
|
||||
wil::unique_cotaskmem_string virtualDesktopId;
|
||||
if (SUCCEEDED_LOG(StringFromCLSID(m_currentVirtualDesktopId, &virtualDesktopId)))
|
||||
{
|
||||
std::wstring uniqueId = ZoneWindowUtils::GenerateUniqueId(monitor, deviceId, virtualDesktopId.get());
|
||||
std::wstring uniqueId = ZoneWindowUtils::GenerateUniqueId(deviceId, virtualDesktopId.get());
|
||||
JSONHelpers::FancyZonesDataInstance().SetActiveDeviceId(uniqueId);
|
||||
|
||||
const bool newWorkArea = IsNewWorkArea(m_currentVirtualDesktopId, monitor);
|
||||
|
@ -63,19 +63,15 @@ namespace ZoneWindowUtils
|
||||
return customZoneSetsTmpFileName;
|
||||
}
|
||||
|
||||
std::wstring GenerateUniqueId(HMONITOR monitor, PCWSTR deviceId, PCWSTR virtualDesktopId)
|
||||
std::wstring GenerateUniqueId(PCWSTR deviceId, PCWSTR virtualDesktopId)
|
||||
{
|
||||
wchar_t uniqueId[256]{}; // Parsed deviceId + resolution + virtualDesktopId
|
||||
|
||||
MONITORINFOEXW mi;
|
||||
mi.cbSize = sizeof(mi);
|
||||
if (virtualDesktopId && GetMonitorInfo(monitor, &mi))
|
||||
if (virtualDesktopId)
|
||||
{
|
||||
wchar_t parsedId[256]{};
|
||||
ParseDeviceId(deviceId, parsedId, 256);
|
||||
|
||||
Rect const monitorRect(mi.rcMonitor);
|
||||
StringCchPrintf(uniqueId, ARRAYSIZE(uniqueId), L"%s_%d_%d_%s", parsedId, monitorRect.width(), monitorRect.height(), virtualDesktopId);
|
||||
StringCchPrintf(uniqueId, ARRAYSIZE(uniqueId), L"%s_%s", parsedId, virtualDesktopId);
|
||||
}
|
||||
return std::wstring{ uniqueId };
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ namespace ZoneWindowUtils
|
||||
const std::wstring& GetActiveZoneSetTmpPath();
|
||||
const std::wstring& GetAppliedZoneSetTmpPath();
|
||||
const std::wstring& GetCustomZoneSetsTmpPath();
|
||||
std::wstring GenerateUniqueId(HMONITOR monitor, PCWSTR deviceId, PCWSTR virtualDesktopId);
|
||||
std::wstring GenerateUniqueId(PCWSTR deviceId, PCWSTR virtualDesktopId);
|
||||
}
|
||||
|
||||
interface __declspec(uuid("{7F017528-8110-4FB3-BE41-F472969C2560}")) IZoneWindow : public IUnknown
|
||||
|
@ -173,11 +173,11 @@ namespace FancyZonesUnitTests
|
||||
TEST_METHOD(CreateZoneWindowNoDeviceId)
|
||||
{
|
||||
// Generate unique id without device id
|
||||
std::wstring uniqueId = ZoneWindowUtils::GenerateUniqueId(m_monitor, nullptr, m_virtualDesktopId.c_str());
|
||||
std::wstring uniqueId = ZoneWindowUtils::GenerateUniqueId(nullptr, m_virtualDesktopId.c_str());
|
||||
m_zoneWindow = MakeZoneWindow(m_hostPtr, m_hInst, m_monitor, uniqueId, false);
|
||||
|
||||
const std::wstring expectedWorkArea = std::to_wstring(m_monitorInfo.rcMonitor.right) + L"_" + std::to_wstring(m_monitorInfo.rcMonitor.bottom);
|
||||
const std::wstring expectedUniqueId = L"FallbackDevice_" + std::to_wstring(m_monitorInfo.rcMonitor.right) + L"_" + std::to_wstring(m_monitorInfo.rcMonitor.bottom) + L"_" + m_virtualDesktopId;
|
||||
const std::wstring expectedUniqueId = L"FallbackDevice_" + m_virtualDesktopId;
|
||||
|
||||
Assert::IsNotNull(m_zoneWindow.get());
|
||||
Assert::IsFalse(m_zoneWindow->IsDragEnabled());
|
||||
@ -189,10 +189,9 @@ namespace FancyZonesUnitTests
|
||||
TEST_METHOD(CreateZoneWindowNoDesktopId)
|
||||
{
|
||||
// Generate unique id without virtual desktop id
|
||||
std::wstring uniqueId = ZoneWindowUtils::GenerateUniqueId(m_monitor, m_deviceId.c_str(), nullptr);
|
||||
std::wstring uniqueId = ZoneWindowUtils::GenerateUniqueId(m_deviceId.c_str(), nullptr);
|
||||
m_zoneWindow = MakeZoneWindow(m_hostPtr, m_hInst, m_monitor, uniqueId, false);
|
||||
|
||||
const std::wstring expectedWorkArea = std::to_wstring(m_monitorInfo.rcMonitor.right) + L"_" + std::to_wstring(m_monitorInfo.rcMonitor.bottom);
|
||||
Assert::IsNotNull(m_zoneWindow.get());
|
||||
Assert::IsFalse(m_zoneWindow->IsDragEnabled());
|
||||
Assert::IsTrue(m_zoneWindow->UniqueId().empty());
|
||||
|
Loading…
Reference in New Issue
Block a user