summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJiwoong Im <jiwoong.im@samsung.com>2016-11-29 16:08:49 +0900
committerJiwoong Im <jiwoong.im@samsung.com>2017-04-26 11:35:47 +0900
commit660cad6d9c412c0e3ce785e4e9fe329363d8d249 (patch)
tree2aa05a4028a6161f17d95d8b6f5901248d6ed9ee /src
parent27d7d92aff7278392e1b28a3eec4fde4046a9960 (diff)
downloadui-gadget-1-660cad6d9c412c0e3ce785e4e9fe329363d8d249.tar.gz
ui-gadget-1-660cad6d9c412c0e3ce785e4e9fe329363d8d249.tar.bz2
ui-gadget-1-660cad6d9c412c0e3ce785e4e9fe329363d8d249.zip
modify sources about diff with tizen_2.4
- add execption handling codes remove unnecessary codes modify codes related with "transition,finished" in ug-efl-engine add indicator update codes Change-Id: I9e1baacc7fb962cf0b4bd0488163c10777bc4394 Signed-off-by: Jiwoong Im <jiwoong.im@samsung.com>
Diffstat (limited to 'src')
-rw-r--r--src/manager.c330
1 files changed, 282 insertions, 48 deletions
diff --git a/src/manager.c b/src/manager.c
index 0a1a336..e10935e 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -30,6 +30,8 @@
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <Ecore_X.h>
+#else
+#include <Ecore_Wayland.h>
#endif
#include <Ecore.h>
@@ -62,8 +64,6 @@ struct ug_manager {
Display *disp;
#endif
- void *conform;
-
enum ug_option base_opt;
enum ug_event last_rotate_evt;
@@ -297,6 +297,31 @@ static void ugman_tree_dump(ui_gadget_h ug)
}
}
+static int ugman_ug_free(ui_gadget_h ug)
+{
+ if (!ug) {
+ _ERR("ug free failed: Invalid ug");
+ errno = EINVAL;
+ return -1;
+ }
+
+ if (ug->module)
+ ug_module_unload(ug->module);
+
+ if (ug->name) {
+ free((void *)ug->name);
+ ug->name = NULL;
+ }
+ if (ug->app_control) {
+ app_control_destroy(ug->app_control);
+ ug->app_control = NULL;
+ }
+ free(ug);
+ ug = NULL;
+ return 0;
+}
+
+
static int ugman_ug_find(ui_gadget_h p, ui_gadget_h ug)
{
GSList *child = NULL;
@@ -348,12 +373,32 @@ static int ugman_ug_pause(void *data)
struct ug_module_ops *ops = NULL;
GSList *child = NULL;
+ if (!ug_man.is_initted) {
+ _ERR("ugman_pause failed: manager is not initted");
+ return -1;
+ }
+
+ if (!ug_man.root) {
+ _WRN("ugman_pause failed: no root");
+ return -1;
+ }
+
+ if (ug_man.destroy_all == 1) {
+ _WRN("ugman_pause skipped : app is termanating with ug_destory_all");
+ return -1;
+ }
+
+ if ((data != ug_man.root) && (!ugman_ug_find(ug_man.root, data))) {
+ _WRN("ugman_pause skipped : invalid ug(%p)", data);
+ return -1;
+ }
+
job_start();
- if (!ug || ug->state != UG_STATE_RUNNING)
+ if (!ug) {
+ _WRN("ug pointer is null");
goto end;
-
- ug->state = UG_STATE_STOPPED;
+ }
if (ug->children) {
child = ug->children;
@@ -363,11 +408,21 @@ static int ugman_ug_pause(void *data)
}
}
+ if (ug->state != UG_STATE_RUNNING) {
+ if (ug != ug_man.root)
+ _WRN("ug(%p)->state : %d", ug, ug->state);
+ goto end;
+ }
+
if (ug->module)
ops = &ug->module->ops;
- if (ops && ops->pause)
+ if (ops && ops->pause) {
+ _DBG("call ug(%p) pause cb", ug);
ops->pause(ug, ug->app_control, ops->priv);
+ }
+
+ ug->state = UG_STATE_STOPPED;
end:
job_end();
@@ -380,12 +435,45 @@ static int ugman_ug_resume(void *data)
struct ug_module_ops *ops = NULL;
GSList *child = NULL;
+ if (!ug_man.is_initted) {
+ _ERR("ugman_resume failed: manager is not initted");
+ return -1;
+ }
+
+ if (!ug_man.root) {
+ _WRN("ugman_resume failed: no root");
+ return -1;
+ }
+
+ if (ug_man.destroy_all == 1) {
+ _WRN("ugman_resume skipped : app is termanating with ug_destory_all");
+ return -1;
+ }
+
+ if ((data != ug_man.root) && (!ugman_ug_find(ug_man.root, data))) {
+ _WRN("ugman_resume skipped : invalid ug(%p)", data);
+ return -1;
+ }
+
job_start();
- if (!ug)
+ if (!ug) {
+ _WRN("ug pointer is null");
goto end;
+ }
+
+ if (ug->children) {
+ child = ug->children;
+ while (child) {
+ ugman_ug_resume(child->data);
+ child = g_slist_next(child);
+ }
+ }
- _DBG("ug(%p)->state : %d", ug, ug->state);
+ if (ug->state != UG_STATE_STOPPED) {
+ if (ug != ug_man.root)
+ _WRN("ug(%p)->state : %d", ug, ug->state);
+ }
switch (ug->state) {
case UG_STATE_CREATED:
@@ -397,31 +485,100 @@ static int ugman_ug_resume(void *data)
goto end;
}
- ug->state = UG_STATE_RUNNING;
-
- if (ug->children) {
- child = ug->children;
- while (child) {
- ugman_ug_resume(child->data);
- child = g_slist_next(child);
- }
- }
-
if (ug->module)
ops = &ug->module->ops;
- if (ops && ops->resume)
+ if (ops && ops->resume) {
+ _DBG("call ug(%p) resume cb", ug);
ops->resume(ug, ug->app_control, ops->priv);
+ }
+
+ ug->state = UG_STATE_RUNNING;
end:
job_end();
return 0;
}
+#ifdef UG_WAYLAND
+static void _ugman_enable_indicator(Evas_Object *win, int enable)
+{
+ Ecore_Wl_Window *wlwin = elm_win_wl_window_get(win);
+
+ if (enable == 1)
+ ecore_wl_window_indicator_state_set(wlwin, ECORE_WL_INDICATOR_STATE_ON);
+ else
+ ecore_wl_window_indicator_state_set(wlwin, ECORE_WL_INDICATOR_STATE_OFF);
+}
+
+static int _ugman_get_indicator_state(Evas_Object *win)
+{
+ Ecore_Wl_Window *wlwin = elm_win_wl_window_get(win);
+ Ecore_Wl_Indicator_State state;
+ int ret;
+
+ state = ecore_wl_window_indicator_state_get(wlwin);
+ if (state == ECORE_WL_INDICATOR_STATE_OFF)
+ ret = 0;
+ else if (state == ECORE_WL_INDICATOR_STATE_ON)
+ ret = 1;
+ else
+ ret = -1;
+
+ return ret;
+}
+#endif
+
static int ugman_indicator_update(enum ug_option opt, enum ug_event event)
{
+#ifndef UG_WAYLAND
_ERR("controlling indicator is disabled");
+#else
+ int enable;
+ int cur_state;
+
+ cur_state = _ugman_get_indicator_state(ug_man.win);
+
+ _DBG("indicator update opt(%d) cur_state(%d)", opt, cur_state);
+
+ switch (opt) {
+#ifndef ENABLE_UG_HANDLE_INDICATOR_HIDE
+ case UG_OPT_INDICATOR_ENABLE:
+ case UG_OPT_INDICATOR_PORTRAIT_ONLY:
+ case UG_OPT_INDICATOR_LANDSCAPE_ONLY:
+ case UG_OPT_INDICATOR_DISABLE:
+ enable = 1;
+ break;
+#else
+ case UG_OPT_INDICATOR_ENABLE:
+ if (event == UG_EVENT_NONE)
+ enable = 1;
+ else
+ enable = cur_state ? 1 : 0;
+ break;
+ case UG_OPT_INDICATOR_PORTRAIT_ONLY:
+ enable = ug_man.is_landscape ? 0 : 1;
+ break;
+ case UG_OPT_INDICATOR_LANDSCAPE_ONLY:
+ enable = ug_man.is_landscape ? 1 : 0;
+ break;
+ case UG_OPT_INDICATOR_DISABLE:
+ enable = 0;
+ break;
+#endif
+ case UG_OPT_INDICATOR_MANUAL:
+ return 0;
+ default:
+ _ERR("update failed: Invalid opt(%d)", opt);
+ return -1;
+ }
+ if (cur_state != enable) {
+ _DBG("set indicator status as %d", enable);
+ _ugman_enable_indicator(ug_man.win, enable);
+ }
+
+#endif
return 0;
}
@@ -526,6 +683,11 @@ static int ugman_ug_destroy(void *data)
} else {
_WRN("pended parent ug(%p) will be destroyed after another children is destroyed", ug->parent);
}
+ } else {
+ if (ug->parent)
+ _DBG("ug parent(%p) state(%d)", ug->parent, ug->parent->state);
+ else
+ _WRN("ug parent is null");
}
if (ug != ug_man.root)
@@ -542,7 +704,7 @@ static int ugman_ug_destroy(void *data)
}
_DBG("free ug(%p)", ug);
- ug_free(ug);
+ ugman_ug_free(ug);
if (ug_man.root == ug)
ug_man.root = NULL;
@@ -571,9 +733,11 @@ static int ugman_ug_create(void *data)
struct ug_module_ops *ops = NULL;
struct ug_cbs *cbs;
struct ug_engine_ops *eng_ops = NULL;
+ void *conformant = NULL;
+
if (!ug || ug->state != UG_STATE_READY) {
- _ERR("ug(%p) input param error");
+ _ERR("ug(%p) input param error", ug);
return -1;
}
@@ -588,15 +752,18 @@ static int ugman_ug_create(void *data)
if (ops && ops->create) {
ug->layout = ops->create(ug, ug->mode, ug->app_control, ops->priv);
if (!ug->layout) {
- ug_relation_del(ug);
_ERR("ug(%p) layout is null", ug);
return -1;
}
if (ug->mode == UG_MODE_FULLVIEW) {
if (eng_ops && eng_ops->create) {
- ug_man.conform = eng_ops->create(ug_man.win, ug, ugman_ug_start);
- if (!ug_man.conform)
+ conformant = eng_ops->create(ug_man.win, ug, ugman_ug_start);
+ if (!conformant) {
+ _ERR("conformant(%p) error. ug(%p) destory cb is invoked.",
+ conformant, ug);
+ ops->destroy(ug, ug->app_control, ops->priv);
return -1;
+ }
}
}
cbs = &ug->cbs;
@@ -639,10 +806,27 @@ static int ugman_ug_create(void *data)
return 0;
}
+static ui_gadget_h ugman_root_ug_create(void)
+{
+ ui_gadget_h ug;
+
+ ug = calloc(1, sizeof(struct ui_gadget_s));
+ if (!ug) {
+ _ERR("ug root create failed: Memory allocation failed");
+ return NULL;
+ }
+
+ ug->mode = UG_MODE_FULLVIEW;
+ ug->state = UG_STATE_RUNNING;
+ ug->children = NULL;
+
+ return ug;
+}
+
int ugman_ug_add(ui_gadget_h parent, ui_gadget_h ug)
{
if (!ug_man.is_initted) {
- _ERR("failed: manager is not initted");
+ _ERR("failed: manager is not initialized");
return -1;
}
@@ -653,7 +837,7 @@ int ugman_ug_add(ui_gadget_h parent, ui_gadget_h ug)
return -1;
}
- ug_man.root = ug_root_create();
+ ug_man.root = ugman_root_ug_create();
if (!ug_man.root) {
_ERR("failed : ug root create fail");
return -1;
@@ -683,6 +867,7 @@ int ugman_ug_add(ui_gadget_h parent, ui_gadget_h ug)
if (ugman_ug_create(ug) == -1) {
_ERR("failed : ugman_ug_create fail");
+ ug_relation_del(ug);
return -1;
}
if (ug->mode == UG_MODE_FULLVIEW)
@@ -724,14 +909,14 @@ ui_gadget_h ugman_ug_load(ui_gadget_h parent,
r = ugman_ug_add(parent, ug);
if (r) {
- _ERR("ug_create() failed: Tree update failed");
+ _ERR("ugman ug add failed");
goto load_fail;
}
return ug;
load_fail:
- ug_free(ug);
+ ugman_ug_free(ug);
return NULL;
}
@@ -739,7 +924,23 @@ int ugman_ug_destroying(ui_gadget_h ug)
{
struct ug_module_ops *ops = NULL;
- _DBG("ugman_ug_destroying");
+ _DBG("ugman_ug_destroying start ug(%p)", ug);
+
+ if (!ug || !ugman_ug_exist(ug)) {
+ _ERR("ugman_ug_destroying failed: Invalid ug(%p)");
+ errno = EINVAL;
+ return -1;
+ }
+
+ switch (ug->state) {
+ case UG_STATE_DESTROYING:
+ case UG_STATE_PENDING_DESTROY:
+ case UG_STATE_DESTROYED:
+ _WRN("ug(%p) state(%d) is already on destroying", ug, ug->state);
+ return 0;
+ default:
+ break;
+ }
ug->destroy_me = 1;
ug->state = UG_STATE_DESTROYING;
@@ -757,13 +958,23 @@ int ugman_ug_del(ui_gadget_h ug)
{
struct ug_engine_ops *eng_ops = NULL;
- if (!ug || !ugman_ug_exist(ug) || ug->state == UG_STATE_DESTROYED) {
+ _DBG("ugman_ug_del start ug(%p)", ug);
+
+ if (!ug || !ugman_ug_exist(ug)) {
_ERR("ugman_ug_del failed: Invalid ug(%p)");
errno = EINVAL;
return -1;
}
- _DBG("ugman_ug_del start ug(%p)", ug);
+ switch (ug->state) {
+ case UG_STATE_DESTROYING:
+ case UG_STATE_PENDING_DESTROY:
+ case UG_STATE_DESTROYED:
+ _WRN("ug(%p) state(%d) is already on destroying", ug, ug->state);
+ return 0;
+ default:
+ break;
+ }
if (ug->destroy_me) {
_WRN("ugman_ug_del failed: ug is alreay on destroying");
@@ -771,7 +982,7 @@ int ugman_ug_del(ui_gadget_h ug)
}
if (!ug_man.is_initted) {
- _WRN("ugman_ug_del failed: manager is not initted");
+ _WRN("ugman_ug_del failed: manager is not initialized");
return -1;
}
@@ -853,11 +1064,30 @@ int ugman_ug_del_child(ui_gadget_h ug)
return 0;
}
+static void ugman_ug_unset_content(void)
+{
+ struct ug_engine_ops *eng_ops = NULL;
+
+ if (ug_man.engine) {
+ eng_ops = &ug_man.engine->ops;
+ } else {
+ _WRN("ui engine is not loaded");
+ return;
+ }
+
+ if (eng_ops && eng_ops->create)
+ eng_ops->request(ug_man.win, NULL, UG_UI_REQ_UNSET_CONTENT);
+ else
+ _WRN("ui engine is not loaded");
+
+ return;
+}
+
int ugman_ug_del_all(void)
{
/* Terminate */
if (!ug_man.is_initted) {
- _ERR("ugman_ug_del_all failed: manager is not initted");
+ _ERR("ugman_ug_del_all failed: manager is not initialized");
return -1;
}
@@ -868,10 +1098,12 @@ int ugman_ug_del_all(void)
_DBG("ug_del_all. root(%p) walking(%d) ", ug_man.root, ug_man.walking);
- if (ug_man.walking > 0)
+ if (ug_man.walking > 0) {
ug_man.destroy_all = 1;
- else
+ } else {
+ ugman_ug_unset_content();
ugman_ug_del_child(ug_man.root);
+ }
return 0;
}
@@ -924,7 +1156,7 @@ int ugman_resume(void)
{
/* RESUME */
if (!ug_man.is_initted) {
- _ERR("ugman_resume failed: manager is not initted");
+ _ERR("ugman_resume failed: manager is not initialized");
return -1;
}
@@ -933,6 +1165,11 @@ int ugman_resume(void)
return -1;
}
+ if (ug_man.destroy_all == 1) {
+ _WRN("ugman_resume skip : app is termanating with ug_destory_all");
+ return 0;
+ }
+
_DBG("ugman_resume called");
ugman_idler_add((Idle_Cb)ugman_ug_resume, ug_man.root);
@@ -963,7 +1200,7 @@ int ugman_pause(void)
{
/* PAUSE (Background) */
if (!ug_man.is_initted) {
- _ERR("ugman_pause failed: manager is not initted");
+ _ERR("ugman_pause failed: manager is not initialized");
return -1;
}
@@ -972,6 +1209,11 @@ int ugman_pause(void)
return -1;
}
+ if (ug_man.destroy_all == 1) {
+ _WRN("ugman_pause skip : app is termanating with ug_destory_all");
+ return 0;
+ }
+
_DBG("ugman_pause called");
ugman_idler_add((Idle_Cb)ugman_ug_pause, ug_man.root);
@@ -1015,7 +1257,7 @@ int ugman_send_event(enum ug_event event)
/* Propagate event */
if (!ug_man.is_initted) {
- _ERR("ugman_send_event failed: manager is not initted");
+ _ERR("ugman_send_event failed: manager is not initialized");
return -1;
}
@@ -1063,8 +1305,6 @@ static int ugman_send_key_event_to_ug(ui_gadget_h ug,
if (ops && ops->key_event)
ops->key_event(ug, event, ug->app_control, ops->priv);
- else
- return -1;
return 0;
}
@@ -1072,7 +1312,7 @@ static int ugman_send_key_event_to_ug(ui_gadget_h ug,
int ugman_send_key_event(enum ug_key_event event)
{
if (!ug_man.is_initted) {
- _ERR("ugman_send_key_event failed: manager is not initted");
+ _ERR("ugman_send_key_event failed: manager is not initialized");
return -1;
}
@@ -1089,7 +1329,7 @@ int ugman_send_message(ui_gadget_h ug, app_control_h msg)
{
struct ug_module_ops *ops = NULL;
if (!ug || !ugman_ug_exist(ug) || ug->state == UG_STATE_DESTROYED) {
- _ERR("ugman_send_message failed: Invalid ug");
+ _ERR("ugman_send_message failed: Invalid ug(%p)", ug);
errno = EINVAL;
return -1;
}
@@ -1119,11 +1359,6 @@ void *ugman_get_conformant(void)
struct ug_engine_ops *eng_ops = NULL;
void* ret = NULL;
- if (ug_man.conform) {
- _DBG("return cached conform(%p) info", ug_man.conform);
- return ug_man.conform;
- }
-
if (ug_man.engine) {
eng_ops = &ug_man.engine->ops;
} else {
@@ -1133,7 +1368,6 @@ void *ugman_get_conformant(void)
if (eng_ops && eng_ops->create) {
ret = eng_ops->request(ug_man.win, NULL, UG_UI_REQ_GET_CONFORMANT);
- ug_man.conform = ret;
} else {
_WRN("ui engine is not loaded");
}