[FancyZones] Clone parent data only for new VD (#7116)

* [FancyZones] Clone parent data only for new VD
This commit is contained in:
Enrico Giordani
2020-10-08 16:02:51 +02:00
committed by GitHub
parent de4436ccc0
commit 038087e076
3 changed files with 9 additions and 6 deletions

View File

@@ -171,7 +171,7 @@ std::optional<FancyZonesDataTypes::CustomZoneSetData> FancyZonesData::FindCustom
return it != end(customZoneSetsMap) ? std::optional{ it->second } : std::nullopt; return it != end(customZoneSetsMap) ? std::optional{ it->second } : std::nullopt;
} }
void FancyZonesData::AddDevice(const std::wstring& deviceId) bool FancyZonesData::AddDevice(const std::wstring& deviceId)
{ {
using namespace FancyZonesDataTypes; using namespace FancyZonesDataTypes;
@@ -192,7 +192,11 @@ void FancyZonesData::AddDevice(const std::wstring& deviceId)
{ {
deviceInfoMap[deviceId] = DeviceInfoData{ ZoneSetData{ NonLocalizable::NullStr, ZoneSetLayoutType::Blank } }; deviceInfoMap[deviceId] = DeviceInfoData{ ZoneSetData{ NonLocalizable::NullStr, ZoneSetLayoutType::Blank } };
} }
return true;
} }
return false;
} }
void FancyZonesData::CloneDeviceInfo(const std::wstring& source, const std::wstring& destination) void FancyZonesData::CloneDeviceInfo(const std::wstring& source, const std::wstring& destination)
@@ -209,7 +213,6 @@ void FancyZonesData::CloneDeviceInfo(const std::wstring& source, const std::wstr
return; return;
} }
// Clone information from source device if destination device is uninitialized (Blank).
deviceInfoMap[destination] = deviceInfoMap[source]; deviceInfoMap[destination] = deviceInfoMap[source];
} }

View File

@@ -58,7 +58,7 @@ public:
return appZoneHistoryMap; return appZoneHistoryMap;
} }
void AddDevice(const std::wstring& deviceId); bool AddDevice(const std::wstring& deviceId);
void CloneDeviceInfo(const std::wstring& source, const std::wstring& destination); void CloneDeviceInfo(const std::wstring& source, const std::wstring& destination);
void UpdatePrimaryDesktopData(const std::wstring& desktopId); void UpdatePrimaryDesktopData(const std::wstring& desktopId);
void RemoveDeletedDesktops(const std::vector<std::wstring>& activeDesktops); void RemoveDeletedDesktops(const std::vector<std::wstring>& activeDesktops);

View File

@@ -443,9 +443,9 @@ ZoneWindow::ClearSelectedZones() noexcept
void ZoneWindow::InitializeZoneSets(const std::wstring& parentUniqueId) noexcept void ZoneWindow::InitializeZoneSets(const std::wstring& parentUniqueId) noexcept
{ {
// If there is not defined zone layout for this work area, created default entry. bool deviceAdded = FancyZonesDataInstance().AddDevice(m_uniqueId);
FancyZonesDataInstance().AddDevice(m_uniqueId); // If the device has been added, check if it should inherit the parent's layout
if (!parentUniqueId.empty()) if (deviceAdded && !parentUniqueId.empty())
{ {
FancyZonesDataInstance().CloneDeviceInfo(parentUniqueId, m_uniqueId); FancyZonesDataInstance().CloneDeviceInfo(parentUniqueId, m_uniqueId);
} }