diff options
author | 2010-11-05 18:41:12 +0900 | |
---|---|---|
committer | 2010-11-06 01:10:55 +0900 | |
commit | 59b7bd07301196ac333dabafb5dd80750fcd2987 (patch) | |
tree | e8fe26f8e99a57a29c7124719a6146ef86b428f2 /java/src/com/android/inputmethod/latin/PointerTracker.java | |
parent | 68864723cf8d8e48385bfcaf30237fba25a8895a (diff) | |
download | latinime-59b7bd07301196ac333dabafb5dd80750fcd2987.tar.gz latinime-59b7bd07301196ac333dabafb5dd80750fcd2987.tar.xz latinime-59b7bd07301196ac333dabafb5dd80750fcd2987.zip |
Using distance to the edge of key as proximity detection
Because there may be very long key, such as space bar on tablet, we
should not use the distance between the touch point and the center of
key as proximity detection. Instead of that, this change uses the
distance between the point and the nearest edge of key as proximity
detection.
Also this change fixes the bug that space key (code 32) was not
counted in proximity detection.
Bug: 3164020
Bug: 3168138
Change-Id: I687f1ce94a8e944c3f6eea0fe00e18ed6e68e278
Diffstat (limited to '')
-rw-r--r-- | java/src/com/android/inputmethod/latin/PointerTracker.java | 14 |
1 files changed, 1 insertions, 13 deletions
diff --git a/java/src/com/android/inputmethod/latin/PointerTracker.java b/java/src/com/android/inputmethod/latin/PointerTracker.java index 78e00720a..2194ed91b 100644 --- a/java/src/com/android/inputmethod/latin/PointerTracker.java +++ b/java/src/com/android/inputmethod/latin/PointerTracker.java @@ -396,24 +396,12 @@ public class PointerTracker { if (newKey == curKey) { return true; } else if (isValidKeyIndex(curKey)) { - return getSquareDistanceToKeyEdge(x, y, mKeys[curKey]) < mKeyHysteresisDistanceSquared; + return mKeys[curKey].squaredDistanceToEdge(x, y) < mKeyHysteresisDistanceSquared; } else { return false; } } - private static int getSquareDistanceToKeyEdge(int x, int y, Key key) { - final int left = key.x; - final int right = key.x + key.width; - final int top = key.y; - final int bottom = key.y + key.height; - final int edgeX = x < left ? left : (x > right ? right : x); - final int edgeY = y < top ? top : (y > bottom ? bottom : y); - final int dx = x - edgeX; - final int dy = y - edgeY; - return dx * dx + dy * dy; - } - private void showKeyPreviewAndUpdateKeyGraphics(int keyIndex) { updateKeyGraphics(keyIndex); // The modifier key, such as shift key, should not be shown as preview when multi-touch is |