From: Jonathan Maw Date: Tue, 12 Aug 2014 10:50:00 +0000 (+0000) Subject: weston-ivi-shell, ilmControl and ilmCommon: Implement GetKeyboardFocus X-Git-Tag: 0.2.4~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f7390ed1da0e3c6eaed38b0797f3583c47e6d4e;p=profile%2Fivi%2Fwayland-ivi-extension.git weston-ivi-shell, ilmControl and ilmCommon: Implement GetKeyboardFocus This commit implements ilm_GetKeyboardFocusSurfaceId using the "input focus" event from the "ivi controller surface" interface. ilm_types.h has been expanded to store keyboard focus on a per-surface basis. Signed-off-by: James Thomas --- diff --git a/ivi-layermanagement-api/ilmCommon/include/ilm_types.h b/ivi-layermanagement-api/ilmCommon/include/ilm_types.h index 0d9a6dd..e9c84b0 100644 --- a/ivi-layermanagement-api/ilmCommon/include/ilm_types.h +++ b/ivi-layermanagement-api/ilmCommon/include/ilm_types.h @@ -238,6 +238,7 @@ struct ilmSurfaceProperties t_ilm_uint chromaKeyGreen; /*!< chromakey's green value of the surface */ t_ilm_uint chromaKeyBlue; /*!< chromakey's blue value of the surface */ t_ilm_int creatorPid; /*!< process id of application that created this surface */ + t_ilm_bool hasKeyboardFocus; /*!< whether this surface has keyboard focus */ }; /** diff --git a/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c b/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c index b1c0787..8585a09 100644 --- a/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c +++ b/ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c @@ -765,10 +765,15 @@ controller_surface_listener_input_focus(void *data, uint32_t device, int32_t enabled) { - (void)data; - (void)controller; - (void)device; - (void)enabled; + struct surface_context *ctx_surf = data; + + if (ctx_surf == NULL) { + fprintf(stderr, "%s: Invalid surface context\n", __FUNCTION__); + return; + } + if (device & IVI_CONTROLLER_SURFACE_INPUT_DEVICE_KEYBOARD) { + ctx_surf->prop.hasKeyboardFocus = enabled; + } } static struct ivi_controller_surface_listener controller_surface_listener= @@ -2153,10 +2158,18 @@ ilm_SetKeyboardFocusOn(t_ilm_surface surfaceId) ILM_EXPORT ilmErrorTypes ilm_GetKeyboardFocusSurfaceId(t_ilm_surface* pSurfaceId) { - ilmErrorTypes returnValue = ILM_FAILED; - (void)pSurfaceId; - returnValue = ILM_SUCCESS; - return returnValue; + struct ilm_control_context *ctx = sync_and_acquire_instance(); + struct surface_context *ctx_surf = NULL; + + wl_list_for_each(ctx_surf, &ctx->wl.list_surface, link) { + if (ctx_surf->prop.hasKeyboardFocus) { + *pSurfaceId = ctx_surf->id_surface; + break; + } + } + + release_instance(); + return ILM_SUCCESS; } ILM_EXPORT ilmErrorTypes diff --git a/weston-ivi-shell/src/ivi-controller.c b/weston-ivi-shell/src/ivi-controller.c index 0f152e1..f341454 100755 --- a/weston-ivi-shell/src/ivi-controller.c +++ b/weston-ivi-shell/src/ivi-controller.c @@ -441,6 +441,11 @@ send_surface_event(struct wl_resource *resource, ivi_controller_surface_send_pixelformat(resource, prop->pixelformat); } + if (mask & IVI_NOTIFICATION_KEYBOARD_FOCUS) { + ivi_controller_surface_send_input_focus(resource, + IVI_CONTROLLER_SURFACE_INPUT_DEVICE_KEYBOARD, + prop->hasKeyboardFocus); + } if (mask & IVI_NOTIFICATION_REMOVE) { send_surface_add_event(ivisurf, resource, IVI_NOTIFICATION_REMOVE); } @@ -1064,6 +1069,28 @@ controller_surface_destroy(struct wl_client *client, wl_resource_destroy(resource); } +static void send_all_keyboard_focus(struct ivishell *shell) +{ + struct ivi_layout_SurfaceProperties props; + struct ivicontroller_surface *ctrlsurf; + struct ivisurface *current_surf; + uint32_t id_surface; + + wl_list_for_each(current_surf, &shell->list_surface, link) { + ivi_layout_getPropertiesOfSurface(current_surf->layout_surface, + &props); + id_surface = ivi_layout_getIdOfSurface(current_surf->layout_surface); + wl_list_for_each(ctrlsurf, &shell->list_controller_surface, link) { + if (id_surface != ctrlsurf->id_surface) { + continue; + } + ivi_controller_surface_send_input_focus(ctrlsurf->resource, + IVI_CONTROLLER_SURFACE_INPUT_DEVICE_KEYBOARD, + props.hasKeyboardFocus); + } + } +} + static void controller_surface_set_input_focus(struct wl_client *client, struct wl_resource *resource, @@ -1076,6 +1103,7 @@ controller_surface_set_input_focus(struct wl_client *client, if (device & IVI_CONTROLLER_SURFACE_INPUT_DEVICE_KEYBOARD) { if (enabled) { ivi_layout_SetKeyboardFocusOn(ivisurf->layout_surface); + send_all_keyboard_focus(ivisurf->shell); } } }