[PATCH 2/2] DIX/Xi: Don't grab device buttons if no grab is registered

Peter Hutterer peter.hutterer at who-t.net
Thu Aug 15 22:37:42 PDT 2013


On Thu, Aug 15, 2013 at 03:49:21PM +0200, Egbert Eich wrote:
> Core events implicietely grab buttons on button press events, for

typo

> Xi (ie. device) button press events this is not specified.

it is specified, see XIproto.txt:
  For DeviceButtonPress events, the client may specify whether or
  not an implicit passive grab should be done when the button is
  pressed. If the client wants to guarantee that it will receive
  a DeviceButtonRelease event for each DeviceButtonPress event it
  receives, it should specify the DeviceButtonPressGrab event
  class as well as the DeviceButtonPress event class. This
  restricts the client in that only one client at a time may
  request DeviceButtonPress events from the same device and
  window if any client specifies this class.

I read this as default: no implicit grab, DeviceButtonPressGrab: always
implicit grab.

> The test clause we are removing however applied the core event
> behavior also to Xi events causing button release events being
> delivered only to a single client even if no client explicitely
> belongs to the DeviceButtonPressGrabClass.
> Note: while this behavior is reasonable there is nothing in the
> Xi specs that guarantees the delivery of a ButtonRelease event
> for every ButtonPress event if the client hasn't specifically
> registered for the DeviceButtonPressGrab class.
> In other words this patch removes the 'implicite dragging' from
> Xi extension button events.

This doesn't take the DeviceButtonPressGrab into account then.
how about this diff?

diff --git a/dix/events.c b/dix/events.c
index c3a0ae7..10351e3 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -1990,6 +1990,8 @@ ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win,

     if (type == ButtonPress)
         grabtype = CORE;
+    else if (type == DeviceButtonPress && (deliveryMask & DeviceButtonGrabMask))
+        grabtype = XI;
     else if ((type = xi2_get_type(event)) == XI_ButtonPress)
         grabtype = XI2;
     else

what I do wonder though is if there are clients that rely on the current
behaviour. did you have something break that triggered this patchset?

Cheers,
   Peter

 
> Signed-off-by: Egbert Eich <eich at freedesktop.org>
> ---
>  dix/events.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/dix/events.c b/dix/events.c
> index 36708bf..11dafa9 100644
> --- a/dix/events.c
> +++ b/dix/events.c
> @@ -2034,8 +2034,6 @@ ActivateImplicitGrab(DeviceIntPtr dev, ClientPtr client, WindowPtr win,
>  
>      if (type == ButtonPress)
>          grabtype = CORE;
> -    else if (type == DeviceButtonPress)
> -        grabtype = XI;
>      else if ((type = xi2_get_type(event)) == XI_ButtonPress)
>          grabtype = XI2;
>      else
> -- 
> 1.8.1.4
> 


More information about the xorg-devel mailing list