[PATCH libinput 3/3] touchpad: Disable touchpads on trackpoint activity

Hans de Goede hdegoede at redhat.com
Sun Sep 28 04:20:21 PDT 2014


Hi,

On 09/22/2014 07:18 AM, Peter Hutterer wrote:
> On Thu, Sep 18, 2014 at 01:11:05PM +0200, Hans de Goede wrote:
>> Some laptops with both a clickpad and a trackpoint have such a large touchpad,
>> that parts of the users hands will touch the pad when using the trackpoint.
>> Examples of this are the Lenovo T440s and the Toshiba Tecra Z40-A.
>>
>> This commit makes libinput automatically disable the touchpad while using
>> the trackpoint on these devices, except for the buttons, as people may want
>> to use the touchpad (hardware or soft) buttons while using the trackpoint.
>>
>> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
>> ---
>>  src/evdev-mt-touchpad.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++--
>>  src/evdev-mt-touchpad.h |  3 +++
>>  2 files changed, 65 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
>> index 1c32cc6..31e2e83 100644
>> --- a/src/evdev-mt-touchpad.c
>> +++ b/src/evdev-mt-touchpad.c
>> @@ -31,6 +31,7 @@
>>  
>>  #define DEFAULT_ACCEL_NUMERATOR 1200.0
>>  #define DEFAULT_HYSTERESIS_MARGIN_DENOMINATOR 700.0
>> +#define DEFAULT_TRACKPOINT_ACTIVITY_TIMEOUT 500 /* ms */
>>  
>>  static inline int
>>  tp_hysteresis(int in, int center, int margin)
>> @@ -523,8 +524,8 @@ tp_post_events(struct tp_dispatch *tp, uint64_t time)
>>  	double dx, dy;
>>  	int consumed = 0;
>>  
>> -	/* Only post (top) button events while suspended */
>> -	if (tp->device->suspended) {
>> +	/* Only post (top) button events? */
>> +	if (tp->device->suspended || tp->sendevents.trackpoint_active) {
>>  		tp_post_button_events(tp, time);
>>  		return;
>>  	}
>> @@ -594,6 +595,16 @@ tp_process(struct evdev_dispatch *dispatch,
>>  }
>>  
>>  static void
>> +tp_destroy_sendevents(struct tp_dispatch *tp)
>> +{
>> +	libinput_timer_cancel(&tp->sendevents.trackpoint_timer);
>> +
>> +	if (tp->buttons.trackpoint)
>> +		libinput_device_remove_eventlistener(
>> +					&tp->sendevents.trackpoint_listener);
>> +}
>> +
>> +static void
>>  tp_destroy(struct evdev_dispatch *dispatch)
>>  {
>>  	struct tp_dispatch *tp =
>> @@ -601,6 +612,7 @@ tp_destroy(struct evdev_dispatch *dispatch)
>>  
>>  	tp_destroy_tap(tp);
>>  	tp_destroy_buttons(tp);
>> +	tp_destroy_sendevents(tp);
>>  
>>  	filter_destroy(tp->filter);
>>  	free(tp->touches);
>> @@ -667,6 +679,36 @@ tp_resume(struct tp_dispatch *tp, struct evdev_device *device)
>>  }
>>  
>>  static void
>> +tp_trackpoint_timeout(uint64_t now, void *data)
>> +{
>> +	struct tp_dispatch *tp = data;
>> +
>> +	tp_clear_state(tp, tp->device);
>> +	tp->sendevents.trackpoint_active = false;
>> +}
>> +
>> +static void
>> +tp_trackpoint_event(struct libinput_event *event, void *data)
>> +{
>> +	struct tp_dispatch *tp = data;
>> +
>> +	/* Only movement counts as trackpad activity, as people may use
>> +	   the trackpoint buttons in combination with the touchpad. */
>> +	if (event->type != LIBINPUT_EVENT_POINTER_MOTION)
>> +		return;
> 
> the wheel emulation code posts axis events, you'll need to include those
> here as well. 

A valid poinr, unfortunately fixing this has shown a somewhat
big issue with my approach, we cannot use tp_clear_state when suspending
the touchpad because of trackpoint activity as tp_clear_state releases
pressed buttons breaking using touchpad (or clickpad) buttons to drag and
drop with the trackpoint.

So besides fixing the 64 bit timestamp issue, I've also had to add
tp_tap_suspend / resume functionality (dealing with the rest without
doing a full tp_clear_state is easy). So v2 is going to be somewhat
more different of v1 then I initially hoped.

While working on the tap suspend / resume functionality I've also
noticed some other issues in the tap code, so I'm also sending a
second patch-set dealing with those.

Regards,

Hans


More information about the wayland-devel mailing list