Repository: PowerToys
Issue: FancyZones: Strange Window Switching Behavior
Labels: Issue-Bug,Product-FancyZones,Needs-Triage

### Microsoft PowerToys version

0.82.1

### Installation method

GitHub, PowerToys auto-update

### Running as admin

No

### Area(s) with issue?

FancyZones

### Steps to reproduce

As I was trying to get a concrete way to replicate this I realized how niche it is, and I'm not really sure if it's a Firefox or PowerToys > FancyZones issue. Oh well, I'll submit it still and see what happens.

Important!
This bug seems to only pertain to Firefox (and maybe Opera, but I recently uninstalled it). I cannot replicate it on Chrome. It seems to be hit or miss whether this bug occurs when I only have 1 monitor. It seems to happen much more often when switching windows between multiple monitors, or at least break more when I do.

Step 1
---
First I create 3 tabs. These are just to demonstrate what is happening. Tabs 1 and 2 are for demonstrating switching between windows "Switch between windows in the current zone". Tab 3 is where the problem becomes later. This window is in a zone.

![1](https://github.com/user-attachments/assets/d12e49db-4d91-426b-a7ac-d9217a9fb948)

Step 2
---
For all movements of tabs I grab the tab itself, not the Windows bar thing. The green arrows show where I grab and move to (click and hold). First, I move tab 2 and turn it into a new window.

![2](https://github.com/user-attachments/assets/27e9bbe1-0d0b-4c58-be6f-895d86ca72fd)

Step 3
---
It will look like the following, where the tab 2 window is in the same zone as the other window. This is normal and expected. I can switch between these two windows with the keybinds I have set

![3](https://github.com/user-attachments/assets/1a610bfe-8ed7-4157-b70c-5b7df9649982)

![image](https://github.com/user-attachments/assets/82de1891-ee5b-4b09-aa04-f952593e2574)

Step 4
---
Next I move tab 3 out of the window anywhere (first image). The new tab 3 window snaps back on top of the original window afterwards (second image).

![4](https://github.com/user-attachments/assets/995a2d50-75b6-4339-9a38-1018bd18148f)

![5](https://github.com/user-attachments/assets/5216ba4b-598d-429e-881f-01f0cb9c8173)

Step 5
---
Next I pull the tab 3 window away and onto another area (another screen seems to be even more buggy than the same screen). The red line in the middle is my task bar which indicates the split between 2 screens.

![6](https://github.com/user-attachments/assets/c319773b-4a64-45fd-8614-3da37451a5aa)

Step 6
---
The image is what the final setup looks like. Once here, attempting to use my keybinds (win+f11 and win+f12) will cause weird behavior. 
Important: I further describe the exact weird behavior in "Actual Behavior".

![7](https://github.com/user-attachments/assets/21a24647-6591-437f-a3c0-b40e0efad0cd)

Other
---
Picture of my zones
![image](https://github.com/user-attachments/assets/5fd443f2-806d-4a3c-9f21-bf47aafd681e)

Power toys bug report zip file download
[PowerToysReport_2024-07-25-13-32-38.zip](https://github.com/user-attachments/files/16382727/PowerToysReport_2024-07-25-13-32-38.zip)

### ✔️ Expected Behavior

*Continuation of step 6...*
When I switch windows in the current zone with my keybinds, the tab 3 window should no longer be included since it's no longer in the same zone as the tab 1 and 2 windows (it is now in no zone, or snapped into a different zone).

### ❌ Actual Behavior

*Continuation of step 6...*
When first focusing on the left zone (by clicking on a window in it) and using my keybinds it sometimes changes windows in the zone (tab 1 windows and tab 2 window), but sometimes it instead focuses the tab 3 window and then gets stuck where I can no longer switch between windows (pressing my keybinds no longer does anything or switches windows in the wrong zone).
If I were to snap the tab 3 window into a new zone with other windows in it, focus on the tab 1 and 2 zone and attempt to use my keybinds to switch zones, then it would instead switch the windows of the zone the tab 3 window is in.

My assumption is window switching in zones is handled by what window is currently being focused, and since using zone switching and this bug changes my focused window to the tab 3 window it then starts switching the respective zone instead of the intended zone.

### Other Software

Firefox 128.0