[PATCH 01/11] dix: split out window owner event delivery from DeliverEventsToWindow
Peter Hutterer
peter.hutterer at who-t.net
Wed May 11 17:33:43 PDT 2011
On Wed, May 11, 2011 at 01:36:49PM -0700, Jamey Sharp wrote:
> 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;
> }
>
I'm a big fan of the goto out because it makes debugging so much easier.
setting a breakpoint or adding a printf at a single point is faster than
remembering to set 5 points. That's pretty much the only reason for me.
Cheers,
Peter
More information about the xorg-devel
mailing list