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

Commit 5e06b853 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Register the key when the finger slides off it in multitouch

Moved from jb-dev branch (I807fd6f4).

Bug: 6722867
Change-Id: I9764ac72f726396caaac819675d440372c882981
parent d82dcdc9
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()) {