From 5ddc3215d875c08af2b5afd0ce71172e52251f87 Mon Sep 17 00:00:00 2001 From: Jiwoong Im Date: Fri, 23 Jan 2015 15:20:02 +0900 Subject: [PATCH] modify application lifecycle. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit JIRA ticket : TC-2400 changes in app lifecycle - While application launching, application enters running state through app_create cb -> app_control_cb -> app_resume_cb. - If app_control request comes in paused state, app framework activates the applications’s window and calls the app_resume_cb. - When application is terminated in running state, app framework calls app_paused_cb before calling app_terminate_cb. remove source code which is related with _E_PARENT_BORDER_WINDOW property Change-Id: I5274d6344ffaabe1f1e5f7db2a2d2dda9d27e10c Signed-off-by: Jiwoong Im --- src/appcore-X.c | 2 +- src/appcore-efl.c | 65 +++++++++++++++++++++++++++++++++---------------------- 2 files changed, 40 insertions(+), 27 deletions(-) diff --git a/src/appcore-X.c b/src/appcore-X.c index 8595860..7eecf5c 100755 --- a/src/appcore-X.c +++ b/src/appcore-X.c @@ -129,7 +129,7 @@ static int __raise_win(Display *d, Window win) return 0; } -int x_raise_win(pid_t pid) +EXPORT_API int x_raise_win(pid_t pid) { int r; diff --git a/src/appcore-efl.c b/src/appcore-efl.c index c5bcac9..1d04ee5 100644 --- a/src/appcore-efl.c +++ b/src/appcore-efl.c @@ -108,7 +108,9 @@ static const char *_as_name[] = { [AS_DYING] = "DYING", }; -static bool b_active = 0; +static bool b_active = FALSE; +static bool first_launch = TRUE; + struct win_node { unsigned int win; bool bfobscured; @@ -255,10 +257,28 @@ static void __do_app(enum app_event event, void *data, bundle * b) switch (event) { case AE_RESET: _DBG("[APP %d] RESET", _pid); - LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]", - ui->name); + LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:start]", ui->name); if (ui->ops->reset) r = ui->ops->reset(b, ui->ops->data); + LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", ui->name); + + if (first_launch) { + first_launch = FALSE; + _INFO("[APP %d] Initial Launching, call the resume_cb", _pid); + if (ui->ops->resume) + r = ui->ops->resume(ui->ops->data); + } else { + _INFO("[APP %d] App already running, raise the window", _pid); +#ifdef X11 + x_raise_win(getpid()); +#endif + if (ui->state == AS_PAUSED) { + _INFO("[APP %d] Call the resume_cb", _pid); + if (ui->ops->resume) + r = ui->ops->resume(ui->ops->data); + } + } + ui->state = AS_RUNNING; LOG(LOG_DEBUG, "LAUNCH", "[%s:Application:reset:done]", ui->name); @@ -488,7 +508,6 @@ static void __set_wm_rotation_support(unsigned int win, unsigned int set) } } -Ecore_X_Atom atom_parent; #endif static Eina_Bool __show_cb(void *data, int type, void *event) @@ -519,13 +538,6 @@ static Eina_Bool __show_cb(void *data, int type, void *event) ev = event; - ret = ecore_x_window_prop_window_get(ev->win, atom_parent, &parent, 1); - if (ret != 1) - { - // This is child window. Skip!!! - return ECORE_CALLBACK_PASS_ON; - } - _DBG("[EVENT_TEST][EVENT] GET SHOW EVENT!!!. WIN:%x\n", ev->win); if (!__exist_win((unsigned int)ev->win)) { @@ -556,9 +568,9 @@ static Eina_Bool __hide_cb(void *data, int type, void *event) __delete_win((unsigned int)ev->win); bvisibility = __check_visible(); - if (!bvisibility && b_active == 1) { + if (!bvisibility && b_active == TRUE) { _DBG(" Go to Pasue state \n"); - b_active = 0; + b_active = FALSE; __do_app(AE_PAUSE, data, NULL); } } @@ -572,11 +584,10 @@ static Eina_Bool __hide_cb(void *data, int type, void *event) if (__exist_win((unsigned int)ev->win)) { __delete_win((unsigned int)ev->win); - bvisibility = __check_visible(); - if (!bvisibility && b_active == 1) { + if (!bvisibility && b_active == TRUE) { _DBG(" Go to Pasue state \n"); - b_active = 0; + b_active = FALSE; __do_app(AE_PAUSE, data, NULL); } } @@ -604,14 +615,16 @@ static Eina_Bool __visibility_cb(void *data, int type, void *event) #endif bvisibility = __check_visible(); - if (bvisibility && b_active == 0) { + _DBG("bvisibility %d, b_active %d", bvisibility, b_active); + + if (bvisibility && b_active == FALSE) { _DBG(" Go to Resume state\n"); - b_active = 1; + b_active = TRUE; __do_app(AE_RESUME, data, NULL); - } else if (!bvisibility && b_active == 1) { + } else if (!bvisibility && b_active == TRUE) { _DBG(" Go to Pasue state \n"); - b_active = 0; + b_active = FALSE; __do_app(AE_PAUSE, data, NULL); } else _DBG(" No change state \n"); @@ -666,12 +679,6 @@ static void __add_climsg_cb(struct ui_priv *ui) ui->hhide = ecore_event_handler_add(ECORE_WL_EVENT_WINDOW_DEACTIVATE, __hide_cb, ui); #else - atom_parent = ecore_x_atom_get("_E_PARENT_BORDER_WINDOW"); - if (!atom_parent) - { - // Do Error Handling - } - ui->hshow = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHOW, __show_cb, ui); ui->hhide = @@ -756,6 +763,12 @@ static void __after_loop(struct ui_priv *ui) appcore_unset_rotation_cb(); appcore_exit(); + if (ui->state == AS_RUNNING) { + _DBG("[APP %d] PAUSE before termination", _pid); + if (ui->ops && ui->ops->pause) + ui->ops->pause(ui->ops->data); + } + if (ui->ops && ui->ops->terminate) ui->ops->terminate(ui->ops->data); -- 2.7.4