Remove elementary dependency from multiwindow base
[platform/core/appfw/app-core.git] / src / multiwindow_base / appcore_multiwindow_base.c
index 66cfcf0..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;
@@ -130,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();
 }
 
@@ -174,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)
@@ -212,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;
 }
@@ -241,6 +231,8 @@ EXPORT_API int appcore_multiwindow_base_on_create(void)
        _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;
 }