[PATCH 21/21] dix: always allocate and set the grab's sync.event

Peter Hutterer peter.hutterer at who-t.net
Thu Dec 8 19:36:22 PST 2011


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 at who-t.net>
---
 dix/devices.c |    1 +
 dix/events.c  |    8 +-------
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/dix/devices.c b/dix/devices.c
index e448eab..9ca8fe0 100644
--- a/dix/devices.c
+++ b/dix/devices.c
@@ -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);
 
diff --git a/dix/events.c b/dix/events.c
index 69b64ba..828b143 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -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;
 	}
-- 
1.7.7.1



More information about the xorg-devel mailing list