diff options
author | Emre Ucan <eucan@de.adit-jv.com> | 2015-05-20 09:01:16 +0200 |
---|---|---|
committer | Nobuhiko Tanibata <nobuhiko_tanibata@xddp.denso.co.jp> | 2015-06-15 16:23:31 +0900 |
commit | 18b8e27c9464e8e679adadb02ef639780bb8fd8b (patch) | |
tree | 9f6aeba70ef6e8d479dca52cc85d18eb4bb45cdf /ivi-input-controller | |
parent | 9ef8a047a86ebc4fff06acec5cf4bc8d3e60b845 (diff) | |
download | wayland-ivi-extension-18b8e27c9464e8e679adadb02ef639780bb8fd8b.tar.gz |
ivi-input-controller: pointer_grab_button revamp
- Set pointer focus before button event is set
- Set pointer focus by pressed event not released
- Call weston_pointer_set_focus to send enter/leave events
- Do not check all surfaces for pointer focus.
Only one surface can have pointer focus per seat.
Signed-off-by: Emre Ucan <eucan@de.adit-jv.com>
Diffstat (limited to 'ivi-input-controller')
-rw-r--r-- | ivi-input-controller/src/ivi-input-controller.c | 75 |
1 files changed, 37 insertions, 38 deletions
diff --git a/ivi-input-controller/src/ivi-input-controller.c b/ivi-input-controller/src/ivi-input-controller.c index 21caeb3..87653d3 100644 --- a/ivi-input-controller/src/ivi-input-controller.c +++ b/ivi-input-controller/src/ivi-input-controller.c @@ -352,56 +352,42 @@ pointer_grab_button(struct weston_pointer_grab *grab, uint32_t time, struct wl_display *display = compositor->wl_display; struct surface_ctx *surf_ctx; wl_fixed_t sx, sy; - struct weston_view *view; + struct weston_view *picked_view, *w_view, *old_focus; + struct weston_surface *w_surf; + struct wl_resource *resource; + struct wl_client *surface_client; + uint32_t serial; const struct ivi_controller_interface *interface = seat->input_ctx->ivi_controller_interface; - view = weston_compositor_pick_view(compositor, pointer->x, pointer->y, + picked_view = weston_compositor_pick_view(compositor, pointer->x, pointer->y, &sx, &sy); - if (view == NULL) + if (picked_view == NULL) return; - /* 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 wl_resource *resource; - struct wl_client *surface_client; - uint32_t serial; - - surf = interface->surface_get_weston_surface(surf_ctx->layout_surface); - - if (get_accepted_seat(surf_ctx, grab->pointer->seat->seat_name) < 0) - continue; - - /* Send to surfaces that have pointer focus */ - if (surf_ctx->focus & ILM_INPUT_DEVICE_POINTER) { - - surface_client = wl_resource_get_client(surf->resource); - serial = wl_display_next_serial(display); - wl_resource_for_each(resource, &grab->pointer->resource_list) { - if (wl_resource_get_client(resource) != surface_client) - continue; - - wl_pointer_send_button(resource, serial, time, button, state); - } - - wl_resource_for_each(resource, &grab->pointer->focus_resource_list) { - if (wl_resource_get_client(resource) != surface_client) - continue; + /* If a button press, set pointer focus to this surface */ + if ((grab->pointer->focus != picked_view) && + (state == WL_POINTER_BUTTON_STATE_PRESSED)){ + old_focus = grab->pointer->focus; + /* search for the picked view in layout surfaces */ + wl_list_for_each(surf_ctx, &seat->input_ctx->surface_list, link) { + w_surf = interface->surface_get_weston_surface(surf_ctx->layout_surface); + w_view = wl_container_of(w_surf->views.next, w_view, surface_link); - wl_pointer_send_button(resource, serial, time, button, state); - } - } + if (get_accepted_seat(surf_ctx, grab->pointer->seat->seat_name) < 0) + continue; - /* If a button release, set pointer focus to this surface */ - if (pointer->button_count == 0 - && state == WL_POINTER_BUTTON_STATE_RELEASED) { - if (view->surface == surf) { + if (picked_view->surface == w_surf) { + /* Correct layout surface is found*/ surf_ctx->focus |= ILM_INPUT_DEVICE_POINTER; send_input_focus(seat->input_ctx, interface->get_id_of_surface(surf_ctx->layout_surface), ILM_INPUT_DEVICE_POINTER, ILM_TRUE); - } else { + + weston_pointer_set_focus(grab->pointer, picked_view, sx, sy); + + } else if (old_focus == w_view){ + /* Send focus lost event to the surface which has lost the focus*/ surf_ctx->focus &= ~ILM_INPUT_DEVICE_POINTER; send_input_focus(seat->input_ctx, interface->get_id_of_surface(surf_ctx->layout_surface), @@ -409,6 +395,19 @@ pointer_grab_button(struct weston_pointer_grab *grab, uint32_t time, } } } + + /* Send to surfaces that have pointer focus */ + if (grab->pointer->focus == picked_view) { + surface_client = wl_resource_get_client(grab->pointer->focus->surface->resource); + serial = wl_display_next_serial(display); + + wl_resource_for_each(resource, &grab->pointer->focus_resource_list) { + if (wl_resource_get_client(resource) != surface_client) + continue; + + wl_pointer_send_button(resource, serial, time, button, state); + } + } } static void |