Lines Matching refs:event

49  * transforms the motion event stream by modifying, adding, replacing,
133 // Command for delayed sending of a hover enter and move event.
136 // Command for delayed sending of a hover exit event.
185 // The X of the previous event.
188 // The Y of the previous event.
257 // If we have not received an event then we are in initial
259 MotionEvent event = mReceivedPointerTracker.getLastReceivedEvent();
260 if (event != null) {
269 private void clear(MotionEvent event, int policyFlags) {
278 sendUpForInjectedDownPointers(event, policyFlags);
282 sendUpForInjectedDownPointers(event, policyFlags);
320 public void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
322 Slog.d(LOG_TAG, "Received event: " + event + ", policyFlags=0x"
331 handleMotionEventStateTouchExploring(event, rawEvent, policyFlags);
334 handleMotionEventStateDragging(event, policyFlags);
337 handleMotionEventStateDelegating(event, policyFlags);
347 public void onAccessibilityEvent(AccessibilityEvent event) {
348 final int eventType = event.getEventType();
350 // The event for gesture end should be strictly after the
351 // last hover exit event.
358 // The event for touch interaction end should be strictly after the
379 mLastTouchedWindowId = event.getWindowId();
383 mNext.onAccessibilityEvent(event);
388 * Handles a motion event in touch exploring state.
390 * @param event The event to be handled.
391 * @param rawEvent The raw (unmodified) motion event.
392 * @param policyFlags The policy flags associated with the event.
394 private void handleMotionEventStateTouchExploring(MotionEvent event, MotionEvent rawEvent,
400 mDoubleTapDetector.onMotionEvent(event, policyFlags);
402 switch (event.getActionMasked()) {
436 mPerformLongPressDelayed.post(event, policyFlags);
445 mSendHoverEnterAndMoveDelayed.post(event, true, pointerIdBits,
448 // Cache the event until we discern exploration from gesturing.
449 mSendHoverEnterAndMoveDelayed.addEvent(event);
463 final int pointerIndex = event.findPointerIndex(pointerId);
465 switch (event.getPointerCount()) {
476 // Cache the event until we discern exploration from gesturing.
477 mSendHoverEnterAndMoveDelayed.addEvent(event);
504 // Send accessibility event to announce the start
514 sendMotionEvent(event, MotionEvent.ACTION_HOVER_MOVE,
537 sendMotionEvent(event, MotionEvent.ACTION_HOVER_MOVE, pointerIdBits,
578 if (isDraggingGesture(event)) {
583 event.setEdgeFlags(receivedTracker.getLastReceivedDownEdgeFlags());
584 sendMotionEvent(event, MotionEvent.ACTION_DOWN, pointerIdBits,
589 sendDownForAllNotInjectedPointers(event, policyFlags);
611 sendDownForAllNotInjectedPointers(event, policyFlags);
621 final int pointerId = event.getPointerId(event.getActionIndex());
629 mSendHoverExitDelayed.post(event, pointerIdBits, policyFlags);
641 clear(event, policyFlags);
647 * Handles a motion event in dragging state.
649 * @param event The event to be handled.
650 * @param policyFlags The policy flags associated with the event.
652 private void handleMotionEventStateDragging(MotionEvent event, int policyFlags) {
654 switch (event.getActionMasked()) {
664 sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits, policyFlags);
666 sendDownForAllNotInjectedPointers(event, policyFlags);
669 switch (event.getPointerCount()) {
674 if (isDraggingGesture(event)) {
675 final float firstPtrX = event.getX(0);
676 final float firstPtrY = event.getY(0);
677 final float secondPtrX = event.getX(1);
678 final float secondPtrY = event.getY(1);
685 event.setLocation(deltaX / 2, deltaY / 2);
688 // If still dragging send a drag event.
689 sendMotionEvent(event, MotionEvent.ACTION_MOVE, pointerIdBits,
695 // Send an event to the end of the drag gesture.
696 sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits,
699 sendDownForAllNotInjectedPointers(event, policyFlags);
704 // Send an event to the end of the drag gesture.
705 sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits,
708 sendDownForAllNotInjectedPointers(event, policyFlags);
713 final int pointerId = event.getPointerId(event.getActionIndex());
716 // Send an event to the end of the drag gesture.
717 sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits, policyFlags);
725 final int pointerId = event.getPointerId(event.getActionIndex());
728 // Send an event to the end of the drag gesture.
729 sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits, policyFlags);
734 clear(event, policyFlags);
740 * Handles a motion event in delegating state.
742 * @param event The event to be handled.
743 * @param policyFlags The policy flags associated with the event.
745 private void handleMotionEventStateDelegating(MotionEvent event, int policyFlags) {
746 switch (event.getActionMasked()) {
752 // Offset the event if we are doing a long press as the
755 event = offsetEvent(event, - mLongPressingPointerDeltaX,
763 // Deliver the event.
764 sendMotionEvent(event, event.getAction(), ALL_POINTER_ID_BITS, policyFlags);
773 clear(event, policyFlags);
776 // Deliver the event.
777 sendMotionEvent(event, event.getAction(), ALL_POINTER_ID_BITS, policyFlags);
782 private void handleMotionEventGestureDetecting(MotionEvent event, int policyFlags) {
783 switch (event.getActionMasked()) {
785 final float x = event.getX();
786 final float y = event.getY();
789 mStrokeBuffer.add(new GesturePoint(x, y, event.getEventTime()));
792 final float x = event.getX();
793 final float y = event.getY();
799 mStrokeBuffer.add(new GesturePoint(x, y, event.getEventTime()));
809 float x = event.getX();
810 float y = event.getY();
811 mStrokeBuffer.add(new GesturePoint(x, y, event.getEventTime()));
838 clear(event, policyFlags);
844 * Sends an accessibility event of the given type.
846 * @param type The event type.
851 AccessibilityEvent event = AccessibilityEvent.obtain(type);
852 event.setWindowId(mAms.getActiveWindowId());
853 accessibilityManager.sendAccessibilityEvent(event);
870 * @param policyFlags The policy flags associated with the event.
880 // Do not send event for already delivered pointers.
893 * @param policyFlags The policy flags associated with the event.
896 MotionEvent event = mInjectedPointerTracker.getLastInjectedHoverEvent();
897 if (event != null && event.getActionMasked() != MotionEvent.ACTION_HOVER_EXIT) {
898 final int pointerIdBits = event.getPointerIdBits();
902 sendMotionEvent(event, MotionEvent.ACTION_HOVER_EXIT, pointerIdBits, policyFlags);
910 * @param policyFlags The policy flags associated with the event.
913 MotionEvent event = mInjectedPointerTracker.getLastInjectedHoverEvent();
914 if (event != null && event.getActionMasked() == MotionEvent.ACTION_HOVER_EXIT) {
915 final int pointerIdBits = event.getPointerIdBits();
917 sendMotionEvent(event, MotionEvent.ACTION_HOVER_ENTER, pointerIdBits, policyFlags);
926 * @param policyFlags The policy flags associated with the event.
948 * @param policyFlags The policy flags associated with the event.
949 * @param targetAccessibilityFocus Whether the event targets the accessibility focus.
963 * Sends an event.
966 * @param action The action of the event.
968 * @param policyFlags The policy flags associated with the event.
974 MotionEvent event = null;
976 event = prototype;
978 event = prototype.split(pointerIdBits);
981 event.setDownTime(event.getEventTime());
983 event.setDownTime(mInjectedPointerTracker.getLastInjectedDownEventTime());
993 event = offsetEvent(event, - mLongPressingPointerDeltaX,
998 Slog.d(LOG_TAG, "Injecting event: " + event + ", policyFlags=0x"
1002 // Make sure that the user will see the event.
1005 // TODO: For now pass null for the raw event since the touch
1006 // explorer is the last event transformation and it does
1007 // not care about the raw event.
1008 mNext.onMotionEvent(event, null, policyFlags);
1011 mInjectedPointerTracker.onMotionEvent(event);
1013 if (event != prototype) {
1014 event.recycle();
1019 * Offsets all pointers in the given event by adding the specified X and Y
1022 * @param event The event to offset.
1025 * @return An event with the offset pointers or the original event if both
1028 private MotionEvent offsetEvent(MotionEvent event, int offsetX, int offsetY) {
1030 return event;
1032 final int remappedIndex = event.findPointerIndex(mLongPressingPointerId);
1033 final int pointerCount = event.getPointerCount();
1037 event.getPointerProperties(i, props[i]);
1038 event.getPointerCoords(i, coords[i]);
1044 return MotionEvent.obtain(event.getDownTime(),
1045 event.getEventTime(), event.getAction(), event.getPointerCount(),
1046 props, coords, event.getMetaState(), event.getButtonState(),
1047 1.0f, 1.0f, event.getDeviceId(), event.getEdgeFlags(),
1048 event.getSource(), event.getFlags());
1052 * Computes the action for an injected event based on a masked action
1091 public void onMotionEvent(MotionEvent event, int policyFlags) {
1092 final int actionIndex = event.getActionIndex();
1093 final int action = event.getActionMasked();
1098 && !GestureUtils.isSamePointerContext(mFirstTapEvent, event)) {
1101 mDownEvent = MotionEvent.obtain(event);
1108 if (!GestureUtils.isSamePointerContext(mDownEvent, event)) {
1112 if (GestureUtils.isTap(mDownEvent, event, mTapTimeout, mTouchSlop,
1115 event, mDoubleTapTimeout)) {
1116 mFirstTapEvent = MotionEvent.obtain(event);
1121 if (GestureUtils.isMultiTap(mFirstTapEvent, event, mDoubleTapTimeout,
1123 onDoubleTap(event, policyFlags);
1150 // Remove pending event deliveries.
1179 MotionEvent event = MotionEvent.obtain(secondTapUp.getDownTime(),
1184 sendActionDownAndUp(event, policyFlags, targetAccessibilityFocus);
1185 event.recycle();
1208 * @param event The event with the pointer data.
1211 private boolean isDraggingGesture(MotionEvent event) {
1214 final float firstPtrX = event.getX(0);
1215 final float firstPtrY = event.getY(0);
1216 final float secondPtrX = event.getX(1);
1217 final float secondPtrY = event.getY(1);
1365 public void post(MotionEvent event, boolean touchExplorationInProgress,
1368 addEvent(event);
1374 public void addEvent(MotionEvent event) {
1375 mEvents.add(MotionEvent.obtain(event));
1406 // Send an accessibility event to announce the touch exploration start.
1410 // Deliver a down event.
1415 "Injecting motion event: ACTION_HOVER_ENTER");
1425 "Injecting motion event: ACTION_HOVER_MOVE");
1478 Slog.d(LOG_TAG_SEND_HOVER_DELAYED, "Injecting motion event:"
1543 // The last injected hover event.
1546 // The last injected hover event used for performing clicks.
1550 * Processes an injected {@link MotionEvent} event.
1552 * @param event The event to process.
1554 public void onMotionEvent(MotionEvent event) {
1555 final int action = event.getActionMasked();
1559 final int pointerId = event.getPointerId(event.getActionIndex());
1562 mLastInjectedDownEventTime = event.getDownTime();
1566 final int pointerId = event.getPointerId(event.getActionIndex());
1579 mLastInjectedHoverEvent = MotionEvent.obtain(event);
1583 mLastInjectedHoverEventForClick = MotionEvent.obtain(event);
1599 * @return The time of the last injected down event.
1631 * @return The the last injected hover event.
1638 * @return The the last injected hover event.
1674 // The edge flags of the last received down event.
1703 * Processes a received {@link MotionEvent} event.
1705 * @param event The event to process.
1707 public void onMotionEvent(MotionEvent event) {
1711 mLastReceivedEvent = MotionEvent.obtain(event);
1713 final int action = event.getActionMasked();
1716 handleReceivedPointerDown(event.getActionIndex(), event);
1719 handleReceivedPointerDown(event.getActionIndex(), event);
1722 handleReceivedPointerUp(event.getActionIndex(), event);
1725 handleReceivedPointerUp(event.getActionIndex(), event);
1734 * @return The last received event.
1814 * @return The edge flags of the last received down event.
1821 * Handles a received pointer down event.
1824 * @param event The event to be handled.
1826 private void handleReceivedPointerDown(int pointerIndex, MotionEvent event) {
1827 final int pointerId = event.getPointerId(pointerIndex);
1834 mLastReceivedDownEdgeFlags = event.getEdgeFlags();
1837 mReceivedPointerDownX[pointerId] = event.getX(pointerIndex);
1838 mReceivedPointerDownY[pointerId] = event.getY(pointerIndex);
1839 mReceivedPointerDownTime[pointerId] = event.getEventTime();
1845 * Handles a received pointer up event.
1848 * @param event The event to be handled.
1850 private void handleReceivedPointerUp(int pointerIndex, MotionEvent event) {
1851 final int pointerId = event.getPointerId(pointerIndex);