[PATCH weston 3/4] Only update the touch grab position for the first finger

Neil Roberts neil at linux.intel.com
Thu Oct 3 08:43:06 PDT 2013


Previously if you add a second finger while moving a window with a
touch grab then the position will keep jumping between the position of
each finger as you move them around. This patch changes it so that it
keeps track of the first touch id that starts the grab and only
updates the grab position when that finger moves.
---
 src/compositor.h | 1 +
 src/input.c      | 7 +++++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/compositor.h b/src/compositor.h
index ad5a786..ffa5124 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -343,6 +343,7 @@ struct weston_touch {
 
 	struct weston_touch_grab *grab;
 	struct weston_touch_grab default_grab;
+	int grab_touch_id;
 	wl_fixed_t grab_x, grab_y;
 	uint32_t grab_serial;
 	uint32_t grab_time;
diff --git a/src/input.c b/src/input.c
index 3e4f4b1..4e6818c 100644
--- a/src/input.c
+++ b/src/input.c
@@ -1093,8 +1093,10 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
 	wl_fixed_t sx, sy;
 
 	/* Update grab's global coordinates. */
-	touch->grab_x = x;
-	touch->grab_y = y;
+	if (touch_id == touch->grab_touch_id && touch_type != WL_TOUCH_UP) {
+		touch->grab_x = x;
+		touch->grab_y = y;
+	}
 
 	switch (touch_type) {
 	case WL_TOUCH_DOWN:
@@ -1124,6 +1126,7 @@ notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
 		if (seat->num_tp == 1) {
 			touch->grab_serial =
 				wl_display_get_serial(ec->wl_display);
+			touch->grab_touch_id = touch_id;
 			touch->grab_time = time;
 			touch->grab_x = x;
 			touch->grab_y = y;
-- 
1.8.3.1



More information about the wayland-devel mailing list