<AWT Dev> [9] Review request for 8166591 [macos 10.12] Trackpad scrolling of text on OS X 10.12 Sierra is very fast (Trackpad, Retina only)

Sergey Malenkov malenkov at gmail.com
Thu Sep 29 18:56:35 UTC 2016


> - The SCROLL_MASK_PHASE_CANCELLED  and SCROLL_MASK_PHASE_ENDED scroll masks
> are added.

Now we use the scrollMask value and the following constants:

static final int SCROLL_MASK_WHEEL = 1;
static final int SCROLL_MASK_TRACKPAD = 1 << 1;
static final int SCROLL_MASK_PHASE_BEGAN = 1 << 2;
static final int SCROLL_MASK_PHASE_CANCELLED = 1 << 3;
static final int SCROLL_MASK_PHASE_ENDED = 1 << 4;

All these masks cannot be used together.
So I suggest to replace it with the scrollPhase value:

static final int SCROLL_PHASE_UNSUPPORTED = 0; // for mouse events
static final int SCROLL_PHASE_BEGAN = 1;
static final int SCROLL_PHASE_CONTINUED = 2;
static final int SCROLL_PHASE_CANCELLED = 3;
static final int SCROLL_PHASE_ENDED = 4;

It simplifies if-statements:
- if ((scrollMask & NSEvent.SCROLL_MASK_PHASE_BEGAN) != 0) {
+ if (scrollPhase == NSEvent.SCROLL_PHASE_BEGAN) {

and the following method:

+ (jint) scrollTypeToMask: (NSEventPhase) phase {
    if (phase) return SCROLL_PHASE_UNSUPPORTED;
    switch (phase) {
        case NSEventPhaseBegan:    return SCROLL_MASK_PHASE_BEGAN;
        case NSEventPhaseCancelled:    return SCROLL_MASK_PHASE_CANCELLED;
        case NSEventPhaseEnded:    return SCROLL_MASK_PHASE_ENDED;
    }
    return SCROLL_PHASE_CONTINUED;
}

What do you think?

-- 
Best regards,
Sergey A. Malenkov


More information about the awt-dev mailing list