diff options
Diffstat (limited to 'xorg-server/dix/grabs.c')
-rw-r--r-- | xorg-server/dix/grabs.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/xorg-server/dix/grabs.c b/xorg-server/dix/grabs.c index 3b02352df..a03897af4 100644 --- a/xorg-server/dix/grabs.c +++ b/xorg-server/dix/grabs.c @@ -189,7 +189,7 @@ UngrabAllDevices(Bool kill_client) } GrabPtr -AllocGrab(void) +AllocGrab(const GrabPtr src) { GrabPtr grab = calloc(1, sizeof(GrabRec)); @@ -201,6 +201,12 @@ AllocGrab(void) } } + if (src && !CopyGrab(grab, src)) { + free(grab->xi2mask); + free(grab); + grab = NULL; + } + return grab; } @@ -213,7 +219,7 @@ CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice, { GrabPtr grab; - grab = AllocGrab(); + grab = AllocGrab(NULL); if (!grab) return (GrabPtr) NULL; grab->resource = FakeClientID(client); @@ -235,13 +241,11 @@ CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice, grab->detail.exact = keybut; grab->detail.pMask = NULL; grab->confineTo = confineTo; - grab->cursor = cursor; + grab->cursor = RefCursor(cursor); grab->next = NULL; if (grabtype == XI2) xi2mask_merge(grab->xi2mask, mask->xi2mask); - if (cursor) - cursor->refcnt++; return grab; } @@ -249,8 +253,7 @@ CreateGrab(int client, DeviceIntPtr device, DeviceIntPtr modDevice, void FreeGrab(GrabPtr pGrab) { - if (pGrab->grabtype == XI2 && pGrab->type == XI_TouchBegin) - TouchListenerGone(pGrab->resource); + BUG_RETURN(!pGrab); free(pGrab->modifiersDetail.pMask); free(pGrab->detail.pMask); @@ -269,9 +272,6 @@ CopyGrab(GrabPtr dst, const GrabPtr src) Mask *details_mask = NULL; XI2Mask *xi2mask; - if (src->cursor) - src->cursor->refcnt++; - if (src->modifiersDetail.pMask) { int len = MasksPerDetailMask * sizeof(Mask); @@ -309,6 +309,7 @@ CopyGrab(GrabPtr dst, const GrabPtr src) dst->modifiersDetail.pMask = mdetails_mask; dst->detail.pMask = details_mask; dst->xi2mask = xi2mask; + dst->cursor = RefCursor(src->cursor); xi2mask_merge(dst->xi2mask, src->xi2mask); |