зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1143618 - Change Window::OnTouch implementation to use MultiTouchInput class. r=kats
This commit is contained in:
Родитель
533750696e
Коммит
e2514a23d9
|
@ -80,7 +80,10 @@ public:
|
|||
INPUTDATA_AS_CHILD_TYPE(TapGestureInput, TAPGESTURE_INPUT)
|
||||
INPUTDATA_AS_CHILD_TYPE(ScrollWheelInput, SCROLLWHEEL_INPUT)
|
||||
|
||||
InputData()
|
||||
InputData(InputType aInputType)
|
||||
: mInputType(aInputType),
|
||||
mTime(0),
|
||||
modifiers(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -207,6 +210,7 @@ public:
|
|||
}
|
||||
|
||||
MultiTouchInput()
|
||||
: InputData(MULTITOUCH_INPUT)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -181,6 +181,7 @@
|
|||
|
||||
#include "mozilla/layers/APZCTreeManager.h"
|
||||
#include "mozilla/layers/InputAPZContext.h"
|
||||
#include "InputData.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
@ -6138,86 +6139,89 @@ bool nsWindow::OnTouch(WPARAM wParam, LPARAM lParam)
|
|||
PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs];
|
||||
|
||||
if (mGesture.GetTouchInputInfo((HTOUCHINPUT)lParam, cInputs, pInputs)) {
|
||||
WidgetTouchEvent* touchEventToSend = nullptr;
|
||||
WidgetTouchEvent* touchEndEventToSend = nullptr;
|
||||
nsEventStatus status;
|
||||
MultiTouchInput touchInput, touchEndInput;
|
||||
|
||||
// Walk across the touch point array processing each contact point
|
||||
// Walk across the touch point array processing each contact point.
|
||||
for (uint32_t i = 0; i < cInputs; i++) {
|
||||
uint32_t msg;
|
||||
bool addToEvent = false, addToEndEvent = false;
|
||||
|
||||
// N.B.: According with MS documentation
|
||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd317334(v=vs.85).aspx
|
||||
// TOUCHEVENTF_DOWN cannot be combined with TOUCHEVENTF_MOVE or TOUCHEVENTF_UP.
|
||||
// Possibly, it means that TOUCHEVENTF_MOVE and TOUCHEVENTF_UP can be combined together.
|
||||
|
||||
if (pInputs[i].dwFlags & (TOUCHEVENTF_DOWN | TOUCHEVENTF_MOVE)) {
|
||||
// Create a standard touch event to send
|
||||
if (!touchEventToSend) {
|
||||
touchEventToSend = new WidgetTouchEvent(true, NS_TOUCH_MOVE, this);
|
||||
touchEventToSend->time = ::GetMessageTime();
|
||||
touchEventToSend->timeStamp =
|
||||
GetMessageTimeStamp(touchEventToSend->time);
|
||||
if (touchInput.mTimeStamp.IsNull()) {
|
||||
// Initialize a touch event to send.
|
||||
touchInput.mType = MultiTouchInput::MULTITOUCH_MOVE;
|
||||
touchInput.mTime = ::GetMessageTime();
|
||||
touchInput.mTimeStamp = GetMessageTimeStamp(touchInput.mTime);
|
||||
ModifierKeyState modifierKeyState;
|
||||
modifierKeyState.InitInputEvent(*touchEventToSend);
|
||||
touchInput.modifiers = modifierKeyState.GetModifiers();
|
||||
}
|
||||
|
||||
// Pres shell expects this event to be a NS_TOUCH_START if new contact
|
||||
// points have been added since the last event sent.
|
||||
// Pres shell expects this event to be a NS_TOUCH_START
|
||||
// if any new contact points have been added since the last event sent.
|
||||
if (pInputs[i].dwFlags & TOUCHEVENTF_DOWN) {
|
||||
touchEventToSend->message = msg = NS_TOUCH_START;
|
||||
} else {
|
||||
msg = NS_TOUCH_MOVE;
|
||||
touchInput.mType = MultiTouchInput::MULTITOUCH_START;
|
||||
}
|
||||
} else if (pInputs[i].dwFlags & TOUCHEVENTF_UP) {
|
||||
// Pres shell expects removed contacts points to be delivered in a
|
||||
// separate NS_TOUCH_END event containing only the contact points
|
||||
// that were removed.
|
||||
if (!touchEndEventToSend) {
|
||||
touchEndEventToSend = new WidgetTouchEvent(true, NS_TOUCH_END, this);
|
||||
touchEndEventToSend->time = ::GetMessageTime();
|
||||
touchEndEventToSend->timeStamp =
|
||||
GetMessageTimeStamp(touchEndEventToSend->time);
|
||||
addToEvent = true;
|
||||
}
|
||||
if (pInputs[i].dwFlags & TOUCHEVENTF_UP) {
|
||||
// Pres shell expects removed contacts points to be delivered in a separate
|
||||
// NS_TOUCH_END event containing only the contact points that were removed.
|
||||
if (touchEndInput.mTimeStamp.IsNull()) {
|
||||
// Initialize a touch event to send.
|
||||
touchEndInput.mType = MultiTouchInput::MULTITOUCH_END;
|
||||
touchEndInput.mTime = ::GetMessageTime();
|
||||
touchEndInput.mTimeStamp = GetMessageTimeStamp(touchEndInput.mTime);
|
||||
ModifierKeyState modifierKeyState;
|
||||
modifierKeyState.InitInputEvent(*touchEndEventToSend);
|
||||
touchEndInput.modifiers = modifierKeyState.GetModifiers();
|
||||
}
|
||||
msg = NS_TOUCH_END;
|
||||
} else {
|
||||
// Filter out spurious Windows events we don't understand, like palm
|
||||
// contact.
|
||||
addToEndEvent = true;
|
||||
}
|
||||
if (!addToEvent && !addToEndEvent) {
|
||||
// Filter out spurious Windows events we don't understand, like palm contact.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Setup the touch point we'll append to the touch event array
|
||||
// Setup the touch point we'll append to the touch event array.
|
||||
nsPointWin touchPoint;
|
||||
touchPoint.x = TOUCH_COORD_TO_PIXEL(pInputs[i].x);
|
||||
touchPoint.y = TOUCH_COORD_TO_PIXEL(pInputs[i].y);
|
||||
touchPoint.ScreenToClient(mWnd);
|
||||
nsRefPtr<Touch> touch =
|
||||
new Touch(pInputs[i].dwID,
|
||||
LayoutDeviceIntPoint::FromUntyped(touchPoint),
|
||||
/* radius, if known */
|
||||
pInputs[i].dwFlags & TOUCHINPUTMASKF_CONTACTAREA ?
|
||||
nsIntPoint(
|
||||
TOUCH_COORD_TO_PIXEL(pInputs[i].cxContact) / 2,
|
||||
TOUCH_COORD_TO_PIXEL(pInputs[i].cyContact) / 2) :
|
||||
nsIntPoint(1,1),
|
||||
/* rotation angle and force */
|
||||
0.0f, 0.0f);
|
||||
|
||||
// Append to the appropriate event
|
||||
if (msg == NS_TOUCH_START || msg == NS_TOUCH_MOVE) {
|
||||
touchEventToSend->touches.AppendElement(touch);
|
||||
} else {
|
||||
touchEndEventToSend->touches.AppendElement(touch);
|
||||
// Initialize the touch data.
|
||||
SingleTouchData touchData(pInputs[i].dwID, // aIdentifier
|
||||
ScreenIntPoint::FromUntyped(touchPoint), // aScreenPoint
|
||||
/* radius, if known */
|
||||
pInputs[i].dwFlags & TOUCHINPUTMASKF_CONTACTAREA
|
||||
? ScreenSize(
|
||||
TOUCH_COORD_TO_PIXEL(pInputs[i].cxContact) / 2,
|
||||
TOUCH_COORD_TO_PIXEL(pInputs[i].cyContact) / 2)
|
||||
: ScreenSize(1, 1), // aRadius
|
||||
0.0f, // aRotationAngle
|
||||
0.0f); // aForce
|
||||
|
||||
// Append touch data to the appropriate event.
|
||||
if (addToEvent) {
|
||||
touchInput.mTouches.AppendElement(touchData);
|
||||
}
|
||||
if (addToEndEvent) {
|
||||
touchEndInput.mTouches.AppendElement(touchData);
|
||||
}
|
||||
}
|
||||
|
||||
// Dispatch touch start and move event if we have one.
|
||||
if (touchEventToSend) {
|
||||
status = DispatchAPZAwareEvent(touchEventToSend);
|
||||
delete touchEventToSend;
|
||||
// Dispatch touch start and touch move event if we have one.
|
||||
if (!touchInput.mTimeStamp.IsNull()) {
|
||||
// Convert MultiTouchInput to WidgetTouchEvent interface.
|
||||
WidgetTouchEvent widgetTouchEvent = touchInput.ToWidgetTouchEvent(this);
|
||||
DispatchAPZAwareEvent(&widgetTouchEvent);
|
||||
}
|
||||
|
||||
// Dispatch touch end event if we have one.
|
||||
if (touchEndEventToSend) {
|
||||
status = DispatchAPZAwareEvent(touchEndEventToSend);
|
||||
delete touchEndEventToSend;
|
||||
if (!touchEndInput.mTimeStamp.IsNull()) {
|
||||
// Convert MultiTouchInput to WidgetTouchEvent interface.
|
||||
WidgetTouchEvent widgetTouchEvent = touchEndInput.ToWidgetTouchEvent(this);
|
||||
DispatchAPZAwareEvent(&widgetTouchEvent);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче