2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <appcore-common.h>
25 #include "taskmanager.h"
26 #include "_util_log.h"
27 #include "_util_efl.h"
30 #include "_progressbar.h"
33 int _dead_cb(int pid, void *data)
37 struct appdata *ad = (struct appdata *)data;
38 retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
43 if (ad->update_timer) {
44 ecore_timer_del(ad->update_timer);
45 ad->update_timer = NULL;
48 ret = _subt_einalist_item(ad, pid);
49 _D("mode(%d) count(%d) pid(%d) \n", ad->mode, ad->endcnt, pid);
55 case MODE_DEL_HISTORY:
56 case MODE_DEL_ALL_HISTORY:
65 case MODE_END_ALL_INUSE:
66 case MODE_KILL_ALL_INUSE:
68 if (ad->endcnt <= 1) {
85 static void _back_cb(void *data, Evas_Object *obj, void *event_info)
87 struct appdata *ad = (struct appdata *)data;
89 _unset_notification_level(ad->win);
95 static void _drag_start_cb(void *data, Evas_Object *obj, void *event_info)
98 struct appdata *ad = (struct appdata *)data;
99 if (ad->update_timer) {
100 ecore_timer_del(ad->update_timer);
101 ad->update_timer = NULL;
105 static void _drag_stop_cb(void *data, Evas_Object *obj, void *event_info)
108 struct appdata *ad = (struct appdata *)data;
109 if (ad->update_timer) {
110 ecore_timer_del(ad->update_timer);
111 ad->update_timer = NULL;
113 ad->update_timer = ecore_timer_add(2.0, _update_list, ad);
117 static void _anim_start_cb(void *data, Evas_Object *obj, void *event_info)
120 struct appdata *ad = (struct appdata *)data;
121 if (ad->update_timer) {
122 ecore_timer_del(ad->update_timer);
123 ad->update_timer = NULL;
127 static void _anim_stop_cb(void *data, Evas_Object *obj, void *event_info)
130 struct appdata *ad = (struct appdata *)data;
131 if (ad->update_timer) {
132 ecore_timer_del(ad->update_timer);
133 ad->update_timer = NULL;
135 ad->update_timer = ecore_timer_add(2.0, _update_list, ad);
138 static void _moved_cb(void *data, Evas_Object *obj, void *event_info)
143 int _app_create(struct appdata *ad)
145 Evas_Object *ly, *bg, *nv, *bt, *gl;
147 retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
148 ad->ending = EINA_FALSE;
150 ly = _add_layout_main(ad->win, EINA_TRUE, EINA_FALSE);
151 retvm_if(ly == NULL, -1, "Failed to add layout main\n");
153 bg = _add_bg(ad->win, "group_list");
154 retvm_if(bg == NULL, -1, "Failed to add bg\n");
155 elm_object_part_content_set(ly, "elm.swallow.bg", bg);
157 nv = _add_naviframe(ly);
158 retvm_if(nv == NULL, -1, "Failed to add naviframe\n");
161 ly = _add_layout(ad->nv, EDJ_NAME, GRP_TM);
162 retvm_if(ly == NULL, -1, "Failed to add layout\n");
165 /* Load default content (running task) */
166 gl = _add_genlist(ly);
167 retvm_if(gl == NULL, -1, "Failed to add genlist\n");
168 elm_genlist_block_count_set(gl, 20);
169 evas_object_data_set(gl, "appdata", ad);
170 elm_object_part_content_set(ly, "list", gl);
171 evas_object_smart_callback_add(gl, "scroll,drag,start", _drag_start_cb, ad);
172 evas_object_smart_callback_add(gl, "scroll,drag,stop", _drag_stop_cb, ad);
173 evas_object_smart_callback_add(gl, "scroll,anim,start", _anim_start_cb, ad);
174 evas_object_smart_callback_add(gl, "scroll,anim,stop", _anim_stop_cb, ad);
177 bt = elm_button_add(nv);
178 retvm_if(bt == NULL, -1, "Failed to add button\n");
179 elm_object_style_set(bt, "naviframe/end_btn/default");
180 evas_object_smart_callback_add(bt, "clicked", _back_cb, ad);
182 elm_naviframe_item_push(nv,
183 T_("IDS_TASKMGR_HEADER_TASK_SWITCHER"),
189 static void _get_win_geometry(struct appdata *ad)
191 Ecore_X_Window focus_win;
192 Ecore_X_Window root_win;
194 focus_win = ecore_x_window_focus_get();
195 root_win = ecore_x_window_root_get(focus_win);
196 ecore_x_window_size_get(root_win, &ad->root_w, &ad->root_h);
199 /* this func is to exit taskmanager after launching application */
200 static Eina_Bool __climsg_cb(void *data, int type, void *event)
205 struct appdata *ad = (struct appdata *)data;
206 Ecore_X_Event_Client_Message *ev = event;
209 _E("Invalid argument: event is NULL\n");
211 return ECORE_CALLBACK_CANCEL;
214 pid_a = ev->data.l[1];
215 pid_d = ev->data.l[3];
216 a_deact = ecore_x_atom_get("_X_ILLUME_DEACTIVATE_WINDOW");
218 /* when pid_a == pid_d, this is useless data */
219 if (pid_a == pid_d) {
220 return ECORE_CALLBACK_RENEW;
223 if (ev->message_type == a_deact) {
225 return ECORE_CALLBACK_CANCEL;
227 _D("messagre is act\n");
231 return ECORE_CALLBACK_CANCEL;
234 void _ok_response_cb(void *data, Evas_Object *obj, void *event_info)
236 struct appdata *ad = (struct appdata *)data;
238 retm_if(data == NULL, "Invalid argument: appdata is NULL\n");
240 evas_object_del(ad->popup_ask);
241 ad->popup_ask = NULL;
247 _del_popup_timer(ad);
248 _show_progressbar(ad);
249 response_end_inuse(ad);
250 _restart_pthread(ad);
253 case MODE_END_ALL_INUSE:
254 _D("end all inuse\n");
255 _del_popup_timer(ad);
256 _show_progressbar(ad);
257 response_end_all_inuse(ad);
260 case MODE_DEL_HISTORY:
262 _del_popup_timer(ad);
263 response_del_history(ad);
266 case MODE_DEL_ALL_HISTORY:
267 _D("del all inuse\n");
268 _del_popup_timer(ad);
269 response_del_all_history(ad);
272 case MODE_KILL_INUSE:
273 _D("kill all inuse\n");
274 response_kill_inuse(ad);
277 case MODE_KILL_ALL_INUSE:
278 _D("kill all inuse\n");
279 response_kill_all_inuse(ad);
283 printf("[Wanning] taskmanager: check mode [%d]\n",
289 void _cancel_response_cb(void *data, Evas_Object *obj, void *event_info)
291 struct appdata *ad = (struct appdata *)data;
293 retm_if(data == NULL, "Invalid argument: appdata is NULL\n");
295 evas_object_del(ad->popup_ask);
296 ad->popup_ask = NULL;
300 Eina_Bool _create_idler_cb(void *data)
302 Evas_Object *pu, *bt1, *bt2;
303 struct appdata *ad = (struct appdata *)data;
304 retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "Invalid argument\n");
306 evas_object_show(ad->win);
311 _get_win_geometry(ad);
312 ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, __climsg_cb, ad);
314 return ECORE_CALLBACK_CANCEL;