[PATCH 1/4] Let CheckPassiveGrabsOnWindow callers check if device is already grabbed.

Peter Hutterer peter.hutterer at who-t.net
Wed Aug 11 18:26:20 PDT 2010


[sorry, was stuck in my outbox]

On Wed, Aug 04, 2010 at 02:23:02PM -0700, Jamey Sharp wrote:
> CheckDeviceGrabs checked all the ancestors of the window containing this
> device's pointer even if no new grabs could possibly apply due to the
> device already being grabbed.
> 
> ActivateFocusInGrab and ActivateEnterGrab already checked whether they
> should break an existing grab, and then set up an event that was
> completely ignored if they didn't actually break the grab.
> 
> In both cases, just do what we would have done eventually anyway--return
> FALSE from CheckPassiveGrabsOnWindow's caller--but do it sooner.
> 
> Signed-off-by: Jamey Sharp <jamey at minilop.net>
> Cc: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  dix/events.c |   22 +++++++++++-----------
>  1 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/dix/events.c b/dix/events.c
> index 07f7b1f..e03e58c 100644
> --- a/dix/events.c
> +++ b/dix/events.c
> @@ -2648,11 +2648,11 @@ ActivateFocusInGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
>      BOOL rc = FALSE;
>      DeviceEvent event;
>  
> -    if (dev->deviceGrab.grab &&
> -        dev->deviceGrab.fromPassiveGrab &&
> -        dev->deviceGrab.grab->type == XI_Enter)
> +    if (dev->deviceGrab.grab)
>      {
> -        if (dev->deviceGrab.grab->window == win ||
> +        if (!dev->deviceGrab.fromPassiveGrab ||
> +            dev->deviceGrab.grab->type != XI_Enter ||
> +            dev->deviceGrab.grab->window == win ||
>              IsParent(dev->deviceGrab.grab->window, win))
>              return FALSE;
>          DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
> @@ -2688,11 +2688,11 @@ ActivateEnterGrab(DeviceIntPtr dev, WindowPtr old, WindowPtr win)
>      BOOL rc = FALSE;
>      DeviceEvent event;
>  
> -    if (dev->deviceGrab.grab &&
> -        dev->deviceGrab.fromPassiveGrab &&
> -        dev->deviceGrab.grab->type == XI_Enter)
> +    if (dev->deviceGrab.grab)
>      {
> -        if (dev->deviceGrab.grab->window == win ||
> +        if (!dev->deviceGrab.fromPassiveGrab ||
> +            dev->deviceGrab.grab->type != XI_Enter ||
> +            dev->deviceGrab.grab->window == win ||
>              IsParent(dev->deviceGrab.grab->window, win))
>              return FALSE;
>          DoEnterLeaveEvents(dev, dev->id, old, win, XINotifyPassiveUngrab);
> @@ -3403,9 +3403,6 @@ CheckPassiveGrabsOnWindow(
>  #define XI2_MATCH        0x4
>      int match = 0;
>  
> -    if (device->deviceGrab.grab)
> -        return FALSE;
> -
>      if (!grab)
>  	return FALSE;
>      /* Fill out the grab details, but leave the type for later before
> @@ -3629,6 +3626,9 @@ CheckDeviceGrabs(DeviceIntPtr device, DeviceEvent *event, int checkFirst)
>          && (device->button->buttonsDown != 1))
>  	return FALSE;
>  
> +    if (device->deviceGrab.grab)
> +        return FALSE;
> +
>      i = checkFirst;
>  
>      if (focus)
> -- 
> 1.7.0

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

Cheers,
  Peter


More information about the xorg-devel mailing list