Bug 1894692 - Part 1. Add mInputSource in MultiTouchInput. r=botond,win-reviewers,gstoll
When `android.touch.resampling.enabled` is true, we store `MultiTouchInput` then dispatch it later. So if dispatched asynchronously, it is no way to set correct input source. So I would like to add input source to it to convert `WidgetTouchEvent` with correct input source. Differential Revision: https://phabricator.services.mozilla.com/D234136
This commit is contained in:
@@ -96,7 +96,8 @@ MultiTouchInput::MultiTouchInput(const WidgetTouchEvent& aTouchEvent)
|
||||
aTouchEvent.mModifiers),
|
||||
mHandledByAPZ(aTouchEvent.mFlags.mHandledByAPZ),
|
||||
mButton(aTouchEvent.mButton),
|
||||
mButtons(aTouchEvent.mButtons) {
|
||||
mButtons(aTouchEvent.mButtons),
|
||||
mInputSource(aTouchEvent.mInputSource) {
|
||||
MOZ_ASSERT(NS_IsMainThread(),
|
||||
"Can only copy from WidgetTouchEvent on main thread");
|
||||
|
||||
@@ -154,13 +155,12 @@ void MultiTouchInput::Translate(const ScreenPoint& aTranslation) {
|
||||
}
|
||||
}
|
||||
|
||||
WidgetTouchEvent MultiTouchInput::ToWidgetEvent(nsIWidget* aWidget,
|
||||
uint16_t aInputSource) const {
|
||||
WidgetTouchEvent MultiTouchInput::ToWidgetEvent(nsIWidget* aWidget) const {
|
||||
MOZ_ASSERT(NS_IsMainThread(),
|
||||
"Can only convert To WidgetTouchEvent on main thread");
|
||||
MOZ_ASSERT(aInputSource ==
|
||||
MOZ_ASSERT(mInputSource ==
|
||||
mozilla::dom::MouseEvent_Binding::MOZ_SOURCE_TOUCH ||
|
||||
aInputSource == mozilla::dom::MouseEvent_Binding::MOZ_SOURCE_PEN);
|
||||
mInputSource == mozilla::dom::MouseEvent_Binding::MOZ_SOURCE_PEN);
|
||||
|
||||
EventMessage touchEventMessage = eVoidEvent;
|
||||
switch (mType) {
|
||||
@@ -192,7 +192,7 @@ WidgetTouchEvent MultiTouchInput::ToWidgetEvent(nsIWidget* aWidget,
|
||||
event.mFlags.mHandledByAPZ = mHandledByAPZ;
|
||||
event.mFocusSequenceNumber = mFocusSequenceNumber;
|
||||
event.mLayersId = mLayersId;
|
||||
event.mInputSource = aInputSource;
|
||||
event.mInputSource = mInputSource;
|
||||
event.mButton = mButton;
|
||||
event.mButtons = mButtons;
|
||||
|
||||
|
||||
@@ -229,10 +229,7 @@ class MultiTouchInput : public InputData {
|
||||
|
||||
void Translate(const ScreenPoint& aTranslation);
|
||||
|
||||
WidgetTouchEvent ToWidgetEvent(
|
||||
nsIWidget* aWidget,
|
||||
uint16_t aInputSource =
|
||||
/* MouseEvent_Binding::MOZ_SOURCE_TOUCH = */ 5) const;
|
||||
WidgetTouchEvent ToWidgetEvent(nsIWidget* aWidget) const;
|
||||
|
||||
// Return the index into mTouches of the SingleTouchData with the given
|
||||
// identifier, or -1 if there is no such SingleTouchData.
|
||||
@@ -252,6 +249,7 @@ class MultiTouchInput : public InputData {
|
||||
// WidgetMouseEventBase, except mButton defaults to -1 to follow PointerEvent.
|
||||
int16_t mButton = eNotPressed;
|
||||
int16_t mButtons = 0;
|
||||
uint16_t mInputSource = /* MouseEvent_Binding::MOZ_SOURCE_TOUCH = */ 5;
|
||||
};
|
||||
|
||||
class MouseInput : public InputData {
|
||||
|
||||
@@ -1213,12 +1213,12 @@ class DispatchInputOnControllerThread : public Runnable {
|
||||
const APZOnly mAPZOnly;
|
||||
};
|
||||
|
||||
void nsBaseWidget::DispatchTouchInput(MultiTouchInput& aInput,
|
||||
uint16_t aInputSource) {
|
||||
void nsBaseWidget::DispatchTouchInput(MultiTouchInput& aInput) {
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(aInputSource ==
|
||||
MOZ_ASSERT(aInput.mInputSource ==
|
||||
mozilla::dom::MouseEvent_Binding::MOZ_SOURCE_TOUCH ||
|
||||
aInputSource == mozilla::dom::MouseEvent_Binding::MOZ_SOURCE_PEN);
|
||||
aInput.mInputSource ==
|
||||
mozilla::dom::MouseEvent_Binding::MOZ_SOURCE_PEN);
|
||||
if (mAPZC) {
|
||||
MOZ_ASSERT(APZThreadUtils::IsControllerThread());
|
||||
|
||||
@@ -1227,10 +1227,10 @@ void nsBaseWidget::DispatchTouchInput(MultiTouchInput& aInput,
|
||||
return;
|
||||
}
|
||||
|
||||
WidgetTouchEvent event = aInput.ToWidgetEvent(this, aInputSource);
|
||||
WidgetTouchEvent event = aInput.ToWidgetEvent(this);
|
||||
ProcessUntransformedAPZEvent(&event, result);
|
||||
} else {
|
||||
WidgetTouchEvent event = aInput.ToWidgetEvent(this, aInputSource);
|
||||
WidgetTouchEvent event = aInput.ToWidgetEvent(this);
|
||||
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&event, status);
|
||||
|
||||
@@ -621,10 +621,7 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
|
||||
* be called from the main thread, and if APZ is enabled, that must also be
|
||||
* the APZ controller thread.
|
||||
*/
|
||||
void DispatchTouchInput(
|
||||
mozilla::MultiTouchInput& aInput,
|
||||
uint16_t aInputSource =
|
||||
mozilla::dom::MouseEvent_Binding::MOZ_SOURCE_TOUCH);
|
||||
void DispatchTouchInput(mozilla::MultiTouchInput& aInput);
|
||||
|
||||
/**
|
||||
* Dispatch the given PanGestureInput through APZ to Gecko (if APZ is enabled)
|
||||
|
||||
@@ -1099,6 +1099,7 @@ struct ParamTraits<mozilla::MultiTouchInput> {
|
||||
WriteParam(aWriter, aParam.mScreenOffset);
|
||||
WriteParam(aWriter, aParam.mButton);
|
||||
WriteParam(aWriter, aParam.mButtons);
|
||||
WriteParam(aWriter, aParam.mInputSource);
|
||||
}
|
||||
|
||||
static bool Read(MessageReader* aReader, paramType* aResult) {
|
||||
@@ -1108,7 +1109,8 @@ struct ParamTraits<mozilla::MultiTouchInput> {
|
||||
ReadParam(aReader, &aResult->mHandledByAPZ) &&
|
||||
ReadParam(aReader, &aResult->mScreenOffset) &&
|
||||
ReadParam(aReader, &aResult->mButton) &&
|
||||
ReadParam(aReader, &aResult->mButtons);
|
||||
ReadParam(aReader, &aResult->mButtons) &&
|
||||
ReadParam(aReader, &aResult->mInputSource);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -7978,12 +7978,13 @@ bool nsWindow::DispatchTouchEventFromWMPointer(
|
||||
touchInput.mTouches.AppendElement(touchData);
|
||||
touchInput.mButton = aButton;
|
||||
touchInput.mButtons = aPointerInfo.mButtons;
|
||||
touchInput.mInputSource = MouseEvent_Binding::MOZ_SOURCE_PEN;
|
||||
|
||||
// POINTER_INFO.dwKeyStates can't be used as it only supports Shift and Ctrl
|
||||
ModifierKeyState modifierKeyState;
|
||||
touchInput.modifiers = modifierKeyState.GetModifiers();
|
||||
|
||||
DispatchTouchInput(touchInput, MouseEvent_Binding::MOZ_SOURCE_PEN);
|
||||
DispatchTouchInput(touchInput);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user