⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 109415 in webkit


Ignore:
Timestamp:
Mar 1, 2012, 1:51:26 PM (15 years ago)
Author:
abecsi@webkit.org
Message:

[Qt][WK2] Make the interaction with the Flickable work on the N9
​https://bugs.webkit.org/show_bug.cgi?id=80029

Reviewed by Simon Hausmann.

Because the WebView item accepts all touch events it receives and sends
them to the web process before propagating them to the gesture recognizers,
which is correct behaviour, we can not rely on the touch->mouse conversion
of Qt5 when controlling Flickable. Hence we need to convert the received
touch events to mouse events in the QtFlickProvider.

  • UIProcess/qt/QtFlickProvider.cpp:

(QtFlickProvider::handleTouchFlickEvent):
Do the touch to mouse event conversion for the Flickable.

  • UIProcess/qt/QtPanGestureRecognizer.cpp:

(WebKit::QtPanGestureRecognizer::recognize):
A touch begin event should cancel the previous pan gesture
and stop the ongoing flick animation.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r109405 r109415  
     12012-03-01  Andras Becsi  <andras.becsi@nokia.com>
     2
     3        [Qt][WK2] Make the interaction with the Flickable work on the N9
     4        https://bugs.webkit.org/show_bug.cgi?id=80029
     5
     6        Reviewed by Simon Hausmann.
     7
     8        Because the WebView item accepts all touch events it receives and sends
     9        them to the web process before propagating them to the gesture recognizers,
     10        which is correct behaviour, we can not rely on the touch->mouse conversion
     11        of Qt5 when controlling Flickable. Hence we need to convert the received
     12        touch events to mouse events in the QtFlickProvider.
     13
     14        * UIProcess/qt/QtFlickProvider.cpp:
     15        (QtFlickProvider::handleTouchFlickEvent):
     16        Do the touch to mouse event conversion for the Flickable.
     17        * UIProcess/qt/QtPanGestureRecognizer.cpp:
     18        (WebKit::QtPanGestureRecognizer::recognize):
     19        A touch begin event should cancel the previous pan gesture
     20        and stop the ongoing flick animation.
     21
    1222012-03-01  Anders Carlsson  <andersca@apple.com>
    223
  • trunk/Source/WebKit2/UIProcess/qt/QtFlickProvider.cpp

    r109094 r109415  
    2727#include <QCoreApplication>
    2828#include <QDeclarativeEngine>
     29#include <QMouseEvent>
    2930#include <QPointF>
     31#include <QQuickCanvas>
    3032#include <QQuickItem>
    3133#include <QTouchEvent>
    … …  
    117119}
    118120
    119 void QtFlickProvider::handleTouchFlickEvent(QTouchEvent* event)
    120 {
    121     QCoreApplication::sendEvent(m_flickable, event);
     121void QtFlickProvider::handleTouchFlickEvent(QTouchEvent* touchEvent)
     122{
     123    // Since the Flickable does not handle touch events directly the sent
     124    // touch event would end up in the WebView again and would thus trigger
     125    // an infinite loop.
     126    // Hence do the touch to mouse event conversion for the Flickable here.
     127    QEvent::Type mouseEventType = QEvent::None;
     128    Qt::MouseButton mouseButton = Qt::NoButton;
     129
     130    switch (touchEvent->type()) {
     131    case QEvent::TouchBegin:
     132        mouseEventType = QEvent::MouseButtonPress;
     133
     134        // We need to set the mouse button so that the Flickable
     135        // item receives the initial mouse press event.
     136        mouseButton = Qt::LeftButton;
     137        break;
     138    case QEvent::TouchUpdate:
     139        mouseEventType = QEvent::MouseMove;
     140        break;
     141    case QEvent::TouchEnd:
     142        mouseEventType = QEvent::MouseButtonRelease;
     143        break;
     144    default:
     145        ASSERT_NOT_REACHED();
     146        break;
     147    }
     148
     149    QPointF touchPosition = touchEvent->touchPoints().last().pos();
     150    QMouseEvent mouseEvent(mouseEventType, touchPosition, mouseButton, mouseButton, Qt::NoModifier);
     151
     152    // Send the event to the canvas and let the canvas propagate it
     153    // to the Flickable. This makes sure that the Flickable grabs
     154    // the mouse so that it also receives the events of gestures
     155    // which started inside the viewport but ended outside of it.
     156    QCoreApplication::sendEvent(m_flickable->canvas(), &mouseEvent);
    122157}
    123158
  • trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp

    r107232 r109415  
    6464        m_firstPosition = touchPoint.screenPos();
    6565        m_touchBegin.reset(new QTouchEvent(*event));
     66        interactionEngine()->panGestureCancelled();
    6667        return false;
    6768    case QEvent::TouchUpdate: {
Note: See TracChangeset for help on using the changeset viewer.