[PATCH weston v2 03/12] libweston: notify_touch API to use weston_touch_device
Pekka Paalanen
ppaalanen at gmail.com
Mon Apr 30 13:03:25 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>
Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>
v1 Tested-by: Matt Hoosier <matt.hoosier at gmail.com>
---
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 0f3e3c19..a9eaa132 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -2145,7 +2145,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;
}
@@ -2186,7 +2186,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
@@ -2215,7 +2215,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
@@ -2226,7 +2226,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
@@ -2237,7 +2237,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 5a2dd69d..1c29b69c 100644
--- a/libweston/compositor.h
+++ b/libweston/compositor.h
@@ -1539,13 +1539,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 acb564e0..e02b3060 100644
--- a/libweston/input.c
+++ b/libweston/input.c
@@ -2347,12 +2347,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);
@@ -2426,19 +2426,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 1fc01335..dda28fdc 100644
--- a/libweston/libinput-device.c
+++ b/libweston/libinput-device.c
@@ -438,7 +438,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
@@ -467,7 +467,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
@@ -476,9 +476,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