[PATCH 16/21] dix: move grab matching code into a helper function

Chase Douglas chase.douglas at canonical.com
Sun Dec 11 21:50:33 PST 2011


On 12/08/2011 07:36 PM, Peter Hutterer wrote:
> No functional changes.
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  dix/events.c |   81 +++++++++++++++++++++++++++++++++++++++++++---------------
>  1 files changed, 60 insertions(+), 21 deletions(-)
> 
> diff --git a/dix/events.c b/dix/events.c
> index 4d80358..9fcd447 100644
> --- a/dix/events.c
> +++ b/dix/events.c
> @@ -3751,6 +3751,62 @@ CoreGrabInterferes(DeviceIntPtr device, GrabPtr grab)
>      return interfering;
>  }
>  
> +enum MatchFlags {
> +    NO_MATCH    = 0x0,
> +    CORE_MATCH  = 0x1,
> +    XI_MATCH    = 0x2,
> +    XI2_MATCH   = 0x4,
> +};
> +
> +/**
> + * Match the grab against the temporary grab on the given input level.
> + * Modifies the temporary grab pointer.
> + *
> + * @param grab The grab to match against
> + * @param tmp The temporary grab to use for matching
> + * @param level The input level we want to match on
> + * @param event_type Wire protocol event type
> + *
> + * @return The respective matched flag or 0 for no match
> + */
> +static enum MatchFlags
> +MatchForType(const GrabPtr grab, GrabPtr tmp, enum InputLevel level, int event_type)
> +{
> +    enum MatchFlags match;
> +    BOOL ignore_device = FALSE;
> +    int grabtype;
> +    int evtype;
> +
> +    switch(level)
> +    {
> +        case XI2:
> +            grabtype = GRABTYPE_XI2;
> +            evtype = GetXI2Type(event_type);
> +            BUG_WARN(!evtype);
> +            match = XI2_MATCH;
> +            break;
> +        case XI:
> +            grabtype = GRABTYPE_XI;
> +            evtype = GetXIType(event_type);
> +            match = XI_MATCH;
> +            break;
> +        case CORE:
> +            grabtype = GRABTYPE_CORE;
> +            evtype = GetCoreType(event_type);
> +            match = CORE_MATCH;
> +            ignore_device = TRUE;
> +            break;
> +    }
> +
> +    tmp->grabtype = grabtype;
> +    tmp->type = evtype;

Why use two variables on the stack when you could just set tmp->grabtype
and tmp->type directly in the switch statement?

There aren't any functional issues with the code. As such, it's good
enough for me:

Reviewed-by: Chase Douglas <chase.douglas at canonical.com>


More information about the xorg-devel mailing list