Esempio n. 1
0
static nsEventStatus
sendTouchEvent(UserInputData& data, bool* captured)
{
    uint32_t msg;
    int32_t action = data.action & AMOTION_EVENT_ACTION_MASK;
    switch (action) {
    case AMOTION_EVENT_ACTION_DOWN:
    case AMOTION_EVENT_ACTION_POINTER_DOWN:
        msg = NS_TOUCH_START;
        break;
    case AMOTION_EVENT_ACTION_MOVE:
        msg = NS_TOUCH_MOVE;
        break;
    case AMOTION_EVENT_ACTION_UP:
    case AMOTION_EVENT_ACTION_POINTER_UP:
        msg = NS_TOUCH_END;
        break;
    case AMOTION_EVENT_ACTION_OUTSIDE:
    case AMOTION_EVENT_ACTION_CANCEL:
        msg = NS_TOUCH_CANCEL;
        break;
    }

    WidgetTouchEvent event(true, msg, nullptr);

    event.time = data.timeMs;
    event.modifiers = data.DOMModifiers();

    int32_t i;
    if (msg == NS_TOUCH_END) {
        i = data.action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK;
        i >>= AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
        addDOMTouch(data, event, i);
    } else {
Esempio n. 2
0
static void
sendMouseEvent(uint32_t msg, UserInputData& data, bool forwardToChildren)
{
    WidgetMouseEvent event(true, msg, nullptr,
                           WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);

    event.refPoint.x = data.motion.touches[0].coords.getX();
    event.refPoint.y = data.motion.touches[0].coords.getY();
    event.time = data.timeMs;
    event.button = WidgetMouseEvent::eLeftButton;
    event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
    if (msg != NS_MOUSE_MOVE)
        event.clickCount = 1;
    event.modifiers = data.DOMModifiers();

    event.mFlags.mNoCrossProcessBoundaryForwarding = !forwardToChildren;

    nsWindow::DispatchInputEvent(event);
}