[PATCH v2] xkb: post-fix PointerKeys button events with a DeviceChangedEvent.

Peter Hutterer peter.hutterer at who-t.net
Wed Aug 11 23:46:25 PDT 2010


On Thu, Aug 12, 2010 at 04:27:06PM +1000, Peter Hutterer wrote:
> commit 14327858391ebe929b806efb53ad79e789361883
>     xkb: release XTEST pointer buttons on physical releases. (#28808)
> revealed a bug with the XTEST/PointerKeys interaction.
[...]
> @@ -1368,41 +1386,47 @@ XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
>          mieqProcessDeviceEvent(ptr, (InternalEvent*)events[i].event, NULL);
>  
>      FreeEventList(events, GetMaximumEventsNum());
> +
> +}
> +
> +static void
> +XkbFakePointerMotion(DeviceIntPtr dev, unsigned flags,int x,int y)
> +{
> +    int                 gpe_flags = 0;
> +
> +    /* ignore attached SDs */
> +    if (!IsMaster(dev) && GetMaster(dev, MASTER_POINTER) != NULL)
> +        return;
> +
> +    if (flags & XkbSA_MoveAbsoluteX || flags & XkbSA_MoveAbsoluteY)
> +        gpe_flags = POINTER_ABSOLUTE;
> +    else
> +        gpe_flags = POINTER_RELATIVE;
> +
> +    InjectPointerKeyEvents(dev, MotionNotify, 0, gpe_flags, 2, (int[]){x, y});
>  }
>  
>  void
>  XkbFakeDeviceButton(DeviceIntPtr dev,Bool press,int button)
>  {
> -    EventListPtr        events;
> -    int                 nevents, i;
>      DeviceIntPtr        ptr;
>  
>      /* If dev is a slave device, and the SD is attached, do nothing. If we'd
>       * post through the attached master pointer we'd get duplicate events.
>       *
>       * if dev is a master keyboard, post through the XTEST device
> -     *
>       * if dev is a floating slave, post through the device itself.
> +     *
>       */
>  
> -    if (IsMaster(dev))
> -        ptr = GetXTestDevice(GetMaster(dev, MASTER_POINTER));
> -    else if (!dev->u.master)
> +    if (IsMaster(dev)) {
> +        DeviceIntPtr mpointer = GetMaster(dev, MASTER_POINTER);
> +        ptr = GetXTestDevice(mpointer);
> +    } else if (!dev->u.master)
>          ptr = dev;
>      else
>          return;

as Daniel pointed out on IRC, this check should be the same as in
XkbFakePointerMotion. It isn't, because the follow-up patch uses ptr to
check for button down and I didn't fix this up during the rebase &
squashing. So rather than adding the same check and removing it with the
follow-up patch, this is the final hunk. Sorry, I can rebase this again to
look proper in the history but there's no adverse effect.

Cheers,
  Peter
  


More information about the xorg-devel mailing list