[PATCH v2 1/2] Don't clobber virtual core pointer touches array length

Peter Hutterer peter.hutterer at who-t.net
Tue Feb 14 16:32:32 PST 2012


The VCP has its own touches array, don't overwrite it when the class is
copied from the SD to the master.

Reported-by: Chase Douglas <chase.douglas at canonical.com>
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
Changes to v1:
- copy fields one-by-one instead of a memcpy and then writing back the ones
  that shouldn't change

This patch doesn't include a test yet, mainly because I want to clean up
this code anyway and then write the test against the new version

 Xi/exevents.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 816dfa7..ca8060d 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -671,7 +671,7 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
 
     if (from->touch)
     {
-        TouchPointInfoPtr tmp;
+        TouchClassPtr t, f;
         if (!to->touch)
         {
             classes = to->unused_classes;
@@ -692,10 +692,18 @@ DeepCopyPointerClasses(DeviceIntPtr from, DeviceIntPtr to)
             } else
                 classes->touch = NULL;
         }
-        tmp = to->touch->touches;
-        memcpy(to->touch, from->touch, sizeof(TouchClassRec));
-        to->touch->touches = tmp;
-        to->touch->sourceid = from->id;
+
+
+        t = to->touch;
+        f = from->touch;
+        t->sourceid = f->sourceid;
+        t->max_touches = f->max_touches;
+        t->mode = f->mode;
+        t->buttonsDown = f->buttonsDown;
+        t->state = f->state;
+        t->motionMask = f->motionMask;
+        /* to->touches and to->num_touches are separate on the master,
+         * don't copy */
     } else if (to->touch)
     {
         ClassesPtr classes;
-- 
1.7.7.5



More information about the xorg-devel mailing list