Ejemplo n.º 1
0
void GestureEngine::updateTouchPoint(QTouchEvent::TouchPoint e)
{
    gwc::touchpoint updated_point;
    updated_point.init(e.id(), e.pos().x() / 1920, e.pos().y()/ 1080, 0, 1, 1);
    updated_point.status = gwc::TOUCHUPDATE;
    addEvent(updated_point);
}
Ejemplo n.º 2
0
bool QtPanGestureRecognizer::update(const QTouchEvent::TouchPoint& touchPoint, qint64 eventTimestampMillis)
{
    if (!viewportHandler())
        return false;

    m_lastPosition = touchPoint.pos();
    m_lastEventTimestampMillis = eventTimestampMillis;

    switch (m_state) {
    case NoGesture:
        m_state = GestureRecognitionStarted;
        m_firstScreenPosition = touchPoint.screenPos();
        viewportHandler()->cancelScrollAnimation();
        return false;
    case GestureRecognitionStarted: {
        // To start the gesture, the delta from start in screen coordinates
        // must be bigger than the trigger threshold.
        QPointF totalOffsetFromStart(touchPoint.screenPos() - m_firstScreenPosition);
        if (qAbs(totalOffsetFromStart.x()) < panningInitialTriggerDistanceThreshold && qAbs(totalOffsetFromStart.y()) < panningInitialTriggerDistanceThreshold)
            return false;

        m_state = GestureRecognized;
        viewportHandler()->panGestureStarted(touchPoint.pos(), eventTimestampMillis);
        return true;
    }
    case GestureRecognized:
        viewportHandler()->panGestureRequestUpdate(touchPoint.pos(), eventTimestampMillis);
        return true;
    default:
        ASSERT_NOT_REACHED();
    }
    return false;
}
Ejemplo n.º 3
0
void GestureEngine::removeTouchPoint(QTouchEvent::TouchPoint e)
{
    gwc::touchpoint removed_point;
    removed_point.init(e.id(), e.pos().x() / 1920, e.pos().y()/ 1080, 0, 1, 1);
    removed_point.status = gwc::TOUCHREMOVED;
    addEvent(removed_point);
}
Ejemplo n.º 4
0
void GestureEngine::addTouchPoint(QTouchEvent::TouchPoint e)
{
    gwc::touchpoint new_point;
    new_point.init(e.id(), e.pos().x() / 1920, e.pos().y() / 1080, 0, 1920, 1080);
    new_point.status = gwc::TOUCHADDED;
    addEvent(new_point);

    qDebug() << "Added to Gestureworks";
}
Ejemplo n.º 5
0
bool TreeViewTouch::event(QEvent *event) {
#if QT_VERSION >= 0x050000
    if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->device()->type()==QTouchDevice::TouchScreen) {
#else
    if (event->type() == QEvent::TouchBegin && ((QTouchEvent*)event)->deviceType()==QTouchEvent::TouchScreen) {
#endif
        // Register that we may be scrolling, set the scroll mode to scroll-per-pixel
        // and accept the event (return true) so that we will receive TouchUpdate and TouchEnd/TouchCancel
        _touchScrollInProgress = true;
        setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
        return true;
    }

    if (event->type() == QEvent::TouchUpdate && _touchScrollInProgress) {
        QTouchEvent::TouchPoint p = ((QTouchEvent*)event)->touchPoints().at(0);
        if (!_firstTouchUpdateHappened) {
            // After the first movement of a Touch-Point, calculate the distance in both axis
            // and if the point moved more horizontally abort scroll.
            double dx = qAbs(p.lastPos().x() - p.pos().x());
            double dy = qAbs(p.lastPos().y() - p.pos().y());
            if (dx > dy) {
                _touchScrollInProgress = false;
            }
            _firstTouchUpdateHappened = true;
        }
        // Apply touch movement to scrollbar
        verticalScrollBar()->setValue(verticalScrollBar()->value() - (p.pos().y() - p.lastPos().y()));
        return true;
    }

#if QT_VERSION >= 0x050000
    if (event->type() == QEvent::TouchEnd || event->type() == QEvent::TouchCancel) {
#else
    if (event->type() == QEvent::TouchEnd) {
#endif
        // End scroll and reset variables
        _touchScrollInProgress = false;
        _firstTouchUpdateHappened = false;
        return true;
    }

    return QTreeView::event(event);
}


void TreeViewTouch::mousePressEvent(QMouseEvent *event) {
    if (!_touchScrollInProgress)
        QTreeView::mousePressEvent(event);
}


void TreeViewTouch::mouseMoveEvent(QMouseEvent *event) {
    if (!_touchScrollInProgress)
        QTreeView::mouseMoveEvent(event);
};
Ejemplo n.º 6
0
void QtWebPageEventHandler::activateTapHighlight(const QTouchEvent::TouchPoint& point)
{
#if ENABLE(TOUCH_EVENTS)
    ASSERT(!point.pos().toPoint().isNull());
    ASSERT(!m_isTapHighlightActive);
    m_isTapHighlightActive = true;
    QTransform fromItemTransform = m_webPage->transformFromItem();
    m_webPageProxy->handlePotentialActivation(IntPoint(fromItemTransform.map(point.pos()).toPoint()), IntSize(point.rect().size().toSize()));
#else
    Q_UNUSED(point);
#endif
}
Ejemplo n.º 7
0
void QtWebPageEventHandler::handlePotentialSingleTapEvent(const QTouchEvent::TouchPoint& point)
{
#if ENABLE(TOUCH_EVENTS)
    if (point.pos() == QPointF()) {
        // An empty point deactivates the highlighting.
        m_webPageProxy->handlePotentialActivation(IntPoint(), IntSize());
    } else {
        QTransform fromItemTransform = m_webPage->transformFromItem();
        m_webPageProxy->handlePotentialActivation(IntPoint(fromItemTransform.map(point.pos()).toPoint()), IntSize(point.rect().size().toSize()));
    }
#else
    Q_UNUSED(point);
#endif
}
Ejemplo n.º 8
0
void QtWebPageEventHandler::handleSingleTapEvent(const QTouchEvent::TouchPoint& point)
{
    m_postponeTextInputStateChanged = true;

    QTransform fromItemTransform = m_webPage->transformFromItem();
    WebGestureEvent gesture(WebEvent::GestureSingleTap, fromItemTransform.map(point.pos()).toPoint(), point.screenPos().toPoint(), WebEvent::Modifiers(0), 0, IntSize(point.rect().size().toSize()), FloatPoint(0, 0));
    m_webPageProxy->handleGestureEvent(gesture);
}
Ejemplo n.º 9
0
void QtWebPageEventHandler::handleDoubleTapEvent(const QTouchEvent::TouchPoint& point)
{
    if (!m_webView->isInteractive())
        return;

    deactivateTapHighlight();
    QTransform fromItemTransform = m_webPage->transformFromItem();
    m_webPageProxy->findZoomableAreaForPoint(fromItemTransform.map(point.pos()).toPoint(), IntSize(point.rect().size().toSize()));
}
Ejemplo n.º 10
0
void QtPanGestureRecognizer::finish(const QTouchEvent::TouchPoint& touchPoint, qint64 eventTimestampMillis)
{
    if (m_state == NoGesture)
        return;

    ASSERT(viewportHandler());
    viewportHandler()->panGestureEnded(touchPoint.pos(), eventTimestampMillis);
    reset();
}
Ejemplo n.º 11
0
void MainGraphicsView::processTouchEvent(QTouchEvent *touchEvent) {
    QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
    //qDebug("touch event %d count %d", event->type(), touchPoints.count());
    if( touchPoints.count() > 1 ) {
        this->has_kinetic_scroll = false;
        this->single_left_mouse_down = false;
        // can't trust last mouse position if more that one touch!
        this->has_last_mouse = false;
    }
#if QT_VERSION >= 0x050000
#ifdef Q_OS_ANDROID
    // on Android with Qt 5, mouse events are never received, instead it's done purely via touch events
    if( touchPoints.count() == 1 ) {
        QTouchEvent::TouchPoint touchPoint = touchPoints.at(0);
        int m_x = touchPoint.pos().x();
        int m_y = touchPoint.pos().y();
        if( touchEvent->type() == QEvent::TouchBegin ) {
            this->mousePress(m_x, m_y);
        }
        else if( touchEvent->type() == QEvent::TouchEnd ) {
            this->mouseRelease(m_x, m_y);
        }
        else if( touchEvent->type() == QEvent::TouchUpdate ) {
            this->mouseMove(m_x, m_y);
        }
    }
#endif
#endif
    if( touchPoints.count() == 2 ) {
        // determine scale factor
        const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
        const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
        /*float scale_factor =
                QLineF(touchPoint0.pos(), touchPoint1.pos()).length()
                / QLineF(touchPoint0.startPos(), touchPoint1.startPos()).length();*/
        QPointF touch_centre = (touchPoint0.pos() + touchPoint1.pos())*0.5;
        QPointF zoom_centre = this->mapToScene(QPoint(touch_centre.x(), touch_centre.y()));
        float scale_factor =
                QLineF(touchPoint0.pos(), touchPoint1.pos()).length()
                / QLineF(touchPoint0.lastPos(), touchPoint1.lastPos()).length();
        /*if (touchEvent->touchPointStates() & Qt::TouchPointReleased) {
            // if one of the fingers is released, remember the current scale
            // factor so that adding another finger later will continue zooming
            // by adding new scale factor to the existing remembered value.
            totalScaleFactor *= currentScaleFactor;
            currentScaleFactor = 1;
        }*/
        /*setTransform(QTransform().scale(totalScaleFactor * currentScaleFactor,
                                        totalScaleFactor * currentScaleFactor));*/
        float n_scale = c_scale *scale_factor;
        //LOG("multitouch scale: %f : %f\n", scale_factor, n_scale);
        this->setScale(zoom_centre, n_scale);
    }
}
Ejemplo n.º 12
0
QGestureRecognizer::Result
QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
                                        QEvent *event)
{
    QTapAndHoldGesture *q = static_cast<QTapAndHoldGesture *>(state);
    QTapAndHoldGesturePrivate *d = q->d_func();

    if (object == state && event->type() == QEvent::Timer) {
        q->killTimer(d->timerId);
        d->timerId = 0;
        return QGestureRecognizer::Ignore | QGestureRecognizer::ConsumeEventHint;
    }

    const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);

    QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture;

    enum { TimerInterval = 2000 };
    enum { TapRadius = 40 };

    switch (event->type()) {
    case QEvent::TouchBegin:
        d->position = ev->touchPoints().at(0).pos();
        if (d->timerId)
            q->killTimer(d->timerId);
        d->timerId = q->startTimer(TimerInterval);
        result = QGestureRecognizer::TriggerGesture;
        break;
    case QEvent::TouchEnd:
        if (d->timerId)
            result = QGestureRecognizer::CancelGesture;
        else
            result = QGestureRecognizer::FinishGesture;
        break;
    case QEvent::TouchUpdate:
        if (q->state() != Qt::NoGesture && ev->touchPoints().size() == 1) {
            QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
            QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
            if (delta.manhattanLength() <= TapRadius)
                result = QGestureRecognizer::TriggerGesture;
        }
        break;
    case QEvent::MouseButtonPress:
    case QEvent::MouseMove:
    case QEvent::MouseButtonRelease:
        result = QGestureRecognizer::Ignore;
        break;
    default:
        result = QGestureRecognizer::Ignore;
        break;
    }
    return result;
}
QGestureRecognizer::Result
WebosTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
                                        QEvent *event)
{
    QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture;
    WebosTapAndHoldGesture *q = static_cast<WebosTapAndHoldGesture *>(state);

    if (object == state && event->type() == QEvent::Timer) {
        q->stopTapTimer();
        if (q->state() != Qt::NoGesture && q->state() != Qt::GestureCanceled) {
            result = QGestureRecognizer::FinishGesture;
        }
        return result | QGestureRecognizer::ConsumeEventHint;
    }

    const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);

    //Todo Here use a const value to set up the timer interval but maybe need to use the Timeout value
    //enum { TimerInterval = 700 };
    enum { TapRadius = 40 };
    switch (event->type()) {
    case QEvent::TouchBegin:
        q->setPosition(ev->touchPoints().at(0).startScreenPos());
        q->setHotSpot(q->position());
        q->stopTapTimer();
        q->startTapTimer();
        return QGestureRecognizer::TriggerGesture;
    case QEvent::TouchEnd:
        result = QGestureRecognizer::CancelGesture;
        q->stopTapTimer();
        break;
    case QEvent::TouchUpdate:
        if (q->tapTimerId() && ev->touchPoints().size() == 1) {
            QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
            QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
            if (delta.manhattanLength() > TapRadius) {
                result = QGestureRecognizer::CancelGesture;
                q->stopTapTimer();
            } else {
                result = QGestureRecognizer::Ignore;
            }
        } else if (ev->touchPoints().size() > 1) {
            result = QGestureRecognizer::CancelGesture;
            q->stopTapTimer();
        } else {
            result = QGestureRecognizer::Ignore;
        }
        break;
    default:
        return QGestureRecognizer::Ignore;
    }
    return result;
}
Ejemplo n.º 14
0
WebGestureEvent WebEventFactory::createWebGestureEvent(const QTouchEvent::TouchPoint& point, const WebEvent::Type& gestureType, const QTransform& fromItemTransform)
{
    WebEvent::Type type             = gestureType;
    IntPoint position               = fromItemTransform.map(point.pos()).toPoint();
    IntPoint screenPosition         = point.screenPos().toPoint();
    WebEvent::Modifiers modifiers   = WebEvent::Modifiers(0);
    double timestamp                = 0;
    IntSize area                    = IntSize(point.rect().size().toSize());
    FloatPoint delta                = FloatPoint(0, 0);

    return WebGestureEvent(type, position, screenPosition, modifiers, timestamp, area, delta);
}
Ejemplo n.º 15
0
QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &s)
{
	dbg.nospace() << "\"TouchPoint\":"
			<< "{ \"id\":" << s.id()
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
			<< ", \"primary\":\"" << (s.isPrimary() ? "true" : "false") << "\""
#endif
			<< ", \"state\":" << touchStateToString(s.state())
			<< ", \"pos\":\"" << s.pos() << "\""
			<< ", \"pressure\":\"" << s.pressure() << "\""
			<< " }";
	return dbg.space();
}
Ejemplo n.º 16
0
PlatformTouchPoint::PlatformTouchPoint(const QTouchEvent::TouchPoint& point)
{
    // The QTouchEvent::TouchPoint API states that ids will be >= 0.
    m_id = static_cast<unsigned>(point.id());
    switch (point.state()) {
    case Qt::TouchPointReleased: m_state = TouchReleased; break;
    case Qt::TouchPointMoved: m_state = TouchMoved; break;
    case Qt::TouchPointPressed: m_state = TouchPressed; break;
    case Qt::TouchPointStationary: m_state = TouchStationary; break;
    }
    m_screenPos = point.screenPos().toPoint();
    m_pos = point.pos().toPoint();
}
Ejemplo n.º 17
0
QGestureRecognizer::Result QTapGestureRecognizer::recognize(QGesture *state,
                                                            QObject *,
                                                            QEvent *event)
{
    QTapGesture *q = static_cast<QTapGesture *>(state);
    QTapGesturePrivate *d = q->d_func();

    const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);

    QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture;

    switch (event->type()) {
    case QEvent::TouchBegin: {
        d->position = ev->touchPoints().at(0).pos();
        q->setHotSpot(ev->touchPoints().at(0).screenPos());
        result = QGestureRecognizer::TriggerGesture;
        break;
    }
    case QEvent::TouchUpdate:
    case QEvent::TouchEnd: {
        if (q->state() != Qt::NoGesture && ev->touchPoints().size() == 1) {
            QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
            QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
            enum { TapRadius = 40 };
            if (delta.manhattanLength() <= TapRadius) {
                if (event->type() == QEvent::TouchEnd)
                    result = QGestureRecognizer::FinishGesture;
                else
                    result = QGestureRecognizer::TriggerGesture;
            }
        }
        break;
    }
    case QEvent::MouseButtonPress:
    case QEvent::MouseMove:
    case QEvent::MouseButtonRelease:
        result = QGestureRecognizer::Ignore;
        break;
    default:
        result = QGestureRecognizer::Ignore;
        break;
    }
    return result;
}
Ejemplo n.º 18
0
PlatformTouchPoint::PlatformTouchPoint(const QTouchEvent::TouchPoint& point, State state)
    // The QTouchEvent::TouchPoint API states that ids will be >= 0.
    : m_id(point.id())
    , m_state(state)
    , m_screenPos(point.screenPos().toPoint())
    , m_pos(point.pos().toPoint())
{
    // Qt reports touch point size as rectangles, but we will pretend it is an oval.
    QRect touchRect = point.rect().toAlignedRect();
    if (touchRect.isValid()) {
        m_radiusX = point.rect().width() / 2;
        m_radiusY = point.rect().height() / 2;
    } else {
        // http://www.w3.org/TR/2011/WD-touch-events-20110505: 1 if no value is known.
        m_radiusX = 1;
        m_radiusY = 1;
    }
    m_force = point.pressure();
    // FIXME: Support m_rotationAngle if QTouchEvent at some point supports it.
}
Ejemplo n.º 19
0
void TouchInputDevice::processTouch(QEvent *e)
{
	m_numPoints = 0;

	QTouchEvent *touchEvent = static_cast<QTouchEvent *>(e);
	QList<QTouchEvent::TouchPoint> points = touchEvent->touchPoints();

	for (int i = 0; i < points.size(); i++) {
		QTouchEvent::TouchPoint point = points.at(i);
		if (point.state() & Qt::TouchPointReleased)
			continue;

		m_points[m_numPoints] = point.pos().toPoint();
		m_numPoints++;
		if (m_numPoints >= MaxPoints)
			break;
	}

	m_converted = false;
}
bool ModelSelectionPane::eventFilter(QObject *obj, QEvent *event)
{
    bool flipAction = false;
    static float last_x = 0.0f;
    static float touchBeginLastX = 0.0f;

    int deltaX = 0;
    float acceleration = 0.0f;

    switch(event->type()) {
#if 0
    case QEvent::TouchBegin: {
        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchBegin";
        flipAction = true;
        m_time.start();
        const QTouchEvent *touchEvent = static_cast<const QTouchEvent *>(event);
        QTouchEvent::TouchPoint touchPoint = touchEvent->touchPoints().first();
        last_x = touchPoint.pos().x();
        touchBeginLastX = touchPoint.pos().x();
    }
        break;
    case QEvent::TouchUpdate: {
        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchUpdate";
        flipAction = true;
        const QTouchEvent *touchEvent = static_cast<const QTouchEvent *>(event);
        QTouchEvent::TouchPoint touchPoint = touchEvent->touchPoints().first();
        deltaX = touchPoint.pos().x() - last_x;
        last_x = touchPoint.pos().x();
    }
        break;

    case QEvent::TouchEnd: {
        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchEnd";
        flipAction = true;
        const QTouchEvent *touchEvent = static_cast<const QTouchEvent *>(event);
        QTouchEvent::TouchPoint touchPoint = touchEvent->touchPoints().first();
        int elapseTime = m_time.elapsed();
        LogManagerInst << LogManager::LogDegreeType_Normal  << "elapseTime" << QString::number(elapseTime);
        deltaX = touchPoint.pos().x() - last_x;
        acceleration = (touchPoint.pos().x() - touchBeginLastX) / elapseTime;
    }
        break;
#else

    case QEvent::MouseButtonPress: {
 //       LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchBegin";
        flipAction = true;
        m_time.start();
        const QMouseEvent *mouseEvent = static_cast<const QMouseEvent *>(event);
        last_x = mouseEvent->x();
        touchBeginLastX = mouseEvent->x();
    }
        break;

    case QEvent::MouseMove: {
 //       LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchUpdate";
        flipAction = true;
        const QMouseEvent *mouseEvent = static_cast<const QMouseEvent *>(event);
        deltaX = mouseEvent->x() - last_x;
        last_x = mouseEvent->x();
    }
        break;

    case QEvent::MouseButtonRelease: {
//        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchEnd";
        flipAction = true;
        int elapseTime = m_time.elapsed();
 //       LogManagerInst << LogManager::LogDegreeType_Normal  << "elapseTime" << QString::number(elapseTime);
        const QMouseEvent *mouseEvent = static_cast<const QMouseEvent *>(event);
        deltaX = mouseEvent->x() - last_x;
        acceleration = (mouseEvent->x() - touchBeginLastX) / elapseTime;
    }
        break;
#endif
    default:
        break;
    }

    if(flipAction) {
//        const QTouchEvent *touchEvent = static_cast<const QTouchEvent *>(event);
//        QTouchEvent::TouchPoint touchPoint = touchEvent->touchPoints().first();
//        LogManagerInst << LogManager::LogDegreeType_Normal << "FlipInfo"
 //                      << "deltaX" << QString::number(deltaX)
 //                      << "acceleration" << QString::number(acceleration);
  //                     << "TouchPostion" << QString::number(touchPoint.pos().x())
  //                     << "TouchPoints" << QString::number(touchEvent->touchPoints().size());

        if(acceleration != 0) {
            if((acceleration > 1) || (deltaX > width()/2)) {
                FlipAnimationStart(deltaX > 0 ? FlipDirection_Right : FlipDirection_Left);
            }
        } else {
   //         LogManagerInst << LogManager::LogDegreeType_Normal << "Position" << QString::number(ui->itemsetpane->x());
            QPoint targetPos = ui->itemsetpane->pos()+QPoint(deltaX,0);
            if(targetPos.x() > width()/4) {
                targetPos.setX(width()/4);
            } else if(targetPos.x() < width() - m_itemSetPaneSize.width() - width()/4) {
                targetPos.setX(width() - m_itemSetPaneSize.width() - width()/4);
            } else {

            }
            qDebug() << ui->itemsetpane->pos();
            ui->itemsetpane->move(targetPos);
    //        ui->itemsetpane->update();
    //        this->move(targetPos);
        }

    }

    return obj->event(event);
}
bool ModelSelectionPane::event(QEvent *event)
{
#if 0
    if(event->type() == QEvent::Gesture) {
        LogManagerInst << LogManager::LogDegreeType_Normal << "QEvent::Gesture";
        QGestureEvent* gestureEvent = static_cast<QGestureEvent*>(event);
        QGesture *gesture = gestureEvent->gesture(Qt::PanGesture);
        if(NULL == gestureEvent) {
            LogManagerInst << LogManager::LogDegreeType_Error << "QEvent::Gesture is NULL";
        }else {
            QList<QGesture *> gestures = gestureEvent->gestures();
            QList<QGesture *> activeGestures = gestureEvent->activeGestures();

            LogManagerInst << "Gesture Value" << QString::number((int)gesture, 16);

            LogManagerInst << LogManager::LogDegreeType_Normal << "Gesture Count" << QString::number(gestures.count()) << "activeGestures Count" << QString::number(activeGestures.count());
            LogManagerInst << LogManager::LogDegreeType_Normal
                << (gestureEvent->gesture(Qt::TapGesture) != NULL?"TapGesture":"")
                << (gestureEvent->gesture(Qt::TapAndHoldGesture) != NULL?"TapAndHoldGesture":"")
                << ((NULL != gesture)?"PanGesture":"")
                << (gestureEvent->gesture(Qt::PinchGesture) != NULL?"PinchGesture":"")
                << (gestureEvent->gesture(Qt::SwipeGesture) != NULL?"SwipeGesture":"") ;
        }

        LogManagerInst << (gesture == NULL?"PanGesture == NULL":"PanGesture != NULL");
        if(gesture != NULL) {
            LogManagerInst << LogManager::LogDegreeType_Normal << "Handle Pan Gesture";
            QPanGesture* panGesture = static_cast<QPanGesture*>(gesture);
            LogManagerInst << LogManager::LogDegreeType_Normal << "Acceleration" << QString::number(panGesture->acceleration());
            LogManagerInst << LogManager::LogDegreeType_Normal << "delta" << QString::number(panGesture->delta().x());
            LogManagerInst << LogManager::LogDegreeType_Normal << "State" << QString::number(gesture->state());
            if(gesture->state() == Qt::GestureFinished) {
                if((panGesture->acceleration() > 2) || (panGesture->delta().x() > width()/2)) {
                    FlipAnimationStart(panGesture->delta().x() > 0 ? FlipDirection_Right : FlipDirection_Left);
                }
            } else {
                LogManagerInst << LogManager::LogDegreeType_Normal << "Position" << QString::number(ui->itemsetpane->x());
                QPoint targetPos = ui->itemsetpane->pos()+QPoint(panGesture->delta().x(),0);
                if(targetPos.x() > width()/4) {
                    targetPos.setX(width()/4);
                } else if(targetPos.x() < width() - m_itemSetPaneSize.width() - width()/4) {
                    targetPos.setX(width() - m_itemSetPaneSize.width() - width()/4);
                } else {

                }
                ui->itemsetpane->move(targetPos);
            }
        }
    }
#endif

#if 1
    /*****
     * 外面是阴天,我也成了阴天
     * 狗屎的Gesture
     * Document明明图示QPanGesture是一个手指
     * 源码里却他妈的是3个
     * 你他妈的逗我么
     * 我就是个秀逗
     * 明天dota只能用秀逗了
     * 悲剧啊悲剧啊
     * 我的时间
     * 如同我的身体老去
     *****/

    bool flipAction = false;
    static float last_x = 0.0f;
    static float touchBeginLastX = 0.0f;

    int deltaX = 0;
    float acceleration = 0.0f;

    switch(event->type()) {
#if 1
    case QEvent::TouchBegin: {
        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchBegin";
        flipAction = true;
        m_time.start();
        const QTouchEvent *touchEvent = static_cast<const QTouchEvent *>(event);
        QTouchEvent::TouchPoint touchPoint = touchEvent->touchPoints().first();
        last_x = touchPoint.pos().x();
        touchBeginLastX = touchPoint.pos().x();
    }
        break;
    case QEvent::TouchUpdate: {
        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchUpdate";
        flipAction = true;
        const QTouchEvent *touchEvent = static_cast<const QTouchEvent *>(event);
        QTouchEvent::TouchPoint touchPoint = touchEvent->touchPoints().first();
        deltaX = touchPoint.pos().x() - last_x;
        last_x = touchPoint.pos().x();
    }
        break;

    case QEvent::TouchEnd: {
        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchEnd";
        flipAction = true;
        const QTouchEvent *touchEvent = static_cast<const QTouchEvent *>(event);
        QTouchEvent::TouchPoint touchPoint = touchEvent->touchPoints().first();
        int elapseTime = m_time.elapsed();
        LogManagerInst << LogManager::LogDegreeType_Normal  << "elapseTime" << QString::number(elapseTime);
        deltaX = touchPoint.pos().x() - last_x;
        acceleration = (touchPoint.pos().x() - touchBeginLastX) / elapseTime;
    }
        break;
#else

    case QEvent::MouseButtonPress: {
        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchBegin";
        flipAction = true;
        m_time.start();
        const QMouseEvent *mouseEvent = static_cast<const QMouseEvent *>(event);
        last_x = mouseEvent->x();
        touchBeginLastX = mouseEvent->x();
    }
        break;

    case QEvent::MouseMove: {
        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchUpdate";
        flipAction = true;
        const QMouseEvent *mouseEvent = static_cast<const QMouseEvent *>(event);
        deltaX = mouseEvent->x() - last_x;
        last_x = mouseEvent->x();
    }
        break;

    case QEvent::MouseButtonRelease: {
        LogManagerInst << LogManager::LogDegreeType_Normal  << "TouchEnd";
        flipAction = true;
        int elapseTime = m_time.elapsed();
        LogManagerInst << LogManager::LogDegreeType_Normal  << "elapseTime" << QString::number(elapseTime);
        const QMouseEvent *mouseEvent = static_cast<const QMouseEvent *>(event);
        deltaX = mouseEvent->x() - last_x;
        acceleration = (mouseEvent->x() - touchBeginLastX) / elapseTime;
    }
        break;
#endif
    default:
        break;
    }

    if(flipAction) {
//        const QTouchEvent *touchEvent = static_cast<const QTouchEvent *>(event);
//        QTouchEvent::TouchPoint touchPoint = touchEvent->touchPoints().first();
        LogManagerInst << LogManager::LogDegreeType_Normal << "FlipInfo"
                       << "deltaX" << QString::number(deltaX)
                       << "acceleration" << QString::number(acceleration);
  //                     << "TouchPostion" << QString::number(touchPoint.pos().x())
  //                     << "TouchPoints" << QString::number(touchEvent->touchPoints().size());

        if(acceleration != 0) {
            if((acceleration > 1) || (deltaX > width()/2)) {
                FlipAnimationStart(deltaX > 0 ? FlipDirection_Right : FlipDirection_Left);
            }
        } else {
            LogManagerInst << LogManager::LogDegreeType_Normal << "Position" << QString::number(ui->itemsetpane->x());
            QPoint targetPos = ui->itemsetpane->pos()+QPoint(deltaX,0);
            if(targetPos.x() > width()/4) {
                targetPos.setX(width()/4);
            } else if(targetPos.x() < width() - m_itemSetPaneSize.width() - width()/4) {
                targetPos.setX(width() - m_itemSetPaneSize.width() - width()/4);
            } else {

            }

            ui->itemsetpane->move(targetPos);
            ui->itemsetpane->update();
        }

    }
#endif

    return PaneBase::event(event);
}
Ejemplo n.º 22
0
QGestureRecognizer::Result
QTapAndHoldGestureRecognizer::recognize(QGesture *state, QObject *object,
                                        QEvent *event)
{
#ifndef QT_WEBOS
    QTapAndHoldGesture *q = static_cast<QTapAndHoldGesture *>(state);
    QTapAndHoldGesturePrivate *d = q->d_func();

    if (object == state && event->type() == QEvent::Timer) {
        q->killTimer(d->timerId);
        d->timerId = 0;
        return QGestureRecognizer::FinishGesture | QGestureRecognizer::ConsumeEventHint;
    }

    const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);
    const QMouseEvent *me = static_cast<const QMouseEvent *>(event);
