Bug 1335895 - part 11: Add Translate function to MultiTouchData r=kats,botond
Compile fix: widget/nsGUIEventIPC.h needed to have all
static_cast<InputData> changed to static_cast<const InputData&>
MozReview-Commit-ID: EEiXCeHjrUG
--- a/widget/InputData.cpp
+++ b/widget/InputData.cpp
@@ -176,16 +176,27 @@ MultiTouchInput::MultiTouchInput(const W
mTouches.AppendElement(SingleTouchData(0,
ViewAs<ScreenPixel>(aMouseEvent.mRefPoint,
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent),
ScreenSize(1, 1),
180.0f,
1.0f));
}
+void
+MultiTouchInput::Translate(const ScreenPoint& aTranslation)
+{
+ const int32_t xTranslation = (int32_t)(aTranslation.x + 0.5f);
+ const int32_t yTranslation = (int32_t)(aTranslation.y + 0.5f);
+
+ for (auto iter = mTouches.begin(); iter != mTouches.end(); iter++) {
+ iter->mScreenPoint.MoveBy(xTranslation, yTranslation);
+ }
+}
+
WidgetTouchEvent
MultiTouchInput::ToWidgetTouchEvent(nsIWidget* aWidget) const
{
MOZ_ASSERT(NS_IsMainThread(),
"Can only convert To WidgetTouchEvent on main thread");
EventMessage touchEventMessage = eVoidEvent;
switch (mType) {
--- a/widget/InputData.h
+++ b/widget/InputData.h
@@ -203,16 +203,17 @@ public:
explicit MultiTouchInput(const WidgetTouchEvent& aTouchEvent);
// This conversion from WidgetMouseEvent to MultiTouchInput is needed because
// on the B2G emulator we can only receive mouse events, but we need to be
// able to pan correctly. To do this, we convert the events into a format that
// the panning code can handle. This code is very limited and only supports
// SingleTouchData. It also sends garbage for the identifier, radius, force
// and rotation angle.
explicit MultiTouchInput(const WidgetMouseEvent& aMouseEvent);
+ void Translate(const ScreenPoint& aTranslation);
WidgetTouchEvent ToWidgetTouchEvent(nsIWidget* aWidget) const;
WidgetMouseEvent ToWidgetMouseEvent(nsIWidget* aWidget) const;
// Return the index into mTouches of the SingleTouchData with the given
// identifier, or -1 if there is no such SingleTouchData.
int32_t IndexOfTouch(int32_t aTouchIdentifier);