Skip to content
Prev Previous commit
Next Next commit
Correct clamping of mouse position to viewport coordinates; previous …
…edition has used AWT size of canvas, and mouse positions from MouseEvents are converted to GL surface coordinates early on.
  • Loading branch information
gbburkhardt committed Jan 10, 2024
commit d4b6bf436b5b3849e7cde9ca7e1beb767d0bce79
8 changes: 5 additions & 3 deletions src/gov/nasa/worldwind/awt/AbstractViewInputHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ public double computeDragSlope(Point point1, Point point2, Vec4 vec1, Vec4 vec2)
return slope - 1.0;
}

protected static Point constrainToSourceBounds(Point point, Object source)
protected static Point constrainToSourceBounds(Point point, WorldWindow source)
{
if (point == null)
return null;
Expand All @@ -973,8 +973,10 @@ protected static Point constrainToSourceBounds(Point point, Object source)
int y = (int) point.getY();
if (y < 0)
y = 0;
if (y > c.getHeight())
y = c.getHeight();

// c.getHeight() is AWT coords height, point is MouseEvent GL surface coords
if (y >= source.getView().getViewport().height)
y = source.getView().getViewport().height - 1;

return new Point(x, y);
}
Expand Down