Merge "Register the key when the finger slides off it in multitouch"
This commit is contained in:
commit
20823b4623
2 changed files with 24 additions and 0 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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()) {
|
||||||
|
|
Loading…
Reference in a new issue