dix: always allocate and set the grab's sync.event

Allocate the memory at device creation time and always store the event, even
if we're not frozen. This way we know which event triggered the grab.
Since the event was never freed anyway except on device shutdown, this
doesn't really change things much.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
This commit is contained in:
Peter Hutterer 2011-12-08 15:38:44 +10:00
parent 218752bdc5
commit a15abf82dd
2 changed files with 2 additions and 7 deletions

View File

@ -275,6 +275,7 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart)
dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab;
dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab;
dev->deviceGrab.activeGrab = AllocGrab();
dev->deviceGrab.sync.event = calloc(1, sizeof(DeviceEvent));
XkbSetExtension(dev, ProcessKeyboardEvent);

View File

@ -3717,12 +3717,8 @@ ActivatePassiveGrab(DeviceIntPtr device, GrabPtr grab, InternalEvent *event)
}
if (grabinfo->sync.state == FROZEN_NO_EVENT)
{
if (!grabinfo->sync.event)
grabinfo->sync.event = calloc(1, sizeof(DeviceEvent));
*grabinfo->sync.event = event->device_event;
grabinfo->sync.state = FROZEN_WITH_EVENT;
}
*grabinfo->sync.event = event->device_event;
free(xE);
return TRUE;
@ -4310,8 +4306,6 @@ DeliverGrabbedEvent(InternalEvent *event, DeviceIntPtr thisDev,
case FREEZE_NEXT_EVENT:
grabinfo->sync.state = FROZEN_WITH_EVENT;
FreezeThaw(thisDev, TRUE);
if (!grabinfo->sync.event)
grabinfo->sync.event = calloc(1, sizeof(InternalEvent));
*grabinfo->sync.event = event->device_event;
break;
}