diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
index b612f09..14da9eb 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardActionListener.java
@@ -80,6 +80,8 @@
      */
     public void onEndBatchInput(InputPointers batchPointers);
 
+    public void onCancelBatchInput();
+
     /**
      * Called when user released a finger outside any key.
      */
@@ -107,6 +109,8 @@
         @Override
         public void onEndBatchInput(InputPointers batchPointers) {}
         @Override
+        public void onCancelBatchInput() {}
+        @Override
         public void onCancelInput() {}
         @Override
         public boolean onCustomRequest(int requestCode) {
diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
index c868052..c8052af 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -305,8 +305,8 @@
     // true if keyboard layout has been changed.
     private boolean mKeyboardLayoutHasBeenChanged;
 
-    // true if event is already translated to a key action.
-    private boolean mKeyAlreadyProcessed;
+    // true if this pointer is no longer tracking touch event.
+    private boolean mIsTrackingCanceled;
 
     // true if this pointer has been long-pressed and is showing a more keys panel.
     private boolean mIsShowingMoreKeysPanel;
@@ -517,7 +517,7 @@
         mKeyboard = keyDetector.getKeyboard();
         final int keyWidth = mKeyboard.mMostCommonKeyWidth;
         final int keyHeight = mKeyboard.mMostCommonKeyHeight;
-        mGestureStrokeWithPreviewPoints.setKeyboardGeometry(keyWidth);
+        mGestureStrokeWithPreviewPoints.setKeyboardGeometry(keyWidth, mKeyboard.mOccupiedHeight);
         final Key newKey = mKeyDetector.detectHitKey(mKeyX, mKeyY);
         if (newKey != mCurrentKey) {
             if (mDrawingProxy != null) {
@@ -730,13 +730,15 @@
         synchronized (sAggregratedPointers) {
             mGestureStrokeWithPreviewPoints.appendAllBatchPoints(sAggregratedPointers);
             if (getActivePointerTrackerCount() == 1) {
-                if (DEBUG_LISTENER) {
-                    Log.d(TAG, String.format("[%d] onEndBatchInput   : batchPoints=%d",
-                            mPointerId, sAggregratedPointers.getPointerSize()));
-                }
                 sInGesture = false;
                 sTimeRecorder.onEndBatchInput(eventTime);
-                mListener.onEndBatchInput(sAggregratedPointers);
+                if (!mIsTrackingCanceled) {
+                    if (DEBUG_LISTENER) {
+                        Log.d(TAG, String.format("[%d] onEndBatchInput   : batchPoints=%d",
+                                mPointerId, sAggregratedPointers.getPointerSize()));
+                    }
+                    mListener.onEndBatchInput(sAggregratedPointers);
+                }
             }
         }
         mDrawingProxy.showGesturePreviewTrail(this, isOldestTrackerInQueue(this));
@@ -784,7 +786,7 @@
                 if (ProductionFlag.IS_EXPERIMENTAL) {
                     ResearchLogger.pointerTracker_onDownEvent(deltaT, distance * distance);
                 }
-                mKeyAlreadyProcessed = true;
+                cancelTracking();
                 return;
             }
         }
@@ -821,7 +823,7 @@
                 || (key != null && key.isModifier())
                 || mKeyDetector.alwaysAllowsSlidingInput();
         mKeyboardLayoutHasBeenChanged = false;
-        mKeyAlreadyProcessed = false;
+        mIsTrackingCanceled = false;
         resetSlidingKeyInput();
         if (key != null) {
             // This onPress call may have changed keyboard layout. Those cases are detected at
@@ -853,7 +855,17 @@
             final boolean isMajorEvent, final Key key) {
         final int gestureTime = (int)(eventTime - sGestureFirstDownTime);
         if (mIsDetectingGesture) {
-            mGestureStrokeWithPreviewPoints.addPoint(x, y, gestureTime, isMajorEvent);
+            final boolean onValidArea = mGestureStrokeWithPreviewPoints.addPointOnKeyboard(
+                    x, y, gestureTime, isMajorEvent);
+            if (!onValidArea) {
+                sPointerTrackerQueue.cancelAllPointerTracker();
+                if (DEBUG_LISTENER) {
+                    Log.d(TAG, String.format("[%d] onCancelBatchInput: batchPoints=%d",
+                            mPointerId, sAggregratedPointers.getPointerSize()));
+                }
+                mListener.onCancelBatchInput();
+                return;
+            }
             mayStartBatchInput(key);
             if (sInGesture) {
                 mayUpdateBatchInput(eventTime, key);
@@ -865,7 +877,7 @@
         if (DEBUG_MOVE_EVENT) {
             printTouchEvent("onMoveEvent:", x, y, eventTime);
         }
-        if (mKeyAlreadyProcessed) {
+        if (mIsTrackingCanceled) {
             return;
         }
 
@@ -979,11 +991,11 @@
                         + " detected sliding finger while multi touching", mPointerId));
             }
             onUpEvent(x, y, eventTime);
-            mKeyAlreadyProcessed = true;
+            cancelTracking();
             setReleasedKeyGraphics(oldKey);
         } else {
             if (!mIsDetectingGesture) {
-                mKeyAlreadyProcessed = true;
+                cancelTracking();
             }
             setReleasedKeyGraphics(oldKey);
         }
@@ -997,7 +1009,7 @@
             onMoveToNewKey(null, x, y);
         } else {
             if (!mIsDetectingGesture) {
-                mKeyAlreadyProcessed = true;
+                cancelTracking();
             }
         }
     }
