[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xorg-server: Changes to 'upstream-1.11+input'



 Xext/xtest.c        |   10 ++
 Xi/exevents.c       |  229 ++++++++++++++++++++++++++++------------------------
 Xi/xiallowev.c      |   81 +++++++-----------
 Xi/xipassivegrab.c  |    7 +
 configure.ac        |    2 
 dix/eventconvert.c  |    4 
 dix/events.c        |   39 +++-----
 dix/getevents.c     |   37 +++++---
 dix/inpututils.c    |    3 
 dix/touch.c         |   76 +++++++++++++++--
 include/exevents.h  |    7 +
 include/input.h     |   10 +-
 include/inputstr.h  |    1 
 test/.gitignore     |    1 
 test/xi2/.gitignore |    1 
 15 files changed, 312 insertions(+), 196 deletions(-)

New commits:
commit cc5bf30ebc4e9486b1ce360c7234cb6ede5c4a17
Author: Chase Douglas <chase.douglas@canonical.com>
Date:   Thu Mar 29 18:06:03 2012 -0700

    Implement passive touch ungrabbing
    
    Whoops. Forgot to implement this. The code currently generates an error
    due to the unhandled grab type.
    
    X.Org Bug 48069 <https://bugs.freedesktop.org/show_bug.cgi?id=48069>
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 1110facdfeb95b1ad47d03c0ca3d73933b86dbd6)
    (cherry picked from commit 259aa5a69b69aa72be3fb7402b68560f9a6b05d6)
    
    Conflicts:
    
    	Xi/xipassivegrab.c
    
    Signed-off-by: Chase Douglas <chase.douglas@ubuntu.com>

diff --git a/Xi/xipassivegrab.c b/Xi/xipassivegrab.c
index d911702..89a285f 100644
--- a/Xi/xipassivegrab.c
+++ b/Xi/xipassivegrab.c
@@ -303,14 +303,16 @@ ProcXIPassiveUngrabDevice(ClientPtr client)
     if (stuff->grab_type != XIGrabtypeButton &&
         stuff->grab_type != XIGrabtypeKeycode &&
         stuff->grab_type != XIGrabtypeEnter &&
-        stuff->grab_type != XIGrabtypeFocusIn)
+        stuff->grab_type != XIGrabtypeFocusIn &&
+        stuff->grab_type != XIGrabtypeTouchBegin)
     {
         client->errorValue = stuff->grab_type;
         return BadValue;
     }
 
     if ((stuff->grab_type == XIGrabtypeEnter ||
-         stuff->grab_type == XIGrabtypeFocusIn) && stuff->detail != 0)
+         stuff->grab_type == XIGrabtypeFocusIn ||
+         stuff->grab_type == XIGrabtypeTouchBegin) && stuff->detail != 0)
     {
         client->errorValue = stuff->detail;
         return BadValue;
@@ -336,6 +338,7 @@ ProcXIPassiveUngrabDevice(ClientPtr client)
         case XIGrabtypeKeycode:  tempGrab->type = XI_KeyPress;    break;
         case XIGrabtypeEnter:   tempGrab->type = XI_Enter;       break;
         case XIGrabtypeFocusIn: tempGrab->type = XI_FocusIn;     break;
+        case XIGrabtypeTouchBegin: tempGrab->type = XI_TouchBegin; break;
     }
     tempGrab->grabtype = XI2;
     tempGrab->modifierDevice = mod_dev;

