mirror of
https://gitlab.freedesktop.org/xorg/xserver.git
synced 2026-01-01 20:00:09 +01:00
dix: free the old grab when activating a new grab
A client may call XIGrabDevice twice, overwriting the existing grab. Thus,
make sure we free the old copy after we copied it. Free it last, to make
sure our refcounts don't run to 0 and inadvertantly free something on the
way.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 3093f78d17)
This commit is contained in:
parent
ef0fff102d
commit
0ee9704f3c
1 changed files with 6 additions and 1 deletions
|
|
@ -1465,6 +1465,7 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab,
|
|||
TimeStamp time, Bool autoGrab)
|
||||
{
|
||||
GrabInfoPtr grabinfo = &mouse->deviceGrab;
|
||||
GrabPtr oldgrab = grabinfo->grab;
|
||||
WindowPtr oldWin = (grabinfo->grab) ?
|
||||
grabinfo->grab->window : mouse->spriteInfo->sprite->win;
|
||||
Bool isPassive = autoGrab & ~ImplicitGrabMask;
|
||||
|
|
@ -1497,6 +1498,8 @@ ActivatePointerGrab(DeviceIntPtr mouse, GrabPtr grab,
|
|||
UpdateTouchesForGrab(mouse);
|
||||
CheckGrabForSyncs(mouse, (Bool) grab->pointerMode,
|
||||
(Bool) grab->keyboardMode);
|
||||
if (oldgrab)
|
||||
FreeGrab(oldgrab);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1567,6 +1570,7 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time,
|
|||
Bool passive)
|
||||
{
|
||||
GrabInfoPtr grabinfo = &keybd->deviceGrab;
|
||||
GrabPtr oldgrab = grabinfo->grab;
|
||||
WindowPtr oldWin;
|
||||
|
||||
/* slave devices need to float for the duration of the grab. */
|
||||
|
|
@ -1592,12 +1596,13 @@ ActivateKeyboardGrab(DeviceIntPtr keybd, GrabPtr grab, TimeStamp time,
|
|||
grabinfo->grabTime = syncEvents.time;
|
||||
else
|
||||
grabinfo->grabTime = time;
|
||||
BUG_WARN(grabinfo->grab != NULL);
|
||||
grabinfo->grab = AllocGrab(grab);
|
||||
grabinfo->fromPassiveGrab = passive;
|
||||
grabinfo->implicitGrab = passive & ImplicitGrabMask;
|
||||
CheckGrabForSyncs(keybd, (Bool) grab->keyboardMode,
|
||||
(Bool) grab->pointerMode);
|
||||
if (oldgrab)
|
||||
FreeGrab(oldgrab);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue