Don't crash when sending touch events.
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Wed, 11 Jan 2012 13:50:51 +0000 (15:50 +0200)
committerJørgen Lind <jorgen.lind@nokia.com>
Wed, 11 Jan 2012 19:37:56 +0000 (20:37 +0100)
Change-Id: I62bf4913338e6daa3245400b0e2c7004907cb29a
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
examples/qwindow-compositor/qwindowcompositor.cpp
src/compositor/wayland_wrapper/wlinputdevice.cpp

index eff7541..d0f14e9 100644 (file)
@@ -268,16 +268,17 @@ bool QWindowCompositor::eventFilter(QObject *obj, QEvent *event)
     case QEvent::TouchUpdate:
     case QEvent::TouchEnd:
     {
-        QSet<WaylandSurface *> targets;
+        WaylandSurface *targetSurface = 0;
         QTouchEvent *te = static_cast<QTouchEvent *>(event);
         QList<QTouchEvent::TouchPoint> points = te->touchPoints();
-        for (int i = 0; i < points.count(); ++i) {
-            const QTouchEvent::TouchPoint &tp(points.at(i));
-            WaylandSurface *targetSurface = surfaceAt(tp.pos().toPoint());
-            if (targetSurface)
-                targets.insert(targetSurface);
+        QPoint pointPos;
+        if (!points.isEmpty()) {
+            pointPos = points.at(0).pos().toPoint();
+            targetSurface = surfaceAt(pointPos);
         }
-        foreach (WaylandSurface *surface, targets)
+        if (targetSurface && targetSurface != input->mouseFocus())
+            input->setMouseFocus(targetSurface, pointPos, pointPos);
+        if (input->mouseFocus())
             input->sendFullTouchEvent(te);
         break;
     }
index 92eb122..70c0560 100644 (file)
@@ -131,7 +131,7 @@ void InputDevice::sendTouchPointEvent(int id, int x, int y, Qt::TouchPointState
     struct wl_resource *resource = base()->pointer_focus_resource;
     switch (state) {
     case Qt::TouchPointPressed:
-        wl_resource_post_event(resource, WL_INPUT_DEVICE_TOUCH_DOWN, time, this, id, x, y);
+        wl_resource_post_event(resource, WL_INPUT_DEVICE_TOUCH_DOWN, time, base()->pointer_focus, id, x, y);
         break;
     case Qt::TouchPointMoved:
         wl_resource_post_event(resource, WL_INPUT_DEVICE_TOUCH_MOTION, time, id, x, y);