Odd Snapping Behavior

Mar 6, 2011 at 5:27 PM
Edited Mar 6, 2011 at 5:36 PM

Hi there. First, I want to say thank you for this project. I have long wondered when Microsoft would put a respectable interpreter together for Powershell. Why they take an awesome technology and then wrap it up in a 1990s DOS UX makes no sense. The ISE is nice, but this is nicer in many ways.

Anyway, I noticed this strange behavior where the window seems to be snapping to something in the middle of the screen, and resizing is behaving oddly. Not sure how to describe it, so I captured a video.

http://www.youtube.com/watch?v=s6PCHfK0f5M

I am using a high-DPI display (1920x1080 13.1") and the DPI in Windows is set to 135%. Not sure if that's the cause, but thought it worth pointing out. Maybe next time I have to reboot I'll try changing the DPI and retesting.

I have turned off SnapToScreenEdge and set SnapDistance=1; neither seem to change the behavior.

Edit: Regarding high-dpi, I noticed that when I $Host.PrivateData.Settings.WindowTop=100; and measure the distance from the top of the screen to the top of the window, it's 135px. Again, not sure if that factors into this issue, but thought it worth pointing out.

Coordinator
Mar 6, 2011 at 11:12 PM

Weird. That looks like it thinks your start menu is there …

I’m pretty sure that’s fixed already, but I’ve been delaying the release because I introduced a regression which prevents selecting text from the buffer.

Anyway, bear with me while I fix that, and I’ll finally get a new build out, it’s long overdue.

Mar 7, 2011 at 12:01 AM

 I just cloned the trunk and built it; the bottom edge of the window is snapping in the exact same place, and exhibiting that same behavior. Believe me, this is not a deal-breaker, just a quirk that I can live with :)

Mar 7, 2011 at 12:44 AM

I can't resist tinkering :) In NativeMethods.DPITransformFromWindow, when debugging, Left=0,Top=0,Right=1781,Bottom=1080. As I mentioned, my display is 1920x1080; I keep my taskbar on the right--so we were in fact seeing the bottom of the window try to snap to the bottom of my screen. The matrix transform scales that rect to make it smaller; by commenting it out, the window snaps as designed to the all edges of my screen (80px to bottom, 20px everywhere else). 

            //return new Rect( matrix.Transform(new Point(this.Left, this.Top)),
            //                 matrix.Transform(new Point(this.Right, this.Bottom)));
             return new Rect(new Point(this.Left, this.Top),
                             new Point(this.Right, this.Bottom));

In SnapToBehavior.OnPreviewPositionChange, windowPosition is in unscaled pixels (that is, when it's snapped to the bottom, windowPosition.Bottom==1080). If it were in scaled pixels, it should have been 1080/1.35=800. 

That's about as far as my knowledge can take this. Hope it's helpful in fixing the bug.

Travis

Coordinator
Mar 8, 2011 at 3:00 AM

Right now, to get the latest, you have to pull the Metro tip, not the default, so you may have gotten the wrong thing.

I'll have a look at the transform though: it's entirely possible that I'm doing the wrong thing there, because I haven't messed with my DPI settings personally, and I copied the DPITransformFromWindow from something else.