diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2013-04-23 15:52:18 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2013-07-17 14:35:49 +1000 |
commit | 6bd9badc780ec9d1fb147dfa0c671979c75b722c (patch) | |
tree | ef1e231db1c8e204f15e830387688b2c3d7fdef1 /dix | |
parent | 479f8bf236d17e2a2093d349d2ef6471ff089a53 (diff) |
dix: AllocGrab can copy if an argument is passed in
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 925e35122ebad877395bcf13676e9dbeb254bdfa)
Diffstat (limited to 'dix')
-rw-r--r-- | dix/events.c | 16 | ||||
-rw-r--r-- | dix/grabs.c | 10 |
2 files changed, 15 insertions, 11 deletions
diff --git a/dix/events.c b/dix/events.c index 0216502a2..6a8e7a64a 100644 --- a/dix/events.c +++ b/dix/events.c @@ -1489,8 +1489,7 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab, if (grab->cursor) grab->cursor->refcnt++; BUG_WARN(grabinfo->grab != NULL); - grabinfo->grab = AllocGrab(); - CopyGrab(grabinfo->grab, grab); + grabinfo->grab = AllocGrab(grab); grabinfo->fromPassiveGrab = isPassive; grabinfo->implicitGrab = autoGrab & ImplicitGrabMask; PostNewCursor(mouse); @@ -1593,8 +1592,7 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time, else grabinfo->grabTime = time; BUG_WARN(grabinfo->grab != NULL); - grabinfo->grab = AllocGrab(); - CopyGrab(grabinfo->grab, grab); + grabinfo->grab = AllocGrab(grab); grabinfo->fromPassiveGrab = passive; grabinfo->implicitGrab = passive & ImplicitGrabMask; CheckGrabForSyncs(keybd, (Bool) grab->keyboardMode, @@ -1988,7 +1986,7 @@ ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win, else return FALSE; - tempGrab = AllocGrab(); + tempGrab = AllocGrab(NULL); if (!tempGrab) return FALSE; tempGrab->next = NULL; @@ -3895,7 +3893,7 @@ CheckPassiveGrabsOnWindow(WindowPtr pWin, if (!grab) return NULL; - tempGrab = AllocGrab(); + tempGrab = AllocGrab(NULL); /* Fill out the grab details, but leave the type for later before * comparing */ @@ -5084,7 +5082,7 @@ GrabDevice(ClientPtr client, DeviceIntPtr dev, else { GrabPtr tempGrab; - tempGrab = AllocGrab(); + tempGrab = AllocGrab(NULL); tempGrab->next = NULL; tempGrab->window = pWin; @@ -5440,7 +5438,7 @@ ProcUngrabKey(ClientPtr client) client->errorValue = stuff->modifiers; return BadValue; } - tempGrab = AllocGrab(); + tempGrab = AllocGrab(NULL); if (!tempGrab) return BadAlloc; tempGrab->resource = client->clientAsMask; @@ -5634,7 +5632,7 @@ ProcUngrabButton(ClientPtr client) ptr = PickPointer(client); - tempGrab = AllocGrab(); + tempGrab = AllocGrab(NULL); if (!tempGrab) return BadAlloc; tempGrab->resource = client->clientAsMask; diff --git a/dix/grabs.c b/dix/grabs.c index 0a2111d8a..f46a6b23a 100644 --- a/dix/grabs.c +++ b/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); |