[PATCH 11/11] dix: add is_xi2_event_of_type helper function.

Jamey Sharp jamey at minilop.net
Wed May 11 14:45:57 PDT 2011


I'm not sure this is an improvement if you take my proposed alternative
to patches 3 and 4. With that alternative patch, the check for
((xGenericEvent*)pEvents)->evtype == XI_ButtonPress is immediately
followed by "type = ((xGenericEvent*)pEvents)->evtype", which suggests
other ways you could refactor it if you care.

Still, you're welcome to a

Reviewed-by: Jamey Sharp <jamey at minilop.net>

Jamey

On Wed, May 11, 2011 at 02:49:50PM +1000, Peter Hutterer wrote:
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  dix/events.c |   23 ++++++++++++++---------
>  1 files changed, 14 insertions(+), 9 deletions(-)
> 
> diff --git a/dix/events.c b/dix/events.c
> index 7885e86..f3af5ee 100644
> --- a/dix/events.c
> +++ b/dix/events.c
> @@ -190,6 +190,11 @@ is_xi2_event(const xEvent *event)
>             ((xGenericEvent*)event)->extension == IReqCode;
>  }
>  
> +static inline BOOL
> +is_xi2_event_of_type(const xEvent *event, int type)
> +{
> +    return is_xi2_event(event) && ((xGenericEvent*)event)->evtype == type;
> +}
>  
>  /**
>   * Used to indicate a implicit passive grab created by a ButtonPress event.
> @@ -2105,7 +2110,7 @@ IsButtonPressEvent(xEvent *pEvents)
>  {
>      int type = pEvents->u.u.type;
>  
> -    if (((is_xi2_event(pEvents) && ((xGenericEvent*)pEvents)->evtype == XI_ButtonPress)) ||
> +    if (is_xi2_event_of_type(pEvents, XI_ButtonPress) ||
>              type == DeviceButtonPress || type == ButtonPress)
>          return TRUE;
>      else
> @@ -2340,14 +2345,14 @@ FixUpEventFromWindow(
>      {
>          xXIDeviceEvent* event = (xXIDeviceEvent*)xE;
>  
> -        if (event->evtype == XI_RawKeyPress ||
> -            event->evtype == XI_RawKeyRelease ||
> -            event->evtype == XI_RawButtonPress ||
> -            event->evtype == XI_RawButtonRelease ||
> -            event->evtype == XI_RawMotion ||
> -            event->evtype == XI_DeviceChanged ||
> -            event->evtype == XI_HierarchyChanged ||
> -            event->evtype == XI_PropertyEvent)
> +        if (is_xi2_event_of_type(xE, XI_RawKeyRelease)    ||
> +            is_xi2_event_of_type(xE, XI_RawKeyRelease)    ||
> +            is_xi2_event_of_type(xE, XI_RawButtonPress)   ||
> +            is_xi2_event_of_type(xE, XI_RawButtonRelease) ||
> +            is_xi2_event_of_type(xE, XI_RawMotion)        ||
> +            is_xi2_event_of_type(xE, XI_DeviceChanged)    ||
> +            is_xi2_event_of_type(xE, XI_HierarchyChanged) ||
> +            is_xi2_event_of_type(xE, XI_PropertyEvent))
>              return;
>  
>          event->root = RootWindow(pSprite)->drawable.id;
> -- 
> 1.7.4.4
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg-devel/attachments/20110511/cab36d88/attachment.pgp>


More information about the xorg-devel mailing list