[PATCH 1/5] Split out helper function TouchListenerAcceptReject()

Chase Douglas chase.douglas at canonical.com
Tue Apr 17 14:10:51 PDT 2012


On 04/12/2012 09:49 PM, Peter Hutterer wrote:
> On Wed, Apr 11, 2012 at 11:22:10AM -0700, Chase Douglas wrote:
>> This will be used for accepting and rejecting touches in the future.
>>
>> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
>> ---
>>  dix/events.c    |   11 +-------
>>  dix/touch.c     |   68 ++++++++++++++++++++++++++++++++++--------------------
>>  include/input.h |    2 +
>>  3 files changed, 47 insertions(+), 34 deletions(-)
>>
>> diff --git a/dix/events.c b/dix/events.c
>> index 4470947..6bcb5eb 100644
>> --- a/dix/events.c
>> +++ b/dix/events.c
>> @@ -1273,18 +1273,11 @@ ComputeFreezes(void)
>>                         event->root_x, event->root_y);
>>          if (!CheckDeviceGrabs(replayDev, event, syncEvents.replayWin)) {
>>              if (IsTouchEvent((InternalEvent *) event)) {
>> -                InternalEvent *events = InitEventList(GetMaximumEventsNum());
>> -                int i, nev;
>>                  TouchPointInfoPtr ti =
>>                      TouchFindByClientID(replayDev, event->touchid);
>>                  BUG_WARN(!ti);
>> -                nev =
>> -                    GetTouchOwnershipEvents(events, replayDev, ti,
>> -                                            XIRejectTouch,
>> -                                            ti->listeners[0].listener, 0);
>> -                for (i = 0; i < nev; i++)
>> -                    mieqProcessDeviceEvent(replayDev, events + i, NULL);
>> -                ProcessInputEvents();
>> +
>> +                TouchListenerAcceptReject(replayDev, ti, 0, XIRejectTouch);
>>              }
>>              else if (replayDev->focus &&
>>                       !IsPointerEvent((InternalEvent *) event))
>> diff --git a/dix/touch.c b/dix/touch.c
>> index 0829b65..dedc686 100644
>> --- a/dix/touch.c
>> +++ b/dix/touch.c
>> @@ -960,15 +960,52 @@ TouchListenerGone(XID resource)
>>  }
>>  
>>  int
>> +TouchListenerAcceptReject(DeviceIntPtr dev, TouchPointInfoPtr ti, int listener,
>> +                          int mode)
>> +{
>> +    InternalEvent *events;
>> +    int nev;
>> +    int i;
>> +
>> +    if (listener > 0) {
>> +        if (mode == XIRejectTouch)
>> +            TouchRejected(dev, ti, ti->listeners[listener].listener, NULL);
>> +        else
>> +            ti->listeners[listener].state = LISTENER_EARLY_ACCEPT;
>> +
>> +        return Success;
>> +    }
>> +
>> +    events = InitEventList(GetMaximumEventsNum());
>> +    if (!events) {
>> +        BUG_WARN_MSG(TRUE, "Failed to allocate touch ownership events\n");
>> +        return BadAlloc;
>> +    }
>> +
>> +    nev = GetTouchOwnershipEvents(events, dev, ti, mode,
>> +                                  ti->listeners[0].listener, 0);
>> +    if (nev == 0) {
>> +        BUG_WARN_MSG(TRUE, "Failed to get touch ownership events\n");
>> +        FreeEventList(events, GetMaximumEventsNum());
>> +        return BadMatch;
> 
> you could turn this into a 
> BUG_WARN_MSG(nev == 0, ...)
> and then return nev ? Success : BadMatch;
> if nev is 0, the loop isn't handled, PIE doesn't do much (I think, can be
> conditional on nev > 0) and FreeEventList is needed anyay.
> This is just so that the bug macro has a better condition than just always
> TRUE.

I think that will work. ProcessInputEvents() calls
mieqProcessInputEvents() and a couple of other miscellaneous state
updates, all of which should be harmless I believe.

-- Chase


More information about the xorg-devel mailing list