Commit 348cc6cf authored by Marco Trevisan's avatar Marco Trevisan
Browse files

dix: keep a copy of current grab if we're rejecting the touch

As part of TouchRemoveListener, the grab will be free'd, thus not risk to
double-free it, better to keep a copy of the current grab.

Fixes #7
parent 3297a1c8
Pipeline #6971 passed with stage
in 1 minute and 41 seconds
......@@ -1556,6 +1556,7 @@ void
DeactivatePointerGrab(DeviceIntPtr mouse)
{
GrabPtr grab = mouse->deviceGrab.grab;
GrabPtr oldGrab = grab;
DeviceIntPtr dev;
Bool wasPassive = mouse->deviceGrab.fromPassiveGrab;
Bool wasImplicit = (mouse->deviceGrab.fromPassiveGrab &&
......@@ -1580,6 +1581,11 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
* TouchEmitTouchEnd for this listener. The other half of
* this hack is in DeliverTouchEndEvent */
ti->listeners[0].state = LISTENER_HAS_END;
} else if (grab == oldGrab) {
/* If we reject a touch, then we implicitly free the Grab
* as part of TouchRemoveListener, and thus let's keep
* a temporary copy here to avoid working on invalid data */
grab = AllocGrab(grab);
}
TouchListenerAcceptReject(mouse, ti, 0, mode);
}
......@@ -1593,7 +1599,7 @@ DeactivatePointerGrab(DeviceIntPtr mouse)
mouse->deviceGrab.fromPassiveGrab = FALSE;
for (dev = inputInfo.devices; dev; dev = dev->next) {
if (dev->deviceGrab.sync.other == grab)
if (dev->deviceGrab.sync.other == oldGrab)
dev->deviceGrab.sync.other = NullGrab;
}
DoEnterLeaveEvents(mouse, mouse->id, grab->window,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment