Fix bug about updating window information
[platform/core/appfw/app-core.git] / src / appcore-efl.c
index 773680e..f0161b3 100644 (file)
@@ -70,8 +70,8 @@ struct ui_priv {
 
        Ecore_Timer *mftimer; /* Ecore Timer for memory flushing */
 
-#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
        struct appcore *app_core;
+#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
        void (*prepare_to_suspend) (void *data);
        void (*exit_from_suspend) (void *data);
 #endif
@@ -99,6 +99,7 @@ static const char *_ae_name[AE_MAX] = {
        [AE_RESET] = "RESET",
        [AE_LOWMEM_POST] = "LOWMEM_POST",
        [AE_MEM_FLUSH] = "MEM_FLUSH",
+       [AE_UPDATE_REQUESTED] = "UPDATE_REQUESTED",
 };
 
 static const char *_as_name[] = {
@@ -256,6 +257,20 @@ static void __appcore_efl_exit_from_suspend(void *data)
 }
 #endif
 
+static void __appcore_efl_update_requested(void *data)
+{
+       struct ui_priv *ui = (struct ui_priv *)data;
+       struct sys_op *op;
+       int dummy = 0;
+
+       if (ui->app_core) {
+               op = &ui->app_core->sops[SE_UPDATE_REQUESTED];
+               if (op && op->func)
+                       op->func((void *)&dummy, op->data);
+       }
+       _DBG("[__UPDATE_REQUESTED__]");
+}
+
 #if defined(MEMORY_FLUSH_ACTIVATE)
 static Eina_Bool __appcore_memory_flush_cb(void *data)
 {
@@ -407,6 +422,8 @@ static void __do_app(enum app_event event, void *data, bundle * b)
        switch (event) {
        case AE_RESET:
                _DBG("[APP %d] RESET", _pid);
+               if (ui->pending_data)
+                       bundle_free(ui->pending_data);
                ui->pending_data = bundle_dup(b);
                LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]", ui->name);
 
@@ -434,6 +451,10 @@ static void __do_app(enum app_event event, void *data, bundle * b)
                LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", ui->name);
 
                if (first_launch) {
+#ifdef _APPFW_FEATURE_BACKGROUND_MANAGEMENT
+                       if (ui->app_core->allowed_bg)
+                               __appcore_timer_add(ui);
+#endif
                        first_launch = FALSE;
                } else {
                        _INFO("[APP %d] App already running, raise the window", _pid);
@@ -483,6 +504,8 @@ static void __do_app(enum app_event event, void *data, bundle * b)
                        _DBG("[__SUSPEND__] resume case");
                        ui->exit_from_suspend(ui);
                }
+               if (ui->app_core->allowed_bg)
+                       __appcore_timer_del(ui);
 #endif
 
                if (ui->state == AS_PAUSED || ui->state == AS_CREATED) {
@@ -527,6 +550,9 @@ static void __do_app(enum app_event event, void *data, bundle * b)
                        _DBG("[APP %d] is another state", _pid);
                }
                break;
+       case AE_UPDATE_REQUESTED:
+               __appcore_efl_update_requested(ui);
+               break;
        default:
                /* do nothing */
                break;
@@ -658,14 +684,10 @@ static bool __update_win(unsigned int win, bool bfobscured)
                return FALSE;
        }
 
-       g_winnode_list = g_slist_remove_link(g_winnode_list, f);
-
        t = (struct win_node *)f->data;
        t->win = win;
        t->bfobscured = bfobscured;
 
-       g_winnode_list = g_slist_concat(g_winnode_list, f);
-
        return TRUE;
 }
 #elif defined(WAYLAND)
@@ -684,16 +706,12 @@ static bool __update_win(unsigned int win, unsigned int surf, bool bfobscured)
                return FALSE;
        }
 
-       g_winnode_list = g_slist_remove_link(g_winnode_list, f);
-
        t = (struct win_node *)f->data;
        t->win = win;
        if (surf != 0)
                t->surf = surf;
        t->bfobscured = bfobscured;
 
-       g_winnode_list = g_slist_concat(g_winnode_list, f);
-
        return TRUE;
 }
 #endif
@@ -1070,6 +1088,12 @@ static void __after_loop(struct ui_priv *ui)
        __appcore_timer_del(ui);
 
        elm_shutdown();
+
+       /* Check loader case */
+       if (getenv("AUL_LOADER_INIT")) {
+               unsetenv("AUL_LOADER_INIT");
+               elm_shutdown();
+       }
 }
 
 static int __set_data(struct ui_priv *ui, const char *name,