summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Fritzsch <marcus.fritzsch@xse.de>2014-07-21 13:43:52 +0200
committerNobuhiko Tanibata <NOBUHIKO_TANIBATA@denso.co.jp>2014-08-12 22:15:12 +0900
commit8265021aebe5e694b79e8dcd6fe55c0f911cb5ed (patch)
tree14673e6d2acc897bcf0865684b8dec6474efba9d
parente0e82b5e26f6c689f94dac03f41664f57e5177d4 (diff)
downloadwayland-ivi-extension-8265021aebe5e694b79e8dcd6fe55c0f911cb5ed.tar.gz
ilmCommon: manage ownership of display connection
Introduced a new flag 'disconnect_display' separate from valid, as adding bits to valid would change its scope and entail changes to all usages of it. Signed-off-by: Marcus Fritzsch <marcus.fritzsch@xse.de>
-rw-r--r--ivi-layermanagement-api/ilmCommon/src/ilm_common_wayland_platform.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/ivi-layermanagement-api/ilmCommon/src/ilm_common_wayland_platform.c b/ivi-layermanagement-api/ilmCommon/src/ilm_common_wayland_platform.c
index b8fd975..fd20b27 100644
--- a/ivi-layermanagement-api/ilmCommon/src/ilm_common_wayland_platform.c
+++ b/ivi-layermanagement-api/ilmCommon/src/ilm_common_wayland_platform.c
@@ -50,10 +50,11 @@ extern char *__progname;
struct ilm_common_context {
int32_t valid;
+ int32_t disconnect_display;
struct wl_display *display;
};
-static struct ilm_common_context ilm_context = {0, 0};
+static struct ilm_common_context ilm_context = {0};
static ilmErrorTypes
wayland_init(t_ilm_nativedisplay nativedisplay)
@@ -62,8 +63,10 @@ wayland_init(t_ilm_nativedisplay nativedisplay)
if (nativedisplay != 0) {
ctx->display = (struct wl_display*)nativedisplay;
+ ctx->disconnect_display = 0;
} else {
ctx->display = wl_display_connect(NULL);
+ ctx->disconnect_display = 1;
if (ctx->display == NULL) {
fprintf(stderr, "Failed to connect display in libilmCommon\n");
return ILM_FAILED;
@@ -102,5 +105,13 @@ wayland_destroy(void)
ctx->valid = 0;
+ // we own the display, act like it.
+ if (ctx->disconnect_display)
+ {
+ wl_display_roundtrip(ctx->display);
+ wl_display_disconnect(ctx->display);
+ ctx->display = NULL;
+ }
+
return ILM_SUCCESS;
}