-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Fancy Zones editor location calculation #520
Conversation
Hi @brenca, |
Hi @brenca, |
Hey @enricogior! |
(If you are wondering the whole bunch of modifications that are uncommitted are just project settings to compile on VS 2017, I was too lazy to upgrade to 2019 :) I don't see how that might have caused the issue tho.) |
Thanks for the screenshots. I put my monitor on the left in portrait mode and with 125% scaling to replicate your configuration but I still don't get anything off. |
It's not recentered even with the default templates, and the issue goes a bit deeper than that - I would have settled with an uncentered editor and probably just posted an issue if that was the case. Sadly, the editor being offset also means that I can't adjust the zones to their proper places (it won't let me move the zones into the non-editor space you see on my screenshot). |
Also, it's not just that the custom layouts are not re-centered, the whole editor window that should cover the monitor is offset to the left and to the top and it also extends over the bounds of the monitor. The size is OK, the position is not. Furthermore, if I edit the zones with the editor from |
There was another bug that was effecting the zones placement and resizing, that has been fixed. |
I tried master, but it didn't fix this for me. I'll see if I can upgrade to VS2019, I have to keep a certain version because of my work. |
Alright, the problem is hiding somewhere else. I'll take a stab at fixing the underlaying issue. You can repro what I'm seeing by having your primary monitor scaled to 1.25 as well (or anything else should work also that's not 1.0). |
Got it! |
Btw, you can install VS 2019 side by side with VS 2017 ;) |
OK, I can confirm that the fix works if both monitors are at 125%, but if the primary monitor is at 100% the zones are now shifted to the right. |
8fc7ae2
to
610a599
Compare
@enricogior I've updated the branch with another way to address this - could you please check if this breaks anything? It does seem to work properly here, but I'd love another set of eyes to test this since I was pretty sure the last time as well :D |
Great! I'll give it a try later and let you know. Thanks! |
Unfortunately it only worked when both monitors have 125% scaling, but if the second monitor (the one on the left) is at 100% scaling while the primary monitor is at 125% scaling, the editor is centered on the second monitor but the zones are shifted to the right and span to the primary monitor. |
Ah, heck, I forgot to test that scenario, I'll take a look at what's going on. (Sorry, I can only work at this during the evenings, and I get a bit tired) |
I'll also borrow my sister's monitor to test some theories (namely if this is related to the primary monitor's scaling and the monitor you are on, or if three monitors would screw things up even more) |
I also noticed that the calculated space for the zone(s) to use are off when using multiple monitors because it's using the primary monitors's amount of work space after accounting for the start menu. But the start menu may not be in the same location on all monitors. If it is, it may not be the same size on all monitors. So this should be calculated per monitor. This is after testing with the 0.12 as well as it's initial behavior with 0.11 |
@brenca |
Summary of the Pull Request
I noticed that while the new Fancy Zones worked on my primary monitor, the editor window was halfway off the screen on the secondary one (it's to the left, Windows refers to it with negative coordinates). I've found the error in the calculations, fixed it and here we are I guess.
References
This is related to Fancy Zones' multi-monitor support.
PR Checklist
Detailed Description of the Pull Request / Additional comments
The current code uses the unscaled top/left coordinates of the monitor, and then adds the difference between the
work area
and themonitor rect
left/top coordinates (this is to compensate for the taskbar, since it can be on any edge).We should instead scale the monitor top/left coordinates as well, and then add the difference between the two areas. I added the
std::abs
calls to mark that we need to add the absolute difference there, but the calculations should always yield positive values anyway if I'm correct.Validation Steps Performed
I opened the build with the fix included, and the positioning of the editor window is now correct, and the zones work correctly.
To validate the fix you could: