2014-09-01 02:38:00 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=2 sts=2 et sw=2 tw=80: */
|
|
|
|
/* Copyright 2014 Mozilla Foundation and Mozilla contributors
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "FrameMetrics.h"
|
|
|
|
#include "GeckoProfiler.h"
|
|
|
|
#include "GeckoTouchDispatcher.h"
|
|
|
|
#include "InputData.h"
|
2014-09-05 23:39:59 +04:00
|
|
|
#include "ProfilerMarkers.h"
|
2014-09-01 02:38:00 +04:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
#include "gfxPrefs.h"
|
|
|
|
#include "libui/Input.h"
|
|
|
|
#include "mozilla/ClearOnShutdown.h"
|
2015-01-14 05:16:51 +03:00
|
|
|
#include "mozilla/MouseEvents.h"
|
2014-09-01 02:38:00 +04:00
|
|
|
#include "mozilla/Mutex.h"
|
|
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#include "mozilla/TouchEvents.h"
|
|
|
|
#include "mozilla/dom/Touch.h"
|
2014-12-18 19:30:06 +03:00
|
|
|
#include "mozilla/layers/CompositorParent.h"
|
2014-09-01 02:38:00 +04:00
|
|
|
#include "nsAppShell.h"
|
|
|
|
#include "nsDebug.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include "nsWindow.h"
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <utils/Timers.h>
|
|
|
|
|
|
|
|
#define LOG(args...) \
|
|
|
|
__android_log_print(ANDROID_LOG_INFO, "Gonk" , ## args)
|
|
|
|
|
|
|
|
// uncomment to print log resample data
|
|
|
|
// #define LOG_RESAMPLE_DATA 1
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
// Amount of time in MS before an input is considered expired.
|
|
|
|
static const uint64_t kInputExpirationThresholdMs = 1000;
|
|
|
|
|
|
|
|
static StaticRefPtr<GeckoTouchDispatcher> sTouchDispatcher;
|
|
|
|
|
|
|
|
GeckoTouchDispatcher::GeckoTouchDispatcher()
|
|
|
|
: mTouchQueueLock("GeckoTouchDispatcher::mTouchQueueLock")
|
|
|
|
, mTouchEventsFiltered(false)
|
|
|
|
{
|
|
|
|
// Since GeckoTouchDispatcher is initialized when input is initialized
|
|
|
|
// and reads gfxPrefs, it is the first thing to touch gfxPrefs.
|
|
|
|
// The first thing to touch gfxPrefs MUST occur on the main thread and init
|
|
|
|
// the singleton
|
|
|
|
MOZ_ASSERT(sTouchDispatcher == nullptr);
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
gfxPrefs::GetSingleton();
|
|
|
|
|
|
|
|
mEnabledUniformityInfo = gfxPrefs::UniformityInfo();
|
|
|
|
mResamplingEnabled = gfxPrefs::TouchResampling() &&
|
2014-10-22 02:40:54 +04:00
|
|
|
gfxPrefs::HardwareVsyncEnabled();
|
2014-10-29 23:37:06 +03:00
|
|
|
mVsyncAdjust = TimeDuration::FromMilliseconds(gfxPrefs::TouchVsyncSampleAdjust());
|
|
|
|
mMaxPredict = TimeDuration::FromMilliseconds(gfxPrefs::TouchResampleMaxPredict());
|
2014-11-11 17:39:00 +03:00
|
|
|
mOldTouchThreshold = TimeDuration::FromMilliseconds(gfxPrefs::TouchResampleOldTouchThreshold());
|
2014-10-29 23:37:06 +03:00
|
|
|
mDelayedVsyncThreshold = TimeDuration::FromMilliseconds(gfxPrefs::TouchResampleVsyncDelayThreshold());
|
2014-09-01 02:38:00 +04:00
|
|
|
sTouchDispatcher = this;
|
|
|
|
ClearOnShutdown(&sTouchDispatcher);
|
|
|
|
}
|
|
|
|
|
|
|
|
class DispatchTouchEventsMainThread : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DispatchTouchEventsMainThread(GeckoTouchDispatcher* aTouchDispatcher,
|
2014-10-29 23:37:06 +03:00
|
|
|
TimeStamp aVsyncTime)
|
2014-09-01 02:38:00 +04:00
|
|
|
: mTouchDispatcher(aTouchDispatcher)
|
|
|
|
, mVsyncTime(aVsyncTime)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
|
|
|
mTouchDispatcher->DispatchTouchMoveEvents(mVsyncTime);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsRefPtr<GeckoTouchDispatcher> mTouchDispatcher;
|
2014-10-29 23:37:06 +03:00
|
|
|
TimeStamp mVsyncTime;
|
2014-09-01 02:38:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class DispatchSingleTouchMainThread : public nsRunnable
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
DispatchSingleTouchMainThread(GeckoTouchDispatcher* aTouchDispatcher,
|
|
|
|
MultiTouchInput& aTouch)
|
|
|
|
: mTouchDispatcher(aTouchDispatcher)
|
|
|
|
, mTouch(aTouch)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHOD Run()
|
|
|
|
{
|
|
|
|
mTouchDispatcher->DispatchTouchEvent(mTouch);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsRefPtr<GeckoTouchDispatcher> mTouchDispatcher;
|
|
|
|
MultiTouchInput mTouch;
|
|
|
|
};
|
|
|
|
|
2014-12-18 19:30:06 +03:00
|
|
|
/* static */ void
|
|
|
|
GeckoTouchDispatcher::SetCompositorVsyncObserver(mozilla::layers::CompositorVsyncObserver *aObserver)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(sTouchDispatcher != nullptr);
|
|
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
// We assume on b2g that there is only 1 CompositorParent
|
|
|
|
MOZ_ASSERT(sTouchDispatcher->mCompositorVsyncObserver == nullptr);
|
|
|
|
if (gfxPrefs::TouchResampling()) {
|
|
|
|
sTouchDispatcher->mCompositorVsyncObserver = aObserver;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-01 02:38:00 +04:00
|
|
|
// Timestamp is in nanoseconds
|
|
|
|
/* static */ bool
|
2014-10-29 23:37:06 +03:00
|
|
|
GeckoTouchDispatcher::NotifyVsync(TimeStamp aVsyncTimestamp)
|
2014-09-01 02:38:00 +04:00
|
|
|
{
|
2014-12-18 19:30:06 +03:00
|
|
|
if ((sTouchDispatcher == nullptr) || !gfxPrefs::TouchResampling()) {
|
2014-09-01 02:38:00 +04:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(sTouchDispatcher->mResamplingEnabled);
|
|
|
|
bool haveTouchData = false;
|
|
|
|
{
|
|
|
|
MutexAutoLock lock(sTouchDispatcher->mTouchQueueLock);
|
|
|
|
haveTouchData = !sTouchDispatcher->mTouchMoveEvents.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (haveTouchData) {
|
|
|
|
NS_DispatchToMainThread(new DispatchTouchEventsMainThread(sTouchDispatcher, aVsyncTimestamp));
|
|
|
|
}
|
|
|
|
|
|
|
|
return haveTouchData;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Touch data timestamps are in milliseconds, aEventTime is in nanoseconds
|
|
|
|
void
|
2014-10-29 23:37:06 +03:00
|
|
|
GeckoTouchDispatcher::NotifyTouch(MultiTouchInput& aTouch, TimeStamp aEventTime)
|
2014-09-01 02:38:00 +04:00
|
|
|
{
|
2014-12-18 19:30:06 +03:00
|
|
|
if (aTouch.mType == MultiTouchInput::MULTITOUCH_START && mCompositorVsyncObserver) {
|
|
|
|
mCompositorVsyncObserver->SetNeedsComposite(true);
|
|
|
|
}
|
|
|
|
|
2014-10-16 16:02:00 +04:00
|
|
|
if (aTouch.mType == MultiTouchInput::MULTITOUCH_MOVE) {
|
|
|
|
MutexAutoLock lock(mTouchQueueLock);
|
|
|
|
if (mResamplingEnabled) {
|
|
|
|
mTouchMoveEvents.push_back(aTouch);
|
|
|
|
return;
|
2014-09-01 02:38:00 +04:00
|
|
|
}
|
|
|
|
|
2014-10-16 16:02:00 +04:00
|
|
|
if (mTouchMoveEvents.empty()) {
|
|
|
|
mTouchMoveEvents.push_back(aTouch);
|
|
|
|
} else {
|
|
|
|
// Coalesce touch move events
|
|
|
|
mTouchMoveEvents.back() = aTouch;
|
|
|
|
}
|
|
|
|
|
2014-10-29 23:37:06 +03:00
|
|
|
NS_DispatchToMainThread(new DispatchTouchEventsMainThread(this, TimeStamp::Now()));
|
2014-10-16 16:02:00 +04:00
|
|
|
} else {
|
|
|
|
NS_DispatchToMainThread(new DispatchSingleTouchMainThread(this, aTouch));
|
|
|
|
}
|
2014-09-01 02:38:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-10-29 23:37:06 +03:00
|
|
|
GeckoTouchDispatcher::DispatchTouchMoveEvents(TimeStamp aVsyncTime)
|
2014-09-01 02:38:00 +04:00
|
|
|
{
|
|
|
|
MultiTouchInput touchMove;
|
|
|
|
|
|
|
|
{
|
|
|
|
MutexAutoLock lock(mTouchQueueLock);
|
|
|
|
if (mTouchMoveEvents.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-16 16:02:00 +04:00
|
|
|
if (mResamplingEnabled) {
|
|
|
|
int touchCount = mTouchMoveEvents.size();
|
2014-11-11 17:39:00 +03:00
|
|
|
TimeDuration vsyncTouchDiff = aVsyncTime - mTouchMoveEvents.back().mTimeStamp;
|
2014-10-16 16:02:00 +04:00
|
|
|
// The delay threshold is a positive pref, but we're testing to see if the
|
|
|
|
// vsync time is delayed from the touch, so add a negative sign.
|
|
|
|
bool isDelayedVsyncEvent = vsyncTouchDiff < -mDelayedVsyncThreshold;
|
2014-11-11 17:39:00 +03:00
|
|
|
bool isOldTouch = vsyncTouchDiff > mOldTouchThreshold;
|
|
|
|
bool resample = (touchCount > 1) && !isDelayedVsyncEvent && !isOldTouch;
|
2014-10-16 16:02:00 +04:00
|
|
|
|
|
|
|
if (!resample) {
|
|
|
|
touchMove = mTouchMoveEvents.back();
|
|
|
|
mTouchMoveEvents.clear();
|
2014-11-11 17:39:00 +03:00
|
|
|
if (!isDelayedVsyncEvent && !isOldTouch) {
|
2014-10-16 16:02:00 +04:00
|
|
|
mTouchMoveEvents.push_back(touchMove);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ResampleTouchMoves(touchMove, aVsyncTime);
|
|
|
|
}
|
|
|
|
} else {
|
2014-09-01 02:38:00 +04:00
|
|
|
touchMove = mTouchMoveEvents.back();
|
|
|
|
mTouchMoveEvents.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DispatchTouchEvent(touchMove);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2014-11-10 14:02:00 +03:00
|
|
|
Interpolate(int start, int end, TimeDuration aFrameDiff, TimeDuration aTouchDiff)
|
2014-09-01 02:38:00 +04:00
|
|
|
{
|
2014-11-10 14:02:00 +03:00
|
|
|
return start + (((end - start) * aFrameDiff.ToMicroseconds()) / aTouchDiff.ToMicroseconds());
|
2014-09-01 02:38:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static const SingleTouchData&
|
|
|
|
GetTouchByID(const SingleTouchData& aCurrentTouch, MultiTouchInput& aOtherTouch)
|
|
|
|
{
|
|
|
|
int32_t id = aCurrentTouch.mIdentifier;
|
|
|
|
for (size_t i = 0; i < aOtherTouch.mTouches.Length(); i++) {
|
|
|
|
SingleTouchData& touch = aOtherTouch.mTouches[i];
|
|
|
|
if (touch.mIdentifier == id) {
|
|
|
|
return touch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We can have situations where a previous touch event had 2 fingers
|
|
|
|
// and we lift 1 finger off. In those cases, we won't find the touch event
|
|
|
|
// with given id, so just return the current touch, which will be resampled
|
|
|
|
// without modification and dispatched.
|
|
|
|
return aCurrentTouch;
|
|
|
|
}
|
|
|
|
|
2014-11-10 14:02:00 +03:00
|
|
|
|
|
|
|
// aTouchDiff is the duration between the base and current touch times
|
|
|
|
// aFrameDiff is the duration between the base and the time we're resampling to
|
2014-09-01 02:38:00 +04:00
|
|
|
static void
|
2014-11-10 14:02:00 +03:00
|
|
|
ResampleTouch(MultiTouchInput& aOutTouch,
|
|
|
|
MultiTouchInput& aBase, MultiTouchInput& aCurrent,
|
|
|
|
TimeDuration aFrameDiff, TimeDuration aTouchDiff)
|
2014-09-01 02:38:00 +04:00
|
|
|
{
|
|
|
|
aOutTouch = aCurrent;
|
|
|
|
|
|
|
|
// Make sure we only resample the correct finger.
|
|
|
|
for (size_t i = 0; i < aOutTouch.mTouches.Length(); i++) {
|
2014-11-10 14:02:00 +03:00
|
|
|
const SingleTouchData& base = aBase.mTouches[i];
|
|
|
|
const SingleTouchData& current = GetTouchByID(base, aCurrent);
|
2014-09-01 02:38:00 +04:00
|
|
|
|
2014-11-10 14:02:00 +03:00
|
|
|
const ScreenIntPoint& baseTouchPoint = base.mScreenPoint;
|
2014-09-01 02:38:00 +04:00
|
|
|
const ScreenIntPoint& currentTouchPoint = current.mScreenPoint;
|
|
|
|
|
|
|
|
ScreenIntPoint newSamplePoint;
|
2014-11-10 14:02:00 +03:00
|
|
|
newSamplePoint.x = Interpolate(baseTouchPoint.x, currentTouchPoint.x, aFrameDiff, aTouchDiff);
|
|
|
|
newSamplePoint.y = Interpolate(baseTouchPoint.y, currentTouchPoint.y, aFrameDiff, aTouchDiff);
|
2014-09-01 02:38:00 +04:00
|
|
|
|
|
|
|
aOutTouch.mTouches[i].mScreenPoint = newSamplePoint;
|
|
|
|
|
|
|
|
#ifdef LOG_RESAMPLE_DATA
|
|
|
|
const char* type = "extrapolate";
|
2014-11-10 14:02:00 +03:00
|
|
|
if (aFrameDiff < aTouchDiff) {
|
2014-09-01 02:38:00 +04:00
|
|
|
type = "interpolate";
|
|
|
|
}
|
|
|
|
|
2014-11-10 14:02:00 +03:00
|
|
|
float alpha = aFrameDiff / aTouchDiff;
|
|
|
|
LOG("%s base (%d, %d), current (%d, %d) to (%d, %d) alpha %f, touch diff %d, frame diff %d\n",
|
2014-09-01 02:38:00 +04:00
|
|
|
type,
|
2014-11-10 14:02:00 +03:00
|
|
|
baseTouchPoint.x, baseTouchPoint.y,
|
2014-09-01 02:38:00 +04:00
|
|
|
currentTouchPoint.x, currentTouchPoint.y,
|
|
|
|
newSamplePoint.x, newSamplePoint.y,
|
2014-11-10 14:02:00 +03:00
|
|
|
alpha, (int)aTouchDiff.ToMilliseconds(), (int)aFrameDiff.ToMilliseconds());
|
2014-09-01 02:38:00 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-10 14:02:00 +03:00
|
|
|
/*
|
|
|
|
* +> Base touch (The touch before current touch)
|
|
|
|
* |
|
|
|
|
* | +> Current touch (Latest touch)
|
|
|
|
* | |
|
|
|
|
* | | +> Maximum resample time
|
|
|
|
* | | |
|
|
|
|
* +-----+------+--------------------> Time
|
|
|
|
* ^ ^
|
|
|
|
* | |
|
|
|
|
* +------+--> Potential vsync events which the touches are resampled to
|
|
|
|
* | |
|
|
|
|
* | +> Extrapolation
|
|
|
|
* |
|
|
|
|
* +> Interpolation
|
|
|
|
*/
|
2014-09-01 02:38:00 +04:00
|
|
|
|
2014-11-10 14:02:00 +03:00
|
|
|
void
|
|
|
|
GeckoTouchDispatcher::ResampleTouchMoves(MultiTouchInput& aOutTouch, TimeStamp aVsyncTime)
|
2014-09-01 02:38:00 +04:00
|
|
|
{
|
|
|
|
MOZ_RELEASE_ASSERT(mTouchMoveEvents.size() >= 2);
|
|
|
|
mTouchQueueLock.AssertCurrentThreadOwns();
|
|
|
|
|
|
|
|
MultiTouchInput currentTouch = mTouchMoveEvents.back();
|
|
|
|
mTouchMoveEvents.pop_back();
|
2014-11-10 14:02:00 +03:00
|
|
|
MultiTouchInput baseTouch = mTouchMoveEvents.back();
|
2014-09-01 02:38:00 +04:00
|
|
|
mTouchMoveEvents.clear();
|
|
|
|
mTouchMoveEvents.push_back(currentTouch);
|
|
|
|
|
2014-10-29 23:37:06 +03:00
|
|
|
TimeStamp sampleTime = aVsyncTime - mVsyncAdjust;
|
2014-11-11 17:39:00 +03:00
|
|
|
TimeDuration touchDiff = currentTouch.mTimeStamp - baseTouch.mTimeStamp;
|
2014-09-01 02:38:00 +04:00
|
|
|
|
2014-11-11 17:39:00 +03:00
|
|
|
if (currentTouch.mTimeStamp < sampleTime) {
|
|
|
|
TimeDuration maxResampleTime = std::min(touchDiff / 2, mMaxPredict);
|
|
|
|
TimeStamp maxTimestamp = currentTouch.mTimeStamp + maxResampleTime;
|
2014-11-10 14:02:00 +03:00
|
|
|
if (sampleTime > maxTimestamp) {
|
|
|
|
sampleTime = maxTimestamp;
|
|
|
|
#ifdef LOG_RESAMPLE_DATA
|
|
|
|
LOG("Overshot extrapolation time, adjusting sample time\n");
|
|
|
|
#endif
|
|
|
|
}
|
2014-09-01 02:38:00 +04:00
|
|
|
}
|
|
|
|
|
2014-11-11 17:39:00 +03:00
|
|
|
ResampleTouch(aOutTouch, baseTouch, currentTouch, sampleTime - baseTouch.mTimeStamp, touchDiff);
|
2014-11-10 14:02:00 +03:00
|
|
|
|
|
|
|
// Both mTimeStamp and mTime are being updated to sampleTime here.
|
|
|
|
// mTime needs to be updated using a delta since TimeStamp doesn't
|
|
|
|
// provide a way to obtain a raw value.
|
|
|
|
aOutTouch.mTime += (sampleTime - aOutTouch.mTimeStamp).ToMilliseconds();
|
2014-10-29 23:37:06 +03:00
|
|
|
aOutTouch.mTimeStamp = sampleTime;
|
2014-09-01 02:38:00 +04:00
|
|
|
}
|
|
|
|
|
2015-01-14 05:16:51 +03:00
|
|
|
// Some touch events get sent as mouse events. If APZ doesn't capture the event
|
|
|
|
// and if a touch only has 1 touch input, we can send a mouse event.
|
|
|
|
void
|
|
|
|
GeckoTouchDispatcher::DispatchMouseEvent(MultiTouchInput& aMultiTouch,
|
|
|
|
bool aForwardToChildren)
|
|
|
|
{
|
|
|
|
WidgetMouseEvent mouseEvent = aMultiTouch.ToWidgetMouseEvent(nullptr);
|
|
|
|
if (mouseEvent.message == NS_EVENT_NULL) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mouseEvent.mFlags.mNoCrossProcessBoundaryForwarding = !aForwardToChildren;
|
|
|
|
nsWindow::DispatchInputEvent(mouseEvent);
|
|
|
|
}
|
|
|
|
|
2014-09-01 02:38:00 +04:00
|
|
|
static bool
|
|
|
|
IsExpired(const MultiTouchInput& aTouch)
|
|
|
|
{
|
|
|
|
// No pending events, the filter state can be updated.
|
|
|
|
uint64_t timeNowMs = systemTime(SYSTEM_TIME_MONOTONIC) / 1000000;
|
|
|
|
return (timeNowMs - aTouch.mTime) > kInputExpirationThresholdMs;
|
|
|
|
}
|
|
|
|
void
|
|
|
|
GeckoTouchDispatcher::DispatchTouchEvent(MultiTouchInput& aMultiTouch)
|
|
|
|
{
|
2014-09-29 21:45:41 +04:00
|
|
|
if ((aMultiTouch.mType == MultiTouchInput::MULTITOUCH_END ||
|
|
|
|
aMultiTouch.mType == MultiTouchInput::MULTITOUCH_CANCEL) &&
|
2014-09-25 08:55:39 +04:00
|
|
|
aMultiTouch.mTouches.Length() == 1) {
|
2014-09-29 21:45:41 +04:00
|
|
|
MutexAutoLock lock(mTouchQueueLock);
|
|
|
|
mTouchMoveEvents.clear();
|
|
|
|
} else if (aMultiTouch.mType == MultiTouchInput::MULTITOUCH_START &&
|
|
|
|
aMultiTouch.mTouches.Length() == 1) {
|
2014-09-01 02:38:00 +04:00
|
|
|
mTouchEventsFiltered = IsExpired(aMultiTouch);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mTouchEventsFiltered) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-01-14 05:16:51 +03:00
|
|
|
bool captured = false;
|
|
|
|
WidgetTouchEvent event = aMultiTouch.ToWidgetTouchEvent(nullptr);
|
|
|
|
nsEventStatus status = nsWindow::DispatchInputEvent(event, &captured);
|
2014-09-01 02:38:00 +04:00
|
|
|
|
2014-09-05 23:39:59 +04:00
|
|
|
if (mEnabledUniformityInfo && profiler_is_active()) {
|
2014-09-01 02:38:00 +04:00
|
|
|
const char* touchAction = "Invalid";
|
|
|
|
switch (aMultiTouch.mType) {
|
|
|
|
case MultiTouchInput::MULTITOUCH_START:
|
|
|
|
touchAction = "Touch_Event_Down";
|
|
|
|
break;
|
|
|
|
case MultiTouchInput::MULTITOUCH_MOVE:
|
|
|
|
touchAction = "Touch_Event_Move";
|
|
|
|
break;
|
|
|
|
case MultiTouchInput::MULTITOUCH_END:
|
|
|
|
case MultiTouchInput::MULTITOUCH_CANCEL:
|
|
|
|
touchAction = "Touch_Event_Up";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-09-05 23:39:59 +04:00
|
|
|
const ScreenIntPoint& touchPoint = aMultiTouch.mTouches[0].mScreenPoint;
|
|
|
|
TouchDataPayload* payload = new TouchDataPayload(touchPoint);
|
|
|
|
PROFILER_MARKER_PAYLOAD(touchAction, payload);
|
2014-09-01 02:38:00 +04:00
|
|
|
}
|
2015-01-14 05:16:51 +03:00
|
|
|
|
|
|
|
if (!captured && (aMultiTouch.mTouches.Length() == 1)) {
|
|
|
|
bool forwardToChildren = status != nsEventStatus_eConsumeNoDefault;
|
|
|
|
DispatchMouseEvent(aMultiTouch, forwardToChildren);
|
|
|
|
}
|
2014-09-01 02:38:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mozilla
|