Remove elementary dependency from multiwindow base
[platform/core/appfw/app-core.git] / src / multiwindow_base / appcore_multiwindow_base.c
index 89f184b..ece1f65 100644 (file)
@@ -23,7 +23,6 @@
 #include <linux/limits.h>
 
 #include <Ecore_Wayland.h>
-#include <Elementary.h>
 #include <glib-object.h>
 #include <malloc.h>
 #include <glib.h>
@@ -71,6 +70,14 @@ static Eina_Bool __stub_lower_cb(void *data, int type, void *event)
        return ECORE_CALLBACK_RENEW;
 }
 
+static Eina_Bool __stub_pre_visibility_cb(void *data, int type, void *event)
+{
+       if (_appcore_mw_context.ops.window.pre_visibility)
+               _appcore_mw_context.ops.window.pre_visibility(type, event, _appcore_mw_context.data);
+
+       return ECORE_CALLBACK_RENEW;
+}
+
 EXPORT_API int appcore_multiwindow_base_init(appcore_multiwindow_base_ops ops, int argc, char **argv, void *data)
 {
        _appcore_mw_context.ops = ops;
@@ -78,12 +85,6 @@ EXPORT_API int appcore_multiwindow_base_init(appcore_multiwindow_base_ops ops, i
        _appcore_mw_context.argc = argc;
        _appcore_mw_context.argv = argv;
 
-       _appcore_mw_context.hshow = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW, __stub_show_cb, NULL);
-       _appcore_mw_context.hhide = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_HIDE, __stub_hide_cb, NULL);
-       _appcore_mw_context.hvchange = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE,
-                               __stub_visibility_cb, NULL);
-       _appcore_mw_context.hlower = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER, __stub_lower_cb, NULL);
-
        return appcore_base_init(ops.base, argc, argv, data);
 }
 
@@ -136,6 +137,11 @@ EXPORT_API void appcore_multiwindow_base_fini(void)
                _appcore_mw_context.hlower = NULL;
        }
 
+       if (_appcore_mw_context.hpvchange) {
+               ecore_event_handler_del(_appcore_mw_context.hpvchange);
+               _appcore_mw_context.hpvchange = NULL;
+       }
+
        appcore_base_fini();
 }
 
@@ -180,32 +186,9 @@ static void __window_on_visibility(int type, void *event, void *data)
        appcore_multiwindow_base_window_on_visibility(type, event);
 }
 
-static void __run(void *data)
-{
-       elm_run();
-}
-
-static void __exit(void *data)
+static void __window_on_pre_visibility(int type, void *event, void *data)
 {
-       elm_exit();
-}
-
-static int __init(int argc, char **argv, void *data)
-{
-       elm_init(argc, argv);
-
-       return 0;
-}
-
-static void __finish(void)
-{
-       elm_shutdown();
-
-       /* Check loader case */
-       if (getenv("AUL_LOADER_INIT")) {
-               unsetenv("AUL_LOADER_INIT");
-               elm_shutdown();
-       }
+       appcore_multiwindow_base_window_on_pre_visibility(type, event);
 }
 
 EXPORT_API appcore_multiwindow_base_ops appcore_multiwindow_base_get_default_ops(void)
@@ -218,15 +201,16 @@ EXPORT_API appcore_multiwindow_base_ops appcore_multiwindow_base_get_default_ops
        ops.base.create = __on_create;
        ops.base.terminate = __on_terminate;
        ops.base.receive = __on_receive;
-       ops.base.init = __init;
-       ops.base.finish = __finish;
-       ops.base.run = __run;
-       ops.base.exit = __exit;
+       ops.base.init = NULL;
+       ops.base.finish = NULL;
+       ops.base.run = NULL;
+       ops.base.exit = NULL;
 
        ops.window.show = __window_on_show;
        ops.window.hide = __window_on_hide;
        ops.window.lower = __window_on_lower;
        ops.window.visibility = __window_on_visibility;
+       ops.window.pre_visibility = __window_on_pre_visibility;
 
        return ops;
 }
@@ -242,6 +226,14 @@ EXPORT_API int appcore_multiwindow_base_on_create(void)
 {
        appcore_base_on_create();
 
+       _appcore_mw_context.hshow = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW, __stub_show_cb, NULL);
+       _appcore_mw_context.hhide = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_HIDE, __stub_hide_cb, NULL);
+       _appcore_mw_context.hvchange = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE,
+                       __stub_visibility_cb, NULL);
+       _appcore_mw_context.hlower = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER, __stub_lower_cb, NULL);
+       _appcore_mw_context.hpvchange = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_PRE_VISIBILITY_CHANGE,
+                       __stub_pre_visibility_cb, NULL);
+
        return 0;
 }