ilmControl: allow to set callback of surfaceAddNotification even if application doen...
authorNobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>
Sun, 10 Aug 2014 12:57:22 +0000 (21:57 +0900)
committerNobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>
Thu, 21 Aug 2014 01:08:14 +0000 (10:08 +0900)
When application map ID to wl_surface by ivi_application.createSurface,
content_state is notified with content_available.

Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>
ivi-layermanagement-api/ilmControl/src/ilm_control_wayland_platform.c

index e3f0e56..11789e0 100644 (file)
@@ -168,6 +168,7 @@ static inline void unlock_context(struct ilm_control_context *ctx)
 static int init_control(void);
 
 static struct ilm_control_context* sync_and_acquire_instance(void);
+static struct surface_context* get_surface_context(struct wayland_context *, uint32_t);
 
 static void release_instance(void);
 
@@ -804,12 +805,14 @@ controller_listener_surface(void *data,
 {
     struct wayland_context *ctx = data;
     struct surface_context *ctx_surf = NULL;
-    int32_t is_inside = 0;
-
-    is_inside = wayland_controller_is_inside_surface_list(
-                    &ctx->list_surface, id_surface);
 
-    if (is_inside != 0) {
+    ctx_surf = get_surface_context(ctx, id_surface);
+    if (ctx_surf != NULL) {
+        if (ctx_surf-> notification != NULL) {
+            ctx_surf->notification(ctx_surf->id_surface,
+                                   &ctx_surf->prop,
+                                   ILM_NOTIFICATION_ALL);
+        }
         fprintf(stderr, "invalid id_surface in controller_listener_surface\n");
         return;
     }
@@ -2400,8 +2403,15 @@ ilm_surfaceAddNotification(t_ilm_surface surface,
     ctx_surf = (struct surface_context*)get_surface_context(
                     &ctx->wl, (uint32_t)surface);
     if (ctx_surf == NULL) {
+        controller_listener_surface(ctx, ctx->wl.controller, (uint32_t)surface);
+        ctx_surf = (struct surface_context*)get_surface_context(
+                        &ctx->wl, (uint32_t)surface);
+    }
+
+    if (ctx_surf == NULL) {
         returnValue = ILM_ERROR_INVALID_ARGUMENTS;
-    } else {
+    }
+    else {
         ctx_surf->notification = callback;
 
         returnValue = ILM_SUCCESS;
@@ -2505,11 +2515,6 @@ ilm_layerRemoveSurface(t_ilm_layer layerId,
         returnValue = ILM_SUCCESS;
     }
 
-    if ((ctx_surf != NULL) && (ctx_surf->notification != NULL)) {
-        ctx_surf->notification = NULL;
-        returnValue = ILM_SUCCESS;
-    }
-
     release_instance();
     return returnValue;
 }