[PATCH v2 4/7] Move AllowTouch to dix/touch.c, and rename to TouchAcceptReject

Chase Douglas chase.douglas at canonical.com
Fri Feb 3 16:19:08 PST 2012


Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
---
Changes since v1:
* Renamed to TouchAcceptReject

 Xi/xiallowev.c  |   46 ++--------------------------------------------
 dix/touch.c     |   45 +++++++++++++++++++++++++++++++++++++++++++++
 include/input.h |    2 ++
 3 files changed, 49 insertions(+), 44 deletions(-)

diff --git a/Xi/xiallowev.c b/Xi/xiallowev.c
index a4b2f57..dab3393 100644
--- a/Xi/xiallowev.c
+++ b/Xi/xiallowev.c
@@ -57,47 +57,6 @@ SProcXIAllowEvents(ClientPtr client)
     return ProcXIAllowEvents(client);
 }
 
-static int
-AllowTouch(ClientPtr client, DeviceIntPtr dev, int mode, uint32_t touchid, XID *error)
-{
-    TouchPointInfoPtr ti;
-    int nev, i;
-    InternalEvent *events = InitEventList(GetMaximumEventsNum());
-
-    if (!events)
-        return BadAlloc;
-
-    if (!dev->touch)
-    {
-        *error = dev->id;
-        return BadDevice;
-    }
-
-    /* FIXME window is unhandled */
-
-    ti = TouchFindByClientID(dev, touchid);
-    if (!ti)
-    {
-        *error = touchid;
-        return BadValue;
-    }
-
-    /* FIXME: Allow for early accept */
-    if (ti->num_listeners == 0 || CLIENT_ID(ti->listeners[0].listener) != client->index)
-        return BadAccess;
-
-    nev = GetTouchOwnershipEvents(events, dev, ti, mode, ti->listeners[0].listener, 0);
-    if (nev == 0)
-        return BadAlloc;
-    for (i = 0; i < nev; i++)
-        mieqProcessDeviceEvent(dev, events + i, NULL);
-
-    ProcessInputEvents();
-
-    FreeEventList(events, GetMaximumEventsNum());
-    return Success;
-}
-
 int
 ProcXIAllowEvents(ClientPtr client)
 {
@@ -138,9 +97,8 @@ ProcXIAllowEvents(ClientPtr client)
 	break;
     case XIRejectTouch:
     case XIAcceptTouch:
-        ret = AllowTouch(client, dev,
-                         stuff->mode, stuff->touchid,
-                         &client->errorValue);
+        ret = TouchAcceptReject(client, dev, stuff->mode, stuff->touchid,
+                                &client->errorValue);
         break;
     default:
 	client->errorValue = stuff->mode;
diff --git a/dix/touch.c b/dix/touch.c
index b42859d..4a116ee 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -34,6 +34,7 @@
 
 #include "eventstr.h"
 #include "exevents.h"
+#include "exglobals.h"
 #include "inpututils.h"
 #include "eventconvert.h"
 #include "windowstr.h"
@@ -984,3 +985,47 @@ TouchListenerGone(XID resource)
 
     FreeEventList(events, GetMaximumEventsNum());
 }
+
+int
+TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
+                  uint32_t touchid, XID *error)
+{
+    TouchPointInfoPtr ti;
+    int nev, i;
+    InternalEvent *events = InitEventList(GetMaximumEventsNum());
+
+    if (!events)
+        return BadAlloc;
+
+    if (!dev->touch)
+    {
+        *error = dev->id;
+        return BadDevice;
+    }
+
+    /* FIXME window is unhandled */
+
+    ti = TouchFindByClientID(dev, touchid);
+    if (!ti)
+    {
+        *error = touchid;
+        return BadValue;
+    }
+
+    /* FIXME: Allow for early accept */
+    if (ti->num_listeners == 0 ||
+        CLIENT_ID(ti->listeners[0].listener) != client->index)
+        return BadAccess;
+
+    nev = GetTouchOwnershipEvents(events, dev, ti, mode,
+                                  ti->listeners[0].listener, 0);
+    if (nev == 0)
+        return BadAlloc;
+    for (i = 0; i < nev; i++)
+        mieqProcessDeviceEvent(dev, events + i, NULL);
+
+    ProcessInputEvents();
+
+    FreeEventList(events, GetMaximumEventsNum());
+    return Success;
+}
diff --git a/include/input.h b/include/input.h
index 53645b4..605e74d 100644
--- a/include/input.h
+++ b/include/input.h
@@ -625,6 +625,8 @@ extern int TouchConvertToPointerEvent(const InternalEvent *ev,
 extern int TouchGetPointerEventType(const InternalEvent *ev);
 extern void TouchRemovePointerGrab(DeviceIntPtr dev);
 extern void TouchListenerGone(XID resource);
+extern int TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
+                             uint32_t touchid, XID *error);
 
 /* misc event helpers */
 extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
-- 
1.7.8.3



More information about the xorg-devel mailing list