[PATCH weston 14/25] libweston: notify_touch API to use weston_touch_device

Pekka Paalanen ppaalanen at gmail.com
Fri Mar 23 12:00:54 UTC 2018


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

Relay touch input events into libweston core through the
weston_touch_device, so that the core can tell which individual physical
device they come from.

This is necessary for supporting touchscreen calibration, where one
needs to process a single physical device at a time instead of the
aggregate of all touch devices on the weston_seat.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 libweston/compositor-wayland.c | 10 +++++-----
 libweston/compositor.h         |  6 +++---
 libweston/input.c              | 18 ++++++++----------
 libweston/libinput-device.c    |  7 +++----
 tests/weston-test.c            |  6 ++++--
 5 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 9d5b3551..27fe5f59 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -2144,7 +2144,7 @@ input_handle_touch_down(void *data, struct wl_touch *wl_touch,
 
 	weston_output_transform_coordinate(&output->base, x, y, &x, &y);
 
-	notify_touch(&input->base, &ts, id, x, y, WL_TOUCH_DOWN);
+	notify_touch(input->touch_device, &ts, id, x, y, WL_TOUCH_DOWN);
 	input->touch_active = true;
 }
 
@@ -2185,7 +2185,7 @@ input_handle_touch_up(void *data, struct wl_touch *wl_touch,
 	}
 
 	if (active)
-		notify_touch(&input->base, &ts, id, 0, 0, WL_TOUCH_UP);
+		notify_touch(input->touch_device, &ts, id, 0, 0, WL_TOUCH_UP);
 }
 
 static void
@@ -2214,7 +2214,7 @@ input_handle_touch_motion(void *data, struct wl_touch *wl_touch,
 
 	weston_output_transform_coordinate(&output->base, x, y, &x, &y);
 
-	notify_touch(&input->base, &ts, id, x, y, WL_TOUCH_MOTION);
+	notify_touch(input->touch_device, &ts, id, x, y, WL_TOUCH_MOTION);
 }
 
 static void
@@ -2225,7 +2225,7 @@ input_handle_touch_frame(void *data, struct wl_touch *wl_touch)
 	if (!input->touch_focus || !input->touch_active)
 		return;
 
-	notify_touch_frame(&input->base);
+	notify_touch_frame(input->touch_device);
 }
 
 static void
@@ -2236,7 +2236,7 @@ input_handle_touch_cancel(void *data, struct wl_touch *wl_touch)
 	if (!input->touch_focus || !input->touch_active)
 		return;
 
-	notify_touch_cancel(&input->base);
+	notify_touch_cancel(input->touch_device);
 }
 
 static const struct wl_touch_listener touch_listener = {
diff --git a/libweston/compositor.h b/libweston/compositor.h
index b08031ac..27daf76a 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -1545,13 +1545,13 @@ void
 notify_keyboard_focus_out(struct weston_seat *seat);
 
 void
-notify_touch(struct weston_seat *seat, const struct timespec *time,
+notify_touch(struct weston_touch_device *device, const struct timespec *time,
 	     int touch_id, double x, double y, int touch_type);
 void
-notify_touch_frame(struct weston_seat *seat);
+notify_touch_frame(struct weston_touch_device *device);
 
 void
-notify_touch_cancel(struct weston_seat *seat);
+notify_touch_cancel(struct weston_touch_device *device);
 
 void
 weston_layer_entry_insert(struct weston_layer_entry *list,
diff --git a/libweston/input.c b/libweston/input.c
index feea9e72..db710da3 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -2345,12 +2345,12 @@ weston_touch_set_focus(struct weston_touch *touch, struct weston_view *view)
  *
  */
 WL_EXPORT void
-notify_touch(struct weston_seat *seat, const struct timespec *time,
+notify_touch(struct weston_touch_device *device, const struct timespec *time,
 	     int touch_id, double double_x, double double_y, int touch_type)
 {
-	struct weston_compositor *ec = seat->compositor;
-	struct weston_touch *touch = weston_seat_get_touch(seat);
-	struct weston_touch_grab *grab = touch->grab;
+	struct weston_touch *touch = device->aggregate;
+	struct weston_touch_grab *grab = device->aggregate->grab;
+	struct weston_compositor *ec = device->aggregate->seat->compositor;
 	struct weston_view *ev;
 	wl_fixed_t sx, sy;
 	wl_fixed_t x = wl_fixed_from_double(double_x);
@@ -2424,19 +2424,17 @@ notify_touch(struct weston_seat *seat, const struct timespec *time,
 }
 
 WL_EXPORT void
-notify_touch_frame(struct weston_seat *seat)
+notify_touch_frame(struct weston_touch_device *device)
 {
-	struct weston_touch *touch = weston_seat_get_touch(seat);
-	struct weston_touch_grab *grab = touch->grab;
+	struct weston_touch_grab *grab = device->aggregate->grab;
 
 	grab->interface->frame(grab);
 }
 
 WL_EXPORT void
-notify_touch_cancel(struct weston_seat *seat)
+notify_touch_cancel(struct weston_touch_device *device)
 {
-	struct weston_touch *touch = weston_seat_get_touch(seat);
-	struct weston_touch_grab *grab = touch->grab;
+	struct weston_touch_grab *grab = device->aggregate->grab;
 
 	grab->interface->cancel(grab);
 }
diff --git a/libweston/libinput-device.c b/libweston/libinput-device.c
index 742cb5c9..9f5793aa 100644
--- a/libweston/libinput-device.c
+++ b/libweston/libinput-device.c
@@ -436,7 +436,7 @@ handle_touch_with_coords(struct libinput_device *libinput_device,
 	weston_output_transform_coordinate(device->output,
 					   x, y, &x, &y);
 
-	notify_touch(device->seat, &time, slot, x, y, touch_type);
+	notify_touch(device->touch_device, &time, slot, x, y, touch_type);
 }
 
 static void
@@ -465,7 +465,7 @@ handle_touch_up(struct libinput_device *libinput_device,
 	timespec_from_usec(&time,
 			   libinput_event_touch_get_time_usec(touch_event));
 
-	notify_touch(device->seat, &time, slot, 0, 0, WL_TOUCH_UP);
+	notify_touch(device->touch_device, &time, slot, 0, 0, WL_TOUCH_UP);
 }
 
 static void
@@ -474,9 +474,8 @@ handle_touch_frame(struct libinput_device *libinput_device,
 {
 	struct evdev_device *device =
 		libinput_device_get_user_data(libinput_device);
-	struct weston_seat *seat = device->seat;
 
-	notify_touch_frame(seat);
+	notify_touch_frame(device->touch_device);
 }
 
 int
diff --git a/tests/weston-test.c b/tests/weston-test.c
index 9662b67c..412eb243 100644
--- a/tests/weston-test.c
+++ b/tests/weston-test.c
@@ -595,12 +595,14 @@ send_touch(struct wl_client *client, struct wl_resource *resource,
 	   int32_t touch_id, wl_fixed_t x, wl_fixed_t y, uint32_t touch_type)
 {
 	struct weston_test *test = wl_resource_get_user_data(resource);
-	struct weston_seat *seat = get_seat(test);
+	struct weston_touch_device *device = test->touch_device[0];
 	struct timespec time;
 
+	assert(device);
+
 	timespec_from_proto(&time, tv_sec_hi, tv_sec_lo, tv_nsec);
 
-	notify_touch(seat, &time, touch_id, wl_fixed_to_double(x),
+	notify_touch(device, &time, touch_id, wl_fixed_to_double(x),
 		     wl_fixed_to_double(y), touch_type);
 }
 
-- 
2.16.1



More information about the wayland-devel mailing list