From e8a8c12f8779eb8afae4193e7ae15a265a85e047 Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sat, 26 Mar 2016 15:38:18 +0100 Subject: [PATCH] Fix MouseDevice.GetPosition. Algorithm was incorrect when in a window with DPI scaling. --- src/Perspex.Input/MouseDevice.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Perspex.Input/MouseDevice.cs b/src/Perspex.Input/MouseDevice.cs index 03329df2e4..303096ecef 100644 --- a/src/Perspex.Input/MouseDevice.cs +++ b/src/Perspex.Input/MouseDevice.cs @@ -87,18 +87,18 @@ namespace Perspex.Input /// The mouse position in the control's coordinates. public Point GetPosition(IVisual relativeTo) { - Point p = Position; + Point p = default(Point); IVisual v = relativeTo; IVisual root = null; while (v != null) { - p -= v.Bounds.Position; + p += v.Bounds.Position; root = v; v = v.VisualParent; } - return root.PointToClient(p); + return root.PointToClient(Position) - p; } private void ProcessRawEvent(RawMouseEventArgs e)