commit 447cabbb16533c735dafdb000f791eb7eef3250e
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Mar 21 14:05:29 2012 +1000

    dix: set raw event values before adding up relative values (#46976)
    
    Regression introduced in 4e52cc0ef48145134cd58d357fb7289e6f8bb709
    
    Raw event values are values as-is from the driver, modified only be
    transformation or acceleration. 4e52cc caused the mask to be updated from
    relative to absolute coordinates which then got written into the raw events.
    
    Move the raw event update into the respective branches for absolute/relative
    events.
    
    X.Org Bug 46976 <http://bugs.freedesktop.org/show_bug.cgi?id=46976>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
    Reviewed-by: Daniel Stone <daniel@fooishbar.org>
    Tested-by: Sven Arvidsson <sa@whiz.se>
    Reviewed-by: Simon Thum <simon.thum@gmx.de>
    (cherry picked from commit 908ab3d580188533168c8cdfd2cab9dc689b4218)
    (cherry picked from commit 5eb20062208177172ff3443e522096a2e8f2f1e8)
    
    Conflicts:
    
    	dix/getevents.c
    
    Signed-off-by: Chase Douglas <chase.douglas@ubuntu.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index 73b1f21..71c55f5 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -1311,17 +1311,18 @@ fill_pointer_events(InternalEvent *events, DeviceIntPtr pDev, int type,
 
         transformAbsolute(pDev, &mask);
         clipAbsolute(pDev, &mask);
+        if ((flags & POINTER_NORAW) == 0)
+            set_raw_valuators(raw, &mask, raw->valuators.data);
     } else {
         if (flags & POINTER_ACCELERATE)
             accelPointer(pDev, &mask, ms);
+        if ((flags & POINTER_NORAW) == 0)
+            set_raw_valuators(raw, &mask, raw->valuators.data);
+
         moveRelative(pDev, &mask);
     }
 
     /* valuators are in device coordinate system in absolute coordinates */
-
-    if ((flags & POINTER_NORAW) == 0)
-        set_raw_valuators(raw, &mask, raw->valuators.data);
-
     scale_to_desktop(pDev, &mask, &devx, &devy, &screenx, &screeny);
     scr = positionSprite(pDev, (flags & POINTER_ABSOLUTE) ? Absolute : Relative,
                          &mask, &devx, &devy, &screenx, &screeny);

commit d4880e674b057aecd77b9fc6239b670a0294e133
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Mar 21 14:03:27 2012 +1000

    dix: fix compiler warning "unused variable 'scr'"
    
    getevents.c: In function 'updateSlaveDeviceCoords':
    getevents.c:326:15: warning: unused variable 'scr' [-Wunused-variable]
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 9c3bd3ae652af386b6821b197d24528f20ba867d)
    (cherry picked from commit a095f7ae96a353073add83e78f88f29d854d289d)
    
    Signed-off-by: Chase Douglas <chase.douglas@ubuntu.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index bf288f8..73b1f21 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -323,7 +323,6 @@ rescaleValuatorAxis(double coord, AxisInfoPtr from, AxisInfoPtr to,
 static void
 updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev)
 {
-    ScreenPtr scr = miPointerGetScreen(pDev);
     int i;
     DeviceIntPtr lastSlave;
 

commit 8cb6ac5d1e0e3604101add3ca570eb475a460361
Author: Chase Douglas <chase.douglas@canonical.com>
Date:   Wed Mar 7 16:06:27 2012 -0800

    Use a new sprite trace for indirect touches when all touches have physically ended
    
    All touches of an indirect device, such as a trackpad, are sent to the
    same window set. When there are no active touches, a new window set is
    created; otherwise, the window set of an existing touch is copied.
    
    The current code checks for any logically active touches. This includes
    touches that have physically ended but are still logically active due to
    unhandled touch grabs. Instead, we want a new window set whenever there
    are no physically active touches.
    
    This change skips over logically active but pending end touches, which
    are touches that have physically ended.
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 31df08a449cf9b6e1740e1c02257997490630d93)
    (cherry picked from commit f8446ad3d71cdf9c2200f5584bd156c629fe3c90)
    
    Signed-off-by: Chase Douglas <chase.douglas@ubuntu.com>

diff --git a/dix/touch.c b/dix/touch.c
index d04801c..0aa24f2 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -524,7 +524,8 @@ TouchBuildDependentSpriteTrace(DeviceIntPtr dev, SpritePtr sprite)
     /* All touches should have the same sprite trace, so find and reuse an
      * existing touch's sprite if possible, else use the device's sprite. */
     for (i = 0; i < t->num_touches; i++)
-        if (t->touches[i].sprite.spriteTraceGood > 0)
+        if (!t->touches[i].pending_finish &&
+            t->touches[i].sprite.spriteTraceGood > 0)
             break;
     if (i < t->num_touches)
         srcsprite = &t->touches[i].sprite;

commit cd3981c13769baf624c3e771b11139114557f441
Author: Chase Douglas <chase.douglas@canonical.com>
Date:   Wed Mar 7 16:06:26 2012 -0800

    Xi: Fix TouchEnd to TouchUpdate change for one accepted grab
    
    If there is only one listener of a touch, the listener is a grab, and is
    accepted before the touch has ended, the current code will not end the
    touch record when the touch does end.
    
    This change adds a listener state for when a touch is accepted but has
    not yet ended. We now keep the touch record alive in this state, but end
    it when the touch ends.
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 58427e08a4a36ce9e213e4b4fe5249d5db2c764d)
    (cherry picked from commit 5a3ec826e653377e8b70e7553d1f0ca72210447c)
    
    Conflicts:
    
    	Xi/exevents.c
    
    Signed-off-by: Chase Douglas <chase.douglas@ubuntu.com>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index f390f67..d71e604 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1252,6 +1252,8 @@ ProcessTouchOwnershipEvent(DeviceIntPtr dev, TouchPointInfoPtr ti,
         /* Owner accepted after receiving end */
         if (ti->listeners[0].state == LISTENER_HAS_END)
             TouchEndTouch(dev, ti);
+        else
+            ti->listeners[0].state = LISTENER_HAS_ACCEPTED;
     } else { /* this is the very first ownership event for a grab */
         DeliverTouchEvents(dev, ti, (InternalEvent*)ev, ev->resource);
     }
@@ -1781,7 +1783,11 @@ DeliverTouchBeginEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev
     {
         if (has_ownershipmask)
             TouchSendOwnershipEvent(dev, ti, 0, listener->listener);
-        state = LISTENER_IS_OWNER;
+
+        if (!has_ownershipmask || listener->type == LISTENER_REGULAR)
+            state = LISTENER_HAS_ACCEPTED;
+        else
+            state = LISTENER_IS_OWNER;
     }
     listener->state = state;
 
@@ -1812,22 +1818,23 @@ DeliverTouchEndEvent(DeviceIntPtr dev, TouchPointInfoPtr ti, InternalEvent *ev,
         listener->state = LISTENER_HAS_END;
     } else if (TouchResourceIsOwner(ti, listener->listener))
     {
+        Bool normal_end = !(ev->device_event.flags & TOUCH_ACCEPT);
+
         /* FIXME: what about early acceptance */
-        if (!(ev->device_event.flags & TOUCH_ACCEPT))
-        {
-            if (listener->state != LISTENER_HAS_END)
-                rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev);
-            listener->state = LISTENER_HAS_END;
-        }
+        if (normal_end && listener->state != LISTENER_HAS_END)
+            rc = DeliverOneTouchEvent(client, dev, ti, grab, win, ev);
+
         if ((ti->num_listeners > 1 ||
-             (listener->type == LISTENER_GRAB &&
-              xi2mask_isset(xi2mask, dev, XI_TouchOwnership))) &&
+             listener->state != LISTENER_HAS_ACCEPTED) &&
             (ev->device_event.flags & (TOUCH_ACCEPT|TOUCH_REJECT)) == 0)
         {
             ev->any.type = ET_TouchUpdate;
             ev->device_event.flags |= TOUCH_PENDING_END;
             ti->pending_finish = TRUE;
         }
+
+        if (normal_end)
+            listener->state = LISTENER_HAS_END;
     }
 
 out:
diff --git a/include/input.h b/include/input.h
index 1015a74..8dec9fc 100644
--- a/include/input.h
+++ b/include/input.h
@@ -589,7 +589,8 @@ enum TouchListenerState{
     LISTENER_AWAITING_OWNER,       /**< Waiting for a TouchOwnership event */
     LISTENER_EARLY_ACCEPT,         /**< Waiting for ownership, has already
                                         accepted */
-    LISTENER_IS_OWNER,             /**< Is the current owner */
+    LISTENER_IS_OWNER,             /**< Is the current owner, hasn't accepted */
+    LISTENER_HAS_ACCEPTED,         /**< Is the current owner, has accepted */
     LISTENER_HAS_END,              /**< Has already received the end event */
 };
 

commit b3677a34d77797c1bdf1e14ed8fbacf119bdaf00
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon Feb 27 10:09:44 2012 +1000

    dix: when rescaling from master, rescale from desktop dimensions (#46657)
    
    master->last.valuators[] is in desktop dimensions, so use those as
    rescale axis ranges, not the screen. Otherwise, a rescale on any screen
    not the top-left will cause out-of-bounds coordinates which will always
    map to the bottom-right screen, causing the device to be stuck on that
    screen.
    
    X.Org Bug 46657 <http://bugs.freedesktop.org/show_bug.cgi?id=46657>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
    (cherry picked from commit eb84c154ed38194c32651727b6dfe2d1bde4c599)
    (cherry picked from commit a8c9a93c66edce893af3ba460d728fe2bc48c2af)
    
    Signed-off-by: Chase Douglas <chase.douglas@ubuntu.com>
    (cherry picked from commit 43782cb0eb49b0e9528f7e4655c52829ebe97c70)
    
    Signed-off-by: Chase Douglas <chase.douglas@ubuntu.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index 5da92f7..bf288f8 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -341,14 +341,16 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev)
         pDev->last.valuators[0] = rescaleValuatorAxis(pDev->last.valuators[0],
                                                       NULL,
                                                       pDev->valuator->axes + 0,
-                                                      0, scr->width);
+                                                      screenInfo.x,
+                                                      screenInfo.width);
     }
     if(pDev->valuator->numAxes > 1)
     {
         pDev->last.valuators[1] = rescaleValuatorAxis(pDev->last.valuators[1],
                                                       NULL,
                                                       pDev->valuator->axes + 1,
-                                                      0, scr->height);
+                                                      screenInfo.y,
+                                                      screenInfo.height);
     }
 
     /* calculate the other axis as well based on info from the old

commit 8474de3168a6bf4fd1d1fb7ccd3e7b58dfede76b
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Feb 16 15:11:40 2012 +1000

    Xext: return BadAccess if PickPointer fails (#45796)
    
    PickPointer or PickKeyboard return NULL, all MDs are currently disabled and
    we cannot emulate a core event. This wasn't anticipated by the protocol, so
    we don't really have an error code we may use here - BadAccess is simply the
    least bad of the possible ones.
    
    And returning BadAccess beats crashing the server.
    
    X.Org Bug 45796 <http://bugs.freedesktop.org/show_bug.cgi?id=45796>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 6b6afd3d013e3f4910fae3520d1d786df2b0e47a)
    (cherry picked from commit bc8dc7183b50800470080eaa9c04cfd6ecc3591b)
    
    Signed-off-by: Chase Douglas <chase.douglas@ubuntu.com>
    (cherry picked from commit 10f83ac92fce51fbbe892d0a3619a29d08cb1d40)
    
    Signed-off-by: Chase Douglas <chase.douglas@ubuntu.com>

diff --git a/Xext/xtest.c b/Xext/xtest.c
index cc675c1..9f07016 100644
--- a/Xext/xtest.c
+++ b/Xext/xtest.c
@@ -121,6 +121,10 @@ ProcXTestCompareCursor(ClientPtr client)
     rc = dixLookupWindow(&pWin, stuff->window, client, DixGetAttrAccess);
     if (rc != Success)
         return rc;
+
+    if (!ptr)
+        return BadAccess;
+
     if (stuff->cursor == None)
         pCursor = NullCursor;
     else if (stuff->cursor == XTestCurrentCursor)
@@ -321,9 +325,15 @@ ProcXTestFakeInput(ClientPtr client)
                 return BadValue;
         }
 
+        /* Technically the protocol doesn't allow for BadAccess here but
+         * this can only happen when all MDs are disabled.  */
+        if (!dev)
+            return BadAccess;
+
         dev = GetXTestDevice(dev);
     }
 
+
     /* If the event has a time set, wait for it to pass */
     if (ev->u.keyButtonPointer.time)
     {

commit 0e7b1080415c85f55462ad863de36df7011bf869
Author: Gaetan Nadon <memsize@videotron.ca>
Date:   Sun Feb 26 17:51:50 2012 -0500

    test: add new test cases to .gitignore
    
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit e08ed0b757b9b48344a301f612fabb3e39ffec78)
    
    Conflicts:
    
    	test/.gitignore
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/test/.gitignore b/test/.gitignore
index 0e1ed42..16be629 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -4,3 +4,4 @@ xtest
 list
 misc
 fixes
+touch
diff --git a/test/xi2/.gitignore b/test/xi2/.gitignore
index 3e9816d..817aa7b 100644
--- a/test/xi2/.gitignore
+++ b/test/xi2/.gitignore
@@ -8,3 +8,4 @@ protocol-xiqueryversion
 protocol-xiselectevents
 protocol-xisetclientpointer
 protocol-xiwarppointer
+xi2

commit ab03aafffdbad2966dc01334ecd5d328512acf90
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Feb 22 15:32:56 2012 +1000

    dix: avoid NULL-pointer dereference on button-only devices (#38313)
    
    And for such devices simply take the last.valuators[] which must be valid at
    all times anyway. UpdateSlaveDeviceCoords takes care of that.
    
    X.Org Bug 38313 <http://bugs.freedesktop.org/show_bug.cgi?id=38313>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
    (cherry picked from commit 2416ee4a015068359807a10f433e8c54192c78a9)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/dix/getevents.c b/dix/getevents.c
index d1b259d..5da92f7 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -840,10 +840,15 @@ scale_to_desktop(DeviceIntPtr dev, ValuatorMask *mask,
     ScreenPtr scr = miPointerGetScreen(dev);
     double x, y;
 
-    BUG_WARN(!dev->valuator);
-    BUG_WARN(dev->valuator->numAxes < 2);
+    BUG_WARN(!dev->valuator || dev->valuator->numAxes < 2);
     if (!dev->valuator || dev->valuator->numAxes < 2)
+    {
+        /* if we have no axes, last.valuators must be in screen coords
+         * anyway */
+        *devx = *screenx = dev->last.valuators[0];
+        *devy = *screeny = dev->last.valuators[1];
         return scr;
+    }
 
     if (valuator_mask_isset(mask, 0))
         x = valuator_mask_get_double(mask, 0);
@@ -1493,8 +1498,6 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
 {
     CARD32 ms = GetTimeInMillis();
     int num_events = 0, nev_tmp;
-    int h_scroll_axis = pDev->valuator->h_scroll_axis;
-    int v_scroll_axis = pDev->valuator->v_scroll_axis;
     ValuatorMask mask;
     ValuatorMask scroll;
     int i;
@@ -1519,6 +1522,14 @@ GetPointerEvents(InternalEvent *events, DeviceIntPtr pDev, int type,
     {
         double val, adj;
         int axis;
+        int h_scroll_axis = -1;
+        int v_scroll_axis = -1;
+
+        if (pDev->valuator)
+        {
+            h_scroll_axis = pDev->valuator->h_scroll_axis;
+            v_scroll_axis = pDev->valuator->v_scroll_axis;
+        }
 
         /* Up is negative on valuators, down positive */
         switch (buttons) {

commit b533a9bc374ddd863e29eafd9b30018a494b63aa
Author: Jeremy Huddleston <jeremyhu@apple.com>
Date:   Tue Jan 31 11:06:21 2012 -0800

    Revert "dix: don't XWarpPointer through the last slave anymore (#38313)"
    
    This reverts commit 2bfb802839688ecf328119c4c6979390fc60348d.
    
    This commit caused a regression.
    
    See: http://xquartz.macosforge.org/trac/ticket/517#comment:10
    
    Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 38000e7d1f958f5944e641de3e716944a5876d41)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/dix/events.c b/dix/events.c
index 3c7d5d0..0195255 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -3449,21 +3449,16 @@ XineramaWarpPointer(ClientPtr client)
 {
     WindowPtr	dest = NULL;
     int		x, y, rc;
-    DeviceIntPtr dev;
-    SpritePtr   pSprite;
+    SpritePtr   pSprite = PickPointer(client)->spriteInfo->sprite;
 
     REQUEST(xWarpPointerReq);
 
+
     if (stuff->dstWid != None) {
 	rc = dixLookupWindow(&dest, stuff->dstWid, client, DixReadAccess);
 	if (rc != Success)
 	    return rc;
     }
-
-    /* Post through the XTest device */
-    dev = PickPointer(client);
-    dev = GetXTestDevice(dev);
-    pSprite = dev->spriteInfo->sprite;
     x = pSprite->hotPhys.x;
     y = pSprite->hotPhys.y;
 
@@ -3513,9 +3508,9 @@ XineramaWarpPointer(ClientPtr client)
     else if (y >= pSprite->physLimits.y2)
 	y = pSprite->physLimits.y2 - 1;
     if (pSprite->hotShape)
-	ConfineToShape(dev, pSprite->hotShape, &x, &y);
+	ConfineToShape(PickPointer(client), pSprite->hotShape, &x, &y);
 
-    XineramaSetCursorPosition(dev, x, y, TRUE);
+    XineramaSetCursorPosition(PickPointer(client), x, y, TRUE);
 
     return Success;
 }
@@ -3533,7 +3528,7 @@ ProcWarpPointer(ClientPtr client)
     WindowPtr	dest = NULL;
     int		x, y, rc;
     ScreenPtr	newScreen;
-    DeviceIntPtr dev, tmp, xtest_dev = NULL;
+    DeviceIntPtr dev, tmp;
     SpritePtr   pSprite;
 
     REQUEST(xWarpPointerReq);
@@ -3546,13 +3541,11 @@ ProcWarpPointer(ClientPtr client)
 	    rc = XaceHook(XACE_DEVICE_ACCESS, client, dev, DixWriteAccess);
 	    if (rc != Success)
 		return rc;
-            if (IsXTestDevice(tmp, dev))
-                xtest_dev = tmp;
 	}
     }
 
-    /* Use the XTest device to actually move the pointer */
-    dev = xtest_dev;
+    if (dev->lastSlave)
+        dev = dev->lastSlave;
     pSprite = dev->spriteInfo->sprite;
 
 #ifdef PANORAMIX

commit ac98fb5a83b458ebecf1a2dfd2d35c9a9c8b1643
Author: Keith Packard <keithp@keithp.com>
Date:   Wed Feb 22 18:07:20 2012 +1300

    Merge remote-tracking branch 'whot/for-keith'
    (cherry picked from commit 71594746c7da32e1c7986341a0da30f241a7a2be)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index 1ecc3ba..f390f67 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,17 +692,22 @@ 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;
-    } else if (to->touch)
-    {
-        ClassesPtr classes;
-        classes = to->unused_classes;
-        classes->touch = to->touch;
-        to->touch      = NULL;
+
+
+        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 */
     }
+    /* Don't remove touch class if from->touch is non-existent. The to device
+     * may have an active touch grab, so we need to keep the touch class record
+     * around. */
 }
 
 /**
@@ -1164,6 +1169,7 @@ TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti,
     {
         EmitTouchEnd(dev, ti, 0, 0);
         TouchEndTouch(dev, ti);
+        return;
     }
 
     if (ti->listeners[0].state == LISTENER_EARLY_ACCEPT)
@@ -2215,7 +2221,7 @@ DeviceFocusEvent(DeviceIntPtr dev, int type, int mode, int detail,
 
     for (i = 0; mouse && mouse->button && i < mouse->button->numButtons; i++)
         if (BitIsOn(mouse->button->down, i))
-            SetBit(&xi2event[1], i);
+            SetBit(&xi2event[1], mouse->button->map[i]);
 
     if (dev->key)
     {
diff --git a/dix/getevents.c b/dix/getevents.c
index 048cba5..d1b259d 100644
--- a/dix/getevents.c
+++ b/dix/getevents.c
@@ -360,6 +360,7 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev)
             if (i >= lastSlave->valuator->numAxes)
             {
                 pDev->last.valuators[i] = 0;
+                valuator_mask_set_double(pDev->last.scroll, i, 0);
             }
             else
             {
@@ -367,6 +368,7 @@ updateSlaveDeviceCoords(DeviceIntPtr master, DeviceIntPtr pDev)
                 val = rescaleValuatorAxis(val, lastSlave->valuator->axes + i,
                                           pDev->valuator->axes + i, 0, 0);
                 pDev->last.valuators[i] = val;
+                valuator_mask_set_double(pDev->last.scroll, i, val);
             }
         }
     }

commit 453020e435db12eca2a3f21c1944a6e855c2349d
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Jan 27 12:41:09 2012 +1000

    Xi: handle new XIAllowEvents request in inputproto 2.1.99.6
    
    grab_window and touchid were removed from the struct for ABI compatibility
    reasons, we need to pull in the new, XI 2.2-specific struct.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Keith Packard <keithp@keithp.com>
    Signed-off-by: Keith Packard <keithp@keithp.com>
    (cherry picked from commit 7674d00b04da5cf73cfa5c7ed1d3a9f42b59960e)
    
    Conflicts:
    
    	Xi/xiallowev.c
    	configure.ac
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/Xi/xiallowev.c b/Xi/xiallowev.c
index f44dd49..6b9c795 100644
--- a/Xi/xiallowev.c
+++ b/Xi/xiallowev.c
@@ -41,6 +41,7 @@
 #include <X11/extensions/XI2proto.h>
 
 #include "exglobals.h" /* BadDevice */
+#include "exevents.h"
 #include "xiallowev.h"
 
 int
@@ -53,8 +54,12 @@ SProcXIAllowEvents(ClientPtr client)
     swaps(&stuff->length, n);
     swaps(&stuff->deviceid, n);
     swapl(&stuff->time, n);
-    /* FIXME swap touchid */
-    /* FIXME swap window */
+    if (stuff->length > 3)
+    {
+        xXI2_2AllowEventsReq *req_xi22 = (xXI2_2AllowEventsReq*)stuff;
+        swapl(&req_xi22->touchid, n);
+        swapl(&req_xi22->grab_window, n);
+    }
 
     return ProcXIAllowEvents(client);
 }
@@ -65,9 +70,21 @@ ProcXIAllowEvents(ClientPtr client)
     TimeStamp time;
     DeviceIntPtr dev;
     int ret = Success;
+    XIClientPtr xi_client;
+    Bool have_xi22 = FALSE;
+    REQUEST(xXI2_2AllowEventsReq);
 
-    REQUEST(xXIAllowEventsReq);
-    /* FIXME: check request length, 12 for XI 2.0+, 20 for XI 2.2+ */
+    xi_client = dixLookupPrivate(&client->devPrivates, XIClientPrivateKey);
+
+    if (version_compare(xi_client->major_version,
+                        xi_client->minor_version, 2, 2) >= 0)
+    {
+        REQUEST_AT_LEAST_SIZE(xXI2_2AllowEventsReq);
+        have_xi22 = TRUE;
+    } else
+    {
+        REQUEST_SIZE_MATCH(xXIAllowEventsReq);
+    }
 
     ret = dixLookupDevice(&dev, stuff->deviceid, client, DixGetAttrAccess);
     if (ret != Success)
@@ -99,8 +116,20 @@ ProcXIAllowEvents(ClientPtr client)
 	break;
     case XIRejectTouch:
     case XIAcceptTouch:
-        ret = TouchAcceptReject(client, dev, stuff->mode, stuff->touchid,
-                                stuff->grab_window, &client->errorValue);
+        {
+            int rc;
+            WindowPtr win;
+
+            if (!have_xi22)
+                return BadValue;
+
+            rc = dixLookupWindow(&win, stuff->grab_window, client, DixReadAccess);
+            if (rc != Success)
+                return rc;
+
+            ret = TouchAcceptReject(client, dev, stuff->mode, stuff->touchid,
+                                    stuff->grab_window, &client->errorValue);
+        }
         break;
     default:
 	client->errorValue = stuff->mode;
diff --git a/configure.ac b/configure.ac
index 6c83be9..5e29b2a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -785,7 +785,7 @@ WINDOWSWMPROTO="windowswmproto"
 APPLEWMPROTO="applewmproto >= 1.4"
 
 dnl Core modules for most extensions, et al.
-SDK_REQUIRED_MODULES="[xproto >= 7.0.22] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 2.1.99.5] [kbproto >= 1.0.3] fontsproto"
+SDK_REQUIRED_MODULES="[xproto >= 7.0.22] [randrproto >= 1.2.99.3] [renderproto >= 0.11] [xextproto >= 7.1.99] [inputproto >= 2.1.99.6] [kbproto >= 1.0.3] fontsproto"
 # Make SDK_REQUIRED_MODULES available for inclusion in xorg-server.pc
 AC_SUBST(SDK_REQUIRED_MODULES)
 

commit 4d7d1bd15a6a63f82f6075b2efe1e4596c41d322
Author: Benjamin Otte <otte@redhat.com>
Date:   Tue Feb 7 18:01:25 2012 +1000

    dix: fix an out-of-memory crash
    
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit b96275c4cdb164aa71f7aa9fbf88be18886d1936)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/dix/inpututils.c b/dix/inpututils.c
index 1fb9a8a..09eef25 100644
--- a/dix/inpututils.c
+++ b/dix/inpututils.c
@@ -431,6 +431,9 @@ valuator_mask_new(int num_valuators)
      * flying-car future, when we can dynamically alloc the masks and are
      * not constrained by signals, we can start using num_valuators */
     ValuatorMask *mask = calloc(1, sizeof(ValuatorMask));
+    if (mask == NULL)
+        return NULL;
+
     mask->last_bit = -1;
     return mask;
 }

commit a569ffd93767f6b496eb9f0f3f87f1bf1d03fa3f
Author: Chase Douglas <chase.douglas@canonical.com>
Date:   Fri Feb 3 16:19:11 2012 -0800

    Implement touch early accept
    
    This doesn't really implement early accept as it should. Ideally, the
    server should send end events to all subsequent touch clients as soon as
    an early accept comes in. However, this implementation is still protocol
    compliant. We can always improve it later.
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 6241b5e4fdbdb08d30cc8787d858ac27122d2d49)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/Xi/exevents.c b/Xi/exevents.c
index b0832d0..1ecc3ba 100644
--- a/Xi/exevents.c
+++ b/Xi/exevents.c
@@ -1088,6 +1088,27 @@ DeliverOneTouchEvent(ClientPtr client, DeviceIntPtr dev, TouchPointInfoPtr ti,
     return TRUE;
 }
 
+static void
+ActivateEarlyAccept(DeviceIntPtr dev, TouchPointInfoPtr ti)
+{
+    int rc;
+    ClientPtr client;
+    XID error;
+
+    rc = dixLookupClient(&client, ti->listeners[0].listener, serverClient,
+                         DixSendAccess);
+    if (rc != Success)
+    {
+        ErrorF("[Xi] Failed to lookup early accepting client.\n");
+        return;
+    }
+
+    if (TouchAcceptReject(client, dev, XIAcceptTouch, ti->client_id,
+                          ti->listeners[0].window->drawable.id, &error) !=
+        Success)
+        ErrorF("[Xi] Failed to accept touch grab after early acceptance.\n");
+}
+
 /**
  * Generate and deliver a TouchEnd event.
  *
@@ -1130,7 +1151,8 @@ TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti,
                      TouchOwnershipEvent *ev)
 {
     /* Deliver the ownership */
