4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
27 #include <Elementary.h>
30 #include <X11/Xatom.h>
31 #include <X11/Xutil.h>
34 #include <Ecore_Wayland.h>
40 #include "ug-manager.h"
41 #include "ug-engine.h"
44 #define Idle_Cb Ecore_Cb
46 #define ugman_idler_add(func, data) \
47 ecore_job_add((Ecore_Cb) func, (void *)data);
49 #ifdef ENABLE_UG_CREATE_CB
50 typedef void (*fn_ug_trace_cb)(char *ug, char *mem, char *parent, void *user_data);
51 fn_ug_trace_cb g_create_cb;
52 void *g_create_cb_user_data;
67 enum ug_option base_opt;
68 enum ug_event last_rotate_evt;
76 struct ug_engine *engine;
79 static struct ug_manager ug_man;
81 static inline void job_start(void);
82 static inline void job_end(void);
84 static int ug_relation_add(ui_gadget_h p, ui_gadget_h c)
87 /* prepend element to avoid the inefficiency,
88 which is to traverse the entire list to find the end*/
89 p->children = g_slist_prepend(p->children, c);
94 static int ug_relation_del(ui_gadget_h ug)
100 _WRN("ug_relation_del failed: no parent");
105 p->children = g_slist_remove(p->children, ug);
108 g_slist_free(ug->children);
117 static int ug_fvlist_add(ui_gadget_h c)
119 ug_man.fv_list = g_slist_prepend(ug_man.fv_list, c);
125 static int ug_fvlist_del(ui_gadget_h c)
129 ug_man.fv_list = g_slist_remove(ug_man.fv_list, c);
131 /* update fullview top ug*/
132 t = g_slist_nth_data(ug_man.fv_list, 0);
139 static int __ug_x_get_window_property(Display *dpy, Window win, Atom atom,
140 Atom type, unsigned int *val,
143 unsigned char *prop_ret;
145 unsigned long bytes_after;
146 unsigned long num_ret;
152 if (XGetWindowProperty(dpy, win, atom, 0, 0x7fffffff, False,
153 type, &type_ret, &format_ret, &num_ret,
154 &bytes_after, &prop_ret) != Success)
157 if (type_ret != type || format_ret != 32)
159 else if (num_ret == 0 || !prop_ret)
164 for (i = 0; i < len; i++)
165 val[i] = ((unsigned long *)prop_ret)[i];
177 static enum ug_event __ug_x_rotation_get(Display *dpy, Window win)
183 enum ug_event func_ret;
185 Atom atom_active_win;
186 Atom atom_win_rotate_angle;
188 root_win = XDefaultRootWindow(dpy);
190 atom_active_win = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
191 ret = __ug_x_get_window_property(dpy, root_win, atom_active_win,
193 (unsigned int *)&active_win, 1);
195 func_ret = UG_EVENT_ROTATE_PORTRAIT;
199 atom_win_rotate_angle =
200 XInternAtom(dpy, "_E_ILLUME_ROTATE_ROOT_ANGLE", False);
201 ret = __ug_x_get_window_property(dpy, root_win,
202 atom_win_rotate_angle, XA_CARDINAL,
203 (unsigned int *)&rotation, 1);
205 _DBG("x_rotation_get / ret(%d),degree(%d)", ret, rotation);
208 func_ret = UG_EVENT_ROTATE_PORTRAIT;
212 func_ret = UG_EVENT_ROTATE_PORTRAIT;
215 func_ret = UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN;
218 func_ret = UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN;
221 func_ret = UG_EVENT_ROTATE_LANDSCAPE;
224 func_ret = UG_EVENT_ROTATE_PORTRAIT;
234 static enum ug_event __ug_evas_rotation_get(Evas_Object *win)
237 int angle = elm_win_rotation_get(win);
238 enum ug_event func_ret;
240 _DBG("win angle : %d", angle);
244 func_ret = UG_EVENT_ROTATE_PORTRAIT;
247 func_ret = UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN;
250 func_ret = UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN;
253 func_ret = UG_EVENT_ROTATE_LANDSCAPE;
256 func_ret = UG_EVENT_ROTATE_PORTRAIT;
262 static void ugman_tree_dump(ui_gadget_h ug)
274 if (ug == ug_man.root) {
276 _DBG("============== TREE_DUMP =============");
277 _DBG("ROOT: Manager");
281 child = ug->children;
290 _DBG("[%d] %s [%c] (mem : %s) (ug : %p) (PARENT: %s)",
292 c && c->name ? c->name : "NO CHILD INFO FIXIT!!!",
293 c && c->mode == UG_MODE_FULLVIEW ? 'F' : 'f',
294 c->module->addr, c, name);
296 child = g_slist_next(child);
300 static int ugman_ug_free(ui_gadget_h ug)
303 _ERR("ug free failed: Invalid ug");
309 ug_module_unload(ug->module);
312 free((void *)ug->name);
315 if (ug->app_control) {
316 app_control_destroy(ug->app_control);
317 ug->app_control = NULL;
325 static int ugman_ug_find(ui_gadget_h p, ui_gadget_h ug)
327 GSList *child = NULL;
334 if (child->data == ug)
336 if (ugman_ug_find(child->data, ug))
338 child = g_slist_next(child);
344 static void ugman_ug_start(void *data)
346 ui_gadget_h ug = data;
347 struct ug_module_ops *ops = NULL;
352 } else if (ug->state != UG_STATE_CREATED) {
353 _DBG("start cb will be not invoked because ug(%p) state(%d) is not created", ug, ug->state);
359 ug->state = UG_STATE_RUNNING;
362 ops = &ug->module->ops;
364 if (ops && ops->start)
365 ops->start(ug, ug->app_control, ops->priv);
370 static int ugman_ug_pause(void *data)
372 ui_gadget_h ug = data;
373 struct ug_module_ops *ops = NULL;
374 GSList *child = NULL;
376 if (!ug_man.is_initted) {
377 _ERR("ugman_pause failed: manager is not initted");
382 _WRN("ugman_pause failed: no root");
386 if (ug_man.destroy_all == 1) {
387 _WRN("ugman_pause skipped : app is termanating with ug_destory_all");
391 if ((data != ug_man.root) && (!ugman_ug_find(ug_man.root, data))) {
392 _WRN("ugman_pause skipped : invalid ug(%p)", data);
399 _WRN("ug pointer is null");
404 child = ug->children;
406 ugman_ug_pause(child->data);
407 child = g_slist_next(child);
411 if (ug->state != UG_STATE_RUNNING) {
412 if (ug != ug_man.root)
413 _WRN("ug(%p)->state : %d", ug, ug->state);
418 ops = &ug->module->ops;
420 if (ops && ops->pause) {
421 _DBG("call ug(%p) pause cb", ug);
422 ops->pause(ug, ug->app_control, ops->priv);
425 ug->state = UG_STATE_STOPPED;
432 static int ugman_ug_resume(void *data)
434 ui_gadget_h ug = data;
435 struct ug_module_ops *ops = NULL;
436 GSList *child = NULL;
438 if (!ug_man.is_initted) {
439 _ERR("ugman_resume failed: manager is not initted");
444 _WRN("ugman_resume failed: no root");
448 if (ug_man.destroy_all == 1) {
449 _WRN("ugman_resume skipped : app is termanating with ug_destory_all");
453 if ((data != ug_man.root) && (!ugman_ug_find(ug_man.root, data))) {
454 _WRN("ugman_resume skipped : invalid ug(%p)", data);
461 _WRN("ug pointer is null");
466 child = ug->children;
468 ugman_ug_resume(child->data);
469 child = g_slist_next(child);
473 if (ug->state != UG_STATE_STOPPED) {
474 if (ug != ug_man.root)
475 _WRN("ug(%p)->state : %d", ug, ug->state);
479 case UG_STATE_CREATED:
482 case UG_STATE_STOPPED:
489 ops = &ug->module->ops;
491 if (ops && ops->resume) {
492 _DBG("call ug(%p) resume cb", ug);
493 ops->resume(ug, ug->app_control, ops->priv);
496 ug->state = UG_STATE_RUNNING;
504 static void _ugman_enable_indicator(Evas_Object *win, int enable)
506 Ecore_Wl_Window *wlwin = elm_win_wl_window_get(win);
509 ecore_wl_window_indicator_state_set(wlwin, ECORE_WL_INDICATOR_STATE_ON);
511 ecore_wl_window_indicator_state_set(wlwin, ECORE_WL_INDICATOR_STATE_OFF);
514 static int _ugman_get_indicator_state(Evas_Object *win)
516 Ecore_Wl_Window *wlwin = elm_win_wl_window_get(win);
517 Ecore_Wl_Indicator_State state;
520 state = ecore_wl_window_indicator_state_get(wlwin);
521 if (state == ECORE_WL_INDICATOR_STATE_OFF)
523 else if (state == ECORE_WL_INDICATOR_STATE_ON)
532 static int ugman_indicator_update(enum ug_option opt, enum ug_event event)
535 _ERR("controlling indicator is disabled");
540 cur_state = _ugman_get_indicator_state(ug_man.win);
542 _DBG("indicator update opt(%d) cur_state(%d)", opt, cur_state);
545 #ifndef ENABLE_UG_HANDLE_INDICATOR_HIDE
546 case UG_OPT_INDICATOR_ENABLE:
547 case UG_OPT_INDICATOR_PORTRAIT_ONLY:
548 case UG_OPT_INDICATOR_LANDSCAPE_ONLY:
549 case UG_OPT_INDICATOR_DISABLE:
553 case UG_OPT_INDICATOR_ENABLE:
554 if (event == UG_EVENT_NONE)
557 enable = cur_state ? 1 : 0;
559 case UG_OPT_INDICATOR_PORTRAIT_ONLY:
560 enable = ug_man.is_landscape ? 0 : 1;
562 case UG_OPT_INDICATOR_LANDSCAPE_ONLY:
563 enable = ug_man.is_landscape ? 1 : 0;
565 case UG_OPT_INDICATOR_DISABLE:
569 case UG_OPT_INDICATOR_MANUAL:
572 _ERR("update failed: Invalid opt(%d)", opt);
576 if (cur_state != enable) {
577 _DBG("set indicator status as %d", enable);
578 _ugman_enable_indicator(ug_man.win, enable);
585 static int ugman_ug_getopt(ui_gadget_h ug)
590 /* Indicator Option */
591 if (ug->mode == UG_MODE_FULLVIEW)
592 ugman_indicator_update(ug->opt, UG_EVENT_NONE);
597 static int ugman_ug_event(ui_gadget_h ug, enum ug_event event)
599 struct ug_module_ops *ops = NULL;
600 GSList *child = NULL;
606 child = ug->children;
608 ugman_ug_event(child->data, event);
609 child = g_slist_next(child);
614 ops = &ug->module->ops;
616 _DBG("ug_event_cb : ug(%p) / event(%d)", ug, event);
618 if (ops && ops->event)
619 ops->event(ug, event, ug->app_control, ops->priv);
624 static int ugman_ug_destroy(void *data)
626 ui_gadget_h ug = data;
627 struct ug_module_ops *ops = NULL;
635 _DBG("ug(%p) state(%d)", ug, ug->state);
638 case UG_STATE_CREATED:
639 case UG_STATE_RUNNING:
640 case UG_STATE_STOPPED:
641 case UG_STATE_DESTROYING:
642 case UG_STATE_PENDING_DESTROY:
645 _WRN("ug(%p) state is already destroyed", ug);
649 ug->state = UG_STATE_DESTROYED;
651 if ((ug != ug_man.root) && (ug->layout) &&
652 (ug->mode == UG_MODE_FULLVIEW) &&
653 (ug->layout_state != UG_LAYOUT_DESTROY)) {
654 /* ug_destroy_all case */
655 struct ug_engine_ops *eng_ops = NULL;
658 eng_ops = &ug_man.engine->ops;
660 if (eng_ops && eng_ops->destroy)
661 eng_ops->destroy(ug, NULL, NULL);
665 ops = &ug->module->ops;
667 if (ops && ops->destroy) {
668 _DBG("ug(%p) module destory cb call", ug);
669 ops->destroy(ug, ug->app_control, ops->priv);
673 if (cbs && cbs->end_cb) {
674 _DBG("ug(%p) end cb will be invoked", ug);
675 cbs->end_cb(ug, cbs->priv);
678 if ((ug->parent) && (ug->parent->state == UG_STATE_PENDING_DESTROY)) {
679 if ((ug->parent->children) && (g_slist_length(ug->parent->children) == 1)) {
680 _WRN("pended parent ug(%p) destroy job is added to loop", ug->parent);
681 ugman_idler_add((Idle_Cb)ugman_ug_destroy, ug->parent);
683 _WRN("pended parent ug(%p) will be destroyed after another children is destroyed", ug->parent);
687 _DBG("ug parent(%p) state(%d)", ug->parent, ug->parent->state);
689 _WRN("ug parent is null");
692 if (ug != ug_man.root)
695 if (ug->mode == UG_MODE_FULLVIEW) {
696 if (ug_man.fv_top == ug) {
698 if (!ug_man.destroy_all)
699 ugman_ug_getopt(ug_man.fv_top);
705 _DBG("free ug(%p)", ug);
708 if (ug_man.root == ug)
711 ugman_tree_dump(ug_man.root);
718 static void ug_hide_end_cb(void *data)
720 ui_gadget_h ug = data;
722 _WRN("child ug is still destroying. parent ug(%p) will be destroyed later", ug);
723 ug->state = UG_STATE_PENDING_DESTROY;
725 ugman_idler_add((Idle_Cb)ugman_ug_destroy, (void *)ug);
729 static int ugman_ug_create(void *data)
731 ui_gadget_h ug = data;
732 struct ug_module_ops *ops = NULL;
734 struct ug_engine_ops *eng_ops = NULL;
735 void *conformant = NULL;
738 if (!ug || ug->state != UG_STATE_READY) {
739 _ERR("ug(%p) input param error", ug);
743 ug->state = UG_STATE_CREATED;
746 ops = &ug->module->ops;
749 eng_ops = &ug_man.engine->ops;
751 if (ops && ops->create) {
752 ug->layout = ops->create(ug, ug->mode, ug->app_control, ops->priv);
754 _ERR("ug(%p) layout is null", ug);
757 if (ug->mode == UG_MODE_FULLVIEW) {
758 if (eng_ops && eng_ops->create) {
759 conformant = eng_ops->create(ug_man.win, ug, ugman_ug_start);
761 _ERR("conformant(%p) error. ug(%p) destory cb is invoked.",
763 ops->destroy(ug, ug->app_control, ops->priv);
770 if (cbs && cbs->layout_cb)
771 cbs->layout_cb(ug, ug->mode, cbs->priv);
773 _DBG("after caller layout cb call");
774 ugman_indicator_update(ug->opt, UG_EVENT_NONE);
777 if (ug_man.last_rotate_evt == UG_EVENT_NONE) {
779 ug_man.last_rotate_evt = __ug_x_rotation_get(ug_man.disp, ug_man.win_id);
781 ug_man.last_rotate_evt = __ug_evas_rotation_get((Evas_Object *)ug_man.win);
784 ugman_ug_event(ug, ug_man.last_rotate_evt);
786 if (ug->mode == UG_MODE_FRAMEVIEW)
789 ugman_tree_dump(ug_man.root);
791 #ifdef ENABLE_UG_CREATE_CB
793 ui_gadget_h parent = ug->parent;
795 _DBG("invoke trace create cb(%p)", g_create_cb);
797 g_create_cb((char *)ug->name,
798 ug->module ? (char *)ug->module->addr : NULL,
799 parent ? (char *)parent->name : NULL,
800 g_create_cb_user_data);
808 static ui_gadget_h ugman_root_ug_create(void)
812 ug = calloc(1, sizeof(struct ui_gadget_s));
814 _ERR("ug root create failed: Memory allocation failed");
818 ug->mode = UG_MODE_FULLVIEW;
819 ug->state = UG_STATE_RUNNING;
825 int ugman_ug_add(ui_gadget_h parent, ui_gadget_h ug)
827 if (!ug_man.is_initted) {
828 _ERR("failed: manager is not initialized");
834 _ERR("failed: parent has to be NULL w/o root");
839 ug_man.root = ugman_root_ug_create();
841 _ERR("failed : ug root create fail");
844 ug_man.root->opt = ug_man.base_opt;
845 ug_man.root->layout = ug_man.win;
846 ug_fvlist_add(ug_man.root);
850 parent = ug_man.root;
852 switch (parent->state) {
853 case UG_STATE_DESTROYING:
854 case UG_STATE_PENDING_DESTROY:
855 case UG_STATE_DESTROYED:
856 _WRN("parent(%p) state(%d) error", parent, parent->state);
862 if (ug_relation_add(parent, ug)) {
863 _ERR("failed : ug_relation_add fail");
867 if (ugman_ug_create(ug) == -1) {
868 _ERR("failed : ugman_ug_create fail");
872 if (ug->mode == UG_MODE_FULLVIEW)
878 ui_gadget_h ugman_ug_load(ui_gadget_h parent,
881 app_control_h app_control, struct ug_cbs *cbs)
886 ug = calloc(1, sizeof(struct ui_gadget_s));
888 _ERR("ug_create() failed: Memory allocation failed");
892 ug->module = ug_module_load(name);
894 _ERR("ug_create() failed: Module loading failed");
898 ug->name = strdup(name);
901 app_control_clone(&ug->app_control, app_control);
902 ug->opt = ug->module->ops.opt;
903 ug->state = UG_STATE_READY;
907 memcpy(&ug->cbs, cbs, sizeof(struct ug_cbs));
909 r = ugman_ug_add(parent, ug);
911 _ERR("ugman ug add failed");
922 int ugman_ug_destroying(ui_gadget_h ug)
924 struct ug_module_ops *ops = NULL;
926 _DBG("ugman_ug_destroying start ug(%p)", ug);
928 if (!ug || !ugman_ug_exist(ug)) {
929 _ERR("ugman_ug_destroying failed: Invalid ug");
935 case UG_STATE_DESTROYING:
936 case UG_STATE_PENDING_DESTROY:
937 case UG_STATE_DESTROYED:
938 _WRN("ug(%p) state(%d) is already on destroying", ug, ug->state);
945 ug->state = UG_STATE_DESTROYING;
948 ops = &ug->module->ops;
950 if (ops && ops->destroying)
951 ops->destroying(ug, ug->app_control, ops->priv);
956 int ugman_ug_del(ui_gadget_h ug)
958 struct ug_engine_ops *eng_ops = NULL;
960 _DBG("ugman_ug_del start ug(%p)", ug);
962 if (!ug || !ugman_ug_exist(ug)) {
963 _ERR("ugman_ug_del failed: Invalid ug");
969 case UG_STATE_DESTROYING:
970 case UG_STATE_PENDING_DESTROY:
971 case UG_STATE_DESTROYED:
972 _WRN("ug(%p) state(%d) is already on destroying", ug, ug->state);
978 if (ug->destroy_me) {
979 _WRN("ugman_ug_del failed: ug is alreay on destroying");
983 if (!ug_man.is_initted) {
984 _WRN("ugman_ug_del failed: manager is not initialized");
989 _ERR("ugman_ug_del failed: no root");
994 GSList *child, *trail;
996 child = ug->children;
997 _DBG("ugman_ug_del ug(%p) has child(%p)", ug, child->data);
999 trail = g_slist_next(child);
1000 ugman_ug_del(child->data);
1005 ugman_ug_destroying(ug);
1007 /* pre call for indicator update time issue */
1008 bool is_update = false;
1009 ui_gadget_h t = NULL;
1010 if (ug_man.fv_top == ug) {
1012 t = g_slist_nth_data(ug_man.fv_list, 1);
1016 child = g_slist_last(ug->children);
1017 if (ug_man.fv_top == (ui_gadget_h)child->data) {
1019 t = g_slist_nth_data(ug_man.fv_list,
1020 g_slist_index(ug_man.fv_list, (gconstpointer)ug) + 1);
1025 if ((is_update) && (t))
1029 eng_ops = &ug_man.engine->ops;
1031 if (ug->mode == UG_MODE_FULLVIEW) {
1032 if (eng_ops && eng_ops->destroy)
1033 eng_ops->destroy(ug, ug_man.fv_top, ug_hide_end_cb);
1035 ugman_idler_add((Idle_Cb)ugman_ug_destroy, ug);
1037 _DBG("ug(%p) mode is frameview", ug);
1041 _DBG("ugman_ug_del(%p) end", ug);
1047 int ugman_ug_del_child(ui_gadget_h ug)
1049 GSList *child, *trail;
1052 child = ug->children;
1053 _DBG("ug destroy all. ug(%p) has child(%p)", ug, child->data);
1055 trail = g_slist_next(child);
1056 ugman_ug_del_child(child->data);
1061 ugman_ug_destroy(ug);
1066 static void ugman_ug_unset_content(void)
1068 struct ug_engine_ops *eng_ops = NULL;
1070 if (ug_man.engine) {
1071 eng_ops = &ug_man.engine->ops;
1073 _WRN("ui engine is not loaded");
1077 if (eng_ops && eng_ops->create)
1078 eng_ops->request(ug_man.win, NULL, UG_UI_REQ_UNSET_CONTENT);
1080 _WRN("ui engine is not loaded");
1085 int ugman_ug_del_all(void)
1088 if (!ug_man.is_initted) {
1089 _ERR("ugman_ug_del_all failed: manager is not initialized");
1094 _ERR("ugman_ug_del_all failed: no root");
1098 _DBG("ug_del_all. root(%p) walking(%d) ", ug_man.root, ug_man.walking);
1100 if (ug_man.walking > 0) {
1101 ug_man.destroy_all = 1;
1103 ugman_ug_unset_content();
1104 ugman_ug_del_child(ug_man.root);
1111 int ugman_init(Display *disp, Window xid, void *win, enum ug_option opt)
1115 ug_man.win_id = xid;
1116 ug_man.base_opt = opt;
1117 ug_man.last_rotate_evt = UG_EVENT_NONE;
1119 if (!ug_man.is_initted)
1120 ug_man.engine = ug_engine_load();
1122 ug_man.is_initted = 1;
1127 int ugman_init(void *win, enum ug_option opt)
1130 ug_man.base_opt = opt;
1131 ug_man.last_rotate_evt = UG_EVENT_NONE;
1133 if (!ug_man.is_initted)
1134 ug_man.engine = ug_engine_load();
1136 ug_man.is_initted = 1;
1142 int ugman_init_efl(Evas_Object *win, enum ug_option opt)
1145 Ecore_X_Window xwin = elm_win_xwindow_get(win);
1147 return ugman_init((Display *)ecore_x_display_get(), xwin, win, opt);
1149 return ugman_init(win, opt);
1154 int ugman_resume(void)
1157 if (!ug_man.is_initted) {
1158 _ERR("ugman_resume failed: manager is not initialized");
1163 _WRN("ugman_resume failed: no root");
1167 if (ug_man.destroy_all == 1) {
1168 _WRN("ugman_resume skip : app is termanating with ug_destory_all");
1172 _DBG("ugman_resume called");
1174 ugman_idler_add((Idle_Cb)ugman_ug_resume, ug_man.root);
1179 int ugman_resume_ug(ui_gadget_h ug)
1181 if (!ug_man.is_initted) {
1182 _ERR("ugman_pause_ug failed: manager is not initialized");
1186 if (!ug_man.root || !ug) {
1187 _WRN("ugman_pause_ug failed: no root");
1191 _DBG("ugman_resume_ug called");
1193 ugman_idler_add((Idle_Cb)ugman_ug_resume, ug);
1198 int ugman_pause(void)
1200 /* PAUSE (Background) */
1201 if (!ug_man.is_initted) {
1202 _ERR("ugman_pause failed: manager is not initialized");
1207 _WRN("ugman_pause failed: no root");
1211 if (ug_man.destroy_all == 1) {
1212 _WRN("ugman_pause skip : app is termanating with ug_destory_all");
1216 _DBG("ugman_pause called");
1218 ugman_idler_add((Idle_Cb)ugman_ug_pause, ug_man.root);
1223 int ugman_pause_ug(ui_gadget_h ug)
1225 if (!ug_man.is_initted) {
1226 _ERR("ugman_pause_ug failed: manager is not initialized");
1230 if (!ug_man.root || !ug) {
1231 _WRN("ugman_pause_ug failed: no root");
1235 _DBG("ugman_pause_ug called");
1237 ugman_idler_add((Idle_Cb)ugman_ug_pause, ug);
1242 static int ugman_send_event_pre(void *data)
1246 ugman_ug_event(ug_man.root, (enum ug_event)data);
1253 int ugman_send_event(enum ug_event event)
1255 int is_rotation = 1;
1257 /* Propagate event */
1258 if (!ug_man.is_initted) {
1259 _ERR("ugman_send_event failed: manager is not initialized");
1264 _WRN("ugman_send_event failed: no root");
1268 /* In case of rotation, indicator state has to be updated */
1270 case UG_EVENT_ROTATE_PORTRAIT:
1271 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
1272 ug_man.last_rotate_evt = event;
1273 ug_man.is_landscape = 0;
1275 case UG_EVENT_ROTATE_LANDSCAPE:
1276 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
1277 ug_man.last_rotate_evt = event;
1278 ug_man.is_landscape = 1;
1284 ugman_idler_add((Idle_Cb)ugman_send_event_pre, (void *)event);
1286 if (is_rotation && ug_man.fv_top)
1287 ugman_indicator_update(ug_man.fv_top->opt, event);
1292 static int ugman_send_key_event_to_ug(ui_gadget_h ug,
1293 enum ug_key_event event)
1295 struct ug_module_ops *ops = NULL;
1301 ops = &ug->module->ops;
1305 if (ops && ops->key_event)
1306 ops->key_event(ug, event, ug->app_control, ops->priv);
1311 int ugman_send_key_event(enum ug_key_event event)
1313 if (!ug_man.is_initted) {
1314 _ERR("ugman_send_key_event failed: manager is not initialized");
1318 if (!ug_man.fv_top || !ugman_ug_exist(ug_man.fv_top)
1319 || ug_man.fv_top->state == UG_STATE_DESTROYED) {
1320 _ERR("ugman_send_key_event failed: full view top UG is invalid");
1324 return ugman_send_key_event_to_ug(ug_man.fv_top, event);
1327 int ugman_send_message(ui_gadget_h ug, app_control_h msg)
1329 struct ug_module_ops *ops = NULL;
1330 if (!ug || !ugman_ug_exist(ug) || ug->state == UG_STATE_DESTROYED) {
1331 _ERR("ugman_send_message failed: Invalid ug(%p)", ug);
1337 _ERR("ugman_send_message failed: Invalid msg");
1343 ops = &ug->module->ops;
1345 if (ops && ops->message)
1346 ops->message(ug, msg, ug->app_control, ops->priv);
1351 void *ugman_get_window(void)
1356 void *ugman_get_conformant(void)
1358 struct ug_engine_ops *eng_ops = NULL;
1361 if (ug_man.engine) {
1362 eng_ops = &ug_man.engine->ops;
1364 _WRN("ui engine is not loaded");
1368 if (eng_ops && eng_ops->create)
1369 ret = eng_ops->request(ug_man.win, NULL, UG_UI_REQ_GET_CONFORMANT);
1371 _WRN("ui engine is not loaded");
1376 static inline void job_start(void)
1381 static inline void job_end(void)
1385 if (!ug_man.walking && ug_man.destroy_all) {
1386 ug_man.destroy_all = 0;
1388 _DBG("ug_destroy_all pneding job exist. ug_destroy_all begin");
1393 if (ug_man.walking < 0)
1397 int ugman_ug_exist(ui_gadget_h ug)
1399 return ugman_ug_find(ug_man.root, ug);
1402 #ifdef ENABLE_UG_CREATE_CB
1403 int ugman_create_cb(void (*create_cb)(char *, char *, char *, void *), void *user_data)
1405 if (create_cb == NULL) {
1406 _DBG("disable trace create cb");
1407 g_create_cb_user_data = NULL;
1410 _DBG("enable trace create cb(%p)", create_cb);
1411 g_create_cb_user_data = user_data;
1412 g_create_cb = create_cb;