@@ -1060,7 +1072,7 @@
             printTouchEvent("onPhntEvent:", getLastX(), getLastY(), eventTime);
         }
         onUpEventInternal(eventTime);
-        mKeyAlreadyProcessed = true;
+        cancelTracking();
     }
 
     private void onUpEventInternal(final long eventTime) {
@@ -1084,7 +1096,7 @@
             return;
         }
 
-        if (mKeyAlreadyProcessed) {
+        if (mIsTrackingCanceled) {
             return;
         }
         if (currentKey != null && !currentKey.isRepeatable()) {
@@ -1098,8 +1110,13 @@
         onDownEvent(x, y, SystemClock.uptimeMillis(), handler);
     }
 
+    @Override
+    public void cancelTracking() {
+        mIsTrackingCanceled = true;
+    }
+
     public void onLongPressed() {
-        mKeyAlreadyProcessed = true;
+        cancelTracking();
         setReleasedKeyGraphics(mCurrentKey);
         sPointerTrackerQueue.remove(this);
     }
@@ -1202,6 +1219,6 @@
         final Key key = mKeyDetector.detectHitKey(x, y);
         final String code = KeyDetector.printableCode(key);
         Log.d(TAG, String.format("[%d]%s%s %4d %4d %5d %s", mPointerId,
-                (mKeyAlreadyProcessed ? "-" : " "), title, x, y, eventTime, code));
+                (mIsTrackingCanceled ? "-" : " "), title, x, y, eventTime, code));
     }
 }
diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
index f8244dd..aab14e9 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStroke.java
@@ -27,6 +27,10 @@
     private static final boolean DEBUG = false;
     private static final boolean DEBUG_SPEED = false;
 
+    // The height of extra area above the keyboard to draw gesture trails.
+    // Proportional to the keyboard height.
+    public static final float EXTRA_GESTURE_TRAIL_AREA_ABOVE_KEYBOARD_RATIO = 0.25f;
+
     public static final int DEFAULT_CAPACITY = 128;
 
     private final int mPointerId;
@@ -37,6 +41,8 @@
     private final GestureStrokeParams mParams;
 
     private int mKeyWidth; // pixel
+    private int mMinYCoordinate; // pixel
+    private int mMaxYCoordinate; // pixel
     // Static threshold for starting gesture detection
     private int mDetectFastMoveSpeedThreshold; // pixel /sec
     private int mDetectFastMoveTime;
@@ -135,8 +141,10 @@
         mParams = params;
     }
 
-    public void setKeyboardGeometry(final int keyWidth) {
+    public void setKeyboardGeometry(final int keyWidth, final int keyboardHeight) {
         mKeyWidth = keyWidth;
+        mMinYCoordinate = -(int)(keyboardHeight * EXTRA_GESTURE_TRAIL_AREA_ABOVE_KEYBOARD_RATIO);
+        mMaxYCoordinate = keyboardHeight - 1;
         // TODO: Find an appropriate base metric for these length. Maybe diagonal length of the key?
         mDetectFastMoveSpeedThreshold = (int)(keyWidth * mParams.mDetectFastMoveSpeedThreshold);
         mGestureDynamicDistanceThresholdFrom =
@@ -167,7 +175,7 @@
                     elapsedTimeAfterTyping, mAfterFastTyping ? " afterFastTyping" : ""));
         }
         final int elapsedTimeFromFirstDown = (int)(downTime - gestureFirstDownTime);
-        addPoint(x, y, elapsedTimeFromFirstDown, true /* isMajorEvent */);
+        addPointOnKeyboard(x, y, elapsedTimeFromFirstDown, true /* isMajorEvent */);
     }
 
     private int getGestureDynamicDistanceThreshold(final int deltaTime) {
@@ -277,7 +285,17 @@
         return dist;
     }
 
