[PATCH libinput 2/2] Change vector_get_direction input to a normalized_coords struct

Hans de Goede hdegoede at redhat.com
Fri Mar 27 06:46:41 PDT 2015


Hi,

On 27-03-15 01:32, Peter Hutterer wrote:
> On Thu, Mar 26, 2015 at 09:57:27AM +0100, Hans de Goede wrote:
>> Change vector_get_direction input to a normalized_coords type rather then
>
> typo, then -> than
>
>> passing in a separate x,y pair, and rename it normalized_get_direction to
>> match. Since it now depends on the normalized_coords type which gets declared
>> in libinput-private.h also move it to libinput-private.h .
>>
>> Note this commit also contains a functional change wrt the get_direction
>> usuage in the palm detection. The palm-detection code was calling get_direction
>> on non normalized coordinates, this commits changes the code to normalize
>> the coordinates first. This is the right thing to do as calling get_direction
>> on non normalized coordinates may result in a wrong direction getting returned
>> when the x and y resolution of the touchpad are not identical.
>>
>> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
>> ---
>>   src/evdev-mt-touchpad.c |  5 +++--
>>   src/filter.c            |  2 +-
>>   src/libinput-private.h  | 57 +++++++++++++++++++++++++++++++++++++++++++++++++
>>   src/libinput-util.h     | 57 -------------------------------------------------
>>   4 files changed, 61 insertions(+), 60 deletions(-)
>>
>> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
>> index b598695..8985352 100644
>> --- a/src/evdev-mt-touchpad.c
>> +++ b/src/evdev-mt-touchpad.c
>> @@ -448,6 +448,7 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
>>   {
>>   	const int PALM_TIMEOUT = 200; /* ms */
>>   	const int DIRECTIONS = NE|E|SE|SW|W|NW;
>> +	int dirs;
>>
>>   	/* If labelled a touch as palm, we unlabel as palm when
>>   	   we move out of the palm edge zone within the timeout, provided
>> @@ -456,8 +457,8 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
>>   	if (t->palm.is_palm) {
>>   		if (time < t->palm.time + PALM_TIMEOUT &&
>>   		    (t->point.x > tp->palm.left_edge && t->point.x < tp->palm.right_edge)) {
>> -			int dirs = vector_get_direction(t->point.x - t->palm.first.x,
>> -							t->point.y - t->palm.first.y);
>> +			dirs = normalized_get_direction(tp_normalize_delta(tp,
>> +				       device_delta(t->point, t->palm.first)));
>
> can we use a tmp variable for delta here? the nesting here makes it a bit confusing
> what is an argument to what.
>
> Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net> for both, otherwise.

Thanks, both comments fixed and both patches have been pushed.

Regards,

Hans


More information about the wayland-devel mailing list