mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 10:46:33 +02:00
[FancyZones] Clean up resources taken by closed virtual desktops on module startup (#2616)
* Clean up resources taken by closed virtual desktops on FancyZones module startup. * Overload GetVirtualDesktopIds to return wide string. * Refactor OnDisplayChange method.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <fstream>
|
||||
#include <regex>
|
||||
#include <sstream>
|
||||
#include <unordered_set>
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -348,6 +349,25 @@ namespace JSONHelpers
|
||||
SaveFancyZonesData();
|
||||
}
|
||||
|
||||
void FancyZonesData::RemoveDeletedDesktops(const std::vector<std::wstring>& activeDesktops)
|
||||
{
|
||||
std::unordered_set<std::wstring> active(std::begin(activeDesktops), std::end(activeDesktops));
|
||||
std::scoped_lock lock{ dataLock };
|
||||
for (auto it = std::begin(deviceInfoMap); it != std::end(deviceInfoMap);)
|
||||
{
|
||||
auto foundId = active.find(ExtractVirtualDesktopId(it->first));
|
||||
if (foundId == std::end(active))
|
||||
{
|
||||
it = deviceInfoMap.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
SaveFancyZonesData();
|
||||
}
|
||||
|
||||
int FancyZonesData::GetAppLastZoneIndex(HWND window, const std::wstring_view& deviceId, const std::wstring_view& zoneSetId) const
|
||||
{
|
||||
std::scoped_lock lock{ dataLock };
|
||||
|
||||
Reference in New Issue
Block a user