[PATCH xwayland 4/4] xwayland: Make the XYToWindowProc implementation aware of touchpoints

Carlos Garnacho carlosg at gnome.org
Wed May 27 09:42:01 PDT 2015


For these, we must first lookup the DIX sequence from the Sprite, we can
then lookup the DDX ID/xwl_touch from xwayland's touch device.

Signed-off-by: Carlos Garnacho <carlosg at gnome.org>
---
 hw/xwayland/xwayland-input.c | 68 +++++++++++++++++++++++++++++++++++---------
 1 file changed, 55 insertions(+), 13 deletions(-)

diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c
index 3229c54..9d554a8 100644
--- a/hw/xwayland/xwayland-input.c
+++ b/hw/xwayland/xwayland-input.c
@@ -818,29 +818,71 @@ DDXRingBell(int volume, int pitch, int duration)
 {
 }
 
-static WindowPtr
-xwl_xy_to_window(ScreenPtr screen, SpritePtr sprite, int x, int y)
+static int32_t
+lookup_sprite_touch_client_id (SpritePtr sprite)
 {
-    struct xwl_seat *xwl_seat = NULL;
     DeviceIntPtr device;
+    int i;
 
     for (device = inputInfo.devices; device; device = device->next) {
-        if (device->deviceProc == xwl_pointer_proc &&
-            device->spriteInfo->sprite == sprite) {
-            xwl_seat = device->public.devicePrivate;
-            break;
+        if (!device->touch)
+            continue;
+
+        for (i = 0; i < device->touch->num_touches; i++) {
+            TouchPointInfoPtr ti = device->touch->touches + i;
+
+            if (sprite == &ti->sprite)
+                return ti->client_id;
         }
     }
 
-    if (xwl_seat == NULL) {
-        /* XTEST device */
-        sprite->spriteTraceGood = 1;
-        return sprite->spriteTrace[0];
+    return 0;
+}
+
+static struct xwl_touch *
+xwl_touch_lookup_from_client_id (struct xwl_seat *xwl_seat, int32_t client_id)
+{
+    DeviceIntPtr touch = xwl_seat->touch;
+    int i;
+
+    for (i = 0; i < touch->last.num_touches; i++) {
+        DDXTouchPointInfoPtr ddx_ti = touch->last.touches + i;
+
+        if (ddx_ti->client_id == client_id)
+            return xwl_seat_lookup_touch(xwl_seat, ddx_ti->ddx_id);
+    }
+
+    return NULL;
+}
+
+static WindowPtr
+xwl_xy_to_window(ScreenPtr screen, SpritePtr sprite, int x, int y)
+{
+    struct xwl_screen *xwl_screen;
+    struct xwl_seat *xwl_seat = NULL;
+    struct xwl_window *xwl_window = NULL;
+    struct xwl_touch *xwl_touch;
+    int32_t client_id;
+
+    xwl_screen = xwl_screen_get(screen);
+
+    xorg_list_for_each_entry(xwl_seat, &xwl_screen->seat_list, link) {
+        if (xwl_seat->pointer->spriteInfo->sprite == sprite) {
+            xwl_window = xwl_seat->focus_window;
+        } else if ((client_id = lookup_sprite_touch_client_id (sprite)) != 0) {
+            xwl_touch = xwl_touch_lookup_from_client_id (xwl_seat, client_id);
+
+            if (xwl_touch)
+                xwl_window = xwl_touch->window;
+        }
+
+        if (xwl_window)
+            break;
     }
 
-    if (xwl_seat->focus_window) {
+    if (xwl_window) {
         sprite->spriteTraceGood = 2;
-        sprite->spriteTrace[1] = xwl_seat->focus_window->window;
+        sprite->spriteTrace[1] = xwl_window->window;
         return miSpriteTrace(sprite, x, y);
     }
     else {
-- 
2.4.1



More information about the wayland-devel mailing list