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. }
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); }
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())); }
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); }
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 }
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())); }
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 }