[PATCH 2/8] evdev-touchpad: Split the reset logic

Alexander E. Patrakov patrakov at gmail.com
Mon Aug 5 03:34:31 PDT 2013


From: "Alexander E. Patrakov" <patrakov at gmail.com>

In old code, the reset both cleared the (global) motion history and
invalidated some state associated with (the) touch point. In the
multitouch case, there is still the global motion history that may need
to be cleared, and there are potentially many touch points that are
certainly not appropriate to invalidate at once. So copy-paste the
logic in order to be able to separate these two kinds of actions as
needed.
---
 src/evdev-touchpad.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/src/evdev-touchpad.c b/src/evdev-touchpad.c
index 35be921..6646896 100644
--- a/src/evdev-touchpad.c
+++ b/src/evdev-touchpad.c
@@ -102,8 +102,6 @@ struct touchpad_dispatch {
 	double min_accel_factor;
 	double max_accel_factor;
 
-	int reset;
-
 	struct {
 		bool enable;
 
@@ -417,13 +415,10 @@ touchpad_update_state(struct touchpad_dispatch *touchpad, uint32_t time)
 	int center_x, center_y;
 	double dx = 0.0, dy = 0.0;
 
-	if (touchpad->reset ||
-	    touchpad->last_finger_state != touchpad->finger_state) {
-		touchpad->reset = 0;
+	if (touchpad->last_finger_state != touchpad->finger_state) {
 		touchpad->motion_count = 0;
 		touchpad->hw_abs.x_valid = touchpad->hw_abs.y_valid = false;
 		touchpad->hw_abs.is_moving = false;
-		/* XXX what about is_pressed? */
 
 		touchpad->last_finger_state = touchpad->finger_state;
 
@@ -511,7 +506,8 @@ on_release(struct touchpad_dispatch *touchpad)
 {
 
 	touchpad->hw_abs.has_moved = touchpad->hw_abs.is_pressed = false;
-	touchpad->reset = 1;
+	touchpad->hw_abs.x_valid = touchpad->hw_abs.y_valid = false;
+	touchpad->hw_abs.is_moving = false;
 
 	push_fsm_event(touchpad, FSM_EVENT_RELEASE);
 }
@@ -589,7 +585,11 @@ process_key(struct touchpad_dispatch *touchpad,
 	case BTN_TOOL_AIRBRUSH:
 	case BTN_TOOL_MOUSE:
 	case BTN_TOOL_LENS:
-		touchpad->reset = 1;
+		/* The reset-logic below was copied without understanding
+		 * and may be inappropriate */
+		touchpad->motion_count = 0;
+		touchpad->hw_abs.x_valid = touchpad->hw_abs.y_valid = false;
+		touchpad->hw_abs.is_moving = false;
 		break;
 	case BTN_TOOL_FINGER:
 		if (e->value)
@@ -711,8 +711,6 @@ touchpad_init(struct touchpad_dispatch *touchpad,
 	touchpad->filter = accel;
 
 	/* Setup initial state */
-	touchpad->reset = 1;
-
 	memset(touchpad->motion_history, 0, sizeof touchpad->motion_history);
 	touchpad->motion_index = 0;
 	touchpad->motion_count = 0;
-- 
1.8.3.2



More information about the wayland-devel mailing list