From ccdf5aef6bbea6fb0a55cda36a92a0b53f8b1277 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 8 Dec 2014 10:46:54 +0100 Subject: [PATCH 01/22] evdev: Remove double-semicolon Signed-off-by: Carlos Garnacho Signed-off-by: Peter Hutterer --- src/evdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/evdev.c b/src/evdev.c index fbfbcd35..0873c99a 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -2031,7 +2031,7 @@ evdev_device_remove(struct evdev_device *device) struct libinput_device *dev; list_for_each(dev, &device->base.seat->devices_list, link) { - struct evdev_device *d = (struct evdev_device*)dev;; + struct evdev_device *d = (struct evdev_device*)dev; if (dev == &device->base) continue; From 700bf87093b9cb73542f7691f809f41f5145e925 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 9 Dec 2014 13:56:02 +1000 Subject: [PATCH 02/22] doc: delete double-empty lines Signed-off-by: Peter Hutterer --- src/libinput.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libinput.h b/src/libinput.h index 0e2ba6b2..7312a173 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -473,7 +473,6 @@ libinput_event_keyboard_get_key(struct libinput_event_keyboard *event); enum libinput_key_state libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event); - /** * @ingroup event_keyboard * @@ -770,7 +769,6 @@ libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event); struct libinput_event * libinput_event_pointer_get_base_event(struct libinput_event_pointer *event); - /** * @defgroup event_touch Touch events * From d43ea432188fde6098647702722de890190318f5 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 9 Dec 2014 13:42:45 +1000 Subject: [PATCH 03/22] doc: fix wording on the dpi normalization paragraph Signed-off-by: Peter Hutterer --- src/libinput.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libinput.h b/src/libinput.h index 7312a173..57d9ded7 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -185,9 +185,9 @@ extern "C" { * * If the property is unset, libinput assumes the resolution is 1000dpi. * - * Note that HW does not usually provide information about the resolution - * changes, libinput will thus not detect when a resolution changes to the - * non-default value. + * Note that HW does not usually provide information about run-time + * resolution changes, libinput will thus not detect when a resolution + * changes to the non-default value. */ /** From c212f2042dee5d5f3e329b93ceaf26e17f2ef3c8 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 9 Dec 2014 12:58:04 +1000 Subject: [PATCH 04/22] README: link to bugzilla and API docs Signed-off-by: Peter Hutterer --- README | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README b/README index 0b05b81b..f55d7c8e 100644 --- a/README +++ b/README @@ -17,3 +17,9 @@ http://cgit.freedesktop.org/wayland/libinput For more information, visit: http://www.freedesktop.org/wiki/Software/libinput/ + +Bugs can be filed in the libinput component of Wayland: +https://bugs.freedesktop.org/enter_bug.cgi?product=Wayland + +Online API documentation: +http://wayland.freedesktop.org/libinput/doc/latest/modules.html From 4a971a69cff5ff05350e05920f4a917393667050 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 5 Dec 2014 12:39:16 +0100 Subject: [PATCH 05/22] evdev: Add a remove callback to the evdev_dispatch_interface Some dispatchers may want to do some cleanup at remove time, rather then at destroy time. Signed-off-by: Hans de Goede Reviewed-by: Peter Hutterer --- src/evdev-mt-touchpad.c | 1 + src/evdev.c | 4 ++++ src/evdev.h | 3 +++ 3 files changed, 8 insertions(+) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 8149c001..cd76e4f3 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -858,6 +858,7 @@ tp_tag_device(struct evdev_device *device, static struct evdev_dispatch_interface tp_interface = { tp_process, + NULL, /* remove */ tp_destroy, tp_device_added, tp_device_removed, diff --git a/src/evdev.c b/src/evdev.c index 0873c99a..b32db684 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -737,6 +737,7 @@ evdev_calibration_get_default_matrix(struct libinput_device *libinput_device, struct evdev_dispatch_interface fallback_interface = { fallback_process, + NULL, /* remove */ fallback_destroy, NULL, /* device_added */ NULL, /* device_removed */ @@ -2041,6 +2042,9 @@ evdev_device_remove(struct evdev_device *device) evdev_device_suspend(device); + if (device->dispatch->interface->remove) + device->dispatch->interface->remove(device->dispatch); + /* A device may be removed while suspended, mark it to * skip re-opening a different device with the same node */ device->was_removed = true; diff --git a/src/evdev.h b/src/evdev.h index 033d4558..820fdccd 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -166,6 +166,9 @@ struct evdev_dispatch_interface { struct input_event *event, uint64_t time); + /* Device is being removed (may be NULL) */ + void (*remove)(struct evdev_dispatch *dispatch); + /* Destroy an event dispatch handler and free all its resources. */ void (*destroy)(struct evdev_dispatch *dispatch); From 36017fbd3c87aca01dd978f2b65bf634885fd8bc Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Fri, 5 Dec 2014 12:50:39 +0100 Subject: [PATCH 06/22] touchpad: Use remove callback to unlink event listener and stop timers We use 2 mechanisms to unregister the trackpoint event listener depending on device removal order. 1) We have a device_removed callback, if the trackpoint gets removed before the touchpad, this gets called, sees the device being removed is the trackpoint and unregisters the listener 2) If the touchpad gets removed first, then in tp_destroy we unregister the listener 2) May be delayed beyond the destruction of the trackpoint itself if the libinput user has a reference to the libinput_device for the touchpad. When this happens the trackpoint still has an eventlistener at destroy time and an assert triggers. To fix this we must do 2) at the same time as we do 1), so at remove time. While working on this I noticed that the touchpad code was also cancelling timers at destroy time rather then remove time, which means that they may expire between remove and destroy time, and cause events to be emitted from a removed device, so this commit moves the cancelling of the timers to the remove callback as well. Signed-off-by: Hans de Goede Reviewed-by: Peter Hutterer --- src/evdev-mt-touchpad-buttons.c | 2 +- src/evdev-mt-touchpad-edge-scroll.c | 2 +- src/evdev-mt-touchpad-tap.c | 2 +- src/evdev-mt-touchpad.c | 24 ++++++++++++++++-------- src/evdev-mt-touchpad.h | 6 +++--- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index cfd6588d..6af3fcf1 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -603,7 +603,7 @@ tp_init_buttons(struct tp_dispatch *tp, } void -tp_destroy_buttons(struct tp_dispatch *tp) +tp_remove_buttons(struct tp_dispatch *tp) { struct tp_touch *t; diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index d68fc686..3684c8a9 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -271,7 +271,7 @@ tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device) } void -tp_destroy_edge_scroll(struct tp_dispatch *tp) +tp_remove_edge_scroll(struct tp_dispatch *tp) { struct tp_touch *t; diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index a38edbe3..c34b2034 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -720,7 +720,7 @@ tp_init_tap(struct tp_dispatch *tp) } void -tp_destroy_tap(struct tp_dispatch *tp) +tp_remove_tap(struct tp_dispatch *tp) { libinput_timer_cancel(&tp->tap.timer); } diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index cd76e4f3..32d6eaca 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -512,9 +512,9 @@ tp_stop_scroll_events(struct tp_dispatch *tp, uint64_t time) } static void -tp_destroy_scroll(struct tp_dispatch *tp) +tp_remove_scroll(struct tp_dispatch *tp) { - tp_destroy_edge_scroll(tp); + tp_remove_edge_scroll(tp); } static void @@ -668,7 +668,7 @@ tp_process(struct evdev_dispatch *dispatch, } static void -tp_destroy_sendevents(struct tp_dispatch *tp) +tp_remove_sendevents(struct tp_dispatch *tp) { libinput_timer_cancel(&tp->sendevents.trackpoint_timer); @@ -677,16 +677,24 @@ tp_destroy_sendevents(struct tp_dispatch *tp) &tp->sendevents.trackpoint_listener); } +static void +tp_remove(struct evdev_dispatch *dispatch) +{ + struct tp_dispatch *tp = + (struct tp_dispatch*)dispatch; + + tp_remove_tap(tp); + tp_remove_buttons(tp); + tp_remove_sendevents(tp); + tp_remove_scroll(tp); +} + static void tp_destroy(struct evdev_dispatch *dispatch) { struct tp_dispatch *tp = (struct tp_dispatch*)dispatch; - tp_destroy_tap(tp); - tp_destroy_buttons(tp); - tp_destroy_sendevents(tp); - tp_destroy_scroll(tp); free(tp->touches); free(tp); @@ -858,7 +866,7 @@ tp_tag_device(struct evdev_device *device, static struct evdev_dispatch_interface tp_interface = { tp_process, - NULL, /* remove */ + tp_remove, tp_destroy, tp_device_added, tp_device_removed, diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index da9c0914..14502882 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -287,7 +287,7 @@ int tp_init_tap(struct tp_dispatch *tp); void -tp_destroy_tap(struct tp_dispatch *tp); +tp_remove_tap(struct tp_dispatch *tp); int tp_init_buttons(struct tp_dispatch *tp, struct evdev_device *device); @@ -298,7 +298,7 @@ tp_init_softbuttons(struct tp_dispatch *tp, double topbutton_size_mult); void -tp_destroy_buttons(struct tp_dispatch *tp); +tp_remove_buttons(struct tp_dispatch *tp); int tp_process_button(struct tp_dispatch *tp, @@ -338,7 +338,7 @@ int tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device); void -tp_destroy_edge_scroll(struct tp_dispatch *tp); +tp_remove_edge_scroll(struct tp_dispatch *tp); void tp_edge_scroll_handle_state(struct tp_dispatch *tp, uint64_t time); From 47e10da12a31817474b5d291d3822154e87a4417 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Tue, 9 Dec 2014 15:55:32 +0100 Subject: [PATCH 07/22] evdev: Ensure the libevdev object receives the new fd on resume Otherwise, input_events will be attempted to read from the wrong place, which also leaves the right/current fd with pending data to be read, making the epoll fd wake up constantly. Signed-off-by: Carlos Garnacho Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- src/evdev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/evdev.c b/src/evdev.c index b32db684..dce035ac 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1986,6 +1986,8 @@ evdev_device_resume(struct evdev_device *device) struct libinput *libinput = device->base.seat->libinput; int fd; const char *devnode; + struct input_event ev; + enum libevdev_read_status status; if (device->fd != -1) return 0; @@ -2012,6 +2014,20 @@ evdev_device_resume(struct evdev_device *device) return -ENODEV; } + libevdev_change_fd(device->evdev, fd); + libevdev_set_clock_id(device->evdev, CLOCK_MONOTONIC); + + /* re-sync libevdev's view of the device, but discard the actual + events. Our device is in a neutral state already */ + libevdev_next_event(device->evdev, + LIBEVDEV_READ_FLAG_FORCE_SYNC, + &ev); + do { + status = libevdev_next_event(device->evdev, + LIBEVDEV_READ_FLAG_SYNC, + &ev); + } while (status == LIBEVDEV_READ_STATUS_SYNC); + device->source = libinput_add_fd(libinput, fd, evdev_device_dispatch, device); if (!device->source) { From 58abea394657baba66f6e0cd6c4c27e084bb5b16 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 10 Dec 2014 11:01:08 +1000 Subject: [PATCH 08/22] test: create a new device during the disable test to change fds In the current test, disable followed by enable would result in the same fd number for the new device, not exposing a bug fixed by "evdev: Ensure the libevdev object receives the new fd on resume" Create a keyboard device after suspending the first device, then re-enable the device. This changes the fd to a different number, so we pick up on internal bugs. Signed-off-by: Peter Hutterer --- test/device.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/device.c b/test/device.c index 28cdb06c..16bb99c9 100644 --- a/test/device.c +++ b/test/device.c @@ -121,6 +121,8 @@ START_TEST(device_disable) struct libinput *li = dev->libinput; struct libinput_device *device; enum libinput_config_status status; + struct libinput_event *event; + struct litest_device *tmp; device = dev->libinput_device; @@ -138,11 +140,30 @@ START_TEST(device_disable) litest_event(dev, EV_SYN, SYN_REPORT, 0); litest_assert_empty_queue(li); + /* create a new device so the resumed fd isn't the same as the + suspended one */ + tmp = litest_add_device(li, LITEST_KEYBOARD); + ck_assert_notnull(tmp); + litest_drain_events(li); + /* no event from resuming */ status = libinput_device_config_send_events_set_mode(device, LIBINPUT_CONFIG_SEND_EVENTS_ENABLED); ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS); litest_assert_empty_queue(li); + + /* event from renabled device */ + litest_event(dev, EV_REL, REL_X, 10); + litest_event(dev, EV_SYN, SYN_REPORT, 0); + + libinput_dispatch(li); + event = libinput_get_event(li); + ck_assert_notnull(event); + ck_assert_int_eq(libinput_event_get_type(event), + LIBINPUT_EVENT_POINTER_MOTION); + libinput_event_destroy(event); + + litest_delete_device(tmp); } END_TEST From 530938a8625e58d7eec9285d108cbfdcfb1c3baf Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 9 Dec 2014 12:55:17 +1000 Subject: [PATCH 09/22] Drop deprecated symbols MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Hutterer Reviewed-by: Jonas Ådahl --- src/evdev.c | 7 ------- src/libinput.c | 16 ---------------- src/libinput.h | 27 --------------------------- 3 files changed, 50 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index dce035ac..06dd1df1 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1605,13 +1605,6 @@ err: return unhandled_device ? EVDEV_UNHANDLED_DEVICE : NULL; } -int -evdev_device_get_keys(struct evdev_device *device, char *keys, size_t size) -{ - memset(keys, 0, size); - return 0; -} - const char * evdev_device_get_output(struct evdev_device *device) { diff --git a/src/libinput.c b/src/libinput.c index 279cce0f..fbefbb38 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -1271,22 +1271,6 @@ libinput_device_led_update(struct libinput_device *device, evdev_device_led_update((struct evdev_device *) device, leds); } -LIBINPUT_EXPORT int -libinput_device_get_keys(struct libinput_device *device, - char *keys, size_t size) -{ - return evdev_device_get_keys((struct evdev_device *) device, - keys, - size); -} - -LIBINPUT_EXPORT void -libinput_device_calibrate(struct libinput_device *device, - float calibration[6]) -{ - evdev_device_calibrate((struct evdev_device *) device, calibration); -} - LIBINPUT_EXPORT int libinput_device_has_capability(struct libinput_device *device, enum libinput_device_capability capability) diff --git a/src/libinput.h b/src/libinput.h index 57d9ded7..e2a3eef0 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -1551,33 +1551,6 @@ void libinput_device_led_update(struct libinput_device *device, enum libinput_led leds); -/** - * @ingroup device - * - * Set the bitmask in keys to the bitmask of the keys present on the device - * (see linux/input.h), up to size characters. - * - * @param device A current input device - * @param keys An array filled with the bitmask for the keys - * @param size Size of the keys array - * - * @return The number of valid bytes in keys, or a negative errno on failure - */ -int -libinput_device_get_keys(struct libinput_device *device, - char *keys, size_t size) - LIBINPUT_ATTRIBUTE_DEPRECATED; - -/** - * @ingroup device - * - * @deprecated Use libinput_device_config_calibration_set_matrix() instead. - */ -void -libinput_device_calibrate(struct libinput_device *device, - float calibration[6]) - LIBINPUT_ATTRIBUTE_DEPRECATED; - /** * @ingroup device * From dd624f50389d8ff63df8297bac9c1d3984d43fb4 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 9 Dec 2014 12:52:45 +1000 Subject: [PATCH 10/22] Use symbol versioning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This isn't the final 0.8.0 API yet, but we might as well get started. Signed-off-by: Peter Hutterer Reviewed-by: Jonas Ådahl --- src/Makefile.am | 5 +- src/libinput.sym | 117 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 src/libinput.sym diff --git a/src/Makefile.am b/src/Makefile.am index 0968459c..eeaf439b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,8 @@ libinput_util_la_CFLAGS = -I$(top_srcdir)/include \ $(LIBUDEV_CFLAGS) \ $(GCC_CFLAGS) -libinput_la_LDFLAGS = -version-info $(LIBINPUT_LT_VERSION) -shared +libinput_la_LDFLAGS = -version-info $(LIBINPUT_LT_VERSION) -shared \ + -Wl,--version-script=$(srcdir)/libinput.sym pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libinput.pc @@ -54,4 +55,4 @@ pkgconfig_DATA = libinput.pc AM_CFLAGS = $(GCC_CFLAGS) DISTCLEANFILES = libinput-version.h -EXTRA_DIST = libinput-version.h.in +EXTRA_DIST = libinput-version.h.in libinput.sym diff --git a/src/libinput.sym b/src/libinput.sym new file mode 100644 index 00000000..f35a0cdf --- /dev/null +++ b/src/libinput.sym @@ -0,0 +1,117 @@ +/* in alphabetical order! */ + +LIBINPUT_0.8.0 { +global: + libinput_config_status_to_str; + libinput_device_config_accel_get_default_speed; + libinput_device_config_accel_get_speed; + libinput_device_config_accel_is_available; + libinput_device_config_accel_set_speed; + libinput_device_config_buttons_get_default_left_handed; + libinput_device_config_buttons_get_left_handed; + libinput_device_config_buttons_has_left_handed; + libinput_device_config_buttons_set_left_handed; + libinput_device_config_calibration_get_default_matrix; + libinput_device_config_calibration_get_matrix; + libinput_device_config_calibration_has_matrix; + libinput_device_config_calibration_set_matrix; + libinput_device_config_scroll_get_button; + libinput_device_config_scroll_get_default_button; + libinput_device_config_scroll_get_default_method; + libinput_device_config_scroll_get_default_natural_scroll_enabled; + libinput_device_config_scroll_get_methods; + libinput_device_config_scroll_get_method; + libinput_device_config_scroll_get_natural_scroll_enabled; + libinput_device_config_scroll_has_natural_scroll; + libinput_device_config_scroll_set_button; + libinput_device_config_scroll_set_method; + libinput_device_config_scroll_set_natural_scroll_enabled; + libinput_device_config_send_events_get_default_mode; + libinput_device_config_send_events_get_modes; + libinput_device_config_send_events_get_mode; + libinput_device_config_send_events_set_mode; + libinput_device_config_tap_get_default_enabled; + libinput_device_config_tap_get_enabled; + libinput_device_config_tap_get_finger_count; + libinput_device_config_tap_set_enabled; + libinput_device_get_context; + libinput_device_get_id_product; + libinput_device_get_id_vendor; + libinput_device_get_name; + libinput_device_get_output_name; + libinput_device_get_seat; + libinput_device_get_size; + libinput_device_get_sysname; + libinput_device_get_udev_device; + libinput_device_get_user_data; + libinput_device_has_button; + libinput_device_has_capability; + libinput_device_led_update; + libinput_device_ref; + libinput_device_set_seat_logical_name; + libinput_device_set_user_data; + libinput_device_unref; + libinput_dispatch; + libinput_event_destroy; + libinput_event_device_notify_get_base_event; + libinput_event_get_context; + libinput_event_get_device_notify_event; + libinput_event_get_device; + libinput_event_get_keyboard_event; + libinput_event_get_pointer_event; + libinput_event_get_touch_event; + libinput_event_get_type; + libinput_event_keyboard_get_base_event; + libinput_event_keyboard_get_key_state; + libinput_event_keyboard_get_key; + libinput_event_keyboard_get_seat_key_count; + libinput_event_keyboard_get_time; + libinput_event_pointer_get_absolute_x; + libinput_event_pointer_get_absolute_x_transformed; + libinput_event_pointer_get_absolute_y; + libinput_event_pointer_get_absolute_y_transformed; + libinput_event_pointer_get_axis; + libinput_event_pointer_get_axis_value; + libinput_event_pointer_get_base_event; + libinput_event_pointer_get_button_state; + libinput_event_pointer_get_button; + libinput_event_pointer_get_dx; + libinput_event_pointer_get_dx_unaccelerated; + libinput_event_pointer_get_dy; + libinput_event_pointer_get_dy_unaccelerated; + libinput_event_pointer_get_seat_button_count; + libinput_event_pointer_get_time; + libinput_event_touch_get_base_event; + libinput_event_touch_get_seat_slot; + libinput_event_touch_get_slot; + libinput_event_touch_get_time; + libinput_event_touch_get_x; + libinput_event_touch_get_x_transformed; + libinput_event_touch_get_y; + libinput_event_touch_get_y_transformed; + libinput_get_event; + libinput_get_fd; + libinput_get_user_data; + libinput_log_get_priority; + libinput_log_set_handler; + libinput_log_set_priority; + libinput_next_event_type; + libinput_path_add_device; + libinput_path_create_context; + libinput_path_remove_device; + libinput_ref; + libinput_resume; + libinput_seat_get_context; + libinput_seat_get_logical_name; + libinput_seat_get_physical_name; + libinput_seat_get_user_data; + libinput_seat_ref; + libinput_seat_set_user_data; + libinput_seat_unref; + libinput_suspend; + libinput_udev_assign_seat; + libinput_udev_create_context; + libinput_unref; +local: + *; +}; From 5ad756ea39da3542c2f05b5111b1f760d01a6385 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 9 Dec 2014 13:19:54 +1000 Subject: [PATCH 11/22] doc: include README as mainpage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit doxygen supports markdown so we can expand the README with general interesting information in markdown format and have it be the front page of the documentation at the same time. This requires renaming README to README.txt, but that's a relatively small price to pay. Signed-off-by: Peter Hutterer Reviewed-by: Jonas Ådahl --- README => README.txt | 5 +++++ doc/Makefile.am | 3 ++- doc/libinput.doxygen.in | 3 ++- src/libinput.h | 7 ------- 4 files changed, 9 insertions(+), 9 deletions(-) rename README => README.txt (97%) diff --git a/README b/README.txt similarity index 97% rename from README rename to README.txt index f55d7c8e..fabe304b 100644 --- a/README +++ b/README.txt @@ -1,4 +1,7 @@ +/*!@mainpage + libinput +======== libinput is a library that handles input devices for display servers and other applications that need to directly deal with input devices. @@ -23,3 +26,5 @@ https://bugs.freedesktop.org/enter_bug.cgi?product=Wayland Online API documentation: http://wayland.freedesktop.org/libinput/doc/latest/modules.html + +*/ diff --git a/doc/Makefile.am b/doc/Makefile.am index a33638da..8f05bd2c 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -5,7 +5,8 @@ if HAVE_DOXYGEN noinst_DATA = html/index.html header_files = \ - $(top_srcdir)/src/libinput.h + $(top_srcdir)/src/libinput.h \ + $(top_srcdir)/README.txt html/index.html: libinput.doxygen $(header_files) $(AM_V_GEN)$(DOXYGEN) $< diff --git a/doc/libinput.doxygen.in b/doc/libinput.doxygen.in index 865cf974..9800f808 100644 --- a/doc/libinput.doxygen.in +++ b/doc/libinput.doxygen.in @@ -753,7 +753,8 @@ WARN_LOGFILE = # spaces. # Note: If this tag is empty the current directory is searched. -INPUT = @top_srcdir@/src/libinput.h +INPUT = @top_srcdir@/src/libinput.h \ + @top_srcdir@/README.txt # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/src/libinput.h b/src/libinput.h index e2a3eef0..682e16f2 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -35,13 +35,6 @@ extern "C" { __attribute__ ((format (printf, _format, _args))) #define LIBINPUT_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated)) -/** - * @mainpage - * libinput is a generic input device handling library. It abstracts - * commonly-used concepts such as keyboard, pointer and touchpad handling - * behind an API. - */ - /** * @page tpbuttons Touchpad button behavior * From dc45db04671a77494d93cdb8335af25d264daed7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 9 Dec 2014 13:31:09 +1000 Subject: [PATCH 12/22] doc: add the various events to the doxygen groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Makes them show up on the respective page and in the data structures list doxygen generates. Signed-off-by: Peter Hutterer Reviewed-by: Jonas Ådahl --- src/libinput.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/libinput.h b/src/libinput.h index 682e16f2..d6e04462 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -306,9 +306,38 @@ struct libinput; struct libinput_device; struct libinput_seat; +/** + * @ingroup event + * @struct libinput_event + * + * The base event type. Use libinput_event_get_pointer_event() or similar to + * get the actual event type. + */ struct libinput_event; + +/** + * @ingroup event + * @struct libinput_event_device_notify + * + * An event notifying the caller of a device being added or removed. + */ struct libinput_event_device_notify; + +/** + * @ingroup event_keyboard + * @struct libinput_event_keyboard + * + * A keyboard event representing a key press/release. + */ struct libinput_event_keyboard; + +/** + * @ingroup event_pointer + * @struct libinput_event_pointer + * + * A pointer event representing relative or absolute pointer movement, + * a button press/release or scroll axis events. + */ struct libinput_event_pointer; /** From 0e9beca049e89d25d506f6b96dc659621499a44d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 9 Dec 2014 13:37:04 +1000 Subject: [PATCH 13/22] doc: document the base structures so they show up in doxygen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Peter Hutterer Reviewed-by: Jonas Ådahl --- src/libinput.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/libinput.h b/src/libinput.h index d6e04462..22b0cfe2 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -302,8 +302,31 @@ enum libinput_event_type { LIBINPUT_EVENT_TOUCH_FRAME }; +/** + * @ingroup base + * @struct libinput + * + * A handle for accessing libinput. This struct is refcounted, use + * libinput_ref() and libinput_unref(). + */ struct libinput; + +/** + * @ingroup device + * @struct libinput_device + * + * A base handle for accessing libinput devices. This struct is + * refcounted, use libinput_device_ref() and libinput_device_unref(). + */ struct libinput_device; + +/** + * @ingroup seat + * @struct libinput_seat + * + * The base handle for accessing libinput seats. This struct is + * refcounted, use libinput_seat_ref() and libinput_seat_unref(). + */ struct libinput_seat; /** @@ -919,6 +942,17 @@ libinput_event_touch_get_base_event(struct libinput_event_touch *event); * @defgroup base Initialization and manipulation of libinput contexts */ +/** + * @ingroup base + * @struct libinput_interface + * + * libinput does not open file descriptors to devices directly, instead + * open_restricted() and close_restricted() are called for each path that + * must be opened. + * + * @see libinput_udev_create_context + * @see libinput_path_create_context + */ struct libinput_interface { /** * Open the device at the given path with the flags provided and From 9a4cf4b0f8207efd773e28ff1af5c5713b69f68f Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 9 Dec 2014 13:52:45 +1000 Subject: [PATCH 14/22] doc: put some extra warning in for libinput_event_destroy() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unlike all other structs, events aren't refcounted and will get destroyed immediately. Signed-off-by: Peter Hutterer Reviewed-by: Jonas Ådahl --- src/libinput.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libinput.h b/src/libinput.h index 22b0cfe2..d62516d1 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -335,6 +335,9 @@ struct libinput_seat; * * The base event type. Use libinput_event_get_pointer_event() or similar to * get the actual event type. + * + * @warning Unlike other structs events are considered transient and + * not refcounted. */ struct libinput_event; @@ -382,7 +385,12 @@ struct libinput_event_touch; /** * @ingroup event * - * Destroy the event. + * Destroy the event, freeing all associated resources. Resources obtained + * from this event must be considered invalid after this call. + * + * @warning Unlike other structs events are considered transient and + * not refcounted. Calling libinput_event_destroy() will + * destroy the event. * * @param event An event retrieved by libinput_get_event(). */ From a296a102c78852bec0d64bcef99823ed8e8ca3b7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 11 Dec 2014 14:02:37 +1000 Subject: [PATCH 15/22] test: print the string of the event type Bit quicker to parse than the number Signed-off-by: Peter Hutterer --- test/litest.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 5 deletions(-) diff --git a/test/litest.c b/test/litest.c index 2ab802bc..abae4f57 100644 --- a/test/litest.c +++ b/test/litest.c @@ -897,6 +897,54 @@ litest_drain_events(struct libinput *li) } } +static const char * +litest_event_type_str(struct libinput_event *event) +{ + const char *str = NULL; + + switch (libinput_event_get_type(event)) { + case LIBINPUT_EVENT_NONE: + abort(); + case LIBINPUT_EVENT_DEVICE_ADDED: + str = "ADDED"; + break; + case LIBINPUT_EVENT_DEVICE_REMOVED: + str = "REMOVED"; + break; + case LIBINPUT_EVENT_KEYBOARD_KEY: + str = "KEY"; + break; + case LIBINPUT_EVENT_POINTER_MOTION: + str = "MOTION"; + break; + case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: + str = "ABSOLUTE"; + break; + case LIBINPUT_EVENT_POINTER_BUTTON: + str = "BUTTON"; + break; + case LIBINPUT_EVENT_POINTER_AXIS: + str = "AXIS"; + break; + case LIBINPUT_EVENT_TOUCH_DOWN: + str = "TOUCH DOWN"; + break; + case LIBINPUT_EVENT_TOUCH_UP: + str = "TOUCH UP"; + break; + case LIBINPUT_EVENT_TOUCH_MOTION: + str = "TOUCH MOTION"; + break; + case LIBINPUT_EVENT_TOUCH_CANCEL: + str = "TOUCH CANCEL"; + break; + case LIBINPUT_EVENT_TOUCH_FRAME: + str = "TOUCH FRAME"; + break; + } + return str; +} + static void litest_print_event(struct libinput_event *event) { @@ -909,26 +957,26 @@ litest_print_event(struct libinput_event *event) type = libinput_event_get_type(event); fprintf(stderr, - "device %s type %d ", + "device %s type %s ", libinput_device_get_sysname(dev), - type); + litest_event_type_str(event)); switch (type) { case LIBINPUT_EVENT_POINTER_MOTION: p = libinput_event_get_pointer_event(event); x = libinput_event_pointer_get_dx(p); y = libinput_event_pointer_get_dy(p); - fprintf(stderr, "motion: %.2f/%.2f", x, y); + fprintf(stderr, "%.2f/%.2f", x, y); break; case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE: p = libinput_event_get_pointer_event(event); x = libinput_event_pointer_get_absolute_x(p); y = libinput_event_pointer_get_absolute_y(p); - fprintf(stderr, "motion: %.2f/%.2f", x, y); + fprintf(stderr, "%.2f/%.2f", x, y); break; case LIBINPUT_EVENT_POINTER_BUTTON: p = libinput_event_get_pointer_event(event); fprintf(stderr, - "button: %d state %d", + "button %d state %d", libinput_event_pointer_get_button(p), libinput_event_pointer_get_button_state(p)); break; From e9b160a9959bb1a0cc687fbb7f4399a084facd2d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 11 Dec 2014 14:11:27 +1000 Subject: [PATCH 16/22] test: print axis event information for debugging too Signed-off-by: Peter Hutterer --- test/litest.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/litest.c b/test/litest.c index abae4f57..befad5aa 100644 --- a/test/litest.c +++ b/test/litest.c @@ -980,6 +980,15 @@ litest_print_event(struct libinput_event *event) libinput_event_pointer_get_button(p), libinput_event_pointer_get_button_state(p)); break; + case LIBINPUT_EVENT_POINTER_AXIS: + p = libinput_event_get_pointer_event(event); + fprintf(stderr, + "axis %s value %.2f", + libinput_event_pointer_get_axis(p) == + LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL ? + "vert" : "horiz", + libinput_event_pointer_get_axis_value(p)); + break; default: break; } From 06b534200178eec62790775ae1f4a1655ff108a1 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 11 Dec 2014 16:30:03 +1000 Subject: [PATCH 17/22] test: fix two compiler warnings device.c:596:2: warning: incompatible pointer to integer conversion initializing 'intmax_t' (aka 'long') with an expression of type 'struct libinput_device *' [-Wint-conversion] ck_assert_int_eq(libinput_event_get_device(event), use ck_assert_ptr_eq() instead Signed-off-by: Peter Hutterer --- test/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/device.c b/test/device.c index 16bb99c9..76486f03 100644 --- a/test/device.c +++ b/test/device.c @@ -593,7 +593,7 @@ START_TEST(device_disable_topsoftbutton) event = libinput_get_event(li); ck_assert_int_eq(libinput_event_get_type(event), LIBINPUT_EVENT_POINTER_BUTTON); - ck_assert_int_eq(libinput_event_get_device(event), + ck_assert_ptr_eq(libinput_event_get_device(event), trackpoint->libinput_device); ptrevent = libinput_event_get_pointer_event(event); ck_assert_int_eq(libinput_event_pointer_get_button(ptrevent), @@ -605,7 +605,7 @@ START_TEST(device_disable_topsoftbutton) event = libinput_get_event(li); ck_assert_int_eq(libinput_event_get_type(event), LIBINPUT_EVENT_POINTER_BUTTON); - ck_assert_int_eq(libinput_event_get_device(event), + ck_assert_ptr_eq(libinput_event_get_device(event), trackpoint->libinput_device); ptrevent = libinput_event_get_pointer_event(event); ck_assert_int_eq(libinput_event_pointer_get_button(ptrevent), From 48e38ea9b89a3be6759e23292935cb5f2a18140e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 12 Dec 2014 11:13:21 +1000 Subject: [PATCH 18/22] touchpad: fix typos in error message Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad-edge-scroll.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index 3684c8a9..0ac81943 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -113,7 +113,7 @@ tp_edge_scroll_handle_none(struct tp_dispatch *tp, case SCROLL_EVENT_TIMEOUT: case SCROLL_EVENT_POSTED: log_bug_libinput(libinput, - "unexpect scroll event in none state\n"); + "unexpected scroll event in none state\n"); break; } } @@ -128,7 +128,7 @@ tp_edge_scroll_handle_edge_new(struct tp_dispatch *tp, switch (event) { case SCROLL_EVENT_TOUCH: log_bug_libinput(libinput, - "unexpect scroll event in edge new state\n"); + "unexpected scroll event in edge new state\n"); break; case SCROLL_EVENT_MOTION: t->scroll.edge &= tp_touch_get_edge(tp, t); @@ -157,7 +157,7 @@ tp_edge_scroll_handle_edge(struct tp_dispatch *tp, case SCROLL_EVENT_TOUCH: case SCROLL_EVENT_TIMEOUT: log_bug_libinput(libinput, - "unexpect scroll event in edge state\n"); + "unexpected scroll event in edge state\n"); break; case SCROLL_EVENT_MOTION: /* If started at the bottom right, decide in which dir to scroll */ @@ -188,7 +188,7 @@ tp_edge_scroll_handle_area(struct tp_dispatch *tp, case SCROLL_EVENT_TIMEOUT: case SCROLL_EVENT_POSTED: log_bug_libinput(libinput, - "unexpect scroll event in area state\n"); + "unexpected scroll event in area state\n"); break; case SCROLL_EVENT_MOTION: break; From e923001c9511aebe027ad32696a194dc268cdbb4 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 12 Dec 2014 11:21:05 +1000 Subject: [PATCH 19/22] touchpad: print event type on state machine error Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad-edge-scroll.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index 0ac81943..616080fa 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -113,7 +113,8 @@ tp_edge_scroll_handle_none(struct tp_dispatch *tp, case SCROLL_EVENT_TIMEOUT: case SCROLL_EVENT_POSTED: log_bug_libinput(libinput, - "unexpected scroll event in none state\n"); + "unexpected scroll event %d in none state\n", + event); break; } } @@ -128,7 +129,8 @@ tp_edge_scroll_handle_edge_new(struct tp_dispatch *tp, switch (event) { case SCROLL_EVENT_TOUCH: log_bug_libinput(libinput, - "unexpected scroll event in edge new state\n"); + "unexpected scroll event %d in edge new state\n", + event); break; case SCROLL_EVENT_MOTION: t->scroll.edge &= tp_touch_get_edge(tp, t); @@ -157,7 +159,8 @@ tp_edge_scroll_handle_edge(struct tp_dispatch *tp, case SCROLL_EVENT_TOUCH: case SCROLL_EVENT_TIMEOUT: log_bug_libinput(libinput, - "unexpected scroll event in edge state\n"); + "unexpected scroll event %d in edge state\n", + event); break; case SCROLL_EVENT_MOTION: /* If started at the bottom right, decide in which dir to scroll */ @@ -188,7 +191,8 @@ tp_edge_scroll_handle_area(struct tp_dispatch *tp, case SCROLL_EVENT_TIMEOUT: case SCROLL_EVENT_POSTED: log_bug_libinput(libinput, - "unexpected scroll event in area state\n"); + "unexpected scroll event %d in area state\n", + event); break; case SCROLL_EVENT_MOTION: break; From 759e5eca6d45eb44ab47669795cac6dd95992480 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 9 Dec 2014 12:47:09 +0100 Subject: [PATCH 20/22] touchpad: Add a tp_post_pointer_motion helper function Split out the pointer-motion handling into a helper function. Signed-off-by: Hans de Goede Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad.c | 46 +++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 32d6eaca..f6a8a899 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -586,32 +586,13 @@ tp_post_process_state(struct tp_dispatch *tp, uint64_t time) tp->queued = TOUCHPAD_EVENT_NONE; } - static void -tp_post_events(struct tp_dispatch *tp, uint64_t time) +tp_post_pointer_motion(struct tp_dispatch *tp, uint64_t time) { struct tp_touch *t = tp_current_touch(tp); double dx, dy; - int filter_motion = 0; double dx_unaccel, dy_unaccel; - /* Only post (top) button events while suspended */ - if (tp->device->suspended) { - tp_post_button_events(tp, time); - return; - } - - filter_motion |= tp_tap_handle_state(tp, time); - filter_motion |= tp_post_button_events(tp, time); - - if (filter_motion || tp->sendevents.trackpoint_active) { - tp_stop_scroll_events(tp, time); - return; - } - - if (tp_post_scroll_events(tp, time) != 0) - return; - if (!t->is_pointer) { tp_for_each_touch(tp, t) { if (t->is_pointer) @@ -633,6 +614,31 @@ tp_post_events(struct tp_dispatch *tp, uint64_t time) } } +static void +tp_post_events(struct tp_dispatch *tp, uint64_t time) +{ + int filter_motion = 0; + + /* Only post (top) button events while suspended */ + if (tp->device->suspended) { + tp_post_button_events(tp, time); + return; + } + + filter_motion |= tp_tap_handle_state(tp, time); + filter_motion |= tp_post_button_events(tp, time); + + if (filter_motion || tp->sendevents.trackpoint_active) { + tp_stop_scroll_events(tp, time); + return; + } + + if (tp_post_scroll_events(tp, time) != 0) + return; + + tp_post_pointer_motion(tp, time); +} + static void tp_handle_state(struct tp_dispatch *tp, uint64_t time) From 6664144611dce94ae42e0e88495d3955f5823de8 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 9 Dec 2014 12:47:10 +0100 Subject: [PATCH 21/22] touchpad: When a clickpad is clicked post combined motion of all touches When clicking a clickpad the user may want to switch fingers to move the pointer around, without lifting so as to not release the button. Switch to using combined motion of all touches when a clickpad is clicked to allow this. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=86807 Signed-off-by: Hans de Goede Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad.c | 43 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index f6a8a899..e8bd77b7 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -448,6 +448,10 @@ tp_twofinger_scroll_post_events(struct tp_dispatch *tp, uint64_t time) if (tp_tap_dragging(tp)) return 0; + /* No 2fg scrolling while a clickpad is clicked */ + if (tp->buttons.is_clickpad && tp->buttons.state) + return 0; + /* Only count active touches for 2 finger scrolling */ tp_for_each_touch(tp, t) { if (tp_touch_active(tp, t)) @@ -587,11 +591,9 @@ tp_post_process_state(struct tp_dispatch *tp, uint64_t time) } static void -tp_post_pointer_motion(struct tp_dispatch *tp, uint64_t time) +tp_get_pointer_delta(struct tp_dispatch *tp, double *dx, double *dy) { struct tp_touch *t = tp_current_touch(tp); - double dx, dy; - double dx_unaccel, dy_unaccel; if (!t->is_pointer) { tp_for_each_touch(tp, t) { @@ -605,7 +607,40 @@ tp_post_pointer_motion(struct tp_dispatch *tp, uint64_t time) t->history.count < TOUCHPAD_MIN_SAMPLES) return; - tp_get_delta(t, &dx, &dy); + tp_get_delta(t, dx, dy); +} + +static void +tp_get_active_touches_delta(struct tp_dispatch *tp, double *dx, double *dy) +{ + struct tp_touch *t; + double tdx, tdy; + unsigned int i; + + for (i = 0; i < tp->real_touches; i++) { + t = tp_get_touch(tp, i); + + if (!tp_touch_active(tp, t) || !t->dirty) + continue; + + tp_get_delta(t, &tdx, &tdy); + *dx += tdx; + *dy += tdy; + } +} + +static void +tp_post_pointer_motion(struct tp_dispatch *tp, uint64_t time) +{ + double dx = 0.0, dy = 0.0; + double dx_unaccel, dy_unaccel; + + /* When a clickpad is clicked, combine motion of all active touches */ + if (tp->buttons.is_clickpad && tp->buttons.state) + tp_get_active_touches_delta(tp, &dx, &dy); + else + tp_get_pointer_delta(tp, &dx, &dy); + tp_filter_motion(tp, &dx, &dy, &dx_unaccel, &dy_unaccel, time); if (dx != 0.0 || dy != 0.0 || dx_unaccel != 0.0 || dy_unaccel != 0.0) { From d21c8886c4bb8b195d99dcc63cec73cfde0d4f6e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Tue, 9 Dec 2014 12:47:11 +0100 Subject: [PATCH 22/22] touchpad: Use TOUCHPAD_MIN_SAMPLES in tp_get_delta Use TOUCHPAD_MIN_SAMPLES in tp_get_delta rather then hardcoding "4". Also remove the superfluous TOUCHPAD_MIN_SAMPLES check before calling tp_get_delta in tp_get_pointer_delta, this is not necessary as tp_get_delta already checks itself. Signed-off-by: Hans de Goede Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index e8bd77b7..964900d2 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -177,7 +177,7 @@ tp_estimate_delta(int x0, int x1, int x2, int x3) void tp_get_delta(struct tp_touch *t, double *dx, double *dy) { - if (t->history.count < 4) { + if (t->history.count < TOUCHPAD_MIN_SAMPLES) { *dx = 0; *dy = 0; return; @@ -602,9 +602,7 @@ tp_get_pointer_delta(struct tp_dispatch *tp, double *dx, double *dy) } } - if (!t->is_pointer || - !t->dirty || - t->history.count < TOUCHPAD_MIN_SAMPLES) + if (!t->is_pointer || !t->dirty) return; tp_get_delta(t, dx, dy);