#ifndef QT_NO_GRAPHICSVIEW
    const QGraphicsSceneMouseEvent *gsme = static_cast<const QGraphicsSceneMouseEvent *>(event);
#endif

    enum { TapRadius = 40 };

    switch (event->type()) {
#ifndef QT_NO_GRAPHICSVIEW
    case QEvent::GraphicsSceneMousePress:
        d->position = gsme->screenPos();
        q->setHotSpot(d->position);
        if (d->timerId)
            q->killTimer(d->timerId);
        d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout);
        return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout
#endif
    case QEvent::MouseButtonPress:
        d->position = me->globalPos();
        q->setHotSpot(d->position);
        if (d->timerId)
            q->killTimer(d->timerId);
        d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout);
        return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout
    case QEvent::TouchBegin:
        d->position = ev->touchPoints().at(0).startScreenPos();
        q->setHotSpot(d->position);
        if (d->timerId)
            q->killTimer(d->timerId);
        d->timerId = q->startTimer(QTapAndHoldGesturePrivate::Timeout);
        return QGestureRecognizer::MayBeGesture; // we don't show a sign of life until the timeout
#ifndef QT_NO_GRAPHICSVIEW
    case QEvent::GraphicsSceneMouseRelease:
#endif
    case QEvent::MouseButtonRelease:
    case QEvent::TouchEnd:
        return QGestureRecognizer::CancelGesture; // get out of the MayBeGesture state
    case QEvent::TouchUpdate:
        if (d->timerId && ev->touchPoints().size() == 1) {
            QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
            QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
            if (delta.manhattanLength() <= TapRadius)
                return QGestureRecognizer::MayBeGesture;
        }
        return QGestureRecognizer::CancelGesture;
    case QEvent::MouseMove: {
        QPoint delta = me->globalPos() - d->position.toPoint();
        if (d->timerId && delta.manhattanLength() <= TapRadius)
            return QGestureRecognizer::MayBeGesture;
        return QGestureRecognizer::CancelGesture;
    }
