[PATCH 5/5] dix: move event filter retrieval helpers to inpututils.c

walter harms wharms at bfs.de
Sat Dec 10 04:55:34 PST 2011



Am 10.12.2011 08:54, schrieb Peter Hutterer:
> No functional changes
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  dix/events.c         |   24 ++++++------------------
>  dix/inpututils.c     |   19 +++++++++++++++++++
>  include/input.h      |    1 -
>  include/inpututils.h |    4 ++++
>  4 files changed, 29 insertions(+), 19 deletions(-)
> 
> diff --git a/dix/events.c b/dix/events.c
> index 309db9e..7bb6b72 100644
> --- a/dix/events.c
> +++ b/dix/events.c
> @@ -367,7 +367,7 @@ extern int DeviceMotionNotify;
>   * time a button is pressed, the filter is modified to also contain the
>   * matching ButtonXMotion mask.
>   */
> -static Mask filters[MAXDEVICES][128];
> +Mask filters[MAXDEVICES][128];
>  
>  static const Mask default_filter[128] =
>  {
> @@ -408,18 +408,6 @@ static const Mask default_filter[128] =
>  	CantBeFiltered		       /* MappingNotify */
>  };
>  

could you please add a line that explains why 128 ?
re,
 wh


> -static inline Mask
> -GetEventFilterMask(DeviceIntPtr dev, int evtype)
> -{
> -    return filters[dev ? dev->id : 0][evtype];
> -}
> -
> -inline Mask
> -GetXI2EventFilterMask(int evtype)
> -{
> -    return (1 << (evtype % 8));
> -}
> -
>  /**
>   * For the given event, return the matching event filter. This filter may then
>   * be AND'ed with the selected event mask.
> @@ -441,9 +429,9 @@ GetEventFilter(DeviceIntPtr dev, xEvent *event)
>      int evtype = 0;
>  
>      if (event->u.u.type != GenericEvent)
> -        return GetEventFilterMask(dev, event->u.u.type);
> +        return event_get_filter_from_type(dev, event->u.u.type);
>      else if ((evtype = xi2_get_type(event)))
> -        return GetXI2EventFilterMask(evtype);
> +        return event_get_filter_from_xi2type(evtype);
>      ErrorF("[dix] Unknown event type %d. No filter\n", event->u.u.type);
>      return 0;
>  }
> @@ -459,7 +447,7 @@ GetXI2MaskByte(XI2Mask *mask, DeviceIntPtr dev, int event_type)
>       * for this mask anyway.
>       */
>      if (xi2mask_isset(mask, dev, event_type))
> -        return GetXI2EventFilterMask(event_type);
> +        return event_get_filter_from_xi2type(event_type);
>      else
>          return 0;
>  }
> @@ -2554,7 +2542,7 @@ EventIsDeliverable(DeviceIntPtr dev, int evtype, WindowPtr win)
>  
>      if ((type = GetXIType(evtype)) != 0)
>      {
> -        filter = GetEventFilterMask(dev, type);
> +        filter = event_get_filter_from_type(dev, type);
>  
>          /* Check for XI mask */
>          if (inputMasks &&
> @@ -2570,7 +2558,7 @@ EventIsDeliverable(DeviceIntPtr dev, int evtype, WindowPtr win)
>  
>      if ((type = GetCoreType(evtype)) != 0)
>      {
> -        filter = GetEventFilterMask(dev, type);
> +        filter = event_get_filter_from_type(dev, type);
>  
>          /* Check for core mask */
>          if ((win->deliverableEvents & filter) &&
> diff --git a/dix/inpututils.c b/dix/inpututils.c
> index 5844daf..54a35fe 100644
> --- a/dix/inpututils.c
> +++ b/dix/inpututils.c
> @@ -695,6 +695,25 @@ void event_set_state(DeviceIntPtr mouse, DeviceIntPtr kbd, DeviceEvent *event)
>      }
>  }
>  
> +/**
> + * Return the event filter mask for the given device and the given core or
> + * XI1 protocol type.
> + */
> +Mask
> +event_get_filter_from_type(DeviceIntPtr dev, int evtype)
> +{
> +    return filters[dev ? dev->id : 0][evtype];
> +}
> +
> +/**
> + * Return the event filter mask for the given device and the given core or
> + * XI2 protocol type.
> + */
> +Mask
> +event_get_filter_from_xi2type(int evtype)
> +{
> +    return (1 << (evtype % 8));
> +}
>  
>  Bool
>  point_on_screen(ScreenPtr pScreen, int x, int y)
> diff --git a/include/input.h b/include/input.h
> index fb24fd5..bd12f68 100644
> --- a/include/input.h
> +++ b/include/input.h
> @@ -544,7 +544,6 @@ extern _X_EXPORT void FreeInputAttributes(InputAttributes *attrs);
>  extern Mask GetEventMask(DeviceIntPtr dev, xEvent* ev, InputClientsPtr clients);
>  extern Mask GetEventFilter(DeviceIntPtr dev, xEvent *event);
>  extern Bool WindowXI2MaskIsset(DeviceIntPtr dev, WindowPtr win, xEvent* ev);
> -extern Mask GetXI2EventFilterMask(int evtype);
>  extern int GetXI2MaskByte(XI2Mask *mask, DeviceIntPtr dev, int event_type);
>  void FixUpEventFromWindow(SpritePtr pSprite,
>                            xEvent *xE,
> diff --git a/include/inpututils.h b/include/inpututils.h
> index 96ad6df..5aa60c2 100644
> --- a/include/inpututils.h
> +++ b/include/inpututils.h
> @@ -32,6 +32,8 @@
>  #include "input.h"
>  #include <X11/extensions/XI2proto.h>
>  
> +extern Mask filters[MAXDEVICES][128];
> +
>  struct _ValuatorMask {
>      int8_t      last_bit; /* highest bit set in mask */
>      uint8_t     mask[(MAX_VALUATORS + 7)/8];
> @@ -42,6 +44,8 @@ extern void verify_internal_event(const InternalEvent *ev);
>  extern void init_device_event(DeviceEvent *event, DeviceIntPtr dev, Time ms);
>  extern int event_get_corestate(DeviceIntPtr mouse, DeviceIntPtr kbd);
>  extern void event_set_state(DeviceIntPtr mouse, DeviceIntPtr kbd, DeviceEvent *event);
> +extern Mask event_get_filter_from_type(DeviceIntPtr dev, int evtype);
> +extern Mask event_get_filter_from_xi2type(int evtype);
>  
>  FP3232 double_to_fp3232(double in);
>  FP1616 double_to_fp1616(double in);


More information about the xorg-devel mailing list