forked from pool/libinput
260 lines
9.0 KiB
Diff
260 lines
9.0 KiB
Diff
|
From 915cd9d9999373aecf3285cba7ead3126c1fdb3d Mon Sep 17 00:00:00 2001
|
||
|
From: Peter Hutterer <peter.hutterer@who-t.net>
|
||
|
Date: Wed, 30 Mar 2016 15:31:07 +1000
|
||
|
Subject: touchpad: fix left-handed top software trackpoint buttons
|
||
|
|
||
|
The previous code would swap the top software buttons depending on the
|
||
|
touchpad's left-handed setting, not the trackpoint setting. Changing both
|
||
|
devices to left-handed resulted in a double-swap, i.e. the trackpoint was
|
||
|
always right-handed.
|
||
|
|
||
|
https://bugs.freedesktop.org/show_bug.cgi?id=94733
|
||
|
|
||
|
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
||
|
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
|
||
|
(cherry picked from commit 1ecf6d7a607c5f481eb9b3b6365d7b55a0f18c53)
|
||
|
|
||
|
diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
|
||
|
index 82c99c7..076eab0 100644
|
||
|
--- a/src/evdev-mt-touchpad-buttons.c
|
||
|
+++ b/src/evdev-mt-touchpad-buttons.c
|
||
|
@@ -963,6 +963,7 @@ tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time)
|
||
|
uint32_t current, old, button, is_top;
|
||
|
enum libinput_button_state state;
|
||
|
enum { AREA = 0x01, LEFT = 0x02, MIDDLE = 0x04, RIGHT = 0x08 };
|
||
|
+ bool want_left_handed = true;
|
||
|
|
||
|
current = tp->buttons.state;
|
||
|
old = tp->buttons.old_state;
|
||
|
@@ -1008,14 +1009,22 @@ tp_post_clickpadbutton_buttons(struct tp_dispatch *tp, uint64_t time)
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
- if ((area & MIDDLE) || ((area & LEFT) && (area & RIGHT)))
|
||
|
- button = evdev_to_left_handed(tp->device, BTN_MIDDLE);
|
||
|
- else if (area & RIGHT)
|
||
|
- button = evdev_to_left_handed(tp->device, BTN_RIGHT);
|
||
|
- else if (area & LEFT)
|
||
|
- button = evdev_to_left_handed(tp->device, BTN_LEFT);
|
||
|
- else /* main or no area (for clickfinger) is always BTN_LEFT */
|
||
|
+ if ((area & MIDDLE) || ((area & LEFT) && (area & RIGHT))) {
|
||
|
+ button = BTN_MIDDLE;
|
||
|
+ } else if (area & RIGHT) {
|
||
|
+ button = BTN_RIGHT;
|
||
|
+ } else if (area & LEFT) {
|
||
|
button = BTN_LEFT;
|
||
|
+ } else { /* main or no area (for clickfinger) is always BTN_LEFT */
|
||
|
+ button = BTN_LEFT;
|
||
|
+ want_left_handed = false;
|
||
|
+ }
|
||
|
+
|
||
|
+ if (is_top)
|
||
|
+ want_left_handed = false;
|
||
|
+
|
||
|
+ if (want_left_handed)
|
||
|
+ button = evdev_to_left_handed(tp->device, button);
|
||
|
|
||
|
tp->buttons.active = button;
|
||
|
tp->buttons.active_is_topbutton = is_top;
|
||
|
diff --git a/test/trackpoint.c b/test/trackpoint.c
|
||
|
index 567fba8..5a68b19 100644
|
||
|
--- a/test/trackpoint.c
|
||
|
+++ b/test/trackpoint.c
|
||
|
@@ -150,6 +150,135 @@ START_TEST(trackpoint_scroll_source)
|
||
|
}
|
||
|
END_TEST
|
||
|
|
||
|
+START_TEST(trackpoint_topsoftbuttons_left_handed_trackpoint)
|
||
|
+{
|
||
|
+ struct litest_device *touchpad = litest_current_device();
|
||
|
+ struct litest_device *trackpoint;
|
||
|
+ struct libinput *li = touchpad->libinput;
|
||
|
+ enum libinput_config_status status;
|
||
|
+ struct libinput_event *event;
|
||
|
+ struct libinput_device *device;
|
||
|
+
|
||
|
+ trackpoint = litest_add_device(li, LITEST_TRACKPOINT);
|
||
|
+ litest_drain_events(li);
|
||
|
+ /* touchpad right-handed, trackpoint left-handed */
|
||
|
+ status = libinput_device_config_left_handed_set(
|
||
|
+ trackpoint->libinput_device, 1);
|
||
|
+ ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||
|
+
|
||
|
+ litest_touch_down(touchpad, 0, 5, 5);
|
||
|
+ libinput_dispatch(li);
|
||
|
+ litest_button_click(touchpad, BTN_LEFT, true);
|
||
|
+ libinput_dispatch(li);
|
||
|
+
|
||
|
+ event = libinput_get_event(li);
|
||
|
+ litest_is_button_event(event,
|
||
|
+ BTN_RIGHT,
|
||
|
+ LIBINPUT_BUTTON_STATE_PRESSED);
|
||
|
+ device = libinput_event_get_device(event);
|
||
|
+ ck_assert(device == trackpoint->libinput_device);
|
||
|
+ libinput_event_destroy(event);
|
||
|
+
|
||
|
+ litest_button_click(touchpad, BTN_LEFT, false);
|
||
|
+ libinput_dispatch(li);
|
||
|
+ event = libinput_get_event(li);
|
||
|
+ litest_is_button_event(event,
|
||
|
+ BTN_RIGHT,
|
||
|
+ LIBINPUT_BUTTON_STATE_RELEASED);
|
||
|
+ device = libinput_event_get_device(event);
|
||
|
+ ck_assert(device == trackpoint->libinput_device);
|
||
|
+ libinput_event_destroy(event);
|
||
|
+
|
||
|
+ litest_delete_device(trackpoint);
|
||
|
+}
|
||
|
+END_TEST
|
||
|
+
|
||
|
+START_TEST(trackpoint_topsoftbuttons_left_handed_touchpad)
|
||
|
+{
|
||
|
+ struct litest_device *touchpad = litest_current_device();
|
||
|
+ struct litest_device *trackpoint;
|
||
|
+ struct libinput *li = touchpad->libinput;
|
||
|
+ enum libinput_config_status status;
|
||
|
+ struct libinput_event *event;
|
||
|
+ struct libinput_device *device;
|
||
|
+
|
||
|
+ trackpoint = litest_add_device(li, LITEST_TRACKPOINT);
|
||
|
+ litest_drain_events(li);
|
||
|
+ /* touchpad left-handed, trackpoint right-handed */
|
||
|
+ status = libinput_device_config_left_handed_set(
|
||
|
+ touchpad->libinput_device, 1);
|
||
|
+ ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||
|
+
|
||
|
+ litest_touch_down(touchpad, 0, 5, 5);
|
||
|
+ libinput_dispatch(li);
|
||
|
+ litest_button_click(touchpad, BTN_LEFT, true);
|
||
|
+ libinput_dispatch(li);
|
||
|
+
|
||
|
+ event = libinput_get_event(li);
|
||
|
+ litest_is_button_event(event, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED);
|
||
|
+ device = libinput_event_get_device(event);
|
||
|
+ ck_assert(device == trackpoint->libinput_device);
|
||
|
+ libinput_event_destroy(event);
|
||
|
+
|
||
|
+ litest_button_click(touchpad, BTN_LEFT, false);
|
||
|
+ libinput_dispatch(li);
|
||
|
+ event = libinput_get_event(li);
|
||
|
+ litest_is_button_event(event,
|
||
|
+ BTN_LEFT,
|
||
|
+ LIBINPUT_BUTTON_STATE_RELEASED);
|
||
|
+ device = libinput_event_get_device(event);
|
||
|
+ ck_assert(device == trackpoint->libinput_device);
|
||
|
+ libinput_event_destroy(event);
|
||
|
+
|
||
|
+ litest_delete_device(trackpoint);
|
||
|
+}
|
||
|
+END_TEST
|
||
|
+
|
||
|
+START_TEST(trackpoint_topsoftbuttons_left_handed_both)
|
||
|
+{
|
||
|
+ struct litest_device *touchpad = litest_current_device();
|
||
|
+ struct litest_device *trackpoint;
|
||
|
+ struct libinput *li = touchpad->libinput;
|
||
|
+ enum libinput_config_status status;
|
||
|
+ struct libinput_event *event;
|
||
|
+ struct libinput_device *device;
|
||
|
+
|
||
|
+ trackpoint = litest_add_device(li, LITEST_TRACKPOINT);
|
||
|
+ litest_drain_events(li);
|
||
|
+ /* touchpad left-handed, trackpoint left-handed */
|
||
|
+ status = libinput_device_config_left_handed_set(
|
||
|
+ touchpad->libinput_device, 1);
|
||
|
+ ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||
|
+ status = libinput_device_config_left_handed_set(
|
||
|
+ trackpoint->libinput_device, 1);
|
||
|
+ ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||
|
+
|
||
|
+ litest_touch_down(touchpad, 0, 5, 5);
|
||
|
+ libinput_dispatch(li);
|
||
|
+ litest_button_click(touchpad, BTN_LEFT, true);
|
||
|
+ libinput_dispatch(li);
|
||
|
+
|
||
|
+ event = libinput_get_event(li);
|
||
|
+ litest_is_button_event(event,
|
||
|
+ BTN_RIGHT,
|
||
|
+ LIBINPUT_BUTTON_STATE_PRESSED);
|
||
|
+ device = libinput_event_get_device(event);
|
||
|
+ ck_assert(device == trackpoint->libinput_device);
|
||
|
+ libinput_event_destroy(event);
|
||
|
+
|
||
|
+ litest_button_click(touchpad, BTN_LEFT, false);
|
||
|
+ libinput_dispatch(li);
|
||
|
+ event = libinput_get_event(li);
|
||
|
+ litest_is_button_event(event,
|
||
|
+ BTN_RIGHT,
|
||
|
+ LIBINPUT_BUTTON_STATE_RELEASED);
|
||
|
+ device = libinput_event_get_device(event);
|
||
|
+ ck_assert(device == trackpoint->libinput_device);
|
||
|
+ libinput_event_destroy(event);
|
||
|
+
|
||
|
+ litest_delete_device(trackpoint);
|
||
|
+}
|
||
|
+END_TEST
|
||
|
void
|
||
|
litest_setup_tests(void)
|
||
|
{
|
||
|
@@ -157,4 +286,7 @@ litest_setup_tests(void)
|
||
|
litest_add("trackpoint:middlebutton", trackpoint_middlebutton_noscroll, LITEST_POINTINGSTICK, LITEST_ANY);
|
||
|
litest_add("trackpoint:scroll", trackpoint_scroll, LITEST_POINTINGSTICK, LITEST_ANY);
|
||
|
litest_add("trackpoint:scroll", trackpoint_scroll_source, LITEST_POINTINGSTICK, LITEST_ANY);
|
||
|
+ litest_add("trackpoint:left-handed", trackpoint_topsoftbuttons_left_handed_trackpoint, LITEST_TOPBUTTONPAD, LITEST_ANY);
|
||
|
+ litest_add("trackpoint:left-handed", trackpoint_topsoftbuttons_left_handed_touchpad, LITEST_TOPBUTTONPAD, LITEST_ANY);
|
||
|
+ litest_add("trackpoint:left-handed", trackpoint_topsoftbuttons_left_handed_both, LITEST_TOPBUTTONPAD, LITEST_ANY);
|
||
|
}
|
||
|
--
|
||
|
cgit v0.10.2
|
||
|
|
||
|
|
||
|
From 2253cf69cbf6861003c2c8396bf0cc11fbd83612 Mon Sep 17 00:00:00 2001
|
||
|
From: Peter Hutterer <peter.hutterer@who-t.net>
|
||
|
Date: Tue, 29 Mar 2016 13:34:00 +1000
|
||
|
Subject: touchpad: only post motion events if we have motion
|
||
|
|
||
|
Because our delta calculation factors in previous events on touchpads (to
|
||
|
reduce jitter) we may get a nonzero delta if we have an event that doesn't
|
||
|
actually change x or y.
|
||
|
|
||
|
Drop the t->dirty workaround introduced in a608d9d, an event that virtually
|
||
|
disappears can mess up our state machines.
|
||
|
|
||
|
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
||
|
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
|
||
|
(cherry picked from commit bc17185f426dae7a1ea4df6ba3459083c2d51f9b)
|
||
|
|
||
|
diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c
|
||
|
index 3c8f5a7..7bbd3b8 100644
|
||
|
--- a/src/evdev-mt-touchpad-gestures.c
|
||
|
+++ b/src/evdev-mt-touchpad-gestures.c
|
||
|
@@ -500,7 +500,8 @@ tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time)
|
||
|
|
||
|
switch (tp->gesture.finger_count) {
|
||
|
case 1:
|
||
|
- tp_gesture_post_pointer_motion(tp, time);
|
||
|
+ if (tp->queued & TOUCHPAD_EVENT_MOTION)
|
||
|
+ tp_gesture_post_pointer_motion(tp, time);
|
||
|
break;
|
||
|
case 2:
|
||
|
case 3:
|
||
|
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
|
||
|
index d0a8e27..082493c 100644
|
||
|
--- a/src/evdev-mt-touchpad.c
|
||
|
+++ b/src/evdev-mt-touchpad.c
|
||
|
@@ -904,10 +904,7 @@ tp_need_motion_history_reset(struct tp_dispatch *tp, uint64_t time)
|
||
|
if (tp->device->model_flags & EVDEV_MODEL_LENOVO_T450_TOUCHPAD) {
|
||
|
if (tp->queued & TOUCHPAD_EVENT_MOTION) {
|
||
|
if (tp->quirks.nonmotion_event_count > 10) {
|
||
|
- struct tp_touch *t;
|
||
|
-
|
||
|
- tp_for_each_touch(tp, t)
|
||
|
- t->dirty = false;
|
||
|
+ tp->queued &= ~TOUCHPAD_EVENT_MOTION;
|
||
|
rc = true;
|
||
|
}
|
||
|
tp->quirks.nonmotion_event_count = 0;
|
||
|
--
|
||
|
cgit v0.10.2
|
||
|
|