Pass device capabilities to client in the touch extension
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Thu, 26 Apr 2012 08:11:50 +0000 (11:11 +0300)
committerJørgen Lind <jorgen.lind@nokia.com>
Thu, 26 Apr 2012 08:35:46 +0000 (10:35 +0200)
Assuming that all capabilities are available is not a good idea.

Change-Id: I06c0f6c14583e7a25d4a07058976ea347e2dc8fa
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
src/compositor/wayland_wrapper/wltouch.cpp
src/plugins/platforms/wayland/qwaylandtouch.cpp
src/plugins/platforms/wayland/qwaylandtouch.h

index 85763db..b6d2590 100644 (file)
@@ -129,7 +129,7 @@ bool TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, Surface *surface)
 
             uint32_t id = tp.id();
             uint32_t state = (tp.state() & 0xFFFF) | (sentPointCount << 16);
-            uint32_t flags = tp.flags();
+            uint32_t flags = (tp.flags() & 0xFFFF) | (int(event->device()->capabilities()) << 16);
 
             QPointF p = tp.pos() - surfacePos; // surface-relative
             int x = toFixed(p.x());
index 725aecf..de77442 100644 (file)
@@ -50,19 +50,17 @@ QWaylandTouchExtension::QWaylandTouchExtension(QWaylandDisplay *display, uint32_
     mPointsLeft = 0;
     mFlags = 0;
     mMouseSourceId = -1;
+    mTouchDevice = 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);
+}
 
-    QTouchDevice::Capabilities caps = QTouchDevice::Position
-            | QTouchDevice::Area
-            | QTouchDevice::Pressure
-            | QTouchDevice::Velocity
-            | QTouchDevice::RawPositions
-            | QTouchDevice::NormalizedPosition;
+void QWaylandTouchExtension::registerDevice(int caps)
+{
     mTouchDevice = new QTouchDevice;
     mTouchDevice->setType(QTouchDevice::TouchScreen);
-    mTouchDevice->setCapabilities(caps);
+    mTouchDevice->setCapabilities(QTouchDevice::Capabilities(caps));
     QWindowSystemInterface::registerTouchDevice(mTouchDevice);
 }
 
@@ -105,7 +103,10 @@ void QWaylandTouchExtension::handle_touch(void *data, wl_touch_extension *ext, u
         Q_ASSERT(sentPointCount > 0);
         self->mPointsLeft = sentPointCount;
     }
-    tp.flags = QTouchEvent::TouchPoint::InfoFlags(int(flags));
+    tp.flags = QTouchEvent::TouchPoint::InfoFlags(int(flags & 0xFFFF));
+
+    if (!self->mTouchDevice)
+        self->registerDevice(flags >> 16);
 
     tp.area = QRectF(0, 0, fromFixed(width), fromFixed(height));
     // Got surface-relative coords but need a (virtual) screen position.
index 4ac0af2..7739642 100644 (file)
@@ -55,6 +55,8 @@ public:
     void touchCanceled();
 
 private:
+    void registerDevice(int caps);
+
     QWaylandDisplay *mDisplay;
     wl_touch_extension *mTouch;
     static const struct wl_touch_extension_listener touch_listener;