mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-01-18 06:29:44 +08:00
[FancyZones] Update app zone history on window removal (#4696)
* Update app zone history on every new window assignment to zone * Compare window positions with already placed windows * Remove window property only after processing window removal from zone
This commit is contained in:
parent
106c316442
commit
ac5a3e7a65
@ -2,6 +2,7 @@
|
||||
#include "JsonHelpers.h"
|
||||
#include "ZoneSet.h"
|
||||
#include "trace.h"
|
||||
#include "Settings.h"
|
||||
|
||||
#include <common/common.h>
|
||||
|
||||
@ -464,10 +465,12 @@ namespace JSONHelpers
|
||||
data->processIdToHandleMap.erase(processId);
|
||||
}
|
||||
|
||||
// if there is another instance placed don't erase history
|
||||
// if there is another instance of same application placed in the same zone don't erase history
|
||||
size_t windowZoneStamp = reinterpret_cast<size_t>(::GetProp(window, MULTI_ZONE_STAMP));
|
||||
for (auto placedWindow : data->processIdToHandleMap)
|
||||
{
|
||||
if (IsWindow(placedWindow.second))
|
||||
size_t placedWindowZoneStamp = reinterpret_cast<size_t>(::GetProp(placedWindow.second, MULTI_ZONE_STAMP));
|
||||
if (IsWindow(placedWindow.second) && (windowZoneStamp == placedWindowZoneStamp))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -518,14 +521,7 @@ namespace JSONHelpers
|
||||
{
|
||||
if (data.deviceId == deviceId)
|
||||
{
|
||||
for (auto placedWindow : data.processIdToHandleMap)
|
||||
{
|
||||
if (IsWindow(placedWindow.second) && processId != placedWindow.first)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// application already has history on this desktop, but zone (or zone layout) has changed
|
||||
// application already has history on this work area, update it with new window position
|
||||
data.processIdToHandleMap[processId] = window;
|
||||
data.zoneSetUuid = zoneSetId;
|
||||
data.zoneIndexSet = zoneIndexSet;
|
||||
@ -535,7 +531,7 @@ namespace JSONHelpers
|
||||
}
|
||||
}
|
||||
|
||||
std::map<DWORD, HWND> processIdToHandleMap{};
|
||||
std::unordered_map<DWORD, HWND> processIdToHandleMap{};
|
||||
processIdToHandleMap[processId] = window;
|
||||
AppZoneHistoryData data{ .processIdToHandleMap = processIdToHandleMap,
|
||||
.zoneSetUuid = zoneSetId,
|
||||
|
@ -133,7 +133,7 @@ namespace JSONHelpers
|
||||
|
||||
struct AppZoneHistoryData
|
||||
{
|
||||
std::map<DWORD, HWND> processIdToHandleMap; // Maps process id(DWORD) of application to zoned window handle(HWND)
|
||||
std::unordered_map<DWORD, HWND> processIdToHandleMap; // Maps process id(DWORD) of application to zoned window handle(HWND)
|
||||
|
||||
std::wstring zoneSetUuid;
|
||||
std::wstring deviceId;
|
||||
|
@ -293,8 +293,6 @@ void WindowMoveHandlerPrivate::MoveSizeEnd(HWND window, POINT const& ptScreen, c
|
||||
}
|
||||
else
|
||||
{
|
||||
::RemoveProp(window, MULTI_ZONE_STAMP);
|
||||
|
||||
if (m_settings->GetSettings()->restoreSize)
|
||||
{
|
||||
if (WindowMoveHandlerUtils::IsCursorTypeIndicatingSizeEvent())
|
||||
@ -325,6 +323,7 @@ void WindowMoveHandlerPrivate::MoveSizeEnd(HWND window, POINT const& ptScreen, c
|
||||
}
|
||||
}
|
||||
}
|
||||
::RemoveProp(window, MULTI_ZONE_STAMP);
|
||||
}
|
||||
|
||||
// Also, hide all windows (regardless of settings)
|
||||
|
Loading…
Reference in New Issue
Block a user