sync app group with tizen_2.4 22/50922/2
authorJiwoong Im <jiwoong.im@samsung.com>
Tue, 3 Nov 2015 12:01:35 +0000 (21:01 +0900)
committerJiwoong Im <jiwoong.im@samsung.com>
Wed, 4 Nov 2015 10:54:20 +0000 (19:54 +0900)
- add appcore_group_attach(), appcore_group_lower().
- add ECORE_WL_EVENT_WINDOW_LOWER callback.

Change-Id: Ia120d8082ef83ad10e9b88f248eadceb964e5c32
Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
include/appcore-internal.h
src/appcore-efl.c
src/appcore-group.c

index 9f91dd7..2a6ab07 100644 (file)
@@ -182,8 +182,8 @@ struct ui_wm_rotate {
 };
 int appcore_set_wm_rotation(struct ui_wm_rotate* wm_rotate);
 
-void appcore_group_reset(bundle *b);
-void appcore_group_resume();
+void appcore_group_attach();
+void appcore_group_lower();
 unsigned int appcore_get_main_window(void);
 
 #define ENV_START "APP_START_TIME"
index 9d9f21f..e092571 100644 (file)
@@ -71,6 +71,9 @@ struct ui_priv {
        Ecore_Event_Handler *hshow;
        Ecore_Event_Handler *hhide;
        Ecore_Event_Handler *hvchange;
+#if defined(WAYLAND)
+       Ecore_Event_Handler *hlower;
+#endif
        Ecore_Event_Handler *hcmsg; /* WM_ROTATE */
 
        Ecore_Timer *mftimer; /* Ecore Timer for memory flushing */
@@ -113,7 +116,7 @@ static bool first_launch = TRUE;
 
 struct win_node {
        unsigned int win;
-#ifdef WAYLAND
+#if defined(WAYLAND)
        unsigned int surf;
 #endif
        bool bfobscured;
@@ -214,7 +217,7 @@ static void __appcore_efl_memory_flush_cb(void)
        _DBG("[APP %d]   __appcore_efl_memory_flush_cb()", _pid);
        elm_cache_all_flush();
 }
-#ifdef WAYLAND
+#if defined(WAYLAND)
 static void wl_raise_win(void)
 {
        Ecore_Wl_Window *win;
@@ -344,11 +347,8 @@ static void __do_app(enum app_event event, void *data, bundle * b)
                        _DBG("[APP %d] RESUME", _pid);
 
                        if (ui->state == AS_CREATED) {
-                               appcore_group_reset(ui->pending_data);
                                bundle_free(ui->pending_data);
                                ui->pending_data = NULL;
-                       } else {
-                               appcore_group_resume();
                        }
 
                        if (ui->ops->resume)
@@ -646,6 +646,7 @@ static Eina_Bool __show_cb(void *data, int type, void *event)
        }
 #endif
 
+       appcore_group_attach();
        return ECORE_CALLBACK_RENEW;
 }
 
@@ -675,6 +676,18 @@ static Eina_Bool __hide_cb(void *data, int type, void *event)
        return ECORE_CALLBACK_RENEW;
 }
 
+#if defined(WAYLAND)
+static Eina_Bool __lower_cb(void *data, int type, void *event)
+{
+       Ecore_Wl_Event_Window_Lower *ev;
+       ev = event;
+       if (!ev) return ECORE_CALLBACK_RENEW;
+       _DBG("ECORE_WL_EVENT_WINDOW_LOWER window id:%u\n", ev->win);
+       appcore_group_lower();
+       return ECORE_CALLBACK_RENEW;
+}
+#endif
+
 static Eina_Bool __visibility_cb(void *data, int type, void *event)
 {
 #if defined(WAYLAND)
@@ -764,25 +777,28 @@ static void __add_climsg_cb(struct ui_priv *ui)
        _ret_if(ui == NULL);
 #if defined(WAYLAND)
        ui->hshow =
-           ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW, __show_cb, ui);
+               ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_SHOW, __show_cb, ui);
        ui->hhide =
-           ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_HIDE, __hide_cb, ui);
+               ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_HIDE, __hide_cb, ui);
        ui->hvchange =
-           ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE,
-                                   __visibility_cb, ui);
+               ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_VISIBILITY_CHANGE,
+                               __visibility_cb, ui);
+       ui->hlower =
+               ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_LOWER,
+                               __lower_cb, ui);
 #elif defined(X11)
        ui->hshow =
-           ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, __show_cb, ui);
+               ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, __show_cb, ui);
        ui->hhide =
-           ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE, __hide_cb, ui);
+               ecore_event_handler_add(ECORE_X_EVENT_WINDOW_HIDE, __hide_cb, ui);
        ui->hvchange =
-           ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE,
-                                   __visibility_cb, ui);
+               ecore_event_handler_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE,
+                               __visibility_cb, ui);
 
        /* Add client message callback for WM_ROTATE */
        if (!__check_wm_rotation_support()) {
                ui->hcmsg = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE,
-                                               __cmsg_cb, ui);
+                               __cmsg_cb, ui);
                ui->wm_rot_supported = 1;
                appcore_set_wm_rotation(&wm_rotate);
        }