#ifndef QT_NO_GRAPHICSVIEW
    case QEvent::GraphicsSceneMouseMove: {
        QPoint delta = gsme->screenPos() - d->position.toPoint();
        if (d->timerId && delta.manhattanLength() <= TapRadius)
            return QGestureRecognizer::MayBeGesture;
        return QGestureRecognizer::CancelGesture;
    }
#endif
    default:
        return QGestureRecognizer::Ignore;
    }
#else
    QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture;
    QTapAndHoldGesture *q = static_cast<QTapAndHoldGesture *>(state);
    QTapAndHoldGesturePrivate *d = q->d_func();

    if (object == state && event->type() == QEvent::Timer) {
        q->killTimer(d->timerId);
        d->timerId = 0;
        if (q->state() != Qt::NoGesture && q->state() != Qt::GestureCanceled) {
        	result = QGestureRecognizer::FinishGesture;
        }
        return result | QGestureRecognizer::ConsumeEventHint;
    }

    const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);

    enum { TimerInterval = 700 };
    enum { TapRadius = 40 };

    switch (event->type()) {
    case QEvent::TouchBegin:
        d->position = ev->touchPoints().at(0).startScreenPos();
        q->setHotSpot(d->position);
        if (d->timerId)
            q->killTimer(d->timerId);
        d->timerId = q->startTimer(TimerInterval);
        return QGestureRecognizer::TriggerGesture;
    case QEvent::TouchEnd:
		result = QGestureRecognizer::CancelGesture;
		if (d->timerId)
			q->killTimer(d->timerId);
		d->timerId = 0;
        break;
    case QEvent::TouchUpdate:
        if (d->timerId && ev->touchPoints().size() == 1) {
            QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
            QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
            if (delta.manhattanLength() > TapRadius) {
                result = QGestureRecognizer::CancelGesture;
				if (d->timerId)
	                q->killTimer(d->timerId);
				d->timerId = 0;
            } else {
            	result = QGestureRecognizer::Ignore;
            }
        } else if (ev->touchPoints().size() > 1) {
        	result = QGestureRecognizer::CancelGesture;
			if (d->timerId)
	        	q->killTimer(d->timerId);
			d->timerId = 0;
        } else {
        	result = QGestureRecognizer::Ignore;
        }
		break;
    default:
        return QGestureRecognizer::Ignore;
    }
    return result;
