[PATCH 01/11] dix: split out window owner event delivery from DeliverEventsToWindow

Jamey Sharp jamey at minilop.net
Wed May 11 13:36:49 PDT 2011


This looks good, but is there some strong reason not to just use early
returns in DeliverToWindowOwner?

I'd re-write it this way:

On Wed, May 11, 2011 at 02:49:40PM +1000, Peter Hutterer wrote:
> +static enum EventDeliveryState
> +DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win,
> +                     xEvent *events, int count, Mask filter,
> +                     GrabPtr grab)
> +{
> +    int attempt;
> +    enum EventDeliveryState rc = EVENT_SKIP;
> +
> +    /* if nobody ever wants to see this event, skip some work */
> +    if (filter != CantBeFiltered &&
> +            !((wOtherEventMasks(win)|win->eventMask) & filter))
> +        goto out;
> +
> +    if (IsInterferingGrab(wClient(win), dev, events))
> +        goto out;
> +
> +    rc = EVENT_NOT_DELIVERED;
> +
> +    if (XaceHook(XACE_RECEIVE_ACCESS, wClient(win), win, events, count))
> +        /* do nothing */;
> +    else if ((attempt = TryClientEvents(wClient(win), dev, events,
> +                                        count, win->eventMask,
> +                                        filter, grab)))
> +        rc = (attempt > 0) ? EVENT_DELIVERED : EVENT_REJECTED;
> +
> +out:
> +    return rc;
> +}

    static enum EventDeliveryState
    DeliverToWindowOwner(DeviceIntPtr dev, WindowPtr win,
                         xEvent *events, int count, Mask filter,
                         GrabPtr grab)
    {
        /* if nobody ever wants to see this event, skip some work */
        if (filter != CantBeFiltered &&
                !((wOtherEventMasks(win)|win->eventMask) & filter))
            return EVENT_SKIP;

        if (IsInterferingGrab(wClient(win), dev, events))
            return EVENT_SKIP;

        if (!XaceHook(XACE_RECEIVE_ACCESS, wClient(win), win, events, count))
        {
            int attempt = TryClientEvents(wClient(win), dev, events,
                                          count, win->eventMask,
                                          filter, grab);

            if (attempt > 0)
                return EVENT_DELIVERED;
            if (attempt < 0)
                return EVENT_REJECTED;
        }

        return EVENT_NOT_DELIVERED;
    }

Jamey
-------------- 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/3764bf0f/attachment.pgp>


More information about the xorg-devel mailing list