Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 20823b46 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka Committed by Android (Google) Code Review
Browse files

Merge "Register the key when the finger slides off it in multitouch"

parents 2ae75ed5 5e06b853
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -610,6 +610,15 @@ public class PointerTracker {
                        onUpEventInternal();
                        onDownEventInternal(x, y, eventTime);
                    } else {
                        // HACK: If there are currently multiple touches, register the key even if
                        // the finger slides off the key. This defends against noise from some
                        // touch panels when there are close multiple touches.
                        // Caveat: When in chording input mode with a modifier key, we don't use
                        // this hack.
                        if (me != null && me.getPointerCount() > 1
                                && !sPointerTrackerQueue.hasModifierKeyOlderThan(this)) {
                            onUpEventInternal();
                        }
                        mKeyAlreadyProcessed = true;
                        setReleasedKeyGraphics(oldKey);
                    }
+15 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ public class PointerTrackerQueue {
    private static final String TAG = PointerTrackerQueue.class.getSimpleName();
    private static final boolean DEBUG = false;

    // TODO: Use ring buffer instead of {@link LinkedList}.
    private final LinkedList<PointerTracker> mQueue = new LinkedList<PointerTracker>();

    public synchronized void add(PointerTracker tracker) {
@@ -81,6 +82,20 @@ public class PointerTrackerQueue {
        }
    }

    public synchronized boolean hasModifierKeyOlderThan(PointerTracker tracker) {
        final Iterator<PointerTracker> it = mQueue.iterator();
        while (it.hasNext()) {
            final PointerTracker t = it.next();
            if (t == tracker) {
                break;
            }
            if (t.isModifier()) {
                return true;
            }
        }
        return false;
    }

    public synchronized boolean isAnyInSlidingKeyInput() {
        for (final PointerTracker tracker : mQueue) {
            if (tracker.isInSlidingKeyInput()) {