ivi-controller, ilmControl: Add ilm_SetKeyboardMultiFocus
authorJonathan Maw <jonathan.maw@codethink.co.uk>
Tue, 28 Oct 2014 12:20:52 +0000 (12:20 +0000)
committerNobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Fri, 14 Nov 2014 04:43:55 +0000 (13:43 +0900)
This adds the function
ilm_SetKeyboardMultiFocus(t_ilm_surface *pSurfaceIds, t_ilm_int number)

which takes an array (and a size) of the surface IDs that should
be focussed.
The old ilm_SetKeyboardFocusOn() has been preserved for the sake of
backwards compatibility.

ivi-layermanagement-api/ilmControl/include/ilm_control.h
ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c
protocol/ivi-controller.xml
weston-ivi-shell/src/ivi-controller.c

index ef3dbd3..405abc9 100644 (file)
@@ -394,6 +394,20 @@ ilmErrorTypes ilm_SetKeyboardFocusOn(t_ilm_surface surfaceId);
 ilmErrorTypes ilm_GetKeyboardFocusSurfaceId(t_ilm_surface* pSurfaceId);
 
 /**
+ * \brief Set the keyboard focus to multiple surfaces
+ * To receive keyboard events, 2 conditions must be fulfilled:
+ *  1- The surface must accept events from keyboard. See ilm_UpdateInputEventAcceptanceOn
+ *  2- The keyboard focus must be set on that surface
+ *
+ * \ingroup ilmControl
+ * \param[in] pSurfaceIds Pointer to an array of surface IDs
+ * \param[in] number The number of surface IDs to set
+ * \return ILM_SUCCESS if the method call was successful
+ * \return ILM_FAILED if the client can not call the method on the service.
+ */
+ilmErrorTypes ilm_SetKeyboardMultiFocus(t_ilm_surface *pSurfaceIds, t_ilm_int number);
+
+/**
  * \brief Set the destination area of a surface within a layer for rendering. The surface will be scaled to this rectangle for rendering.
  * \ingroup ilmControl
  * \param[in] surfaceId Id of surface.
index 8585a09..8f25b39 100644 (file)
@@ -2173,6 +2173,38 @@ ilm_GetKeyboardFocusSurfaceId(t_ilm_surface* pSurfaceId)
 }
 
 ILM_EXPORT ilmErrorTypes
+ilm_SetKeyboardMultiFocus(t_ilm_surface *pSurfaceIds, t_ilm_int number)
+{
+    struct ilm_control_context *ctx = sync_and_acquire_instance();
+    struct surface_context *ctx_surf;
+    unsigned int i, send_elements = 0;
+    struct wl_array send_array;
+    ilmErrorTypes retval = ILM_FAILED;
+    uint32_t *data;
+
+    wl_array_init(&send_array);
+    wl_array_add(&send_array, sizeof(uint32_t) * number);
+
+    data = send_array.data;
+    for (i = 0; i < number; i++) {
+        ctx_surf = get_surface_context(&ctx->wl, (uint32_t) pSurfaceIds[i]);
+        if (ctx_surf->prop.inputDevicesAcceptance & ILM_INPUT_DEVICE_KEYBOARD) {
+            data[send_elements] = pSurfaceIds[i];
+            send_elements++;
+        }
+    }
+
+    if (send_elements > 0) {
+        ivi_controller_set_keyboard_focus(ctx->wl.controller, &send_array);
+        retval = ILM_SUCCESS;
+    }
+
+    wl_array_release(&send_array);
+    release_instance();
+    return retval;
+}
+
+ILM_EXPORT ilmErrorTypes
 ilm_surfaceSetDestinationRectangle(t_ilm_surface surfaceId,
                                    t_ilm_int x, t_ilm_int y,
                                    t_ilm_int width, t_ilm_int height)
index 7dfe4fa..a741618 100644 (file)
             <arg name="error_text" type="string" allow-null="true"/>
         </event>
 
+        <request name="set_keyboard_focus">
+            <description summary="set multiple surfaces to have keyboard focus">
+                set_keyboard_focus will take an array of surfaces, and set
+                keyboard focus to those surfaces.
+            </description>
+            <arg name="surfaces" type="array"/>
+
     </interface>
 
 </protocol>
index 744d87c..196fb7b 100755 (executable)
@@ -1593,10 +1593,21 @@ controller_surface_create(struct wl_client *client,
                        &prop, IVI_NOTIFICATION_ALL);
 }
 
+static void
+controller_set_keyboard_focus(struct wl_client *client,
+                              struct wl_resource *resource,
+                              struct wl_array *surfaces)
+{
+    struct ivicontroller *ctrl = wl_resource_get_user_data(resource);
+    ivi_layout_SetKeyboardFocusOn(surfaces->data, surfaces->size);
+    send_all_keyboard_focus(ctrl->shell);
+}
+
 static const struct ivi_controller_interface controller_implementation = {
     controller_commit_changes,
     controller_layer_create,
-    controller_surface_create
+    controller_surface_create,
+    controller_set_keyboard_focus
 };
 
 static void