diff --git a/src/modules/fancyzones/lib/FancyZonesData.cpp b/src/modules/fancyzones/lib/FancyZonesData.cpp index a2a7e7f19b..28c2beddaf 100644 --- a/src/modules/fancyzones/lib/FancyZonesData.cpp +++ b/src/modules/fancyzones/lib/FancyZonesData.cpp @@ -171,7 +171,7 @@ std::optional FancyZonesData::FindCustom 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; @@ -192,7 +192,11 @@ void FancyZonesData::AddDevice(const std::wstring& deviceId) { deviceInfoMap[deviceId] = DeviceInfoData{ ZoneSetData{ NonLocalizable::NullStr, ZoneSetLayoutType::Blank } }; } + + return true; } + + return false; } 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; } - // Clone information from source device if destination device is uninitialized (Blank). deviceInfoMap[destination] = deviceInfoMap[source]; } diff --git a/src/modules/fancyzones/lib/FancyZonesData.h b/src/modules/fancyzones/lib/FancyZonesData.h index f90c6af5d0..f08f740e9f 100644 --- a/src/modules/fancyzones/lib/FancyZonesData.h +++ b/src/modules/fancyzones/lib/FancyZonesData.h @@ -58,7 +58,7 @@ public: 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 UpdatePrimaryDesktopData(const std::wstring& desktopId); void RemoveDeletedDesktops(const std::vector& activeDesktops); diff --git a/src/modules/fancyzones/lib/ZoneWindow.cpp b/src/modules/fancyzones/lib/ZoneWindow.cpp index 11d815b4b5..8c749af4c2 100644 --- a/src/modules/fancyzones/lib/ZoneWindow.cpp +++ b/src/modules/fancyzones/lib/ZoneWindow.cpp @@ -443,9 +443,9 @@ ZoneWindow::ClearSelectedZones() noexcept void ZoneWindow::InitializeZoneSets(const std::wstring& parentUniqueId) noexcept { - // If there is not defined zone layout for this work area, created default entry. - FancyZonesDataInstance().AddDevice(m_uniqueId); - if (!parentUniqueId.empty()) + bool deviceAdded = FancyZonesDataInstance().AddDevice(m_uniqueId); + // If the device has been added, check if it should inherit the parent's layout + if (deviceAdded && !parentUniqueId.empty()) { FancyZonesDataInstance().CloneDeviceInfo(parentUniqueId, m_uniqueId); }