@@ -864,6 +880,10 @@ static void __after_loop(struct ui_priv *ui)
                ecore_event_handler_del(ui->hhide);
        if (ui->hvchange)
                ecore_event_handler_del(ui->hvchange);
+#if defined(WAYLAND)
+       if (ui->hlower)
+               ecore_event_handler_del(ui->hlower);
+#endif
 
        __appcore_timer_del(ui);
 
@@ -1041,7 +1061,7 @@ EXPORT_API unsigned int appcore_get_main_window(void)
        return 0;
 }
 
-#ifdef WAYLAND
+#if defined(WAYLAND)
 EXPORT_API unsigned int appcore_get_main_surface(void)
 {
        struct win_node *entry = NULL;
index 4f44720..dcdcb6f 100644 (file)
 
 #include "appcore-internal.h"
 
-#define APP_SVC_K_LAUNCH_MODE   "__APP_SVC_LAUNCH_MODE__"
-
-static int __get_top_window(int lpid)
-{
-       int *gpids;
-       int gcnt;
-       int ret = -1;
-
-       aul_app_group_get_group_pids(lpid, &gcnt, &gpids);
-       if (gcnt > 0) {
-               ret =  aul_app_group_get_window(gpids[gcnt-1]);
-       }
-
-       if (gpids != NULL)
-               free(gpids);
-
-       return ret;
-}
-
-static gboolean __can_attach_window(bundle *b)
+void appcore_group_attach()
 {
-       char *str = NULL;
-       char *mode = NULL;
-       char appid[255] = {0, };
-       int ret;
-
-       pkgmgrinfo_appinfo_h handle;
-       ret = aul_app_get_appid_bypid(getpid(), appid, sizeof(appid));
-       if (ret != AUL_R_OK) {
-               _ERR("Failed to aul_app_get_appid_bypid()");
-               return FALSE;
-       }
-
-       ret = pkgmgrinfo_appinfo_get_usr_appinfo(appid, getuid(), &handle);
-       if (ret != PMINFO_R_OK) {
-               _ERR("Failed to pkgmgrinfo_appinfo_get_appinfo()");
-               return FALSE;
-       }
-       ret = pkgmgrinfo_appinfo_get_launch_mode(handle, &mode);
-
-       if (ret != PMINFO_R_OK) {
-               pkgmgrinfo_appinfo_destroy_appinfo(handle);
-               _ERR("Failed to pkgmgrinfo_appinfo_get_launch_mode()");
-               return FALSE;
-       }
+       _DBG("appcore_group_attach");
+       static bool attached = false;
 
-       if (mode != NULL && strncmp(mode, "caller", 6) == 0) {
-               _DBG("launch mode from db is caller");
+       if (attached)
+               return;
 
-               bundle_get_str(b, APP_SVC_K_LAUNCH_MODE, &str);
-               if (str != NULL && strncmp(str, "group", 5) == 0) {
-                       pkgmgrinfo_appinfo_destroy_appinfo(handle);
-                       return TRUE;
-               }
-       } else if (mode != NULL && strncmp(mode, "group", 5) == 0) {
-               pkgmgrinfo_appinfo_destroy_appinfo(handle);
-               return TRUE;
-       }
-
-       pkgmgrinfo_appinfo_destroy_appinfo(handle);
-
-       return FALSE;
-}
-
-void appcore_group_reset(bundle *b)
-{
-       _DBG("appcore_group_reset");
 #ifdef X11
        int wid = appcore_get_main_window();
 #else
        int wid = appcore_get_main_surface();
 #endif
-
-       if (__can_attach_window(b)) {
-               _DBG("attach!!");
-               int lpid;
-               const char *val = NULL;
-               int caller_pid;
-               int caller_wid;
-
-               val = bundle_get_val(b, AUL_K_CALLER_PID);
-
-               if (val != NULL) {
-                       caller_pid = atoi(val);
-                       lpid = aul_app_group_get_leader_pid(caller_pid);
-
-                       if (lpid != -1) {
-                               caller_wid = __get_top_window(lpid);
-                       _DBG("lpid %d, getpid() %d, wid %d, caller_wid %d",
-                                       lpid, getpid(), wid, caller_wid);
-                               aul_app_group_add(lpid, getpid(), wid);
-                               aul_app_group_attach_window(caller_wid, wid);
-                       } else {
-                               _ERR("no lpid");
-                               elm_exit();
-                       }
-               } else {
-                       _ERR("caller pid is null");
-               }
-       } else {
-               int pid = getpid();
-               aul_app_group_add(pid, pid, wid);
+       if (wid == 0) {
+               _ERR("window wasn't ready");
+               return;
        }
+
+       aul_app_group_set_window(wid);
+       attached = true;
 }
 
-void appcore_group_resume()
+void appcore_group_lower()
 {
-       _DBG("appcore_group_resume");
-       aul_app_group_clear_top();
-}
+       _DBG("appcore_group_lower");
+       int exit = 0;
 
+       aul_app_group_lower(&exit);
+       if (exit) {
+               _DBG("appcore_group_lower : sub-app!");
+               elm_exit();
+       }
+}