Skip to content

Commit d4b6bf4

Browse files
committed
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.
1 parent b0b90e1 commit d4b6bf4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/gov/nasa/worldwind/awt/AbstractViewInputHandler.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ public double computeDragSlope(Point point1, Point point2, Vec4 vec1, Vec4 vec2)
954954
return slope - 1.0;
955955
}
956956

957-
protected static Point constrainToSourceBounds(Point point, Object source)
957+
protected static Point constrainToSourceBounds(Point point, WorldWindow source)
958958
{
959959
if (point == null)
960960
return null;
@@ -973,8 +973,10 @@ protected static Point constrainToSourceBounds(Point point, Object source)
973973
int y = (int) point.getY();
974974
if (y < 0)
975975
y = 0;
976-
if (y > c.getHeight())
977-
y = c.getHeight();
976+
977+
// c.getHeight() is AWT coords height, point is MouseEvent GL surface coords
978+
if (y >= source.getView().getViewport().height)
979+
y = source.getView().getViewport().height - 1;
978980

979981
return new Point(x, y);
980982
}

0 commit comments

Comments
 (0)