[PATCH 1/2] dix: split xi2_mask_isset into a per-device function

Peter Hutterer peter.hutterer at who-t.net
Sun Dec 2 15:44:18 PST 2012


On Tue, Nov 20, 2012 at 12:17:55PM +1000, Peter Hutterer wrote:
> For touch selection conflicts, we need to check not only if the mask is set
> for the device, but if it is set for only that specific device (regardless
> of XIAll*Devices)
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>

ping? any takers for this series?

Cheers,
   Peter

> ---
>  dix/inpututils.c     | 30 +++++++++++++++++++++---------
>  include/inpututils.h |  1 +
>  test/xi2/xi2.c       |  6 ++++++
>  3 files changed, 28 insertions(+), 9 deletions(-)
> 
> diff --git a/dix/inpututils.c b/dix/inpututils.c
> index f01e9a7..eb11119 100644
> --- a/dix/inpututils.c
> +++ b/dix/inpututils.c
> @@ -1033,6 +1033,21 @@ xi2mask_free(XI2Mask **mask)
>  }
>  
>  /**
> + * Test if the bit for event type is set for this device only.
> + *
> + * @return TRUE if the bit is set, FALSE otherwise
> + */
> +Bool
> +xi2mask_isset_for_device(XI2Mask *mask, const DeviceIntPtr dev, int event_type)
> +{
> +    BUG_WARN(dev->id < 0);
> +    BUG_WARN(dev->id >= mask->nmasks);
> +    BUG_WARN(bits_to_bytes(event_type + 1) > mask->mask_size);
> +
> +    return BitIsOn(mask->masks[dev->id], event_type);
> +}
> +
> +/**
>   * Test if the bit for event type is set for this device, or the
>   * XIAllDevices/XIAllMasterDevices (if applicable) is set.
>   *
> @@ -1043,15 +1058,12 @@ xi2mask_isset(XI2Mask *mask, const DeviceIntPtr dev, int event_type)
>  {
>      int set = 0;
>  
> -    BUG_WARN(dev->id < 0);
> -    BUG_WARN(dev->id >= mask->nmasks);
> -    BUG_WARN(bits_to_bytes(event_type + 1) > mask->mask_size);
> -
> -    set = ! !BitIsOn(mask->masks[XIAllDevices], event_type);
> -    if (!set)
> -        set = ! !BitIsOn(mask->masks[dev->id], event_type);
> -    if (!set && IsMaster(dev))
> -        set = ! !BitIsOn(mask->masks[XIAllMasterDevices], event_type);
> +    if (xi2mask_isset_for_device(mask, inputInfo.all_devices, event_type))
> +        set = 1;
> +    else if (xi2mask_isset_for_device(mask, dev, event_type))
> +        set = 1;
> +    else if (IsMaster(dev) && xi2mask_isset_for_device(mask, inputInfo.all_master_devices, event_type))
> +        set = 1;
>  
>      return set;
>  }
> diff --git a/include/inpututils.h b/include/inpututils.h
> index cd9a4de..53c96ba 100644
> --- a/include/inpututils.h
> +++ b/include/inpututils.h
> @@ -57,6 +57,7 @@ XI2Mask *xi2mask_new(void);
>  XI2Mask *xi2mask_new_with_size(size_t, size_t); /* don't use it */
>  void xi2mask_free(XI2Mask **mask);
>  Bool xi2mask_isset(XI2Mask *mask, const DeviceIntPtr dev, int event_type);
> +Bool xi2mask_isset_for_device(XI2Mask *mask, const DeviceIntPtr dev, int event_type);
>  void xi2mask_set(XI2Mask *mask, int deviceid, int event_type);
>  void xi2mask_zero(XI2Mask *mask, int deviceid);
>  void xi2mask_merge(XI2Mask *dest, const XI2Mask *source);
> diff --git a/test/xi2/xi2.c b/test/xi2/xi2.c
> index 6ee7052..1cdad1d 100644
> --- a/test/xi2/xi2.c
> +++ b/test/xi2/xi2.c
> @@ -36,8 +36,14 @@ xi2mask_test(void)
>      XI2Mask *xi2mask = NULL, *mergemask = NULL;
>      unsigned char *mask;
>      DeviceIntRec dev;
> +    DeviceIntRec all_devices, all_master_devices;
>      int i;
>  
> +    all_devices.id = XIAllDevices;
> +    inputInfo.all_devices = &all_devices;
> +    all_master_devices.id = XIAllMasterDevices;
> +    inputInfo.all_master_devices = &all_master_devices;
> +
>      /* size >= nmasks * 2 for the test cases below */
>      xi2mask = xi2mask_new_with_size(MAXDEVICES + 2, (MAXDEVICES + 2) * 2);
>      assert(xi2mask);
> -- 
> 1.7.11.7
> 


More information about the xorg-devel mailing list