Lines Matching refs:event

40  * transforms the motion event stream by modifying, adding, replacing,
112 // Command for delayed sending of a hover enter and move event.
115 // Command for delayed sending of a hover exit event.
212 // If we have not received an event then we are in initial
214 MotionEvent event = mReceivedPointerTracker.getLastReceivedEvent();
215 if (event != null) {
220 private void clear(MotionEvent event, int policyFlags) {
229 sendUpForInjectedDownPointers(event, policyFlags);
233 sendUpForInjectedDownPointers(event, policyFlags);
266 public void onMotionEvent(MotionEvent event, MotionEvent rawEvent, int policyFlags) {
267 if (!event.isFromSource(InputDevice.SOURCE_TOUCHSCREEN)) {
269 mNext.onMotionEvent(event, rawEvent, policyFlags);
275 Slog.d(LOG_TAG, "Received event: " + event + ", policyFlags=0x"
290 if (event.getActionMasked() == MotionEvent.ACTION_CANCEL) {
291 clear(event, policyFlags);
297 handleMotionEventStateTouchExploring(event, rawEvent, policyFlags);
300 handleMotionEventStateDragging(event, policyFlags);
303 handleMotionEventStateDelegating(event, policyFlags);
314 public void onKeyEvent(KeyEvent event, int policyFlags) {
316 mNext.onKeyEvent(event, policyFlags);
321 public void onAccessibilityEvent(AccessibilityEvent event) {
322 final int eventType = event.getEventType();
324 // The event for gesture end should be strictly after the
325 // last hover exit event.
332 // The event for touch interaction end should be strictly after the
353 mLastTouchedWindowId = event.getWindowId();
357 mNext.onAccessibilityEvent(event);
362 public void onDoubleTapAndHold(MotionEvent event, int policyFlags) {
363 // Ignore the event if we aren't touch exploring.
373 final int pointerIndex = event.getActionIndex();
374 final int pointerId = event.getPointerId(pointerIndex);
384 mLongPressingPointerDeltaX = (int) event.getX(pointerIndex) - clickLocation.x;
385 mLongPressingPointerDeltaY = (int) event.getY(pointerIndex) - clickLocation.y;
390 sendDownForAllNotInjectedPointers(event, policyFlags);
394 public boolean onDoubleTap(MotionEvent event, int policyFlags) {
395 // Ignore the event if we aren't touch exploring.
400 // Remove pending event deliveries.
418 final int pointerIndex = event.getActionIndex();
419 final int pointerId = event.getPointerId(pointerIndex);
432 event.getPointerProperties(pointerIndex, properties[0]);
437 MotionEvent click_event = MotionEvent.obtain(event.getDownTime(),
438 event.getEventTime(), MotionEvent.ACTION_DOWN, 1, properties,
439 coords, 0, 0, 1.0f, 1.0f, event.getDeviceId(), 0,
440 event.getSource(), event.getFlags());
455 // Send accessibility event to announce the start
475 public boolean onGestureCancelled(MotionEvent event, int policyFlags) {
480 // If the finger is still moving, pass the event on.
481 if (event.getActionMasked() == MotionEvent.ACTION_MOVE) {
487 mSendHoverEnterAndMoveDelayed.addEvent(event);
490 sendMotionEvent(event, MotionEvent.ACTION_HOVER_MOVE, pointerIdBits, policyFlags);
498 * Handles a motion event in touch exploring state.
500 * @param event The event to be handled.
501 * @param rawEvent The raw (unmodified) motion event.
502 * @param policyFlags The policy flags associated with the event.
504 private void handleMotionEventStateTouchExploring(MotionEvent event, MotionEvent rawEvent,
508 switch (event.getActionMasked()) {
534 mSendHoverEnterAndMoveDelayed.post(event, true, pointerIdBits,
537 // Cache the event until we discern exploration from gesturing.
538 mSendHoverEnterAndMoveDelayed.addEvent(event);
551 final int pointerIndex = event.findPointerIndex(pointerId);
553 switch (event.getPointerCount()) {
558 // Cache the event until we discern exploration from gesturing.
559 mSendHoverEnterAndMoveDelayed.addEvent(event);
563 sendMotionEvent(event, MotionEvent.ACTION_HOVER_MOVE, pointerIdBits,
597 if (isDraggingGesture(event)) {
602 event.setEdgeFlags(receivedTracker.getLastReceivedDownEdgeFlags());
603 sendMotionEvent(event, MotionEvent.ACTION_DOWN, pointerIdBits,
608 sendDownForAllNotInjectedPointers(event, policyFlags);
627 sendDownForAllNotInjectedPointers(event, policyFlags);
633 final int pointerId = event.getPointerId(event.getActionIndex());
638 mSendHoverExitDelayed.post(event, pointerIdBits, policyFlags);
653 * Handles a motion event in dragging state.
655 * @param event The event to be handled.
656 * @param policyFlags The policy flags associated with the event.
658 private void handleMotionEventStateDragging(MotionEvent event, int policyFlags) {
661 if (event.findPointerIndex(mDraggingPointerId) == -1) {
662 Slog.e(LOG_TAG, "mDraggingPointerId doesn't match any pointers on current event. " +
664 ", Event: " + event);
669 switch (event.getActionMasked()) {
679 sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits, policyFlags);
681 sendDownForAllNotInjectedPointers(event, policyFlags);
687 switch (event.getPointerCount()) {
692 if (isDraggingGesture(event)) {
693 final float firstPtrX = event.getX(0);
694 final float firstPtrY = event.getY(0);
695 final float secondPtrX = event.getX(1);
696 final float secondPtrY = event.getY(1);
703 event.setLocation(deltaX / 2, deltaY / 2);
706 // If still dragging send a drag event.
707 sendMotionEvent(event, MotionEvent.ACTION_MOVE, pointerIdBits,
713 // Send an event to the end of the drag gesture.
714 sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits,
717 sendDownForAllNotInjectedPointers(event, policyFlags);
722 // Send an event to the end of the drag gesture.
723 sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits,
726 sendDownForAllNotInjectedPointers(event, policyFlags);
731 final int pointerId = event.getPointerId(event.getActionIndex());
734 // Send an event to the end of the drag gesture.
735 sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits, policyFlags);
743 final int pointerId = event.getPointerId(event.getActionIndex());
746 // Send an event to the end of the drag gesture.
747 sendMotionEvent(event, MotionEvent.ACTION_UP, pointerIdBits, policyFlags);
755 * Handles a motion event in delegating state.
757 * @param event The event to be handled.
758 * @param policyFlags The policy flags associated with the event.
760 private void handleMotionEventStateDelegating(MotionEvent event, int policyFlags) {
761 switch (event.getActionMasked()) {
767 // Offset the event if we are doing a long press as the
770 event = offsetEvent(event, - mLongPressingPointerDeltaX,
778 // Deliver the event.
779 sendMotionEvent(event, event.getAction(), ALL_POINTER_ID_BITS, policyFlags);
788 // Deliver the event.
789 sendMotionEvent(event, event.getAction(), ALL_POINTER_ID_BITS, policyFlags);
807 * Sends an accessibility event of the given type.
809 * @param type The event type.
814 AccessibilityEvent event = AccessibilityEvent.obtain(type);
815 event.setWindowId(mAms.getActiveWindowId());
816 accessibilityManager.sendAccessibilityEvent(event);
833 * @param policyFlags The policy flags associated with the event.
843 // Do not send event for already delivered pointers.
856 * @param policyFlags The policy flags associated with the event.
859 MotionEvent event = mInjectedPointerTracker.getLastInjectedHoverEvent();
860 if (event != null && event.getActionMasked() != MotionEvent.ACTION_HOVER_EXIT) {
861 final int pointerIdBits = event.getPointerIdBits();
865 sendMotionEvent(event, MotionEvent.ACTION_HOVER_EXIT, pointerIdBits, policyFlags);
873 * @param policyFlags The policy flags associated with the event.
876 MotionEvent event = mInjectedPointerTracker.getLastInjectedHoverEvent();
877 if (event != null && event.getActionMasked() == MotionEvent.ACTION_HOVER_EXIT) {
878 final int pointerIdBits = event.getPointerIdBits();
880 sendMotionEvent(event, MotionEvent.ACTION_HOVER_ENTER, pointerIdBits, policyFlags);
889 * @param policyFlags The policy flags associated with the event.
911 * @param policyFlags The policy flags associated with the event.
912 * @param targetAccessibilityFocus Whether the event targets the accessibility focus.
926 * Sends an event.
929 * @param action The action of the event.
931 * @param policyFlags The policy flags associated with the event.
937 MotionEvent event = null;
939 event = prototype;
942 event = prototype.split(pointerIdBits);
944 Slog.e(LOG_TAG, "sendMotionEvent: Failed to split motion event: " + e);
949 event.setDownTime(event.getEventTime());
951 event.setDownTime(mInjectedPointerTracker.getLastInjectedDownEventTime());
961 event = offsetEvent(event, - mLongPressingPointerDeltaX,
966 Slog.d(LOG_TAG, "Injecting event: " + event + ", policyFlags=0x"
970 // Make sure that the user will see the event.
973 // TODO: For now pass null for the raw event since the touch
974 // explorer is the last event transformation and it does
975 // not care about the raw event.
976 mNext.onMotionEvent(event, null, policyFlags);
979 mInjectedPointerTracker.onMotionEvent(event);
981 if (event != prototype) {
982 event.recycle();
987 * Offsets all pointers in the given event by adding the specified X and Y
990 * @param event The event to offset.
993 * @return An event with the offset pointers or the original event if both
996 private MotionEvent offsetEvent(MotionEvent event, int offsetX, int offsetY) {
998 return event;
1000 final int remappedIndex = event.findPointerIndex(mLongPressingPointerId);
1001 final int pointerCount = event.getPointerCount();
1005 event.getPointerProperties(i, props[i]);
1006 event.getPointerCoords(i, coords[i]);
1012 return MotionEvent.obtain(event.getDownTime(),
1013 event.getEventTime(), event.getAction(), event.getPointerCount(),
1014 props, coords, event.getMetaState(), event.getButtonState(),
1015 1.0f, 1.0f, event.getDeviceId(), event.getEdgeFlags(),
1016 event.getSource(), event.getFlags());
1020 * Computes the action for an injected event based on a masked action
1058 * @param event The event with the pointer data.
1061 private boolean isDraggingGesture(MotionEvent event) {
1064 final float firstPtrX = event.getX(0);
1065 final float firstPtrY = event.getY(0);
1066 final float secondPtrX = event.getX(1);
1067 final float secondPtrY = event.getY(1);
1156 public void post(MotionEvent event, boolean touchExplorationInProgress,
1159 addEvent(event);
1165 public void addEvent(MotionEvent event) {
1166 mEvents.add(MotionEvent.obtain(event));
1197 // Send an accessibility event to announce the touch exploration start.
1201 // Deliver a down event.
1206 "Injecting motion event: ACTION_HOVER_ENTER");
1216 "Injecting motion event: ACTION_HOVER_MOVE");
1269 Slog.d(LOG_TAG_SEND_HOVER_DELAYED, "Injecting motion event:"
1334 // The last injected hover event.
1337 // The last injected hover event used for performing clicks.
1341 * Processes an injected {@link MotionEvent} event.
1343 * @param event The event to process.
1345 public void onMotionEvent(MotionEvent event) {
1346 final int action = event.getActionMasked();
1350 final int pointerId = event.getPointerId(event.getActionIndex());
1353 mLastInjectedDownEventTime = event.getDownTime();
1357 final int pointerId = event.getPointerId(event.getActionIndex());
1370 mLastInjectedHoverEvent = MotionEvent.obtain(event);
1374 mLastInjectedHoverEventForClick = MotionEvent.obtain(event);
1390 * @return The time of the last injected down event.
1422 * @return The the last injected hover event.
1429 * @return The the last injected hover event.
1465 // The edge flags of the last received down event.
1494 * Processes a received {@link MotionEvent} event.
1496 * @param event The event to process.
1498 public void onMotionEvent(MotionEvent event) {
1502 mLastReceivedEvent = MotionEvent.obtain(event);
1504 final int action = event.getActionMasked();
1507 handleReceivedPointerDown(event.getActionIndex(), event);
1510 handleReceivedPointerDown(event.getActionIndex(), event);
1513 handleReceivedPointerUp(event.getActionIndex(), event);
1516 handleReceivedPointerUp(event.getActionIndex(), event);
1525 * @return The last received event.
1605 * @return The edge flags of the last received down event.
1612 * Handles a received pointer down event.
1615 * @param event The event to be handled.
1617 private void handleReceivedPointerDown(int pointerIndex, MotionEvent event) {
1618 final int pointerId = event.getPointerId(pointerIndex);
1625 mLastReceivedDownEdgeFlags = event.getEdgeFlags();
1628 mReceivedPointerDownX[pointerId] = event.getX(pointerIndex);
1629 mReceivedPointerDownY[pointerId] = event.getY(pointerIndex);
1630 mReceivedPointerDownTime[pointerId] = event.getEventTime();
1636 * Handles a received pointer up event.
1639 * @param event The event to be handled.
1641 private void handleReceivedPointerUp(int pointerIndex, MotionEvent event) {
1642 final int pointerId = event.getPointerId(pointerIndex);