Add new hint to enable/disable auto raising window feature
[platform/core/appfw/app-core.git] / src / ui_base / appcore_ui_base.c
index 524e8cc..8872ac4 100644 (file)
 #include <aul_svc.h>
 #include <bundle_internal.h>
 #include <ttrace.h>
+#include <voice_control_elm.h>
+#include <voice_control_elm_private.h>
 
 #include "appcore_base.h"
 #include "appcore_ui_base.h"
 #include "appcore_ui_base_private.h"
+#include "appcore_ui_plugin.h"
 
 enum app_state {
        AS_NONE,
@@ -441,8 +444,10 @@ static void __do_start(bundle *b)
                }
        }
 
-       if (!bg_state)
-               __raise_win();
+       if (__context.hint & APPCORE_UI_BASE_HINT_WINDOW_AUTO_CONTROL) {
+               if (!bg_state)
+                       __raise_win();
+       }
 }
 
 EXPORT_API int appcore_ui_base_on_receive(aul_type type, bundle *b)
@@ -538,10 +543,22 @@ EXPORT_API int appcore_ui_base_on_control(bundle *b)
 
 static void __group_attach()
 {
-       static bool attached = false;
+       if (!(__context.hint & APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL))
+               return;
+
+       appcore_ui_base_group_add();
+}
 
+static void __group_lower()
+{
        if (!(__context.hint & APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL))
                return;
+       appcore_ui_base_group_remove();
+}
+
+EXPORT_API void appcore_ui_base_group_add()
+{
+       static bool attached = false;
 
        _DBG("__group_attach");
        if (attached)
@@ -557,13 +574,10 @@ static void __group_attach()
        attached = true;
 }
 
-static void __group_lower()
+EXPORT_API void appcore_ui_base_group_remove()
 {
        int exit = 0;
 
-       if (!(__context.hint & APPCORE_UI_BASE_HINT_WINDOW_GROUP_CONTROL))
-               return;
-
        _DBG("__group_lower");
        aul_app_group_lower(&exit);
        if (exit) {
@@ -673,7 +687,10 @@ EXPORT_API int appcore_ui_base_init(appcore_ui_base_ops ops, int argc, char **ar
        const char *bg_launch;
        bundle *b;
        char appid[PATH_MAX] = {0, };
+       int r;
+       bool is_vc_vt_automode = false;
 
+       appcore_ui_plugin_init(&ops, &hint);
        aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
        __context.ops = ops;
        __context.data = data;
@@ -686,6 +703,16 @@ EXPORT_API int appcore_ui_base_init(appcore_ui_base_ops ops, int argc, char **ar
        LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:main:done]", appid);
        elm_init(argc, argv);
 
+       r = vc_elm_is_supported_vt_auto(&is_vc_vt_automode);
+       if (r != 0) {
+               _ERR("[VC] Fail to get vconfkey of vt_automode");
+       } else {
+               if (is_vc_vt_automode == true) {
+                       vc_elm_initialize();
+                       vc_elm_set_auto_register_mode(2, 0);
+               }
+       }
+
        if (__context.hint & APPCORE_UI_BASE_HINT_HW_ACC_CONTROL) {
                hwacc = getenv("HWACC");
 
@@ -718,7 +745,11 @@ EXPORT_API int appcore_ui_base_init(appcore_ui_base_ops ops, int argc, char **ar
 
 EXPORT_API void appcore_ui_base_fini(void)
 {
+       bool is_vc_vt_automode = false;
+       int r;
+
        appcore_base_fini();
+       appcore_ui_plugin_fini();
 
        if (__context.hshow)
                ecore_event_handler_del(__context.hshow);
@@ -730,6 +761,15 @@ EXPORT_API void appcore_ui_base_fini(void)
                ecore_event_handler_del(__context.hlower);
 
        __finish_wl();
+
+       r = vc_elm_is_supported_vt_auto(&is_vc_vt_automode);
+       if (r != 0) {
+               _ERR("[VC] Fail to get vconfkey of vt_automode");
+       } else {
+               if (is_vc_vt_automode == true)
+                       vc_elm_deinitialize();
+       }
+
        elm_shutdown();
 
        /* Check loader case */
@@ -763,6 +803,16 @@ EXPORT_API void appcore_ui_base_exit(void)
                __context.ops.base.exit(__context.data);
 }
 
+EXPORT_API unsigned int appcore_ui_base_get_main_window(void)
+{
+       return __get_main_window();
+}
+
+EXPORT_API unsigned int appcore_ui_base_get_main_surface(void)
+{
+       return __get_main_surface();
+}
+
 static int __on_receive(aul_type type, bundle *b, void *data)
 {
        return appcore_ui_base_on_receive(type, b);