Browse Source

Fix MouseDevice.GetPosition.

Algorithm was incorrect when in a window with DPI scaling.
pull/488/head
Steven Kirk 11 years ago
parent
commit
e8a8c12f87
  1. 6
      src/Perspex.Input/MouseDevice.cs

6
src/Perspex.Input/MouseDevice.cs

@ -87,18 +87,18 @@ namespace Perspex.Input
/// <returns>The mouse position in the control's coordinates.</returns> /// <returns>The mouse position in the control's coordinates.</returns>
public Point GetPosition(IVisual relativeTo) public Point GetPosition(IVisual relativeTo)
{ {
Point p = Position; Point p = default(Point);
IVisual v = relativeTo; IVisual v = relativeTo;
IVisual root = null; IVisual root = null;
while (v != null) while (v != null)
{ {
p -= v.Bounds.Position; p += v.Bounds.Position;
root = v; root = v;
v = v.VisualParent; v = v.VisualParent;
} }
return root.PointToClient(p); return root.PointToClient(Position) - p;
} }
private void ProcessRawEvent(RawMouseEventArgs e) private void ProcessRawEvent(RawMouseEventArgs e)

Loading…
Cancel
Save