Skip to content

Commit

Permalink
[FancyZones] Clone parent data only for new VD
Browse files Browse the repository at this point in the history
  • Loading branch information
enricogior committed Oct 6, 2020
1 parent d246bdd commit 2b0896d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/modules/fancyzones/lib/FancyZonesData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ std::optional<FancyZonesDataTypes::CustomZoneSetData> 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;

Expand All @@ -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)
Expand All @@ -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];
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/fancyzones/lib/FancyZonesData.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FancyZonesData
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<std::wstring>& activeDesktops);
Expand Down
6 changes: 3 additions & 3 deletions src/modules/fancyzones/lib/ZoneWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 2b0896d

Please sign in to comment.