Make touch events working in the qml example compositor.
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Wed, 11 Jan 2012 14:18:21 +0000 (16:18 +0200)
committerJørgen Lind <jorgen.lind@nokia.com>
Wed, 11 Jan 2012 19:40:19 +0000 (20:40 +0100)
Change-Id: I03318359d13caf7287671bcc9e01da91acb928dd
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
src/compositor/compositor_api/waylandsurfaceitem.cpp

index 8d34232..9ecd79e 100644 (file)
@@ -106,6 +106,7 @@ void WaylandSurfaceItem::init(WaylandSurface *surface)
     setSmooth(true);
     setFlag(ItemHasContents);
     setAcceptedMouseButtons(Qt::LeftButton | Qt::RightButton);
+    setAcceptHoverEvents(true);
     connect(surface, SIGNAL(mapped()), this, SLOT(surfaceMapped()));
     connect(surface, SIGNAL(unmapped()), this, SLOT(surfaceUnmapped()));
     connect(surface, SIGNAL(destroyed(QObject *)), this, SLOT(surfaceDestroyed(QObject *)));
@@ -189,15 +190,14 @@ void WaylandSurfaceItem::touchEvent(QTouchEvent *event)
     if (m_touchEventsEnabled && m_surface) {
         WaylandInputDevice *inputDevice = m_surface->compositor()->defaultInputDevice();
         event->accept();
-        QList<QTouchEvent::TouchPoint> points = event->touchPoints();
-        if (!points.isEmpty()) {
-            for (int i = 0; i < points.count(); ++i) {
-                const QTouchEvent::TouchPoint &point(points.at(i));
-                // Wayland expects surface-relative coordinates.
-                inputDevice->sendTouchPointEvent(point.id(), point.pos().x(), point.pos().y(), point.state());
-            }
-            inputDevice->sendTouchFrameEvent();
+        if (inputDevice->mouseFocus() != m_surface) {
+            QPoint pointPos;
+            QList<QTouchEvent::TouchPoint> points = event->touchPoints();
+            if (!points.isEmpty())
+                pointPos = points.at(0).pos().toPoint();
+            inputDevice->setMouseFocus(m_surface, pointPos, pointPos);
         }
+        inputDevice->sendFullTouchEvent(event);
     } else {
         event->ignore();
     }