From 82e8560c47a366d82c6d50f649f0b228ed43cbcd Mon Sep 17 00:00:00 2001 From: Emre Ucan Date: Wed, 16 Dec 2015 10:44:58 +0100 Subject: ivi-input: send touch events in surface coordinates The clients should always get the touch events in surface coordinate system and not the global coordinate system. Therefore, the global positions are transformed to local positions with weston_view_from_global_fixed API. Signed-off-by: Emre Ucan Signed-off-by: Nobuhiko Tanibata --- .../ivi-input-controller/src/ivi-input-controller.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c b/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c index 45f15fd..9ed85d2 100644 --- a/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c +++ b/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c @@ -443,11 +443,12 @@ static struct weston_pointer_grab_interface pointer_grab_interface = { static void touch_grab_down(struct weston_touch_grab *grab, uint32_t time, int touch_id, - wl_fixed_t sx, wl_fixed_t sy) + wl_fixed_t x, wl_fixed_t y) { struct seat_ctx *seat = wl_container_of(grab, seat, touch_grab); struct wl_display *display = grab->touch->seat->compositor->wl_display; struct surface_ctx *surf_ctx; + wl_fixed_t sx, sy; const struct ivi_controller_interface *interface = seat->input_ctx->ivi_controller_interface; @@ -458,6 +459,7 @@ touch_grab_down(struct weston_touch_grab *grab, uint32_t time, int touch_id, /* For each surface_ctx, check for focus and send */ wl_list_for_each(surf_ctx, &seat->input_ctx->surface_list, link) { struct weston_surface *surf; + struct weston_view *view; struct wl_resource *resource; struct wl_client *surface_client; uint32_t serial; @@ -487,6 +489,10 @@ touch_grab_down(struct weston_touch_grab *grab, uint32_t time, int touch_id, if (!(surf_ctx->focus & ILM_INPUT_DEVICE_TOUCH)) continue; + /* Assume one view per surface */ + view = wl_container_of(surf->views.next, view, surface_link); + weston_view_from_global_fixed(view, x, y, &sx, &sy); + surface_client = wl_resource_get_client(surf->resource); serial = wl_display_next_serial(display); wl_resource_for_each(resource, &grab->touch->resource_list) { @@ -560,16 +566,18 @@ touch_grab_up(struct weston_touch_grab *grab, uint32_t time, int touch_id) static void touch_grab_motion(struct weston_touch_grab *grab, uint32_t time, int touch_id, - wl_fixed_t sx, wl_fixed_t sy) + wl_fixed_t x, wl_fixed_t y) { struct seat_ctx *seat = wl_container_of(grab, seat, touch_grab); struct surface_ctx *surf_ctx; + wl_fixed_t sx, sy; const struct ivi_controller_interface *interface = seat->input_ctx->ivi_controller_interface; /* For each surface_ctx, check for focus and send */ wl_list_for_each(surf_ctx, &seat->input_ctx->surface_list, link) { struct weston_surface *surf; + struct weston_view *view; struct wl_resource *resource; struct wl_client *surface_client; @@ -579,7 +587,11 @@ touch_grab_motion(struct weston_touch_grab *grab, uint32_t time, int touch_id, if (get_accepted_seat(surf_ctx, grab->touch->seat->seat_name) < 0) continue; + /* Assume one view per surface */ surf = interface->surface_get_weston_surface(surf_ctx->layout_surface); + view = wl_container_of(surf->views.next, view, surface_link); + weston_view_from_global_fixed(view, x, y, &sx, &sy); + surface_client = wl_resource_get_client(surf->resource); wl_resource_for_each(resource, &grab->touch->resource_list) { if (wl_resource_get_client(resource) != surface_client) -- cgit v1.2.1