Removed build deps on ecore-x and libslp-utilx
[profile/ivi/taskmanager.git] / src / _logic.c
old mode 100644 (file)
new mode 100755 (executable)
index 655deb1..041074a
@@ -1,23 +1,27 @@
- /*
-  * Copyright 2012  Samsung Electronics Co., Ltd
-  *
-  * Licensed under the Flora License, Version 1.0 (the License);
-  * you may not use this file except in compliance with the License.
-  * You may obtain a copy of the License at
-  *
-  *     http://www.tizenopensource.org/license
-  *
-  * Unless required by applicable law or agreed to in writing, software
-  * distributed under the License is distributed on an AS IS BASIS,
-  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  * See the License for the specific language governing permissions and
-  * limitations under the License.
-  */
+/*
+ * Copyright 2012  Samsung Electronics Co., Ltd
+ * 
+ * Licensed under the Flora License, Version 1.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.tizenopensource.org/license
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
 
 
 #include <appcore-common.h>
 #include <aul.h>
+#if HAVE_X
 #include <Ecore_X.h>
+#endif
 #include <vconf.h>
 
 #include "taskmanager.h"
@@ -28,7 +32,6 @@
 #include "_progressbar.h"
 #include "_info.h"
 
-
 int _dead_cb(int pid, void *data)
 {
 _D("func\n");
@@ -36,14 +39,18 @@ _D("func\n");
        struct appdata *ad = (struct appdata *)data;
        retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
 
+       int ret = -1;
+
        _fini_pthread();
        if (ad->update_timer) {
                ecore_timer_del(ad->update_timer);
                ad->update_timer = NULL;
        }
-       _subt_einalist_item(ad, pid);
 
-       _D("mode(%d) count(%d)\n", ad->mode, ad->endcnt);
+       ret = _subt_einalist_item(ad, pid);
+       _D("mode(%d) count(%d) pid(%d) \n", ad->mode, ad->endcnt, pid);
+
+       if (ret != -1) {
        switch (ad->mode) {
        default:
        case MODE_END_INUSE:
@@ -73,6 +80,7 @@ _D("func\n");
                break;
        }
 }
+}
 
 static void _back_cb(void *data, Evas_Object *obj, void *event_info)
 {
@@ -148,7 +156,6 @@ int _app_create(struct appdata *ad)
 
        nv = _add_naviframe(ly);
        retvm_if(nv == NULL, -1, "Failed to add naviframe\n");
-       evas_object_show(nv);
        ad->nv = nv;
 
        ly = _add_layout(ad->nv, EDJ_NAME, GRP_TM);
@@ -165,8 +172,6 @@ int _app_create(struct appdata *ad)
        evas_object_smart_callback_add(gl, "scroll,drag,stop", _drag_stop_cb, ad);
        evas_object_smart_callback_add(gl, "scroll,anim,start", _anim_start_cb, ad);
        evas_object_smart_callback_add(gl, "scroll,anim,stop", _anim_stop_cb, ad);
-//     evas_object_smart_callback_add(gl, "edge,bottom", _moved_cb, ad);
-       evas_object_show(gl);
        ad->gl = gl;
 
        bt = elm_button_add(nv);
@@ -183,12 +188,11 @@ int _app_create(struct appdata *ad)
 
 static void _get_win_geometry(struct appdata *ad)
 {
-       Ecore_X_Window focus_win;
-       Ecore_X_Window root_win;
-
-       focus_win = ecore_x_window_focus_get();
-       root_win = ecore_x_window_root_get(focus_win);
-       ecore_x_window_size_get(root_win, &ad->root_w, &ad->root_h);
+       Evas_Object *eo;
+       Ecore_Evas *ee;
+       ee = ecore_evas_ecore_evas_get(evas_object_evas_get(ad->win));
+       ecore_evas_screen_geometry_get(ee, 0, 0, &ad->root_w, &ad->root_h);
 }
 
 static void _vconf_noti_cb(keynode_t *node, void *data)
@@ -202,23 +206,28 @@ static void _set_vconf_noti(void *data)
                        _vconf_noti_cb, NULL);
 }
 
+/* X specific */
+#if HAVE_X
 /* this func is to exit taskmanager after launching application */
 static Eina_Bool __climsg_cb(void *data, int type, void *event)
 {
        static Atom a_deact;
        pid_t pid_a, pid_d;
 
+       struct appdata *ad = (struct appdata *)data;
        Ecore_X_Event_Client_Message *ev = event;
 
        if(ev == NULL) {
                _E("Invalid argument: event is NULL\n");
-               ecore_timer_add(1.5, _exit_cb, NULL);
+               ecore_timer_add(0.3, _exit_cb, NULL);
                return ECORE_CALLBACK_CANCEL;
        }
 
        pid_a = ev->data.l[1];
        pid_d = ev->data.l[3];
+#if HAVE_X
        a_deact = ecore_x_atom_get("_X_ILLUME_DEACTIVATE_WINDOW");
+#endif
 
        /* when pid_a == pid_d, this is useless data */
        if (pid_a == pid_d) {
@@ -227,7 +236,7 @@ static Eina_Bool __climsg_cb(void *data, int type, void *event)
 
        if (ev->message_type == a_deact) {
                _D("exit after 1.0 sec\n");
-               ecore_timer_add(1.5, _exit_cb, NULL);
+               ad->exit_timer = ecore_timer_add(0.3, _exit_cb, ad);
                return ECORE_CALLBACK_CANCEL;
        } else {
                _D("messagre is act\n");
@@ -236,6 +245,7 @@ static Eina_Bool __climsg_cb(void *data, int type, void *event)
 
        return ECORE_CALLBACK_CANCEL;
 }
+#endif
 
 static Eina_Bool _ask_kill_process(void *data)
 {
@@ -246,18 +256,6 @@ static Eina_Bool _ask_kill_process(void *data)
        ad->mode *= 2;
        /* why? check enum in taskmgr.h */
 
-       switch (ad->mode) {
-               case MODE_KILL_INUSE:
-                       _D("kill all inuse\n");
-                       response_kill_inuse(ad);
-                       break;
-
-               case MODE_KILL_ALL_INUSE:
-                       _D("kill all inuse\n");
-                       response_kill_all_inuse(ad);
-                       break;
-       }
-/*
        if (ad->popup_ask) {
                evas_object_del(ad->popup_ask);
                ad->popup_ask = NULL;
@@ -265,7 +263,7 @@ static Eina_Bool _ask_kill_process(void *data)
        ad->popup_ask = _add_popup_ask(ad->win,
                        "It might be an invalid process. Do you want to kill this proceess anyway?",
                        ad);
-*/
+
        return ECORE_CALLBACK_CANCEL;
 }
 
@@ -347,12 +345,16 @@ Eina_Bool _create_idler_cb(void *data)
 
        evas_object_show(ad->win);
 
+#if HAVE_X
        _key_grab(ad);
+#endif
 
        _init_pthread();
        _get_win_geometry(ad);
        _set_vconf_noti(ad);
-       ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __climsg_cb, NULL);
+#if HAVE_X
+       ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __climsg_cb, ad);
+#endif
 
        return ECORE_CALLBACK_CANCEL;
 }