[PATCH 3/3] dix: add resource type to touch listeners

Peter Hutterer peter.hutterer at who-t.net
Thu Nov 1 22:17:13 PDT 2012


Instead of guessing what resource type the listener is and what property to
retrieve, store the resource type in the listener directly.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=56557

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 Xi/exevents.c      | 25 ++++++++++++-------------
 dix/touch.c        | 23 ++++++++++++-----------
 include/input.h    |  5 +++--
 include/inputstr.h |  1 +
 4 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 4cbeb37..7625c1f 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1310,12 +1310,7 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
 
     if (listener->type == LISTENER_GRAB ||
         listener->type == LISTENER_POINTER_GRAB) {
-        rc = dixLookupResourceByType((pointer *) grab, listener->listener,
-                                     RT_PASSIVEGRAB,
-                                     serverClient, DixSendAccess);
-        if (rc != Success) {
-            /* the grab doesn't exist but we have a grabbing listener - this
-             * is an implicit/active grab */
+        if (listener->resource_type == RT_ACTIVEGRAB) {
             rc = dixLookupClient(client, listener->listener, serverClient,
                                  DixSendAccess);
             if (rc != Success)
@@ -1325,19 +1320,22 @@ RetrieveTouchDeliveryData(DeviceIntPtr dev, TouchPointInfoPtr ti,
             if (!*grab)
                 return FALSE;
         }
+        else {
+            rc = dixLookupResourceByType((pointer *) grab, listener->listener,
+                                         listener->resource_type,
+                                         serverClient, DixSendAccess);
+            if (rc != Success)
+                return FALSE;
+        }
 
         *client = rClient(*grab);
         *win = (*grab)->window;
         *mask = (*grab)->xi2mask;
     }
     else {
-        if (listener->level == CORE)
-            rc = dixLookupWindow(win, listener->listener,
-                                 serverClient, DixSendAccess);
-        else
-            rc = dixLookupResourceByType((pointer *) win, listener->listener,
-                                         RT_INPUTCLIENT,
-                                         serverClient, DixSendAccess);
+        rc = dixLookupResourceByType((pointer *) win, listener->listener,
+                                     listener->resource_type,
+                                     serverClient, DixSendAccess);
         if (rc != Success)
             return FALSE;
 
@@ -1477,6 +1475,7 @@ DeliverTouchEmulatedEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
              */
             l = &ti->listeners[ti->num_listeners - 1];
             l->listener = devgrab->resource;
+            l->resource_type = RT_PASSIVEGRAB;
 
             if (devgrab->grabtype != XI2 || devgrab->type != XI_TouchBegin)
                 l->type = LISTENER_POINTER_GRAB;
diff --git a/dix/touch.c b/dix/touch.c
index 5f77be5..8152598 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -682,11 +682,12 @@ TouchResourceIsOwner(TouchPointInfoPtr ti, XID resource)
  * Add the resource to this touch's listeners.
  */
 void
-TouchAddListener(TouchPointInfoPtr ti, XID resource, enum InputLevel level,
-                 enum TouchListenerType type, enum TouchListenerState state,
-                 WindowPtr window)
+TouchAddListener(TouchPointInfoPtr ti, XID resource, int resource_type,
+                 enum InputLevel level, enum TouchListenerType type,
+                 enum TouchListenerState state, WindowPtr window)
 {
     ti->listeners[ti->num_listeners].listener = resource;
+    ti->listeners[ti->num_listeners].resource_type = resource_type;
     ti->listeners[ti->num_listeners].level = level;
     ti->listeners[ti->num_listeners].state = state;
     ti->listeners[ti->num_listeners].type = type;
@@ -722,7 +723,7 @@ TouchRemoveListener(TouchPointInfoPtr ti, XID resource)
 
 static void
 TouchAddGrabListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
-                     InternalEvent *ev, GrabPtr grab)
+                     InternalEvent *ev, GrabPtr grab, int resource_type)
 {
     enum TouchListenerType type = LISTENER_GRAB;
 
@@ -739,7 +740,7 @@ TouchAddGrabListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
         type = LISTENER_POINTER_GRAB;
     }
 
-    TouchAddListener(ti, grab->resource, grab->grabtype,
+    TouchAddListener(ti, grab->resource, resource_type, grab->grabtype,
                      type, LISTENER_AWAITING_BEGIN, grab->window);
     ti->num_grabs++;
 }
@@ -759,7 +760,7 @@ TouchAddPassiveGrabListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
     if (!grab)
         return;
 
-    TouchAddGrabListener(dev, ti, ev, grab);
+    TouchAddGrabListener(dev, ti, ev, grab, RT_PASSIVEGRAB);
 }
 
 static Bool
@@ -796,7 +797,7 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
             if (!xi2mask_isset(iclients->xi2mask, dev, XI_TouchOwnership))
                 TouchEventHistoryAllocate(ti);
 
-            TouchAddListener(ti, iclients->resource, XI2,
+            TouchAddListener(ti, iclients->resource, RT_INPUTCLIENT, XI2,
                              type, LISTENER_AWAITING_BEGIN, win);
             return TRUE;
         }
@@ -811,7 +812,7 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
                 continue;
 
             TouchEventHistoryAllocate(ti);
-            TouchAddListener(ti, iclients->resource, XI,
+            TouchAddListener(ti, iclients->resource, RT_INPUTCLIENT, XI,
                              LISTENER_POINTER_REGULAR, LISTENER_AWAITING_BEGIN,
                              win);
             return TRUE;
@@ -826,7 +827,7 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
         /* window owner */
         if (IsMaster(dev) && (win->eventMask & core_filter)) {
             TouchEventHistoryAllocate(ti);
-            TouchAddListener(ti, win->drawable.id, CORE,
+            TouchAddListener(ti, win->drawable.id, RT_WINDOW, CORE,
                              LISTENER_POINTER_REGULAR, LISTENER_AWAITING_BEGIN,
                              win);
             return TRUE;
@@ -838,7 +839,7 @@ TouchAddRegularListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
                 continue;
 
             TouchEventHistoryAllocate(ti);
-            TouchAddListener(ti, oclients->resource, CORE,
+            TouchAddListener(ti, oclients->resource, RT_OTHERCLIENT, CORE,
                              type, LISTENER_AWAITING_BEGIN, win);
             return TRUE;
         }
@@ -861,7 +862,7 @@ TouchAddActiveGrabListener(DeviceIntPtr dev, TouchPointInfoPtr ti,
          grab->type != XI_TouchUpdate))
         return;
 
-    TouchAddGrabListener(dev, ti, ev, grab);
+    TouchAddGrabListener(dev, ti, ev, grab, RT_ACTIVEGRAB);
 }
 
 void
diff --git a/include/input.h b/include/input.h
index f8459b8..8636b71 100644
--- a/include/input.h
+++ b/include/input.h
@@ -561,8 +561,9 @@ extern void TouchEventHistoryReplay(TouchPointInfoPtr ti, DeviceIntPtr dev,
                                     XID resource);
 extern Bool TouchResourceIsOwner(TouchPointInfoPtr ti, XID resource);
 extern void TouchAddListener(TouchPointInfoPtr ti, XID resource,
-                             enum InputLevel level, enum TouchListenerType type,
-                             enum TouchListenerState state, WindowPtr window);
+                             int resource_type, enum InputLevel level,
+                             enum TouchListenerType type, enum TouchListenerState state,
+                             WindowPtr window);
 extern Bool TouchRemoveListener(TouchPointInfoPtr ti, XID resource);
 extern void TouchSetupListeners(DeviceIntPtr dev, TouchPointInfoPtr ti,
                                 InternalEvent *ev);
diff --git a/include/inputstr.h b/include/inputstr.h
index 5a38924..91c76b2 100644
--- a/include/inputstr.h
+++ b/include/inputstr.h
@@ -309,6 +309,7 @@ typedef struct _TouchPointInfo {
     struct _TouchListener {
         XID listener;           /* grabs/event selection IDs receiving
                                  * events for this touch */
+        int resource_type;      /* listener's resource type */
         enum TouchListenerType type;
         enum TouchListenerState state;
         enum InputLevel level;  /* matters only for emulating touches */
-- 
1.7.11.7



More information about the xorg-devel mailing list