Rename touch extension interface and fix event sending
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Sat, 14 Jan 2012 12:58:35 +0000 (14:58 +0200)
committerJørgen Lind <jorgen.lind@nokia.com>
Mon, 16 Jan 2012 07:02:36 +0000 (08:02 +0100)
Follow the naming convention of other extensions.

The events are now posted only to the client to which the focus
surface belongs, the check was previously missing.

Change-Id: Ie43b6e887b64c7bed1377babb368129753a3cd0f
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
extensions/touch-extension.xml
src/compositor/wayland_wrapper/wltouch.cpp
src/compositor/wayland_wrapper/wltouch.h
src/plugins/platforms/wayland/qwaylanddisplay.cpp
src/plugins/platforms/wayland/qwaylandtouch.cpp
src/plugins/platforms/wayland/qwaylandtouch.h

index 82cb156..8d63fb9 100644 (file)
@@ -42,7 +42,7 @@
 ****************************************************************************/
     </copyright>
 
-    <interface name="wl_touch" version="1">
+    <interface name="wl_touch_extension" version="1">
       <event name="touch">
         <arg name="time" type="uint" />
         <arg name="id" type="uint" />
index b94d88c..b260bcb 100644 (file)
@@ -49,7 +49,7 @@ static void dummy(wl_client *, wl_resource *)
 {
 }
 
-const struct wl_touch_interface TouchExtensionGlobal::touch_interface = {
+const struct wl_touch_extension_interface TouchExtensionGlobal::touch_interface = {
     dummy
 };
 
@@ -57,7 +57,7 @@ TouchExtensionGlobal::TouchExtensionGlobal(Compositor *compositor)
     : m_compositor(compositor)
 {
     wl_display_add_global(compositor->wl_display(),
-                          &wl_touch_interface,
+                          &wl_touch_extension_interface,
                           this,
                           TouchExtensionGlobal::bind_func);
 }
@@ -72,7 +72,7 @@ void TouchExtensionGlobal::destroy_resource(wl_resource *resource)
 void TouchExtensionGlobal::bind_func(wl_client *client, void *data, uint32_t version, uint32_t id)
 {
     Q_UNUSED(version);
-    wl_resource *resource = wl_client_add_object(client, &wl_touch_interface, &touch_interface, id, data);
+    wl_resource *resource = wl_client_add_object(client, &wl_touch_extension_interface, &touch_interface, id, data);
     resource->destroy = destroy_resource;
     TouchExtensionGlobal *self = static_cast<TouchExtensionGlobal *>(resource->data);
     self->m_resources.append(resource);
@@ -91,10 +91,14 @@ void TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, Surface *surface)
         return;
 
     QPointF surfacePos = surface->pos();
+    wl_client *surfaceClient = surface->base()->resource.client;
     uint32_t time = m_compositor->currentTimeMsecs();
     const int rescount = m_resources.count();
+
     for (int res = 0; res < rescount; ++res) {
         wl_resource *target = m_resources.at(res);
+        if (target->client != surfaceClient)
+            continue;
 
         for (int i = 0; i < pointCount; ++i) {
             const QTouchEvent::TouchPoint &tp(points.at(i));
@@ -112,14 +116,14 @@ void TouchExtensionGlobal::postTouchEvent(QTouchEvent *event, Surface *surface)
             int vy = toFixed(tp.velocity().y());
             uint32_t pressure = uint32_t(tp.pressure() * 255);
             wl_array *rawData = 0;
-            wl_resource_post_event(target, WL_TOUCH_TOUCH,
+            wl_resource_post_event(target, WL_TOUCH_EXTENSION_TOUCH,
                                    time, id, state,
                                    x, y, nx, ny, w, h,
                                    pressure, vx, vy,
                                    flags, rawData);
         }
 
-        wl_resource_post_event(target, WL_TOUCH_TOUCH_FRAME);
+        wl_resource_post_event(target, WL_TOUCH_EXTENSION_TOUCH_FRAME);
     }
 }
 
index e52b795..fbd1cd0 100644 (file)
@@ -65,7 +65,7 @@ private:
 
     static void destroy_resource(wl_resource *resource);
 
-    static const struct wl_touch_interface touch_interface;
+    static const struct wl_touch_extension_interface touch_interface;
 
     QList<wl_resource *> m_resources;
 };
