From 8134681b25dfff814ffeaad8ff70e84316c1869f Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Tue, 28 Jun 2011 20:08:48 -0700 Subject: Improve input event consistency invariants. Fixed some issues where inconsistent streams of events could be generated by the dispatcher, particularly when switching from hovering with one device to hovering with another. Fixed a bug where the touch pad would fail to generate a new HOVER_MOVE following a tap event. As a result, the hover event stream would not resume until the user touched the touch pad again. Change-Id: I444dce84641fb12e56a0af84c931520771d6c493 --- services/input/InputReader.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'services/input/InputReader.cpp') diff --git a/services/input/InputReader.cpp b/services/input/InputReader.cpp index 5a25f8cc9584..a16e7d7caa1e 100644 --- a/services/input/InputReader.cpp +++ b/services/input/InputReader.cpp @@ -3704,6 +3704,29 @@ void TouchInputMapper::dispatchPointerGestures(nsecs_t when, uint32_t policyFlag mPointerGesture.currentGestureCoords, mPointerGesture.currentGestureIdToIndex, mPointerGesture.currentGestureIdBits, -1, 0, 0, mPointerGesture.downTime); + } else if (dispatchedGestureIdBits.isEmpty() + && !mPointerGesture.lastGestureIdBits.isEmpty()) { + // Synthesize a hover move event after all pointers go up to indicate that + // the pointer is hovering again even if the user is not currently touching + // the touch pad. This ensures that a view will receive a fresh hover enter + // event after a tap. + float x, y; + mPointerController->getPosition(&x, &y); + + PointerProperties pointerProperties; + pointerProperties.clear(); + pointerProperties.id = 0; + pointerProperties.toolType = AMOTION_EVENT_TOOL_TYPE_INDIRECT_FINGER; + + PointerCoords pointerCoords; + pointerCoords.clear(); + pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_X, x); + pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_Y, y); + + getDispatcher()->notifyMotion(when, getDeviceId(), mPointerSource, policyFlags, + AMOTION_EVENT_ACTION_HOVER_MOVE, 0, + metaState, buttonState, AMOTION_EVENT_EDGE_FLAG_NONE, + 1, &pointerProperties, &pointerCoords, 0, 0, mPointerGesture.downTime); } // Update state. -- cgit v1.2.3-59-g8ed1b