-    public void addPoint(final int x, final int y, final int time, final boolean isMajorEvent) {
+    /**
+     * Add a touch event as a gesture point. Returns true if the touch event is on the valid
+     * gesture area.
+     * @param x the x-coordinate of the touch event
+     * @param y the y-coordinate of the touch event
+     * @param time the elapsed time in millisecond from the first gesture down
+     * @param isMajorEvent false if this is a historical move event
+     * @return true if the touch event is on the valid gesture area
+     */
+    public boolean addPointOnKeyboard(final int x, final int y, final int time,
+            final boolean isMajorEvent) {
         final int size = mEventTimes.getLength();
         if (size <= 0) {
             // Down event
@@ -293,6 +311,7 @@
             updateIncrementalRecognitionSize(x, y, time);
             updateMajorEvent(x, y, time);
         }
+        return y >= mMinYCoordinate && y < mMaxYCoordinate;
     }
 
     private void updateIncrementalRecognitionSize(final int x, final int y, final int time) {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java b/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java
index 8192c90..7ab7e9a 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/GestureStrokeWithPreviewPoints.java
@@ -56,8 +56,8 @@
     }
 
     @Override
-    public void setKeyboardGeometry(final int keyWidth) {
-        super.setKeyboardGeometry(keyWidth);
+    public void setKeyboardGeometry(final int keyWidth, final int keyboardHeight) {
+        super.setKeyboardGeometry(keyWidth, keyboardHeight);
         final float sampleLength = keyWidth * MIN_PREVIEW_SAMPLE_LENGTH_RATIO_TO_KEY_WIDTH;
         mMinPreviewSampleLengthSquare = (int)(sampleLength * sampleLength);
     }
@@ -69,8 +69,9 @@
     }
 
     @Override
-    public void addPoint(final int x, final int y, final int time, final boolean isMajorEvent) {
-        super.addPoint(x, y, time, isMajorEvent);
+    public boolean addPointOnKeyboard(final int x, final int y, final int time,
+            final boolean isMajorEvent) {
+        final boolean onValidArea = super.addPointOnKeyboard(x, y, time, isMajorEvent);
         if (isMajorEvent || needsSampling(x, y)) {
             mPreviewEventTimes.add(time);
             mPreviewXCoordinates.add(x);
@@ -78,6 +79,7 @@
             mLastX = x;
             mLastY = y;
         }
+        return onValidArea;
     }
 
     public void appendPreviewStroke(final ResizableIntArray eventTimes,
diff --git a/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java b/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java
index a52f202..00fc885 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueue.java
@@ -30,6 +30,7 @@
         public boolean isModifier();
         public boolean isInSlidingKeyInput();
         public void onPhantomUpEvent(long eventTime);
+        public void cancelTracking();
     }
 
     private static final int INITIAL_CAPACITY = 10;
@@ -182,6 +183,15 @@
         return false;
     }
 
+    public synchronized void cancelAllPointerTracker() {
+        final ArrayList<Element> expandableArray = mExpandableArrayOfActivePointers;
+        final int arraySize = mArraySize;
+        for (int index = 0; index < arraySize; index++) {
+            final Element element = expandableArray.get(index);
+            element.cancelTracking();
+        }
+    }
+
     @Override
     public synchronized String toString() {
         final StringBuilder sb = new StringBuilder();
diff --git a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java
index 776ac02..0d44ecd 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/PreviewPlacerView.java
@@ -40,10 +40,6 @@
 import com.android.inputmethod.latin.StaticInnerHandlerWrapper;
 
 public final class PreviewPlacerView extends RelativeLayout {
-    // The height of extra area above the keyboard to draw gesture trails.
-    // Proportional to the keyboard height.
-    private static final float EXTRA_GESTURE_TRAIL_AREA_ABOVE_KEYBOARD_RATIO = 0.25f;
-
     private final int mGestureFloatingPreviewTextColor;
     private final int mGestureFloatingPreviewTextOffset;
     private final int mGestureFloatingPreviewColor;
@@ -175,7 +171,7 @@
     public void setKeyboardViewGeometry(final int x, final int y, final int w, final int h) {
         mKeyboardViewOriginX = x;
         mKeyboardViewOriginY = y;
-        mOffscreenOffsetY = (int)(h * EXTRA_GESTURE_TRAIL_AREA_ABOVE_KEYBOARD_RATIO);
+        mOffscreenOffsetY = (int)(h * GestureStroke.EXTRA_GESTURE_TRAIL_AREA_ABOVE_KEYBOARD_RATIO);
         mOffscreenWidth = w;
         mOffscreenHeight = mOffscreenOffsetY + h;
     }
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index e3508ac..dc3ad4f 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1528,6 +1528,12 @@
                     .sendToTarget();
         }
 
+        public void onCancelBatchInput(final LatinIME latinIme) {
+            mInBatchInput = false;
+            latinIme.mHandler.showGesturePreviewAndSuggestionStrip(
+                    SuggestedWords.EMPTY, true /* dismissGestureFloatingPreviewText */);
+        }
+
         // Run in the UI thread.
         public synchronized SuggestedWords onEndBatchInput(final InputPointers batchPointers,
                 final LatinIME latinIme) {
@@ -1613,6 +1619,11 @@
         mKeyboardSwitcher.onCancelInput();
     }
 
+    @Override
+    public void onCancelBatchInput() {
+        BatchInputUpdater.getInstance().onCancelBatchInput(this);
+    }
+
     private void handleBackspace(final int spaceState) {
         // In many cases, we may have to put the keyboard in auto-shift state again. However
         // we want to wait a few milliseconds before doing it to avoid the keyboard flashing
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueueTests.java b/tests/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueueTests.java
index 8fed28f..2c3e3a5 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueueTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueueTests.java
@@ -49,6 +49,9 @@
         }
 
         @Override
+        public void cancelTracking() {}
+
+        @Override
         public String toString() {
             return Integer.toString(mId);
         }
