Bug 1289435 - Support native event synthesization even for non-touch windows devices. r=jimm

MozReview-Commit-ID: IeHmDOiWOW2
This commit is contained in:
Kartikaya Gupta 2016-08-03 12:06:59 -04:00
Родитель 713c58caee
Коммит 9d9124f381
2 изменённых файлов: 23 добавлений и 1 удалений

Просмотреть файл

@ -128,7 +128,25 @@ nsWindowBase::SynthesizeNativeTouchPoint(uint32_t aPointerId,
AutoObserverNotifier notifier(aObserver, "touchpoint");
if (!InitTouchInjection()) {
return NS_ERROR_NOT_IMPLEMENTED;
// If we don't have touch injection from the OS, we can just fake it and
// synthesize the events from here.
MOZ_ASSERT(NS_IsMainThread());
if (aPointerState == TOUCH_HOVER) {
return NS_ERROR_UNEXPECTED;
}
if (!mSynthesizedTouchInput) {
mSynthesizedTouchInput = MakeUnique<MultiTouchInput>();
}
WidgetEventTime time = CurrentMessageWidgetEventTime();
LayoutDeviceIntPoint pointInWindow = aPoint - WidgetToScreenOffset();
MultiTouchInput inputToDispatch = UpdateSynthesizedTouchState(
mSynthesizedTouchInput.get(), time.mTime, time.mTimeStamp,
aPointerId, aPointerState, pointInWindow, aPointerPressure,
aPointerOrientation);
DispatchTouchInput(inputToDispatch);
return NS_OK;
}
bool hover = aPointerState & TOUCH_HOVER;

Просмотреть файл

@ -129,6 +129,10 @@ protected:
static bool sTouchInjectInitialized;
static InjectTouchInputPtr sInjectTouchFuncPtr;
// This is used by SynthesizeNativeTouchPoint to maintain state between
// multiple synthesized points, in the case where we can't call InjectTouch
// directly.
mozilla::UniquePtr<mozilla::MultiTouchInput> mSynthesizedTouchInput;
protected:
InputContext mInputContext;
};