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.
22 #include <appcore-efl.h>
23 #include <Elementary.h>
30 #include "taskmanager.h"
31 #include "_util_log.h"
32 #include "_util_efl.h"
41 static struct text_part main_txt[] = {
44 static void update_ts(Evas_Object *eo, struct text_part *tp, int size)
48 if (eo == NULL || tp == NULL || size < 0)
51 for (i = 0; i < size; i++) {
52 if (tp[i].part && tp[i].msgid)
53 edje_object_part_text_set(eo,
54 tp[i].part, _(tp[i].msgid));
58 static int _lang_changed(void *data)
60 struct appdata *ad = data;
65 update_ts(elm_layout_edje_get(ad->ly),
66 main_txt, sizeof(main_txt) / sizeof(main_txt[0]));
71 static int rotate(enum appcore_rm m, void *data)
73 struct appdata *ad = data;
76 if (ad == NULL || ad->win == NULL)
80 case APPCORE_RM_PORTRAIT_NORMAL:
83 case APPCORE_RM_PORTRAIT_REVERSE:
86 case APPCORE_RM_LANDSCAPE_NORMAL:
89 case APPCORE_RM_LANDSCAPE_REVERSE:
98 elm_win_rotation_with_resize_set(ad->win, r);
103 Eina_Bool _exit_cb(void *data)
105 struct appdata *ad = (struct appdata *)data;
107 ad->exit_timer = NULL;
109 return ECORE_CALLBACK_CANCEL;
112 void _key_grab(struct appdata *ad)
115 Ecore_X_Window xwin; /* key grab */
116 Ecore_X_Display *disp; /* key grab */
119 disp = ecore_x_display_get();
120 xwin = elm_win_xwindow_get(ad->win);
122 ret = utilx_grab_key(disp, xwin, KEY_SELECT, SHARED_GRAB);
123 retm_if(ret < 0, "Failed to grab home key\n");
126 int _set_launch_effect(Evas_Object *win)
128 Ecore_X_Window xwin = 0;
129 static Ecore_X_Atom ATOM_WM_WINDOW_ROLE = 0;
130 static Ecore_X_Atom ATOM_NET_WM_NAME = 0;
131 retvm_if(win == NULL, -1, "[Error] Invalid argument: win is NULL\n");
133 ATOM_WM_WINDOW_ROLE = ecore_x_atom_get("WM_WINDOW_ROLE");
134 if (!ATOM_WM_WINDOW_ROLE) {
136 "[App] %s(%d) XInternAtom(WM_WINDOW_ROLE) failed.\n",
140 ATOM_NET_WM_NAME = ecore_x_atom_get("_NET_WM_NAME");
141 if (!ATOM_NET_WM_NAME) {
143 "[App] %s(%d) XInternAtom(ATOM_NET_WM_NAME) failed.\n",
147 xwin = elm_win_xwindow_get(win);
148 ecore_x_window_prop_string_set(xwin, ATOM_WM_WINDOW_ROLE,
150 ecore_x_window_prop_string_set(xwin, ATOM_NET_WM_NAME, "TASK_MANAGER");
152 ecore_x_icccm_name_class_set(xwin, "TASK_MANAGER", "TASK_MANAGER");
156 int _unset_notification_level(Evas_Object *win)
160 xwin = elm_win_xwindow_get(win);
161 ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NORMAL);
166 int _set_notification_level(Evas_Object *win, Utilx_Notification_Level level)
168 Ecore_X_Window xwin = 0;
170 xwin = elm_win_xwindow_get(win);
171 ecore_x_netwm_window_type_set(xwin, ECORE_X_WINDOW_TYPE_NOTIFICATION);
172 utilx_set_system_notification_level(ecore_x_display_get(), xwin, level);
176 int app_create(void *data)
179 struct appdata *ad = data;
182 win = _add_window(PACKAGE);
183 retv_if(win == NULL, -1);
184 elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_SHOW);
187 _set_launch_effect(win);
188 // _set_notification_level(win, UTILX_NOTIFICATION_LEVEL_NORMAL);
190 elm_theme_extension_add(NULL, EDJ_THEME);
196 /* set dead signal listener */
197 aul_listen_app_dead_signal(_dead_cb, ad);
199 /* init internationalization */
200 r = appcore_set_i18n(PACKAGE, LOCALEDIR);
201 retvm_if(r < 0, -1, "Failed to set i18n\n");
204 appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE,
207 _restart_pthread(ad);
208 ecore_idler_add(_create_idler_cb, ad);
213 static int app_terminate(void *data)
216 struct appdata *ad = data;
218 // ecore_timer_add(0.2, _exit_cb, NULL);
223 static int app_pause(void *data)
230 static int app_resume(void *data)
233 struct appdata *ad = data;
235 if (ad->exit_timer) {
236 ecore_timer_del(ad->exit_timer);
237 ad->exit_timer = NULL;
243 static int app_reset(bundle *b, void *data)
245 struct appdata *ad = data;
247 /* appcore measure time example */
248 printf("from AUL to %s(): %d msec\n", __func__,
249 appcore_measure_time_from("APP_START_TIME"));
250 printf("from create to %s(): %d msec\n", __func__,
251 appcore_measure_time());
254 elm_win_activate(ad->win);
258 int main(int argc, char *argv[])
260 sysconf_set_mempolicy(OOM_IGNORE);
263 struct appcore_ops ops = {
264 .create = app_create,
265 .terminate = app_terminate,
267 .resume = app_resume,
271 /* appcore measure time example */
272 _D("from AUL to %s(): %d msec\n", __func__,
273 appcore_measure_time_from("APP_START_TIME"));
275 memset(&ad, 0x0, sizeof(struct appdata));
278 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);