diff --git a/dix/devices.c b/dix/devices.c index 9b6faee23..c514d7756 100644 --- a/dix/devices.c +++ b/dix/devices.c @@ -281,7 +281,6 @@ AddInputDevice(ClientPtr client, DeviceProc deviceProc, Bool autoStart) dev->deviceGrab.grabTime = currentTime; dev->deviceGrab.ActivateGrab = ActivateKeyboardGrab; dev->deviceGrab.DeactivateGrab = DeactivateKeyboardGrab; - dev->deviceGrab.activeGrab = AllocGrab(); dev->deviceGrab.sync.event = calloc(1, sizeof(DeviceEvent)); XkbSetExtension(dev, ProcessKeyboardEvent); @@ -977,7 +976,8 @@ CloseDevice(DeviceIntPtr dev) } } - FreeGrab(dev->deviceGrab.activeGrab); + if (dev->deviceGrab.grab) + FreeGrab(dev->deviceGrab.grab); free(dev->deviceGrab.sync.event); free(dev->config_info); /* Allocated in xf86ActivateDevice. */ free(dev->last.scroll); diff --git a/dix/events.c b/dix/events.c index da9bd3821..e2e94a5f6 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1490,8 +1490,9 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab, grabinfo->grabTime = time; if (grab->cursor) grab->cursor->refcnt++; - CopyGrab(grabinfo->activeGrab, grab); - grabinfo->grab = grabinfo->activeGrab; + BUG_WARN(grabinfo->grab != NULL); + grabinfo->grab = AllocGrab(); + CopyGrab(grabinfo->grab, grab); grabinfo->fromPassiveGrab = isPassive; grabinfo->implicitGrab = autoGrab & ImplicitGrabMask; PostNewCursor(mouse); @@ -1554,6 +1555,8 @@ DeactivatePointerGrab(DeviceIntPtr mouse) ReattachToOldMaster(mouse); ComputeFreezes(); + + FreeGrab(grab); } /** @@ -1591,8 +1594,9 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, grabinfo->grabTime = syncEvents.time; else grabinfo->grabTime = time; - CopyGrab(grabinfo->activeGrab, grab); - grabinfo->grab = grabinfo->activeGrab; + BUG_WARN(grabinfo->grab != NULL); + grabinfo->grab = AllocGrab(); + CopyGrab(grabinfo->grab, grab); grabinfo->fromPassiveGrab = passive; grabinfo->implicitGrab = passive & ImplicitGrabMask; CheckGrabForSyncs(keybd, (Bool) grab->keyboardMode, @@ -1638,6 +1642,8 @@ DeactivateKeyboardGrab(DeviceIntPtr keybd) ReattachToOldMaster(keybd); ComputeFreezes(); + + FreeGrab(grab); } void diff --git a/include/inputstr.h b/include/inputstr.h index de96faeda..85be885a0 100644 --- a/include/inputstr.h +++ b/include/inputstr.h @@ -485,7 +485,7 @@ typedef struct _GrabInfoRec { TimeStamp grabTime; Bool fromPassiveGrab; /* true if from passive grab */ Bool implicitGrab; /* implicit from ButtonPress */ - GrabPtr activeGrab; + GrabPtr unused; /* Kept for ABI stability, remove soon */ GrabPtr grab; CARD8 activatingKey; void (*ActivateGrab) (DeviceIntPtr /*device */ ,