am bf1f16f3: Merge "All keys should be processed before processing modifier key" into gingerbread

Merge commit 'bf1f16f35f96e9aca5c62a9793ec2ba7ba1bffbe' into gingerbread-plus-aosp

* commit 'bf1f16f35f96e9aca5c62a9793ec2ba7ba1bffbe':
  All keys should be processed before processing modifier key
main
Tadashi G. Takaoka 2010-09-15 07:43:12 -07:00 committed by Android Git Automerger
commit b9705959df
2 changed files with 40 additions and 8 deletions

View File

@ -345,7 +345,7 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
return -1; return -1;
} }
public void releasePointersOlderThan(PointerTracker tracker, long eventTime) { public void releaseAllPointersOlderThan(PointerTracker tracker, long eventTime) {
LinkedList<PointerTracker> queue = mQueue; LinkedList<PointerTracker> queue = mQueue;
int oldestPos = 0; int oldestPos = 0;
for (PointerTracker t = queue.get(oldestPos); t != tracker; t = queue.get(oldestPos)) { for (PointerTracker t = queue.get(oldestPos); t != tracker; t = queue.get(oldestPos)) {
@ -353,11 +353,24 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
oldestPos++; oldestPos++;
} else { } else {
t.onUpEvent(t.getLastX(), t.getLastY(), eventTime); t.onUpEvent(t.getLastX(), t.getLastY(), eventTime);
t.setAlreadyProcessed();
queue.remove(oldestPos); queue.remove(oldestPos);
} }
} }
} }
public void releaseAllPointersExcept(PointerTracker tracker, long eventTime) {
for (PointerTracker t : mQueue) {
if (t == tracker)
continue;
t.onUpEvent(t.getLastX(), t.getLastY(), eventTime);
t.setAlreadyProcessed();
}
mQueue.clear();
if (tracker != null)
mQueue.add(tracker);
}
public void remove(PointerTracker tracker) { public void remove(PointerTracker tracker) {
mQueue.remove(tracker); mQueue.remove(tracker);
} }
@ -1246,18 +1259,29 @@ public class LatinKeyboardBaseView extends View implements PointerTracker.UIProx
} }
private void onDownEvent(PointerTracker tracker, int x, int y, long eventTime) { private void onDownEvent(PointerTracker tracker, int x, int y, long eventTime) {
if (tracker.isOnModifierKey(x, y)) {
// Before processing a down event of modifier key, all pointers already being tracked
// should be released.
mPointerQueue.releaseAllPointersExcept(null, eventTime);
}
tracker.onDownEvent(x, y, eventTime); tracker.onDownEvent(x, y, eventTime);
mPointerQueue.add(tracker); mPointerQueue.add(tracker);
} }
private void onUpEvent(PointerTracker tracker, int x, int y, long eventTime) { private void onUpEvent(PointerTracker tracker, int x, int y, long eventTime) {
if (tracker.isModifier()) {
// Before processing an up event of modifier key, all pointers already being tracked
// should be released.
mPointerQueue.releaseAllPointersExcept(tracker, eventTime);
} else {
int index = mPointerQueue.lastIndexOf(tracker); int index = mPointerQueue.lastIndexOf(tracker);
if (index >= 0) { if (index >= 0) {
mPointerQueue.releasePointersOlderThan(tracker, eventTime); mPointerQueue.releaseAllPointersOlderThan(tracker, eventTime);
} else { } else {
Log.w(TAG, "onUpEvent: corresponding down event not found for pointer " Log.w(TAG, "onUpEvent: corresponding down event not found for pointer "
+ tracker.mPointerId); + tracker.mPointerId);
} }
}
tracker.onUpEvent(x, y, eventTime); tracker.onUpEvent(x, y, eventTime);
mPointerQueue.remove(tracker); mPointerQueue.remove(tracker);
} }

View File

@ -123,8 +123,8 @@ public class PointerTracker {
return isValidKeyIndex(keyIndex) ? mKeys[keyIndex] : null; return isValidKeyIndex(keyIndex) ? mKeys[keyIndex] : null;
} }
public boolean isModifier() { private boolean isModifierInternal(int keyIndex) {
Key key = getKey(mCurrentKey); Key key = getKey(keyIndex);
if (key == null) if (key == null)
return false; return false;
int primaryCode = key.codes[0]; int primaryCode = key.codes[0];
@ -132,6 +132,14 @@ public class PointerTracker {
|| primaryCode == Keyboard.KEYCODE_MODE_CHANGE; || primaryCode == Keyboard.KEYCODE_MODE_CHANGE;
} }
public boolean isModifier() {
return isModifierInternal(mCurrentKey);
}
public boolean isOnModifierKey(int x, int y) {
return isModifierInternal(mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null));
}
public void updateKey(int keyIndex) { public void updateKey(int keyIndex) {
if (mKeyAlreadyProcessed) if (mKeyAlreadyProcessed)
return; return;