From 813a06e4558f397aec11e457fe7a1d683a8b3bfb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Louis-Francis=20Ratt=C3=A9-Boulianne?= Date: Tue, 28 Nov 2017 20:42:47 -0500 Subject: [PATCH] input: move touchpoint counting up MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The touchpoint counting is needed regardless of what we do with the touch events, so move it out of process_touch_normal() into the caller notify_touch_normalized(). This is pure refactoring. Signed-off-by: Louis-Francis Ratté-Boulianne Signed-off-by: Pekka Paalanen v1 Tested-by: Matt Hoosier Reviewed-by: Peter Hutterer --- libweston/input.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/libweston/input.c b/libweston/input.c index a583822..6816cc3 100644 --- a/libweston/input.c +++ b/libweston/input.c @@ -2359,10 +2359,6 @@ process_touch_normal(struct weston_touch_device *device, switch (touch_type) { case WL_TOUCH_DOWN: - weston_compositor_idle_inhibit(ec); - - touch->num_tp++; - /* the first finger down picks the view, and all further go * to that view for the remainder of the touch session i.e. * until all touch points are up again. */ @@ -2400,17 +2396,6 @@ process_touch_normal(struct weston_touch_device *device, grab->interface->motion(grab, time, touch_id, x, y); break; case WL_TOUCH_UP: - if (touch->num_tp == 0) { - /* This can happen if we start out with one or - * more fingers on the touch screen, in which - * case we didn't get the corresponding down - * event. */ - weston_log("unmatched touch up event\n"); - break; - } - weston_compositor_idle_release(ec); - touch->num_tp--; - grab->interface->up(grab, time, touch_id); if (touch->num_tp == 0) weston_touch_set_focus(touch, NULL); @@ -2450,6 +2435,9 @@ notify_touch_normalized(struct weston_touch_device *device, const struct weston_point2d_device_normalized *norm, int touch_type) { + struct weston_seat *seat = device->aggregate->seat; + struct weston_touch *touch = device->aggregate; + if (touch_type != WL_TOUCH_UP) { if (weston_touch_device_can_calibrate(device)) assert(norm != NULL); @@ -2457,6 +2445,30 @@ notify_touch_normalized(struct weston_touch_device *device, assert(norm == NULL); } + /* Update touchpoints count regardless of the current mode. */ + switch (touch_type) { + case WL_TOUCH_DOWN: + weston_compositor_idle_inhibit(seat->compositor); + + touch->num_tp++; + break; + case WL_TOUCH_UP: + if (touch->num_tp == 0) { + /* This can happen if we start out with one or + * more fingers on the touch screen, in which + * case we didn't get the corresponding down + * event. */ + weston_log("unmatched touch up event\n"); + break; + } + weston_compositor_idle_release(seat->compositor); + + touch->num_tp--; + break; + default: + break; + } + process_touch_normal(device, time, touch_id, x, y, touch_type); } -- 2.7.4