question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FancyZones] Priority grid zone positions are not consistent

See original GitHub issue

Environment

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: image

3 zones: image

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:open
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Aokromescommented, Apr 22, 2020

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.

0reactions
SeraphimaZykovacommented, Jul 29, 2022

TLDR: Zones are numbered left-to-right, correct?

Yes, correct.

Read more comments on GitHub >

github_iconTop Results From Across the Web

PowerToys Fancy Zones Custom Template not showing ...
I've just installed Powertoys(preview) v0.69.1 directly from Github. When I create a custom template it it shows in the list custom ...
Read more >
PowerToys FancyZones utility for Windows
A window manager utility for arranging and snapping windows into efficient layouts.
Read more >
Splitting Monitors With Fancy Zones For FREE!!!! Windows 10
If you found this video helpful feel free to buy me a coffee here - https://www.buymeacoffee.com/chriswatkins ☕️ Download Here ...
Read more >
FancyZones in 5 Minutes (Beginner's Guide) - YouTube
FancyZones allows you to define a set of window locations for a desktop ... When you drag a window into a zone, the...
Read more >
The Return Of The PowerToys - ParTech
PowerToys are back with its breakthrough features, including FancyZones, Window Walker, Shortcut Guide, and allied one; we enjoyed working with Windows 95.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found