[PATCH synaptics 1/5] Don't emit touch sequences if only one touch is active

Chase Douglas chase.douglas at canonical.com
Thu Feb 2 13:10:09 PST 2012


On 02/02/2012 09:40 AM, walter harms wrote:
> 
> 
> Am 02.02.2012 00:50, schrieb Chase Douglas:
>> When a second touch begins, emit a touch begin for the first touch with
>> the current valuator values. When a touch ends and we are going from two
>> touches down to one touch, end both touches. This ensures we don't send
>> a touch sequence at the same time we are moving the pointer.
>>
>> Signed-off-by: Chase Douglas <chase.douglas at canonical.com>
>> ---
>>  src/eventcomm.c |   86 ++++++++++++++++++++++++++++++++++++++++++++++++++----
>>  1 files changed, 79 insertions(+), 7 deletions(-)
>>
>> diff --git a/src/eventcomm.c b/src/eventcomm.c
>> index 2da732f..b9e45e3 100644
>> --- a/src/eventcomm.c
>> +++ b/src/eventcomm.c
>> @@ -78,6 +78,8 @@ struct eventcomm_proto_data
>>      } slot_state;
>>      ValuatorMask *mt_mask;
>>      ValuatorMask **last_mt_vals;
>> +    unsigned int num_touches;
>> +    int *open_slots;
>>  #endif
>>  };
>>  
>> @@ -183,6 +185,8 @@ InitializeTouch(InputInfoPtr pInfo)
>>          for (j = 4; j < priv->num_mt_axes; j++)
>>              valuator_mask_set(proto_data->last_mt_vals[i], j, 0);
>>      }
>> +
>> +    proto_data->open_slots = malloc(num_slots(proto_data) * sizeof(int));
>>  }
>>  #endif
>>  
> 
> hi,
> perhaps calloc() is better ?

I like calloc when allocating memory for a struct, especially when the
struct has values that should be initialized to 0 like pointers.
However, this is an array where the initialized value is undefined until
you actually put things in it. You could argue that it's helpful for
debugging, but only until you start using the array (unless you
reinitialize elements when you delete them, but that is too unnecessary
for my taste).

> I am missing a free()( ? Or is it intentional that this is never freed ?

Yes, thanks for catching that!

-- Chase


More information about the xorg-devel mailing list