From 4f7d278af62a89ef3f45cc9ebbfb076a5a352c76 Mon Sep 17 00:00:00 2001
From: Ken Wakasa <kwakasa@google.com>
Date: Mon, 19 Dec 2011 17:58:36 +0900
Subject: [PATCH] Follow-up fix for I68c667b0

Should have preserved the logic of LatinKeyboard.getNearestKeys().

Change-Id: I97b05aa24006402be03088a215fa07abda9477df
---
 java/src/com/android/inputmethod/keyboard/Keyboard.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java
index 9f4b8811d1..d9d28f1863 100644
--- a/java/src/com/android/inputmethod/keyboard/Keyboard.java
+++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java
@@ -403,7 +403,10 @@ public class Keyboard {
      * point is out of range, then an array of size zero is returned.
      */
     public Key[] getNearestKeys(int x, int y) {
-        return mProximityInfo.getNearestKeys(x, y);
+        // Avoid dead pixels at edges of the keyboard
+        final int adjustedX = Math.max(0, Math.min(x, mOccupiedWidth - 1));
+        final int adjustedY = Math.max(0, Math.min(y, mOccupiedHeight - 1));
+        return mProximityInfo.getNearestKeys(adjustedX, adjustedY);
     }
 
     public static String printableCode(int code) {
-- 
GitLab