1 From e1823ef6721dec9db2343c7f92703d03a435e2bf Mon Sep 17 00:00:00 2001
2 From: Ryo Kagaya <rkagaya@jp.adit-jv.com>
3 Date: Fri, 4 Nov 2016 18:30:06 +0900
4 Subject: [PATCH] ivi-input: support touch and pointer on subsurface
6 When sends event to client, find a focused surface from subsurface list.
8 support following events
14 .../src/ivi-input-controller.c | 78 ++++++++++++++++++----
15 1 file changed, 64 insertions(+), 14 deletions(-)
17 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
18 index 9ed85d2..b1f9d6d 100644
19 --- a/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c
20 +++ b/ivi-input-modules/ivi-input-controller/src/ivi-input-controller.c
21 @@ -372,7 +372,8 @@ pointer_grab_button(struct weston_pointer_grab *grab, uint32_t time,
22 struct surface_ctx *surf_ctx;
24 struct weston_view *picked_view, *w_view, *old_focus;
25 - struct weston_surface *w_surf;
26 + struct weston_surface *w_surf, *send_surf;
27 + struct weston_subsurface *sub;
28 struct wl_resource *resource;
29 struct wl_client *surface_client;
31 @@ -391,12 +392,24 @@ pointer_grab_button(struct weston_pointer_grab *grab, uint32_t time,
32 /* search for the picked view in layout surfaces */
33 wl_list_for_each(surf_ctx, &seat->input_ctx->surface_list, link) {
34 w_surf = interface->surface_get_weston_surface(surf_ctx->layout_surface);
35 - w_view = wl_container_of(w_surf->views.next, w_view, surface_link);
37 + /* Find a focused surface from subsurface list */
39 + if (!wl_list_empty(&w_surf->subsurface_list)) {
40 + wl_list_for_each(sub, &w_surf->subsurface_list, parent_link) {
41 + if (sub->surface == picked_view->surface) {
42 + send_surf = sub->surface;
48 + w_view = wl_container_of(send_surf->views.next, w_view, surface_link);
50 if (get_accepted_seat(surf_ctx, grab->pointer->seat->seat_name) < 0)
53 - if (picked_view->surface == w_surf) {
54 + if (picked_view->surface == send_surf) {
55 /* Correct layout surface is found*/
56 surf_ctx->focus |= ILM_INPUT_DEVICE_POINTER;
57 send_input_focus(seat->input_ctx,
58 @@ -458,7 +471,8 @@ touch_grab_down(struct weston_touch_grab *grab, uint32_t time, int touch_id,
60 /* For each surface_ctx, check for focus and send */
61 wl_list_for_each(surf_ctx, &seat->input_ctx->surface_list, link) {
62 - struct weston_surface *surf;
63 + struct weston_surface *surf, *send_surf;
64 + struct weston_subsurface *sub;
65 struct weston_view *view;
66 struct wl_resource *resource;
67 struct wl_client *surface_client;
68 @@ -469,9 +483,20 @@ touch_grab_down(struct weston_touch_grab *grab, uint32_t time, int touch_id,
69 if (get_accepted_seat(surf_ctx, grab->touch->seat->seat_name) < 0)
72 + /* Find a focused surface from subsurface list */
74 + if (!wl_list_empty(&surf->subsurface_list)) {
75 + wl_list_for_each(sub, &surf->subsurface_list, parent_link) {
76 + if (sub->surface == grab->touch->focus->surface) {
77 + send_surf = sub->surface;
83 /* Touches set touch focus */
84 if (grab->touch->num_tp == 1) {
85 - if (surf == grab->touch->focus->surface) {
86 + if (send_surf == grab->touch->focus->surface) {
87 surf_ctx->focus |= ILM_INPUT_DEVICE_TOUCH;
88 send_input_focus(seat->input_ctx,
89 interface->get_id_of_surface(surf_ctx->layout_surface),
90 @@ -490,23 +515,23 @@ touch_grab_down(struct weston_touch_grab *grab, uint32_t time, int touch_id,
93 /* Assume one view per surface */
94 - view = wl_container_of(surf->views.next, view, surface_link);
95 + view = wl_container_of(send_surf->views.next, view, surface_link);
96 weston_view_from_global_fixed(view, x, y, &sx, &sy);
98 - surface_client = wl_resource_get_client(surf->resource);
99 + surface_client = wl_resource_get_client(send_surf->resource);
100 serial = wl_display_next_serial(display);
101 wl_resource_for_each(resource, &grab->touch->resource_list) {
102 if (wl_resource_get_client(resource) != surface_client)
105 - wl_touch_send_down(resource, serial, time, surf->resource,
106 + wl_touch_send_down(resource, serial, time, send_surf->resource,
109 wl_resource_for_each(resource, &grab->touch->focus_resource_list) {
110 if (wl_resource_get_client(resource) != surface_client)
113 - wl_touch_send_down(resource, serial, time, surf->resource,
114 + wl_touch_send_down(resource, serial, time, send_surf->resource,
118 @@ -525,7 +550,8 @@ touch_grab_up(struct weston_touch_grab *grab, uint32_t time, int touch_id)
120 /* For each surface_ctx, check for focus and send */
121 wl_list_for_each(surf_ctx, &seat->input_ctx->surface_list, link) {
122 - struct weston_surface *surf;
123 + struct weston_surface *surf, *send_surf;
124 + struct weston_subsurface *sub;
125 struct wl_resource *resource;
126 struct wl_client *surface_client;
128 @@ -537,8 +563,20 @@ touch_grab_up(struct weston_touch_grab *grab, uint32_t time, int touch_id)
131 surf = interface->surface_get_weston_surface(surf_ctx->layout_surface);
132 - surface_client = wl_resource_get_client(surf->resource);
133 serial = wl_display_next_serial(display);
135 + /* Find a focused surface from subsurface list */
137 + if (!wl_list_empty(&surf->subsurface_list)) {
138 + wl_list_for_each(sub, &surf->subsurface_list, parent_link) {
139 + if (sub->surface == grab->touch->focus->surface) {
140 + send_surf = sub->surface;
145 + surface_client = wl_resource_get_client(send_surf->resource);
147 wl_resource_for_each(resource, &grab->touch->resource_list) {
148 if (wl_resource_get_client(resource) != surface_client)
150 @@ -555,7 +593,7 @@ touch_grab_up(struct weston_touch_grab *grab, uint32_t time, int touch_id)
152 /* Touches unset touch focus */
153 if (grab->touch->num_tp == 0) {
154 - if (surf == grab->touch->focus->surface)
155 + if (send_surf == grab->touch->focus->surface)
156 surf_ctx->focus &= ~ILM_INPUT_DEVICE_TOUCH;
157 send_input_focus(seat->input_ctx,
158 interface->get_id_of_surface(surf_ctx->layout_surface),
159 @@ -576,7 +614,8 @@ touch_grab_motion(struct weston_touch_grab *grab, uint32_t time, int touch_id,
161 /* For each surface_ctx, check for focus and send */
162 wl_list_for_each(surf_ctx, &seat->input_ctx->surface_list, link) {
163 - struct weston_surface *surf;
164 + struct weston_surface *surf, *send_surf;
165 + struct weston_subsurface *sub;
166 struct weston_view *view;
167 struct wl_resource *resource;
168 struct wl_client *surface_client;
169 @@ -592,7 +631,18 @@ touch_grab_motion(struct weston_touch_grab *grab, uint32_t time, int touch_id,
170 view = wl_container_of(surf->views.next, view, surface_link);
171 weston_view_from_global_fixed(view, x, y, &sx, &sy);
173 - surface_client = wl_resource_get_client(surf->resource);
174 + /* Find a focused surface from subsurface list */
176 + if (!wl_list_empty(&surf->subsurface_list)) {
177 + wl_list_for_each(sub, &surf->subsurface_list, parent_link) {
178 + if (sub->surface == grab->touch->focus->surface) {
179 + send_surf = sub->surface;
184 + surface_client = wl_resource_get_client(send_surf->resource);
186 wl_resource_for_each(resource, &grab->touch->resource_list) {
187 if (wl_resource_get_client(resource) != surface_client)