[PATCH libinput v3 07/17] touchpad: Only enable clickfingers on Apple touchpads

Peter Hutterer peter.hutterer at who-t.net
Wed May 21 22:11:25 PDT 2014


On Tue, May 20, 2014 at 04:34:55PM +0200, Hans de Goede wrote:
> From: Peter Hutterer <peter.hutterer at who-t.net>
> 
> Apple touchpads don't have visible markings for the software button areas
> that almost all other vendors use. OS X provides clickfinger behaviour
> instead, where a click with two fingers on the touchpad generate a right
> button click. Use that same behaviour in libinput.
> 
> For all other touchpads, use the software button areas introduced in a
> follow-up commit.

this one breaks the test, can you squash this diff in please?
that's just to get the tests to succeed, you can drop it again in the 
"touchpad: Add clickpad-style software buttons" commit

diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
index ef514f7..c155e37 100644
--- a/src/evdev-mt-touchpad-buttons.c
+++ b/src/evdev-mt-touchpad-buttons.c
@@ -149,6 +149,8 @@ tp_post_button_events(struct tp_dispatch *tp, uint32_t time)
                rc = tp_post_physical_buttons(tp, time);
        else if (tp->buttons.use_clickfinger)
                rc = tp_post_clickfinger_buttons(tp, time);
+       else if (tp->nfingers_down >= 1)
+               rc = tp_post_physical_buttons(tp, time);
 
        return rc;
 }

Cheers,
   Peter


> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> Reviewed-by: Jonas Ådahl <jadahl at gmail.com>
> Reviewed-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  src/evdev-mt-touchpad-buttons.c |  9 +++++++--
>  src/evdev-mt-touchpad.h         |  1 +
>  test/touchpad.c                 | 12 ++++++++----
>  3 files changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
> index 8265e38..ef514f7 100644
> --- a/src/evdev-mt-touchpad-buttons.c
> +++ b/src/evdev-mt-touchpad-buttons.c
> @@ -60,6 +60,11 @@ tp_init_buttons(struct tp_dispatch *tp,
>  
>  	tp->buttons.motion_dist = diagonal * DEFAULT_BUTTON_MOTION_THRESHOLD;
>  
> +	if (libevdev_get_id_vendor(device->evdev) == 0x5ac) /* Apple */
> +		tp->buttons.use_clickfinger = true;
> +	else
> +		tp->buttons.use_clickfinger = false;
> +
>  	return 0;
>  }
>  
> @@ -134,7 +139,7 @@ tp_post_physical_buttons(struct tp_dispatch *tp, uint32_t time)
>  int
>  tp_post_button_events(struct tp_dispatch *tp, uint32_t time)
>  {
> -	int rc;
> +	int rc = 0;
>  
>  	if ((tp->queued &
>  		(TOUCHPAD_EVENT_BUTTON_PRESS|TOUCHPAD_EVENT_BUTTON_RELEASE)) == 0)
> @@ -142,7 +147,7 @@ tp_post_button_events(struct tp_dispatch *tp, uint32_t time)
>  
>  	if (tp->buttons.has_buttons)
>  		rc = tp_post_physical_buttons(tp, time);
> -	else
> +	else if (tp->buttons.use_clickfinger)
>  		rc = tp_post_clickfinger_buttons(tp, time);
>  
>  	return rc;
> diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
> index 85cf7e5..87d291a 100644
> --- a/src/evdev-mt-touchpad.h
> +++ b/src/evdev-mt-touchpad.h
> @@ -129,6 +129,7 @@ struct tp_dispatch {
>  
>  	struct {
>  		bool has_buttons;		/* true for physical LMR buttons */
> +		bool use_clickfinger;		/* number of fingers decides button number */
>  		uint32_t state;
>  		uint32_t old_state;
>  		uint32_t motion_dist;		/* for pinned touches */
> diff --git a/test/touchpad.c b/test/touchpad.c
> index f4d7839..bbae6cd 100644
> --- a/test/touchpad.c
> +++ b/test/touchpad.c
> @@ -217,7 +217,7 @@ END_TEST
>  
>  START_TEST(touchpad_1fg_clickfinger)
>  {
> -	struct litest_device *dev = litest_current_device();
> +	struct litest_device *dev = litest_create_device(LITEST_BCM5974);
>  	struct libinput *li = dev->libinput;
>  	struct libinput_event *event;
>  	struct libinput_event_pointer *ptrev;
> @@ -237,12 +237,14 @@ START_TEST(touchpad_1fg_clickfinger)
>  			    LIBINPUT_POINTER_BUTTON_STATE_PRESSED);
>  	assert_button_event(li, BTN_LEFT,
>  			    LIBINPUT_POINTER_BUTTON_STATE_RELEASED);
> +
> +	litest_delete_device(dev);
>  }
>  END_TEST
>  
>  START_TEST(touchpad_2fg_clickfinger)
>  {
> -	struct litest_device *dev = litest_current_device();
> +	struct litest_device *dev = litest_create_device(LITEST_BCM5974);
>  	struct libinput *li = dev->libinput;
>  	struct libinput_event *event;
>  	struct libinput_event_pointer *ptrev;
> @@ -264,6 +266,8 @@ START_TEST(touchpad_2fg_clickfinger)
>  			    LIBINPUT_POINTER_BUTTON_STATE_PRESSED);
>  	assert_button_event(li, BTN_RIGHT,
>  			    LIBINPUT_POINTER_BUTTON_STATE_RELEASED);
> +
> +	litest_delete_device(dev);
>  }
>  END_TEST
>  
> @@ -362,8 +366,8 @@ int main(int argc, char **argv) {
>  	litest_add("touchpad:tap", touchpad_1fg_tap_n_drag, LITEST_TOUCHPAD, LITEST_ANY);
>  	litest_add("touchpad:tap", touchpad_2fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
>  
> -	litest_add("touchpad:clickfinger", touchpad_1fg_clickfinger, LITEST_TOUCHPAD, LITEST_ANY);
> -	litest_add("touchpad:clickfinger", touchpad_2fg_clickfinger, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
> +	litest_add_no_device("touchpad:clickfinger", touchpad_1fg_clickfinger);
> +	litest_add_no_device("touchpad:clickfinger", touchpad_2fg_clickfinger);
>  
>  	litest_add("touchpad:click", touchpad_btn_left, LITEST_TOUCHPAD, LITEST_CLICKPAD);
>  	litest_add("touchpad:click", clickpad_btn_left, LITEST_CLICKPAD, LITEST_ANY);
> -- 
> 1.9.0
> 


More information about the wayland-devel mailing list