void GestureEventListener::HandleInputTimeoutLongTap() { GEL_LOG("Running long-tap timeout task in state %d\n", mState); mLongTapTimeoutTask = nullptr; switch (mState) { case GESTURE_FIRST_SINGLE_TOUCH_DOWN: // just in case MAX_TAP_TIME > ContextMenuDelay cancel MAX_TAP timer // and fall through CancelMaxTapTimeoutTask(); case GESTURE_FIRST_SINGLE_TOUCH_MAX_TAP_DOWN: { SetState(GESTURE_LONG_TOUCH_DOWN); TapGestureInput tapEvent(TapGestureInput::TAPGESTURE_LONG, mLastTouchInput.mTime, mLastTouchInput.mTimeStamp, mLastTouchInput.mTouches[0].mScreenPoint, mLastTouchInput.modifiers); mAsyncPanZoomController->HandleGestureEvent(tapEvent); break; } default: NS_WARNING("Unhandled state upon long tap timeout"); SetState(GESTURE_NONE); break; } }
nsEventStatus GestureEventListener::HandleInputEvent(const MultiTouchInput& aEvent) { GEL_LOG("Receiving event type %d with %" PRIuSIZE " touches in state %d\n", aEvent.mType, aEvent.mTouches.Length(), mState); nsEventStatus rv = nsEventStatus_eIgnore; // Cache the current event since it may become the single or long tap that we // send. mLastTouchInput = aEvent; switch (aEvent.mType) { case MultiTouchInput::MULTITOUCH_START: mTouches.Clear(); for (size_t i = 0; i < aEvent.mTouches.Length(); i++) { mTouches.AppendElement(aEvent.mTouches[i]); } if (aEvent.mTouches.Length() == 1) { rv = HandleInputTouchSingleStart(); } else { rv = HandleInputTouchMultiStart(); } break; case MultiTouchInput::MULTITOUCH_MOVE: for (size_t i = 0; i < aEvent.mTouches.Length(); i++) { for (size_t j = 0; j < mTouches.Length(); j++) { if (aEvent.mTouches[i].mIdentifier == mTouches[j].mIdentifier) { mTouches[j].mScreenPoint = aEvent.mTouches[i].mScreenPoint; } } } rv = HandleInputTouchMove(); break; case MultiTouchInput::MULTITOUCH_END: for (size_t i = 0; i < aEvent.mTouches.Length(); i++) { for (size_t j = 0; j < mTouches.Length(); j++) { if (aEvent.mTouches[i].mIdentifier == mTouches[j].mIdentifier) { mTouches.RemoveElementAt(j); break; } } } rv = HandleInputTouchEnd(); break; case MultiTouchInput::MULTITOUCH_CANCEL: mTouches.Clear(); rv = HandleInputTouchCancel(); break; } return rv; }
void GestureEventListener::HandleInputTimeoutMaxTap() { GEL_LOG("Running max-tap timeout task in state %d\n", mState); mMaxTapTimeoutTask = nullptr; if (mState == GESTURE_FIRST_SINGLE_TOUCH_DOWN) { SetState(GESTURE_FIRST_SINGLE_TOUCH_MAX_TAP_DOWN); } else if (mState == GESTURE_FIRST_SINGLE_TOUCH_UP || mState == GESTURE_SECOND_SINGLE_TOUCH_DOWN) { SetState(GESTURE_NONE); TriggerSingleTapConfirmedEvent(); } else { NS_WARNING("Unhandled state upon MAX_TAP timeout"); SetState(GESTURE_NONE); } }