From 8df43f8eae83e081ea54a6aa70c811e6eb4ce484 Mon Sep 17 00:00:00 2001 From: Dmitry Rozhkov Date: Sun, 22 Nov 2015 08:57:45 -0500 Subject: [PATCH] Bug 962243 - Implement PINCH to TOUCHING transition in APZC. r=botond --HG-- extra : commitid : FoHvf2KH9rd --- gfx/layers/apz/src/AsyncPanZoomController.cpp | 8 ++++++++ gfx/layers/apz/src/GestureEventListener.cpp | 15 ++++++++++++++- widget/InputData.h | 3 +++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index 67371bf0cb0f..21fd8006bccd 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -1548,6 +1548,14 @@ nsEventStatus AsyncPanZoomController::OnScaleEnd(const PinchGestureInput& aEvent UpdateSharedCompositorFrameMetrics(); } + // Non-negative focus point would indicate that one finger is still down + if (aEvent.mFocusPoint.x != -1 && aEvent.mFocusPoint.y != -1) { + mPanDirRestricted = false; + mX.StartTouch(aEvent.mFocusPoint.x, aEvent.mTime); + mY.StartTouch(aEvent.mFocusPoint.y, aEvent.mTime); + SetState(TOUCHING); + } + return nsEventStatus_eConsumeNoDefault; } diff --git a/gfx/layers/apz/src/GestureEventListener.cpp b/gfx/layers/apz/src/GestureEventListener.cpp index 9e4e5a6dd610..c310168b2ab6 100644 --- a/gfx/layers/apz/src/GestureEventListener.cpp +++ b/gfx/layers/apz/src/GestureEventListener.cpp @@ -101,6 +101,13 @@ nsEventStatus GestureEventListener::HandleInputEvent(const MultiTouchInput& aEve } 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: @@ -375,10 +382,16 @@ nsEventStatus GestureEventListener::HandleInputTouchEnd() case GESTURE_PINCH: if (mTouches.Length() < 2) { SetState(GESTURE_NONE); + ScreenPoint point(-1, -1); + if (mTouches.Length() == 1) { + // As user still keeps one finger down the event's focus point should + // contain meaningful data. + point = mTouches[0].mScreenPoint; + } PinchGestureInput pinchEvent(PinchGestureInput::PINCHGESTURE_END, mLastTouchInput.mTime, mLastTouchInput.mTimeStamp, - ScreenPoint(), + point, 1.0f, 1.0f, mLastTouchInput.modifiers); diff --git a/widget/InputData.h b/widget/InputData.h index 8125a77cc442..61d001aff11e 100644 --- a/widget/InputData.h +++ b/widget/InputData.h @@ -455,6 +455,9 @@ public: // point is implementation-specific, but can for example be the midpoint // between the very first and very last touch. This is in device pixels and // are the coordinates on the screen of this midpoint. + // For PINCHGESTURE_END events, this instead will hold the coordinates of + // the remaining finger, if there is one. If there isn't one then it will + // store -1, -1. ScreenPoint mFocusPoint; // |mFocusPoint| transformed to the local coordinates of the APZC targeted