Bugfix: TIVI-2880,P1 and TIVI-2883,P2 25/18425/1
authorNobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Sun, 23 Mar 2014 04:19:41 +0000 (13:19 +0900)
committerNobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
Sun, 23 Mar 2014 04:19:41 +0000 (13:19 +0900)
Modify initialize process to use application's native display in
each ilm library.

Change-Id: Ibc6fbd18a67441b93cafd9458bca32529edb3c3b
Signed-off-by: Nobuhiko Tanibata <NOBUHIKO_TANIBATA@xddp.denso.co.jp>
ivi-layermanagement-api/ilmCommon/include/ilm_common_platform.h
ivi-layermanagement-api/ilmCommon/src/ilm_common.c
ivi-layermanagement-api/ilmCommon/src/ilm_common_wayland_platform.c

index 6a7ffe0..59d4b74 100644 (file)
@@ -29,6 +29,7 @@ extern "C" {
 typedef struct _ILM_COMMON_PLATFORM_FUNC
 {
     ilmErrorTypes (*init)(t_ilm_nativedisplay nativedisplay);
+    t_ilm_nativedisplay (*getNativedisplay)();
     t_ilm_bool (*isInitialized)();
     ilmErrorTypes (*destroy)();
 } ILM_COMMON_PLATFORM_FUNC;
index e8868c1..311eab8 100644 (file)
@@ -49,27 +49,30 @@ ILM_EXPORT ilmErrorTypes
 ilm_initWithNativedisplay(t_ilm_nativedisplay nativedisplay)
 {
     ilmErrorTypes err = ILM_SUCCESS;
+    t_ilm_nativedisplay display = 0;
 
     init_ilmCommonPlatformTable();
 
-    err = ilmClient_init(nativedisplay);
+    err = gIlmCommonPlatformFunc.init(nativedisplay);
     if (ILM_SUCCESS != err)
     {
         return err;
     }
 
-    err = ilmControl_init(nativedisplay);
+    display = gIlmCommonPlatformFunc.getNativedisplay();
+
+    err = ilmClient_init(display);
     if (ILM_SUCCESS != err)
     {
-        ilmClient_destroy();
+        gIlmCommonPlatformFunc.destroy();
         return err;
     }
 
-    err = gIlmCommonPlatformFunc.init(nativedisplay);
+    err = ilmControl_init(display);
     if (ILM_SUCCESS != err)
     {
+        gIlmCommonPlatformFunc.destroy();
         ilmClient_destroy();
-        ilmControl_destroy();
         return err;
     }
 
index b4c9895..7eb6210 100644 (file)
 #include "ilm_types.h"
 #include "ilm_configuration.h"
 #include "wayland-util.h"
+#include "wayland-client.h"
 
 static ilmErrorTypes wayland_init(t_ilm_nativedisplay nativedisplay);
+static t_ilm_nativedisplay wayland_getNativedisplay();
 static t_ilm_bool wayland_isInitialized();
 static ilmErrorTypes wayland_destroy();
 
 void init_ilmCommonPlatformTable()
 {
     gIlmCommonPlatformFunc.init = wayland_init;
+    gIlmCommonPlatformFunc.getNativedisplay = wayland_getNativedisplay;
     gIlmCommonPlatformFunc.isInitialized = wayland_isInitialized;
     gIlmCommonPlatformFunc.destroy = wayland_destroy;
 }
@@ -49,21 +52,39 @@ extern char *__progname;
 
 struct ilm_common_context {
     int32_t valid;
+    struct wl_display *display;
 };
 
-static struct ilm_common_context ilm_context = {0};
+static struct ilm_common_context ilm_context = {0, 0};
 
 static ilmErrorTypes
 wayland_init(t_ilm_nativedisplay nativedisplay)
 {
     struct ilm_common_context *ctx = &ilm_context;
-    (void)nativedisplay;
+
+    if (nativedisplay != 0) {
+        ctx->display = (struct wl_display*)nativedisplay;
+    } else {
+        ctx->display = wl_display_connect(NULL);
+        if (ctx->display == NULL) {
+            fprintf(stderr, "Failed to connect display in libilmCommon\n");
+            return ILM_FAILED;
+        }
+    }
 
     ctx->valid = 1;
 
     return ILM_SUCCESS;
 }
 
+static t_ilm_nativedisplay
+wayland_getNativedisplay()
+{
+    struct ilm_common_context *ctx = &ilm_context;
+
+    return (t_ilm_nativedisplay)ctx->display;
+}
+
 static t_ilm_bool
 wayland_isInitialized()
 {