am b9705959: am bf1f16f3: Merge "All keys should be processed before processing modifier key" into gingerbread
Merge commit 'b9705959df5d7de38df5dea53270bf702b87716d' * commit 'b9705959df5d7de38df5dea53270bf702b87716d': All keys should be processed before processing modifier keymain
commit
f027b1c5eb
|
@ -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,17 +1259,28 @@ 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) {
|
||||||
int index = mPointerQueue.lastIndexOf(tracker);
|
if (tracker.isModifier()) {
|
||||||
if (index >= 0) {
|
// Before processing an up event of modifier key, all pointers already being tracked
|
||||||
mPointerQueue.releasePointersOlderThan(tracker, eventTime);
|
// should be released.
|
||||||
|
mPointerQueue.releaseAllPointersExcept(tracker, eventTime);
|
||||||
} else {
|
} else {
|
||||||
Log.w(TAG, "onUpEvent: corresponding down event not found for pointer "
|
int index = mPointerQueue.lastIndexOf(tracker);
|
||||||
+ tracker.mPointerId);
|
if (index >= 0) {
|
||||||
|
mPointerQueue.releaseAllPointersOlderThan(tracker, eventTime);
|
||||||
|
} else {
|
||||||
|
Log.w(TAG, "onUpEvent: corresponding down event not found for pointer "
|
||||||
|
+ tracker.mPointerId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tracker.onUpEvent(x, y, eventTime);
|
tracker.onUpEvent(x, y, eventTime);
|
||||||
mPointerQueue.remove(tracker);
|
mPointerQueue.remove(tracker);
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue