Imported Debian patch 2:1.11.4-0ubuntu10.1
[glsdk/xserver.git] / Xi / exevents.c
index f390f67393b2965d6a5ae3da44ebefff245534dc..d71e604350beb307f6814b4f7655f319c24c1638 100644 (file)
@@ -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: