[PATCH 1/5] Split out helper function TouchListenerAcceptReject()
Chase Douglas
chase.douglas at canonical.com
Thu Apr 19 09:43:36 PDT 2012
On 04/19/2012 09:38 AM, Bryce Harrington 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);
>
> There isn't a null pointer check on ti prior to this dereference. Is it
> guaranteed in all callers that ti will never be NULL?
I think this assumption is sound. The function will only be called by
callers who have analyzed the touchpoint record.
> Should listener < len(ti->listeners) be asserted to catch out of bounds
> errors?
That would be a good thing to add. I can send a follow up patch.
Thanks!
-- Chase
More information about the xorg-devel
mailing list