JRE-100 Scroll with inertia (Mac os) should only work in the initial component

(cherry picked from commit e79502c708)
(cherry picked from commit 223a74bfeb)
This commit is contained in:
Sergey Malenkov
2018-07-13 11:58:21 +07:00
committed by jbrbot
parent ac80ca0d84
commit ac54a66a19

View File

@@ -46,6 +46,10 @@ final class CPlatformResponder {
private int lastKeyPressCode = KeyEvent.VK_UNDEFINED;
private final DeltaAccumulator deltaAccumulatorX = new DeltaAccumulator();
private final DeltaAccumulator deltaAccumulatorY = new DeltaAccumulator();
private boolean momentumStarted;
private int momentumX;
private int momentumY;
private int momentumModifiers;
private int lastDraggedAbsoluteX;
private int lastDraggedAbsoluteY;
private int lastDraggedRelativeX;
@@ -113,11 +117,26 @@ final class CPlatformResponder {
/**
* Handles scroll events.
*/
void handleScrollEvent(final int x, final int y, final int absX,
void handleScrollEvent(int x, int y, final int absX,
final int absY, final int modifierFlags,
final double deltaX, final double deltaY,
final int scrollPhase) {
int jmodifiers = NSEvent.nsToJavaModifiers(modifierFlags);
if (scrollPhase > NSEvent.SCROLL_PHASE_UNSUPPORTED) {
if (scrollPhase == NSEvent.SCROLL_PHASE_BEGAN) {
momentumStarted = false;
} else if (scrollPhase == NSEvent.SCROLL_PHASE_MOMENTUM_BEGAN) {
momentumStarted = true;
momentumX = x;
momentumY = y;
momentumModifiers = jmodifiers;
} else if (momentumStarted) {
x = momentumX;
y = momentumY;
jmodifiers = momentumModifiers;
}
}
final boolean isShift = (jmodifiers & InputEvent.SHIFT_DOWN_MASK) != 0;
int roundDeltaX = deltaAccumulatorX.getRoundedDelta(deltaX, scrollPhase);