diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index f6776035b536..593f3d2bf270 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -2250,6 +2250,7 @@ void APZCTreeManager::SynthesizePinchGestureFromMouseWheel( TargetConfirmationFlags confFlags{true}; PinchGestureInput pinchStart{PinchGestureInput::PINCHGESTURE_START, + PinchGestureInput::MOUSEWHEEL, aWheelInput.mTime, aWheelInput.mTimeStamp, ExternalPoint(0, 0), @@ -2258,6 +2259,7 @@ void APZCTreeManager::SynthesizePinchGestureFromMouseWheel( oldSpan, aWheelInput.modifiers}; PinchGestureInput pinchScale1{PinchGestureInput::PINCHGESTURE_SCALE, + PinchGestureInput::MOUSEWHEEL, aWheelInput.mTime, aWheelInput.mTimeStamp, ExternalPoint(0, 0), @@ -2266,6 +2268,7 @@ void APZCTreeManager::SynthesizePinchGestureFromMouseWheel( oldSpan, aWheelInput.modifiers}; PinchGestureInput pinchScale2{PinchGestureInput::PINCHGESTURE_SCALE, + PinchGestureInput::MOUSEWHEEL, aWheelInput.mTime, aWheelInput.mTimeStamp, ExternalPoint(0, 0), @@ -2274,6 +2277,7 @@ void APZCTreeManager::SynthesizePinchGestureFromMouseWheel( newSpan, aWheelInput.modifiers}; PinchGestureInput pinchEnd{PinchGestureInput::PINCHGESTURE_END, + PinchGestureInput::MOUSEWHEEL, aWheelInput.mTime, aWheelInput.mTimeStamp, ExternalPoint(0, 0), diff --git a/gfx/layers/apz/src/GestureEventListener.cpp b/gfx/layers/apz/src/GestureEventListener.cpp index 6349eafc98b5..bd761d2927b1 100644 --- a/gfx/layers/apz/src/GestureEventListener.cpp +++ b/gfx/layers/apz/src/GestureEventListener.cpp @@ -322,9 +322,10 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() { mOneTouchPinchStartPosition = mLastTouchInput.mTouches[0].mScreenPoint; PinchGestureInput pinchEvent( - PinchGestureInput::PINCHGESTURE_START, mLastTouchInput.mTime, - mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, - currentFocus, currentSpan, currentSpan, mLastTouchInput.modifiers); + PinchGestureInput::PINCHGESTURE_START, PinchGestureInput::ONE_TOUCH, + mLastTouchInput.mTime, mLastTouchInput.mTimeStamp, + mLastTouchInput.mScreenOffset, currentFocus, currentSpan, + currentSpan, mLastTouchInput.modifiers); rv = mAsyncPanZoomController->HandleGestureEvent(pinchEvent); @@ -351,9 +352,10 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() { mFocusChange > PINCH_START_THRESHOLD) { SetState(GESTURE_PINCH); PinchGestureInput pinchEvent( - PinchGestureInput::PINCHGESTURE_START, mLastTouchInput.mTime, - mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, - currentFocus, currentSpan, currentSpan, mLastTouchInput.modifiers); + PinchGestureInput::PINCHGESTURE_START, PinchGestureInput::TOUCH, + mLastTouchInput.mTime, mLastTouchInput.mTimeStamp, + mLastTouchInput.mScreenOffset, currentFocus, currentSpan, + currentSpan, mLastTouchInput.modifiers); rv = mAsyncPanZoomController->HandleGestureEvent(pinchEvent); } else { @@ -379,10 +381,10 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() { ScreenCoord currentSpan = GetCurrentSpan(mLastTouchInput); PinchGestureInput pinchEvent( - PinchGestureInput::PINCHGESTURE_SCALE, mLastTouchInput.mTime, - mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, - GetCurrentFocus(mLastTouchInput), currentSpan, mPreviousSpan, - mLastTouchInput.modifiers); + PinchGestureInput::PINCHGESTURE_SCALE, PinchGestureInput::TOUCH, + mLastTouchInput.mTime, mLastTouchInput.mTimeStamp, + mLastTouchInput.mScreenOffset, GetCurrentFocus(mLastTouchInput), + currentSpan, mPreviousSpan, mLastTouchInput.modifiers); rv = mAsyncPanZoomController->HandleGestureEvent(pinchEvent); mPreviousSpan = currentSpan; @@ -402,10 +404,10 @@ nsEventStatus GestureEventListener::HandleInputTouchMove() { } PinchGestureInput pinchEvent( - PinchGestureInput::PINCHGESTURE_SCALE, mLastTouchInput.mTime, - mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, - currentFocus, effectiveSpan, mPreviousSpan, - mLastTouchInput.modifiers); + PinchGestureInput::PINCHGESTURE_SCALE, PinchGestureInput::ONE_TOUCH, + mLastTouchInput.mTime, mLastTouchInput.mTimeStamp, + mLastTouchInput.mScreenOffset, currentFocus, effectiveSpan, + mPreviousSpan, mLastTouchInput.modifiers); rv = mAsyncPanZoomController->HandleGestureEvent(pinchEvent); mPreviousSpan = effectiveSpan; @@ -489,10 +491,10 @@ nsEventStatus GestureEventListener::HandleInputTouchEnd() { type = PinchGestureInput::PINCHGESTURE_FINGERLIFTED; point = mTouches[0].mScreenPoint; } - PinchGestureInput pinchEvent(type, mLastTouchInput.mTime, - mLastTouchInput.mTimeStamp, - mLastTouchInput.mScreenOffset, point, 1.0f, - 1.0f, mLastTouchInput.modifiers); + PinchGestureInput pinchEvent( + type, PinchGestureInput::TOUCH, mLastTouchInput.mTime, + mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, point, + 1.0f, 1.0f, mLastTouchInput.modifiers); mAsyncPanZoomController->HandleGestureEvent(pinchEvent); } @@ -503,9 +505,10 @@ nsEventStatus GestureEventListener::HandleInputTouchEnd() { case GESTURE_ONE_TOUCH_PINCH: { SetState(GESTURE_NONE); PinchGestureInput pinchEvent( - PinchGestureInput::PINCHGESTURE_END, mLastTouchInput.mTime, - mLastTouchInput.mTimeStamp, mLastTouchInput.mScreenOffset, - ScreenPoint(), 1.0f, 1.0f, mLastTouchInput.modifiers); + PinchGestureInput::PINCHGESTURE_END, PinchGestureInput::ONE_TOUCH, + mLastTouchInput.mTime, mLastTouchInput.mTimeStamp, + mLastTouchInput.mScreenOffset, ScreenPoint(), 1.0f, 1.0f, + mLastTouchInput.modifiers); mAsyncPanZoomController->HandleGestureEvent(pinchEvent); rv = nsEventStatus_eConsumeNoDefault; diff --git a/gfx/layers/apz/test/gtest/APZTestCommon.h b/gfx/layers/apz/test/gtest/APZTestCommon.h index dd1ccf1aa500..c74bc6abbd6e 100644 --- a/gfx/layers/apz/test/gtest/APZTestCommon.h +++ b/gfx/layers/apz/test/gtest/APZTestCommon.h @@ -76,9 +76,9 @@ inline PinchGestureInput CreatePinchGestureInput( PinchGestureInput::PinchGestureType aType, const ScreenPoint& aFocus, float aCurrentSpan, float aPreviousSpan, TimeStamp timestamp) { ParentLayerPoint localFocus(aFocus.x, aFocus.y); - PinchGestureInput result(aType, MillisecondsSinceStartup(timestamp), - timestamp, ExternalPoint(0, 0), aFocus, aCurrentSpan, - aPreviousSpan, 0); + PinchGestureInput result( + aType, PinchGestureInput::UNKNOWN, MillisecondsSinceStartup(timestamp), + timestamp, ExternalPoint(0, 0), aFocus, aCurrentSpan, aPreviousSpan, 0); return result; } diff --git a/widget/InputData.cpp b/widget/InputData.cpp index b915238580d0..98a873e956cd 100644 --- a/widget/InputData.cpp +++ b/widget/InputData.cpp @@ -538,14 +538,17 @@ ParentLayerPoint PanGestureInput::UserMultipliedLocalPanDisplacement() const { PinchGestureInput::PinchGestureInput() : InputData(PINCHGESTURE_INPUT), mType(PINCHGESTURE_START), + mSource(UNKNOWN), mHandledByAPZ(false) {} PinchGestureInput::PinchGestureInput( - PinchGestureType aType, uint32_t aTime, TimeStamp aTimeStamp, - const ExternalPoint& aScreenOffset, const ScreenPoint& aFocusPoint, - ScreenCoord aCurrentSpan, ScreenCoord aPreviousSpan, Modifiers aModifiers) + PinchGestureType aType, PinchGestureSource aSource, uint32_t aTime, + TimeStamp aTimeStamp, const ExternalPoint& aScreenOffset, + const ScreenPoint& aFocusPoint, ScreenCoord aCurrentSpan, + ScreenCoord aPreviousSpan, Modifiers aModifiers) : InputData(PINCHGESTURE_INPUT, aTime, aTimeStamp, aModifiers), mType(aType), + mSource(aSource), mFocusPoint(aFocusPoint), mScreenOffset(aScreenOffset), mCurrentSpan(aCurrentSpan), diff --git a/widget/InputData.h b/widget/InputData.h index bea126e738e6..fbd35d27df44 100644 --- a/widget/InputData.h +++ b/widget/InputData.h @@ -449,11 +449,21 @@ class PinchGestureInput : public InputData { // meaningful data. PINCHGESTURE_END )); + + MOZ_DEFINE_ENUM_AT_CLASS_SCOPE( + PinchGestureSource, ( + UNKNOWN, // Default initialization value. Should never actually be used. + TOUCH, // From two-finger pinch gesture + ONE_TOUCH, // From one-finger pinch gesture + TRACKPAD, // From trackpad pinch gesture + MOUSEWHEEL // Synthesized from modifier+mousewheel + )); // clang-format on // Construct a pinch gesture from a Screen point. - PinchGestureInput(PinchGestureType aType, uint32_t aTime, - TimeStamp aTimeStamp, const ExternalPoint& aScreenOffset, + PinchGestureInput(PinchGestureType aType, PinchGestureSource aSource, + uint32_t aTime, TimeStamp aTimeStamp, + const ExternalPoint& aScreenOffset, const ScreenPoint& aFocusPoint, ScreenCoord aCurrentSpan, ScreenCoord aPreviousSpan, Modifiers aModifiers); @@ -465,6 +475,9 @@ class PinchGestureInput : public InputData { // fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h PinchGestureType mType; + // Some indication of the input device that generated this pinch gesture. + PinchGestureSource mSource; + // Center point of the pinch gesture. That is, if there are two fingers on the // screen, it is their midpoint. In the case of more than two fingers, the // point is implementation-specific, but can for example be the midpoint diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index 246e8b334f01..f4c8a22bff98 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -2837,6 +2837,7 @@ NSEvent* gLastDragMouseDownEvent = nil; // [strong] } PinchGestureInput event{pinchGestureType, + PinchGestureInput::TRACKPAD, eventIntervalTime, eventTimeStamp, screenOffset, diff --git a/widget/nsGUIEventIPC.h b/widget/nsGUIEventIPC.h index d1f3d1e0f917..2ee554ca1886 100644 --- a/widget/nsGUIEventIPC.h +++ b/widget/nsGUIEventIPC.h @@ -1285,6 +1285,14 @@ struct ParamTraits mozilla::PinchGestureInput::PinchGestureType::PINCHGESTURE_START, mozilla::PinchGestureInput::sHighestPinchGestureType> {}; +template <> +struct ParamTraits + : public ContiguousEnumSerializerInclusive< + mozilla::PinchGestureInput::PinchGestureSource, + // Set the min to TOUCH, to ensure UNKNOWN is never sent over IPC + mozilla::PinchGestureInput::PinchGestureSource::TOUCH, + mozilla::PinchGestureInput::sHighestPinchGestureSource> {}; + template <> struct ParamTraits { typedef mozilla::PinchGestureInput paramType; @@ -1292,6 +1300,7 @@ struct ParamTraits { static void Write(Message* aMsg, const paramType& aParam) { WriteParam(aMsg, static_cast(aParam)); WriteParam(aMsg, aParam.mType); + WriteParam(aMsg, aParam.mSource); WriteParam(aMsg, aParam.mScreenOffset); WriteParam(aMsg, aParam.mFocusPoint); WriteParam(aMsg, aParam.mLocalFocusPoint); @@ -1304,6 +1313,7 @@ struct ParamTraits { paramType* aResult) { return ReadParam(aMsg, aIter, static_cast(aResult)) && ReadParam(aMsg, aIter, &aResult->mType) && + ReadParam(aMsg, aIter, &aResult->mSource) && ReadParam(aMsg, aIter, &aResult->mScreenOffset) && ReadParam(aMsg, aIter, &aResult->mFocusPoint) && ReadParam(aMsg, aIter, &aResult->mLocalFocusPoint) && diff --git a/widget/windows/DirectManipulationOwner.cpp b/widget/windows/DirectManipulationOwner.cpp index 0dcbca7b11cd..696fafc204c4 100644 --- a/widget/windows/DirectManipulationOwner.cpp +++ b/widget/windows/DirectManipulationOwner.cpp @@ -393,6 +393,7 @@ void DManipEventHandler::SendPinch(Phase aPhase, float aScale) { PinchGestureInput event{ pinchGestureType, + PinchGestureInput::TRACKPAD, eventIntervalTime, eventTimeStamp, screenOffset,