Store the input device in the touch extension
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Thu, 17 May 2012 09:25:13 +0000 (12:25 +0300)
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>
Thu, 17 May 2012 12:15:13 +0000 (14:15 +0200)
Implicit sharing is nice but not doing anything is better

Change-Id: I2ae753e749c1b7d7e1dce78dd59a084ce8e4e836
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
src/plugins/platforms/wayland/qwaylandtouch.cpp
src/plugins/platforms/wayland/qwaylandtouch.h

index f4de44c..3387f9f 100644 (file)
@@ -49,7 +49,8 @@ QWaylandTouchExtension::QWaylandTouchExtension(QWaylandDisplay *display, uint32_
       mTouchDevice(0),
       mPointsLeft(0),
       mFlags(0),
-      mMouseSourceId(-1)
+      mMouseSourceId(-1),
+      mInputDevice(0)
 {
     mTouch = static_cast<struct wl_touch_extension *>(wl_display_bind(display->wl_display(), id, &wl_touch_extension_interface));
     wl_touch_extension_add_listener(mTouch, &touch_listener, this);
@@ -77,17 +78,20 @@ void QWaylandTouchExtension::handle_touch(void *data, wl_touch_extension *ext, u
 {
     Q_UNUSED(ext);
     QWaylandTouchExtension *self = static_cast<QWaylandTouchExtension *>(data);
-    QList<QWaylandInputDevice *> inputDevices = self->mDisplay->inputDevices();
-    if (inputDevices.isEmpty()) {
-        qWarning("wl_touch_extension: handle_touch: No input device");
-        return;
+
+    if (!self->mInputDevice) {
+        QList<QWaylandInputDevice *> inputDevices = self->mDisplay->inputDevices();
+        if (inputDevices.isEmpty()) {
+            qWarning("wl_touch_extension: handle_touch: No input devices");
+            return;
+        }
+        self->mInputDevice = inputDevices.first();
     }
-    QWaylandInputDevice *dev = inputDevices.first();
-    QWaylandWindow *win = dev->mTouchFocus;
+    QWaylandWindow *win = self->mInputDevice->mTouchFocus;
     if (!win)
-        win = dev->mPointerFocus;
+        win = self->mInputDevice->mPointerFocus;
     if (!win)
-        win = dev->mKeyboardFocus;
+        win = self->mInputDevice->mKeyboardFocus;
     if (!win || !win->window()) {
         qWarning("wl_touch_extension: handle_touch: No pointer focus");
         return;
index 7739642..226c658 100644 (file)
@@ -93,6 +93,7 @@ private:
     QPointF mLastMouseLocal;
     QPointF mLastMouseGlobal;
     QWindow *mTargetWindow;
+    QWaylandInputDevice *mInputDevice;
 };
 
 #endif // QWAYLANDTOUCH_H