< prev index next >
src/java.desktop/macosx/classes/sun/lwawt/macosx/CPlatformResponder.java
Print this page
@@ -263,42 +263,39 @@
eventNotifier.notifyActivation(gained, opposite);
}
static class DeltaAccumulator {
- static final double MIN_THRESHOLD = 0.1;
- static final double MAX_THRESHOLD = 0.5;
double accumulatedDelta;
+ boolean accumulate;
int getRoundedDelta(double delta, int scrollPhase) {
int roundDelta = (int) Math.round(delta);
if (scrollPhase == NSEvent.SCROLL_PHASE_UNSUPPORTED) { // mouse wheel
if (roundDelta == 0 && delta != 0) {
roundDelta = delta > 0 ? 1 : -1;
}
} else { // trackpad
- boolean begin = scrollPhase == NSEvent.SCROLL_PHASE_BEGAN;
- boolean end = scrollPhase == NSEvent.SCROLL_MASK_PHASE_ENDED
- || scrollPhase == NSEvent.SCROLL_MASK_PHASE_CANCELLED;
-
- if (begin) {
+ if (scrollPhase == NSEvent.SCROLL_PHASE_BEGAN) {
accumulatedDelta = 0;
+ accumulate = true;
+ }
+ else if (scrollPhase == NSEvent.SCROLL_PHASE_MOMENTUM_BEGAN) {
+ accumulate = true;
}
+ if (accumulate) {
accumulatedDelta += delta;
- double absAccumulatedDelta = Math.abs(accumulatedDelta);
- if (absAccumulatedDelta > MAX_THRESHOLD) {
roundDelta = (int) Math.round(accumulatedDelta);
+
accumulatedDelta -= roundDelta;
- }
- if (end) {
- if (roundDelta == 0 && absAccumulatedDelta > MIN_THRESHOLD) {
- roundDelta = accumulatedDelta > 0 ? 1 : -1;
+ if (scrollPhase == NSEvent.SCROLL_PHASE_ENDED) {
+ accumulate = false;
}
}
}
return roundDelta;
< prev index next >