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;
}
#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;
}
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()
{