index d329690..a3e9452 100644 (file)
@@ -311,7 +311,7 @@ void QWaylandDisplay::displayHandleGlobal(uint32_t id,
         mWindowExtension = new QWaylandSurfaceExtension(this,id);
     } else if (interface == "wl_sub_surface_extension") {
         mSubSurfaceExtension = new QWaylandSubSurfaceExtension(this,id);
-    } else if (interface == "wl_touch") {
+    } else if (interface == "wl_touch_extension") {
         mTouchExtension = new QWaylandTouchExtension(this, id);
     }
 }
index c1700e3..090b1ec 100644 (file)
@@ -47,8 +47,8 @@
 QWaylandTouchExtension::QWaylandTouchExtension(QWaylandDisplay *display, uint32_t id)
 {
     mDisplay = display;
-    mTouch = static_cast<struct wl_touch *>(wl_display_bind(display->wl_display(), id, &wl_touch_interface));
-    wl_touch_add_listener(mTouch, &touch_listener, this);
+    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
@@ -67,18 +67,18 @@ static inline qreal fromFixed(int f)
     return f / qreal(10000);
 }
 
-void QWaylandTouchExtension::handle_touch(void *data, wl_touch *wl_touch, uint32_t time,
+void QWaylandTouchExtension::handle_touch(void *data, wl_touch_extension *ext, uint32_t time,
                                           uint32_t id, uint32_t state, int32_t x, int32_t y,
                                           int32_t normalized_x, int32_t normalized_y,
                                           int32_t width, int32_t height, uint32_t pressure,
                                           int32_t velocity_x, int32_t velocity_y,
                                           uint32_t flags, wl_array *rawdata)
 {
-    Q_UNUSED(wl_touch);
+    Q_UNUSED(ext);
     QWaylandTouchExtension *self = static_cast<QWaylandTouchExtension *>(data);
     QList<QWaylandInputDevice *> inputDevices = self->mDisplay->inputDevices();
     if (inputDevices.isEmpty()) {
-        qWarning("handle_touch: No input device");
+        qWarning("wl_touch_extension: handle_touch: No input device");
         return;
     }
     QWaylandInputDevice *dev = inputDevices.first();
@@ -87,8 +87,10 @@ void QWaylandTouchExtension::handle_touch(void *data, wl_touch *wl_touch, uint32
         win = dev->mPointerFocus;
     if (!win)
         win = dev->mKeyboardFocus;
-    if (!win || !win->window())
+    if (!win || !win->window()) {
+        qWarning("wl_touch_extension: handle_touch: No pointer focus");
         return;
+    }
 
     QWindowSystemInterface::TouchPoint tp;
     tp.id = id;
@@ -111,9 +113,9 @@ void QWaylandTouchExtension::handle_touch(void *data, wl_touch *wl_touch, uint32
     self->mTimestamp = time;
 }
 
-void QWaylandTouchExtension::handle_touch_frame(void *data, wl_touch *wl_touch)
+void QWaylandTouchExtension::handle_touch_frame(void *data, wl_touch_extension *ext)
 {
-    Q_UNUSED(wl_touch);
+    Q_UNUSED(ext);
     QWaylandTouchExtension *self = static_cast<QWaylandTouchExtension *>(data);
     self->sendTouchEvent();
 }
@@ -159,7 +161,7 @@ void QWaylandTouchExtension::sendTouchEvent()
         mPrevTouchPoints.clear();
 }
 
-const struct wl_touch_listener QWaylandTouchExtension::touch_listener = {
+const struct wl_touch_extension_listener QWaylandTouchExtension::touch_listener = {
     QWaylandTouchExtension::handle_touch,
     QWaylandTouchExtension::handle_touch_frame
 };
index 541958a..d8ada49 100644 (file)
@@ -45,7 +45,7 @@
 #include "qwaylanddisplay.h"
 #include <QWindowSystemInterface>
 
-class wl_touch;
+class wl_touch_extension;
 
 class QWaylandTouchExtension
 {
@@ -54,11 +54,11 @@ public:
 
 private:
     QWaylandDisplay *mDisplay;
-    wl_touch *mTouch;
-    static const struct wl_touch_listener touch_listener;
+    wl_touch_extension *mTouch;
+    static const struct wl_touch_extension_listener touch_listener;
 
     static void handle_touch(void *data,
-                             struct wl_touch *wl_touch,
+                             struct wl_touch_extension *ext,
                              uint32_t time,
                              uint32_t id,
                              uint32_t state,
@@ -75,7 +75,7 @@ private:
                              struct wl_array *rawdata);
 
     static void handle_touch_frame(void *data,
-                                   struct wl_touch *wl_touch);
+                                   struct wl_touch_extension *ext);
 
     void sendTouchEvent();