[FancyZones] Priority grid zone positions are not consistent
See original GitHub issueEnvironment
Windows build number: 19041.172
PowerToys version: Master/0.16.0
PowerToy module for which you are reporting the bug (if applicable): FancyZones
Steps to reproduce
With the ‘During zone layout changes, windows assigned to a zone will match new size/position’ setting enabled: Use the Priority Grid template layout with two zones. Add a window to the ‘priority’ zone (the largest zone). Add a new zone. The window will no longer be in the priority zone and will now be in the non-priority zone to the left. This occurs whenever a new zone is added to the left of the priority zone.
Expected behavior
Windows added to the priority zone should remain in the priority zone when the number of zones are increased or decreased.
In general, when the zone count is increased or decreased windows should stay in the zone that most closely matches the position they’re currently in, as is when increasing/decreasing zones they move around unintuitively.
This is because zone numbering is simply done from top-left to bottom-right without considering what position these zones are in when the zone count is higher or lower.
Actual behavior
See the below screenshots, I am using the priority grid layout with 2 zones, I add a third zone, Visual Studio moves from the priority zone to the leftside non-priority zone. File explorer, not in the priority zone moves into the priority zone.
Screenshots
2 zones:

3 zones:

Proposed fix
The layout info for the priority grid is defined in ZoneSet.cpp, here is a code snippet for 2 and 3 zones:
/* 2 */
JSONHelpers::GridLayoutInfo(JSONHelpers::GridLayoutInfo::Full{
.rows = 1,
.columns = 2,
.rowsPercents = { 10000 },
.columnsPercents = { 6667, 3333 },
.cellChildMap = { { 0, 1 } } }),
/* 3 */
JSONHelpers::GridLayoutInfo(JSONHelpers::GridLayoutInfo::Full{
.rows = 1,
.columns = 3,
.rowsPercents = { 10000 },
.columnsPercents = { 2500, 5000, 2500 },
.cellChildMap = { { 0, 1, 2 } } }),
The cellChildMap for each layout should be changed such that zone positions stay consistent across zone counts. In this example the cellChildMap for 3 zones should be .cellChildMap = { { 2, 0, 1 } }. This would keep the windows in the priority zone in the priority zone, windows on the right hand side of the screen would remain on the right, and a new zone would be added on the left.
As well as this change a new overload method for ZoneSet::AddZone would need adding. Currently this method simply sets the zone’s Id in a top-left to top-right fashion:
IFACEMETHODIMP ZoneSet::AddZone(winrt::com_ptr<IZone> zone) noexcept
{
m_zones.emplace_back(zone);
// Important not to set Id 0 since we store it in the HWND using SetProp.
// SetProp(0) doesn't really work.
zone->SetId(m_zones.size());
return S_OK;
}
The new method should also take in the cellChild value and use that for the Id instead, something like this:
IFACEMETHODIMP ZoneSet::AddZone(winrt::com_ptr<IZone> zone, integer cellChild) noexcept
{
m_zones.emplace_back(zone);
zone->SetId(cellChild + 1);
return S_OK;
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)

Top Related StackOverflow Question
imho priority zone must be on the center of screen, for example on a grid of 5 2 on right, 2 on left one big zone on center. on a grid of 7 3 on right, 3 on left one big zone on center. on a grid of 11 4 on bottom, 3 on left, 3 on right 1 on center top. on a grid of 13 2 rows of 5 on top and bottom, one central row with 2 on side and one big on center.
Yes, correct.