#endif // QT_WEBOS
}
Ejemplo n.º 23
0
QGestureRecognizer::Result QTapGestureRecognizer::recognize(QGesture *state,
                                                            QObject *,
                                                            QEvent *event)
{
    QTapGesture *q = static_cast<QTapGesture *>(state);
    QTapGesturePrivate *d = q->d_func();

    const QTouchEvent *ev = static_cast<const QTouchEvent *>(event);

    QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture;

    switch (event->type()) {
    case QEvent::TouchBegin: {
#ifndef QT_WEBOS // REBASE_CHECK_REQUIRED necessary?
        d->position = ev->touchPoints().at(0).pos();
        q->setHotSpot(ev->touchPoints().at(0).screenPos());
#else // QT_WEBOS
        QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
        d->position = p.pos();
        d->hotSpot = p.screenPos();
        d->isHotSpotSet = true;
#endif // QT_WEBOS
        result = QGestureRecognizer::TriggerGesture;
        break;
    }
    case QEvent::TouchUpdate:
    case QEvent::TouchEnd: {
        if (q->state() != Qt::NoGesture && ev->touchPoints().size() == 1) {
            QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
#ifdef QT_WEBOS // REBASE_CHECK_REQUIRED use setHotSpot?
            d->hotSpot = p.screenPos();
            d->isHotSpotSet = true;
#endif // QT_WEBOS
            QPoint delta = p.pos().toPoint() - p.startPos().toPoint();
            enum { TapRadius = 40 };
            if (delta.manhattanLength() <= TapRadius) {
                if (event->type() == QEvent::TouchEnd)
                    result = QGestureRecognizer::FinishGesture;
                else
                    result = QGestureRecognizer::TriggerGesture;
            }
        }
        break;
    }
    case QEvent::MouseButtonPress:
    case QEvent::MouseMove:
    case QEvent::MouseButtonRelease:
        result = QGestureRecognizer::Ignore;
        break;
#ifdef QT_WEBOS
    case QEvent::Gesture:
    {
    	QGesture* g = static_cast<QGestureEvent*>(event)->gesture(Qt::SysMgrGestureFlick);
		if (g && g->state() == Qt::GestureFinished && q->state() != Qt::NoGesture ) {
			result = QGestureRecognizer::CancelGesture;
			break;
		}
        g = static_cast<QGestureEvent*>(event)->gesture(Qt::SysMgrGestureScreenEdgeFlick);
        if (g && g->state() == Qt::GestureFinished && q->state() != Qt::NoGesture ) {
            result = QGestureRecognizer::CancelGesture;
            break;
        }
    }
    // fall through
#endif // QT_WEBOS
    default:
        result = QGestureRecognizer::Ignore;
        break;
    }
    return result;
}
Ejemplo n.º 24
0
bool QIGraphicsView::event(QEvent *pEvent)
{
    /* Handle known event types: */
    switch (pEvent->type())
    {
        case QEvent::TouchBegin:
        {
            /* Parse the touch event: */
            QTouchEvent *pTouchEvent = static_cast<QTouchEvent*>(pEvent);
            AssertPtrReturn(pTouchEvent, QGraphicsView::event(pEvent));
            /* For touch-screen event we have something special: */
            if (pTouchEvent->deviceType() == QTouchEvent::TouchScreen)
            {
                /* Remember where the scrolling was started: */
                m_iVerticalScrollBarPosition = verticalScrollBar()->value();
                /* Allow further touch events: */
                pEvent->accept();
                /* Mark event handled: */
                return true;
            }
            break;
        }
        case QEvent::TouchUpdate:
        {
            /* Parse the touch-event: */
            QTouchEvent *pTouchEvent = static_cast<QTouchEvent*>(pEvent);
            AssertPtrReturn(pTouchEvent, QGraphicsView::event(pEvent));
            /* For touch-screen event we have something special: */
            if (pTouchEvent->deviceType() == QTouchEvent::TouchScreen)
            {
                /* Determine vertical shift (inverted): */
                const QTouchEvent::TouchPoint point = pTouchEvent->touchPoints().first();
                const int iShift = (int)(point.startPos().y() - point.pos().y());
                /* Calculate new scroll-bar value according calculated shift: */
                int iNewScrollBarValue = m_iVerticalScrollBarPosition + iShift;
                /* Make sure new scroll-bar value is within the minimum/maximum bounds: */
                iNewScrollBarValue = qMax(verticalScrollBar()->minimum(), iNewScrollBarValue);
                iNewScrollBarValue = qMin(verticalScrollBar()->maximum(), iNewScrollBarValue);
                /* Apply calculated scroll-bar shift finally: */
                verticalScrollBar()->setValue(iNewScrollBarValue);
                /* Mark event handled: */
                return true;
            }
            break;
        }
        case QEvent::TouchEnd:
        {
            /* Parse the touch event: */
            QTouchEvent *pTouchEvent = static_cast<QTouchEvent*>(pEvent);
            AssertPtrReturn(pTouchEvent, QGraphicsView::event(pEvent));
            /* For touch-screen event we have something special: */
            if (pTouchEvent->deviceType() == QTouchEvent::TouchScreen)
            {
                /* Reset the scrolling start position: */
                m_iVerticalScrollBarPosition = 0;
                /* Mark event handled: */
                return true;
            }
            break;
        }
        default:
            break;
    }
    /* Call to base-class: */
    return QGraphicsView::event(pEvent);
}
Ejemplo n.º 25
0
void QtWebPageEventHandler::handleDoubleTapEvent(const QTouchEvent::TouchPoint& point)
{
    m_webPageProxy->findZoomableAreaForPoint(point.pos().toPoint());
}
Ejemplo n.º 26
0
void QtWebPageEventHandler::handleSingleTapEvent(const QTouchEvent::TouchPoint& point)
{
    WebGestureEvent gesture(WebEvent::GestureSingleTap, point.pos().toPoint(), point.screenPos().toPoint(), WebEvent::Modifiers(0), 0);
    m_webPageProxy->handleGestureEvent(gesture);
}
Ejemplo n.º 27
0
void QtWebPageEventHandler::handleDoubleTapEvent(const QTouchEvent::TouchPoint& point)
{
    QTransform fromItemTransform = m_webPage->transformFromItem();
    m_webPageProxy->findZoomableAreaForPoint(fromItemTransform.map(point.pos()).toPoint(), IntSize(point.rect().size().toSize()));
}
Ejemplo n.º 28
0
bool MouseHoverable::eventFilter(QObject *o, QEvent *e)
{
    bool prevHovered = m_hovered;
    if (m_composite->underMouse())
    {
        m_hovered = true;
    }
    else
    {
        m_hovered = false;
    }
    if (prevHovered == m_hovered)
    {
        return false;
    }
    else
    {
        int diff = m_lastMouseEvent.msecsTo(QTime::currentTime()) - UI_MOUSEOVERDURATION;
        if (diff < 0)
        {
            m_lastMouseEvent = QTime::currentTime().addMSecs(diff);
        }
        else
            m_lastMouseEvent = QTime::currentTime();
        m_animTimer.start(UI_FRAMETIME / 2);
    }
    return false;

    QTouchEvent *te = static_cast<QTouchEvent*>(e);
    if ((!m_hovered) && (e->type() == QEvent::TouchBegin))
    {
        if (te->touchPoints().size() == 1)
        {
            QTouchEvent::TouchPoint p = te->touchPoints().at(0);
            if (m_composite->rect().contains(p.pos().x(), p.pos().y()))
            {
                m_hovered = true;
            }
        }
    }
    else if (e->type() == QEvent::TouchUpdate)
    {
        if (te->touchPoints().size() == 1)
        {
            QTouchEvent::TouchPoint p = te->touchPoints().at(0);
            if (m_composite->rect().contains(p.pos().x(), p.pos().y()))
            {
                m_hovered = true;
            }
            else
            {
                m_hovered = false;
            }
        }
    }
    else if (e->type() == QEvent::TouchCancel)
    {
        m_hovered = false;
    }
    else if (e->type() == QEvent::TouchEnd)
    {
        if (te->touchPoints().size() == 1)
        {
            m_hovered = false;
        }
    }
#ifndef Q_OS_ANDROID
    if (e->type() == QEvent::Enter)
    {
        m_hovered = true;
    }
    if (e->type() == QEvent::Leave)
    {
        m_hovered = false;
    }
#endif
    if (prevHovered == m_hovered)
    {
        return false;
    }
    if ((e->type() == QEvent::Enter) || (e->type() == QEvent::Leave)
            || (e->type() == QEvent::TouchBegin) || (e->type() == QEvent::TouchEnd))
    {
        int diff = m_lastMouseEvent.msecsTo(QTime::currentTime()) - UI_MOUSEOVERDURATION;
        if (diff < 0)
        {
            m_lastMouseEvent = QTime::currentTime().addMSecs(diff);
        }
        else
            m_lastMouseEvent = QTime::currentTime();
        m_animTimer.start(UI_FRAMETIME / 2);
    }
    return false;
}
static inline QPointF computeTouchCenter(const QTouchEvent::TouchPoint& point1, const QTouchEvent::TouchPoint& point2)
{
    return (point1.pos() + point2.pos()) / 2.0f;
}
Ejemplo n.º 30
0
// generateTouchEvent - iterates through existing touches and creates a QTouchEvent.
// For the primary finger, it also creates a mouse event if the location has move
void QPAHiddTpHandler::generateTouchEvent()
{
	if (m_touches.empty())
		return;
	
	QList<QTouchEvent::TouchPoint> touchPoints;
	QList<HiddTouch>::const_iterator it;

	QWidget* widget = QWidget::mouseGrabber();
	if (!widget) {
		QWidget* window = QApplication::topLevelAt(m_lastTouchDown);
		if (window)
			widget = window->childAt(window->mapFromGlobal(m_lastTouchDown));
	}

	if (!widget) {
		QPoint dummyPt(10, 10);
		QWidget* window = QApplication::topLevelAt(dummyPt);
		if (window)
			widget = window->childAt(window->mapFromGlobal(dummyPt));
	}
	if(!widget) {
	    widget = QApplication::activeWindow();
	    if(QApplication::focusWidget())
	    {
		widget = QApplication::focusWidget();
	    }
	}
	Qt::KeyboardModifiers keyboardModifiers = QApplication::keyboardModifiers();

	if (widget && m_sendPenCancel) {
		//printf("Mouse Up for Pen Cancel: %d, %d\n", m_penCancelPoint.x(), m_penCancelPoint.y());
		QMouseEvent ev(QEvent::MouseButtonRelease, m_penCancelPoint, m_penCancelPoint, true,
				Qt::LeftButton, Qt::NoButton, keyboardModifiers);
		qt_sendSpontaneousEvent((QObject*) widget, &ev);							
		m_sendPenCancel = false;
		m_penCancelPoint = QPoint (0,0);
	}
	
	for (it = m_touches.begin(); it != m_touches.end(); ++it) {
		QTouchEvent::TouchPoint touchPoint;
		touchPoint.setId(it->id);
		touchPoint.setPos(QPoint(it->x, it->y));

		touchPoint.setScreenPos(touchPoint.pos());
		switch (it->state) {
		case QPAHiddTpHandler::FingerDown:
			touchPoint.setState(Qt::TouchPointPressed);
			break;
		case QPAHiddTpHandler::FingerUp:
			touchPoint.setState(Qt::TouchPointReleased);
			break;
		case QPAHiddTpHandler::FingerMove:
			touchPoint.setState(Qt::TouchPointMoved);
			break;
		default:
			touchPoint.setState(Qt::TouchPointStationary);
			break;
		}

		if (it->isPrimary) {
			touchPoint.setState(touchPoint.state() | Qt::TouchPointPrimary);
		}

		touchPoints.append(touchPoint);
//		printf ("%s: adding touch point id %d (hiddId %llu) for pos (%d, %d) primary %d\n", 
//			__func__, it->id, it->hiddId, it->x, it->y, it->isPrimary);

		if (it->isPrimary) {

			QPoint mousePos = QPoint(it->x, it->y);
			if (widget) {
				
				if (it->state == QPAHiddTpHandler::FingerDown) {

					uint32_t currTime = m_touchTimer.elapsed();
					int dx = mousePos.x() - m_mousePress.x();
					int dy = mousePos.y() - m_mousePress.y();
					
					if (((currTime - m_mousePressTime) < (uint32_t) QApplication::doubleClickInterval()) &&
						((dx * dx + dy * dy) <= 144)) {

						//printf("Mouse Double Click: %d, %d\n", mousePos.x(), mousePos.y());
						QMouseEvent ev(QEvent::MouseButtonDblClick, mousePos, mousePos,
									   Qt::LeftButton, Qt::LeftButton, keyboardModifiers);
						qt_sendSpontaneousEvent((QObject*) widget, &ev);

						m_mousePressTime = 0;
					}
					else {

						//printf("Mouse Down: %d, %d\n", mousePos.x(), mousePos.y());
						QMouseEvent ev(QEvent::MouseButtonPress, mousePos, mousePos,
									   Qt::LeftButton, Qt::LeftButton, keyboardModifiers);
						qt_sendSpontaneousEvent((QObject*) widget, &ev);

						m_mousePress = mousePos;

						m_mousePressTime = currTime;
					}

				} else if (it->state == QPAHiddTpHandler::FingerMove) {
					//printf("Mouse Move: %d, %d\n", mousePos.x(), mousePos.y());
					QMouseEvent ev(QEvent::MouseMove, mousePos, mousePos,
								   Qt::LeftButton, Qt::LeftButton, keyboardModifiers);
					qt_sendSpontaneousEvent((QObject*) widget, &ev);							
				}
			}
		}
	}
	
	//printf ("sending touch event\n");
	qt_translateRawTouchEvent(QApplication::activeWindow(), QTouchEvent::TouchScreen, touchPoints);

	for (it = m_touches.begin(); it != m_touches.end(); ++it) {

		if (it->isPrimary) {

			QPoint mousePos = QPoint(it->x, it->y);
			if (widget) {
			
				if (it->state == QPAHiddTpHandler::FingerUp) {
					//printf("Mouse Up: %d, %d\n", mousePos.x(), mousePos.y());
					QMouseEvent ev(QEvent::MouseButtonRelease, mousePos, mousePos,
								   Qt::LeftButton, Qt::NoButton, keyboardModifiers);
					qt_sendSpontaneousEvent((QObject*) widget, &ev);			
				}
			}
		}
	}
}