Register the key when the finger slides off it in multitouch

Moved from jb-dev branch (I807fd6f4).

Bug: 6722867
Change-Id: I9764ac72f726396caaac819675d440372c882981
main
Tadashi G. Takaoka 2012-06-27 09:47:59 +09:00
parent d82dcdc924
commit 5e06b8534f
2 changed files with 24 additions and 0 deletions

View File

@ -610,6 +610,15 @@ public class PointerTracker {
onUpEventInternal(); onUpEventInternal();
onDownEventInternal(x, y, eventTime); onDownEventInternal(x, y, eventTime);
} else { } 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; mKeyAlreadyProcessed = true;
setReleasedKeyGraphics(oldKey); setReleasedKeyGraphics(oldKey);
} }

View File

@ -28,6 +28,7 @@ public class PointerTrackerQueue {
private static final String TAG = PointerTrackerQueue.class.getSimpleName(); private static final String TAG = PointerTrackerQueue.class.getSimpleName();
private static final boolean DEBUG = false; private static final boolean DEBUG = false;
// TODO: Use ring buffer instead of {@link LinkedList}.
private final LinkedList<PointerTracker> mQueue = new LinkedList<PointerTracker>(); private final LinkedList<PointerTracker> mQueue = new LinkedList<PointerTracker>();
public synchronized void add(PointerTracker tracker) { 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() { public synchronized boolean isAnyInSlidingKeyInput() {
for (final PointerTracker tracker : mQueue) { for (final PointerTracker tracker : mQueue) {
if (tracker.isInSlidingKeyInput()) { if (tracker.isInSlidingKeyInput()) {