summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSemun Lee <sm79.lee@samsung.com>2015-06-03 18:51:25 -0700
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>2015-06-03 18:51:25 -0700
commit96b696b75bf8208d4e16e3780a96bb0ef621fdac (patch)
tree8d2fa6a37dd8ed63c693e7051c5e215e145d85a2
parentceeae6608d8b3c181ab5028f895e2785596450d9 (diff)
parent52f74fd0748b8ea6f913fa5399d4fea0461b6c85 (diff)
downloadapp-core-96b696b75bf8208d4e16e3780a96bb0ef621fdac.tar.gz
app-core-96b696b75bf8208d4e16e3780a96bb0ef621fdac.tar.bz2
app-core-96b696b75bf8208d4e16e3780a96bb0ef621fdac.zip
Merge "Add pause, terminate bgapp event" into tizensubmit/tizen/20150604.015241
-rwxr-xr-xinclude/appcore-internal.h3
-rwxr-xr-xsrc/appcore-X.c36
-rw-r--r--src/appcore-efl.c38
-rw-r--r--src/appcore.c30
4 files changed, 90 insertions, 17 deletions
diff --git a/include/appcore-internal.h b/include/appcore-internal.h
index f4d2ccd..c898e56 100755
--- a/include/appcore-internal.h
+++ b/include/appcore-internal.h
@@ -108,9 +108,11 @@ enum app_event {
AE_UNKNOWN,
AE_CREATE,
AE_TERMINATE,
+ AE_TERMINATE_BGAPP,
AE_PAUSE,
AE_RESUME,
AE_RAISE,
+ AE_LOWER,
AE_RESET,
AE_LOWMEM_POST,
AE_MEM_FLUSH,
@@ -163,6 +165,7 @@ void update_region(void);
/* appcore-X.c */
extern int x_raise_win(pid_t pid);
+extern int x_pause_win(pid_t pid);
/* appcore-util.c */
/* extern void stack_trim(void);*/
diff --git a/src/appcore-X.c b/src/appcore-X.c
index 7eecf5c..c0a7e66 100755
--- a/src/appcore-X.c
+++ b/src/appcore-X.c
@@ -169,3 +169,39 @@ EXPORT_API int x_raise_win(pid_t pid)
return r;
}
+
+int x_pause_win(pid_t pid)
+{
+ int r;
+ Display *d;
+ Window win;
+ Eina_List *list_win = NULL;
+
+ if (pid < 1) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ r = kill(pid, 0);
+ if (r == -1) {
+ errno = ESRCH;
+ return -1;
+ }
+
+ d = XOpenDisplay(NULL);
+ _retv_if(d == NULL, -1);
+
+ win = XDefaultRootWindow(d);
+ if (!a_pid)
+ a_pid = XInternAtom(d, "_NET_WM_PID", True);
+
+ __foreach_win(&list_win, d, &win, pid);
+ r = __iconify_win(list_win, d);
+
+ XCloseDisplay(d);
+
+ if (list_win)
+ eina_list_free(list_win);
+
+ return r;
+}
diff --git a/src/appcore-efl.c b/src/appcore-efl.c
index 6dfc5a1..1415824 100644
--- a/src/appcore-efl.c
+++ b/src/appcore-efl.c
@@ -265,6 +265,14 @@ static void __do_app(enum app_event event, void *data, bundle * b)
return;
}
+ if (event == AE_LOWER) {
+#ifdef X11
+ x_pause_win(getpid());
+ return;
+#endif
+ /* TODO: wayland support */
+ }
+
_ret_if(ui->ops == NULL);
switch (event) {
@@ -329,6 +337,18 @@ static void __do_app(enum app_event event, void *data, bundle * b)
ui->name);
_send_to_resourced(PROC_STATUS_FOREGRD);
break;
+ case AE_TERMINATE_BGAPP:
+ if (ui->state == AS_PAUSED) {
+ _DBG("[APP %d] is paused. TERMINATE", _pid);
+ ui->state = AS_DYING;
+ aul_status_update(STATUS_DYING);
+ elm_exit();
+ } else if (ui->state == AS_RUNNING) {
+ _DBG("[APP %d] is running.", _pid);
+ } else {
+ _DBG("[APP %d] is another state", _pid);
+ }
+ break;
default:
/* do nothing */
break;
@@ -555,24 +575,9 @@ static Eina_Bool __hide_cb(void *data, int type, void *event)
{
#ifdef WAYLAND
Ecore_Wl_Event_Window_Hide *ev;
- int bvisibility = 0;
-
- ev = event;
-
- _DBG("[EVENT_TEST][EVENT] GET HIDE EVENT!!!. WIN:%x\n", ev->win);
-
- if (__find_win((unsigned int)ev->win)) {
- __delete_win((unsigned int)ev->win);
-
- bvisibility = __check_visible();
- if (!bvisibility && b_active == TRUE) {
- _DBG(" Go to Pasue state \n");
- b_active = FALSE;
- __do_app(AE_PAUSE, data, NULL);
- }
- }
#else
Ecore_X_Event_Window_Hide *ev;
+#endif
int bvisibility = 0;
ev = event;
@@ -588,7 +593,6 @@ static Eina_Bool __hide_cb(void *data, int type, void *event)
__do_app(AE_PAUSE, data, NULL);
}
}
-#endif
return ECORE_CALLBACK_RENEW;
}
diff --git a/src/appcore.c b/src/appcore.c
index 94d3693..711629b 100644
--- a/src/appcore.c
+++ b/src/appcore.c
@@ -172,6 +172,18 @@ static int __app_terminate(void *data)
return 0;
}
+static int __bgapp_terminate(void *data)
+{
+ struct appcore *ac = data;
+
+ _retv_if(ac == NULL || ac->ops == NULL, -1);
+ _retv_if(ac->ops->cb_app == NULL, 0);
+
+ ac->ops->cb_app(AE_TERMINATE_BGAPP, ac->ops->data, NULL);
+
+ return 0;
+}
+
static gboolean __prt_ltime(gpointer data)
{
int msec;
@@ -206,6 +218,16 @@ static int __app_resume(void *data)
return 0;
}
+static int __app_pause(void *data)
+{
+ struct appcore *ac = data;
+ _retv_if(ac == NULL || ac->ops == NULL, -1);
+ _retv_if(ac->ops->cb_app == NULL, 0);
+
+ ac->ops->cb_app(AE_LOWER, ac->ops->data, NULL);
+ return 0;
+}
+
static int __sys_do_default(struct appcore *ac, enum sys_event event)
{
int r;
@@ -422,6 +444,14 @@ static int __aul_handler(aul_type type, bundle *b, void *data)
_DBG("[APP %d] AUL event: AUL_TERMINATE", _pid);
__app_terminate(data);
break;
+ case AUL_TERMINATE_BGAPP:
+ _DBG("[APP %d] AUL event: AUL_TERMINATE_BGAPP", _pid);
+ __bgapp_terminate(data);
+ break;
+ case AUL_PAUSE:
+ _DBG("[APP %d] AUL event: AUL_PAUSE", _pid);
+ __app_pause(data);
+ break;
default:
_DBG("[APP %d] AUL event: %d", _pid, type);
/* do nothing */