-    if (ti->listeners[0].state == LISTENER_AWAITING_OWNER)
+    if (ti->listeners[0].state == LISTENER_AWAITING_OWNER ||
+        ti->listeners[0].state == LISTENER_EARLY_ACCEPT)
         DeliverTouchEvents(dev, ti, (InternalEvent*)ev, ti->listeners[0].listener);
     else if (ti->listeners[0].state == LISTENER_AWAITING_BEGIN)
         TouchEventHistoryReplay(ti, dev, ti->listeners[0].listener);
@@ -1143,6 +1165,9 @@ TouchPuntToNextOwner(DeviceIntPtr dev, TouchPointInfoPtr ti,
         EmitTouchEnd(dev, ti, 0, 0);
         TouchEndTouch(dev, ti);
     }
+
+    if (ti->listeners[0].state == LISTENER_EARLY_ACCEPT)
+        ActivateEarlyAccept(dev, ti);
 }
 
 /**
diff --git a/dix/touch.c b/dix/touch.c
index f55bb8c..d04801c 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -1022,12 +1022,11 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
     if (i > 0)
     {
         if (mode == XIRejectTouch)
-        {
             TouchRejected(dev, ti, ti->listeners[i].listener, NULL);
-            return Success;
-        }
-        /* FIXME: Implement early accept */
-        return BadAccess;
+        else
+            ti->listeners[i].state = LISTENER_EARLY_ACCEPT;
+
+        return Success;
     }
 
     nev = GetTouchOwnershipEvents(events, dev, ti, mode,
diff --git a/include/input.h b/include/input.h
index 478f13d..1015a74 100644
--- a/include/input.h
+++ b/include/input.h
@@ -587,6 +587,8 @@ extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
 enum TouchListenerState{
     LISTENER_AWAITING_BEGIN = 0,   /**< Waiting for a TouchBegin event */
     LISTENER_AWAITING_OWNER,       /**< Waiting for a TouchOwnership event */
+    LISTENER_EARLY_ACCEPT,         /**< Waiting for ownership, has already
+                                        accepted */
     LISTENER_IS_OWNER,             /**< Is the current owner */
     LISTENER_HAS_END,              /**< Has already received the end event */
 };

commit d6f746e7177fa050e61f6d24e62fe060af829cca
Author: Chase Douglas <chase.douglas@canonical.com>
Date:   Fri Feb 3 16:19:10 2012 -0800

    Implement early touch reject
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit b0c54856df71f9cabf9dad176fdade960ef8c5d9)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/dix/touch.c b/dix/touch.c
index 7daf81b..f55bb8c 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -1019,9 +1019,16 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
     if (i == ti->num_listeners)
         return BadAccess;
 
-    /* FIXME: Implement early accept/reject */
     if (i > 0)
+    {
+        if (mode == XIRejectTouch)
+        {
+            TouchRejected(dev, ti, ti->listeners[i].listener, NULL);
+            return Success;
+        }
+        /* FIXME: Implement early accept */
         return BadAccess;
+    }
 
     nev = GetTouchOwnershipEvents(events, dev, ti, mode,
                                   ti->listeners[0].listener, 0);

commit 50f22a606cd101ece109c46173ba6edcead9e94e
Author: Chase Douglas <chase.douglas@canonical.com>
Date:   Fri Feb 3 16:19:09 2012 -0800

    Check for proper window ID when processing touch allow requests
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 656ab879f20892975510723ce8fe78faf64aadb4)
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>

diff --git a/Xi/xiallowev.c b/Xi/xiallowev.c
index 03d52dd..f44dd49 100644
--- a/Xi/xiallowev.c
+++ b/Xi/xiallowev.c
@@ -100,7 +100,7 @@ ProcXIAllowEvents(ClientPtr client)
     case XIRejectTouch:
     case XIAcceptTouch:
         ret = TouchAcceptReject(client, dev, stuff->mode, stuff->touchid,
-                                &client->errorValue);
+                                stuff->grab_window, &client->errorValue);
         break;
     default:
 	client->errorValue = stuff->mode;
diff --git a/dix/touch.c b/dix/touch.c
index 4a116ee..7daf81b 100644
--- a/dix/touch.c
+++ b/dix/touch.c
@@ -988,7 +988,7 @@ TouchListenerGone(XID resource)
 
 int
 TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
-                  uint32_t touchid, XID *error)
+                  uint32_t touchid, Window grab_window, XID *error)
 {
     TouchPointInfoPtr ti;
     int nev, i;
@@ -1003,8 +1003,6 @@ TouchAcceptReject(ClientPtr client, DeviceIntPtr dev, int mode,
         return BadDevice;
     }
 


Reply to: