microsoft / PowerToys

Windows system utilities to maximize productivity
MIT License
110.77k stars 6.52k forks source link

Wrap-around Fancy Zone hotkey support #28881

Closed CodeCharm closed 4 months ago

CodeCharm commented 1 year ago

Description of the new feature / enhancement

Previously, when I overrode the Windows Snap feature by using the Win+Right and Win+Left shortcut hotkeys, the active window would move to first zone if I reached the last zone when moving with the right arrow, and would move to the last zone when I reached the first zone when moving with the left arrow. This behavior recently changed. When I reach the last or first zone, the window stops moving to a new zone. I would like the original behavior restored.

Scenario when this would be used?

I define four zones:

  1. a narrow focus window (center screen)
  2. a narrower side window to the left of the focus window (zone 1)
  3. a narrower side window to the right of the focus window (zone 1)
  4. a wider focus window (center screen)

When I move a window to Zone 1 for focus, I sometimes want that focus a little wider, so I would use Win+Left arrow to move it to Zone 4 quickly. A little less often, I will want to take that center focus window and snap it into Zones 2 or 3.

To get my center narrow focus window now means I have to:

  1. Press Win+Left out of habit and realize nothing happens until I can unlearn that muscle memory
  2. Press Win+Right three times

Yes, I could rebuild my zones so that what was Zone 4 would now be Zone 1 or 2, and Zones 2 and 3 would become Zones 3 and 4. This is not trivial, as there is no built-in feature that supports just renumbering existing zones.

Supporting information

No response

SeraphimaZykova commented 1 year ago

Hi @CodeCharm, could you please check if the Move windows between zones across all monitors option is enabled in FancyZones settings? It allows cycling between zones even when you have one monitor. Please let me know if it helps. /needinfo

CodeCharm commented 1 year ago

Hi @SeraphimaZykova, no it is not checked, and I have intentionally never enabled the multiple-monitor option even though I was aware of the feature from its introduction. I do have multiple monitors: one is a large widescreen, and the other is the built-in display on my device. Cycling across both monitors has never been a behavior that's been valuable to me; I'll just use the Win+Shift+Left/Right chord to switch monitors when I want to do that. The Fancy Zones feature used to cycle the active window over the just the active monitor's zones even with the multi-monitor option unchecked, but that stopped working within the past month ish.

chrisride commented 1 year ago

Hi @CodeCharm, could you please check if the Move windows between zones across all monitors option is enabled in FancyZones settings? It allows cycling between zones even when you have one monitor. Please let me know if it helps. /needinfo

This fixed the issue for me on a single monitor! Thanks!

vfranchi commented 1 year ago

Hi @SeraphimaZykova, no it is not checked, and I have intentionally never enabled the multiple-monitor option even though I was aware of the feature from its introduction. I do have multiple monitors: one is a large widescreen, and the other is the built-in display on my device. Cycling across both monitors has never been a behavior that's been valuable to me; I'll just use the Win+Shift+Left/Right chord to switch monitors when I want to do that. The Fancy Zones feature used to cycle the active window over the just the active monitor's zones even with the multi-monitor option unchecked, but that stopped working within the past month ish.

I also use multiple monitors and prefer the way it was before, cycling through zones only from the active monitor. Enabling the Move windows between zones across all monitors partially fixes the issue because now I need to also cycle though a zone that I never use.

DanRosenberry commented 7 months ago

@SeraphimaZykova

The fix needed for this is in PowerToys/src/modules/fancyzones/FancyZonesLib/WindowKeyboardSnap.cpp line 121

bool moved = MoveByDirectionAndIndex(window, vkCode, FancyZonesSettings::settings().moveWindowAcrossMonitors /* cycle through zones */, workArea.get());

should be

bool moved = MoveByDirectionAndIndex(window, vkCode, true /* cycle through zones */, workArea.get());

This line is in the single monitor/don't go between monitors else of WindowKeyboardSnap::SnapHotkeyBasedOnZoneNumber

WindowKeyboardSnap::MoveByDirectionAndIndex moves forward within the provided WorkArea and cycles around if the third parameter is true and not if it's false.

Providing the setting for moveWindowAcrossMonitors is incorrect here. The logic for navigating monitors is not part of MoveByDirectionAndIndex, but part of SnapHotkeyBasedOnZoneNumber and handled explicitly outside the call in the multiple monitor case. Once in the single monitor (or multiple where moveWindowAcrossMonitors==false) MoveByDirectionAndIndex should be provided with true in the third parameter in all cases.

You can find the changes at Address-Issue#28881-Wrap-around-Fancy-Zone-hotkey-support

htcfreek commented 7 months ago

@DanRosenberry If @SeraphimaZykova or @jaimecbernardo are okay with your solution you can open the PR as asked in https://github.com/microsoft/PowerToys/issues/28769#issuecomment-2002629619 .

SeraphimaZykova commented 7 months ago

@DanRosenberry, thank you for the suggestion. I'm okay with your solution, so please feel free to go ahead and open the pull request.