Update focus chain handling code.
authorSung-jae Park <nicesj.park@samsung.com>
Thu, 31 Oct 2013 03:01:37 +0000 (12:01 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Thu, 31 Oct 2013 03:01:37 +0000 (12:01 +0900)
Change-Id: I9c2b29b90671fe8c8baba64ba68d9402300ad504

packaging/liblivebox-edje.spec
src/script_port.c

index eb68f95..4cfc2da 100644 (file)
@@ -1,6 +1,6 @@
 Name: liblivebox-edje
 Summary: EDJE Script loader for the data provider master
-Version: 0.5.21
+Version: 0.5.22
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
index 101014a..1be41ea 100644 (file)
@@ -82,8 +82,10 @@ struct info {
        int is_mouse_down;
 
        Evas *e;
+       Evas_Object *parent;
 
        Eina_List *obj_list;
+       Eina_List *access_chain;
 };
 
 struct child {
@@ -95,7 +97,6 @@ struct obj_info {
        char *id;
        Eina_List *children;
        Evas_Object *parent;
-       Eina_List *access_chain;
 };
 
 static struct {
@@ -142,26 +143,6 @@ static inline Evas_Object *find_edje(struct info *handle, const char *id)
        return NULL;
 }
 
-static inline void rebuild_focus_chain(Evas_Object *obj)
-{
-       struct obj_info *obj_info;
-       Evas_Object *ao;
-       Eina_List *l;
-
-       obj_info = evas_object_data_get(obj, "obj_info");
-       if (!obj_info) {
-               ErrPrint("Object info is not available\n");
-               return;
-       }
-
-       elm_object_focus_custom_chain_unset(obj);
-
-       EINA_LIST_FOREACH(obj_info->access_chain, l, ao) {
-               DbgPrint("Append %p\n", ao);
-               elm_object_focus_custom_chain_append(obj, ao, NULL);
-       }
-}
-
 PUBLIC const char *script_magic_id(void)
 {
        return "edje";
@@ -247,7 +228,7 @@ PUBLIC int script_update_text(void *h, Evas *e, const char *id, const char *part
        struct obj_info *obj_info;
        struct info *handle = h;
        Evas_Object *edje;
-       Evas_Object *to;
+       Evas_Object *edje_part;
 
        edje = find_edje(handle, id);
        if (!edje) {
@@ -263,33 +244,34 @@ PUBLIC int script_update_text(void *h, Evas *e, const char *id, const char *part
 
        elm_object_part_text_set(edje, part, text ? text : "");
 
-       to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
-       if (to) {
+       edje_part = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
+       if (edje_part) {
                Evas_Object *ao;
                char *utf8;
 
-               ao = evas_object_data_get(to, "ao");
+               ao = evas_object_data_get(edje_part, "ao");
                if (!ao) {
-                       ao = elm_access_object_register(to, edje);
+                       ao = elm_access_object_register(edje_part, handle->parent);
                        if (!ao) {
                                ErrPrint("Unable to add ao: %s\n", part);
                                goto out;
                        }
-                       obj_info->access_chain = eina_list_append(obj_info->access_chain, ao);
-                       evas_object_data_set(to, "ao", ao);
-                       evas_object_data_set(ao, "edje", edje);
+                       handle->access_chain = eina_list_append(handle->access_chain, edje_part);
+                       (void)evas_object_data_set(edje_part, "ao", ao);
+                       (void)evas_object_data_set(ao, "edje", edje);
                        elm_access_activate_cb_set(ao, activate_cb, NULL);
-                       elm_object_focus_custom_chain_append(edje, ao, NULL);
+                       elm_object_focus_custom_chain_append(handle->parent, ao, NULL);
+
+                       DbgPrint("[%s] Register access info: (%s) to, %p\n", part, text, handle->parent);
                }
 
                if (!text || !strlen(text)) {
-                       obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
-                       evas_object_data_del(to, "ao");
-                       evas_object_data_del(ao, "edje");
+                       handle->access_chain = eina_list_remove(handle->access_chain, edje_part);
+                       (void)evas_object_data_del(edje_part, "ao");
+                       (void)evas_object_data_del(ao, "edje");
                        elm_access_object_unregister(ao);
                        DbgPrint("[%s] Remove access object\n", part);
 
-                       rebuild_focus_chain(edje);
                        goto out;
                }
 
@@ -297,13 +279,12 @@ PUBLIC int script_update_text(void *h, Evas *e, const char *id, const char *part
                if ((!utf8 || !strlen(utf8))) {
                        free(utf8);
 
-                       obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
-                       evas_object_data_del(to, "ao");
-                       evas_object_data_del(ao, "edje");
+                       handle->access_chain = eina_list_remove(handle->access_chain, edje_part);
+                       (void)evas_object_data_del(edje_part, "ao");
+                       (void)evas_object_data_del(ao, "edje");
                        elm_access_object_unregister(ao);
                        DbgPrint("[%s] Remove access object\n", part);
 
-                       rebuild_focus_chain(edje);
                        goto out;
                }
 
@@ -545,7 +526,7 @@ PUBLIC int script_update_access(void *_h, Evas *e, const char *id, const char *p
        struct info *handle = _h;
        Evas_Object *edje;
        struct obj_info *obj_info;
-       Evas_Object *to;
+       Evas_Object *edje_part;
 
        edje = find_edje(handle, id);
        if (!edje) {
@@ -559,35 +540,34 @@ PUBLIC int script_update_access(void *_h, Evas *e, const char *id, const char *p
                return LB_STATUS_ERROR_FAULT;
        }
 
-       to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
-       if (to) {
+       edje_part = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
+       if (edje_part) {
                Evas_Object *ao;
 
-               ao = evas_object_data_get(to, "ao");
+               ao = evas_object_data_get(edje_part, "ao");
                if (ao) {
                        if (text && strlen(text)) {
                                elm_access_info_set(ao, ELM_ACCESS_INFO, text);
+                               DbgPrint("Access info is updated: [%s]\n", text);
                        } else {
-                               obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
-                               evas_object_data_del(to, "ao");
-                               evas_object_data_del(ao, "edje");
+                               handle->access_chain = eina_list_remove(handle->access_chain, edje_part);
+                               (void)evas_object_data_del(edje_part, "ao");
+                               (void)evas_object_data_del(ao, "edje");
                                elm_access_object_unregister(ao);
                                DbgPrint("Successfully unregistered\n");
-
-                               rebuild_focus_chain(edje);
                        }
                } else if (text && strlen(text)) {
-                       ao = elm_access_object_register(to, edje);
+                       ao = elm_access_object_register(edje_part, handle->parent);
                        if (!ao) {
-                               ErrPrint("Unable to register access object\n");
+                               ErrPrint("Unable to register an access object\n");
                        } else {
                                elm_access_info_set(ao, ELM_ACCESS_INFO, text);
-                               obj_info->access_chain = eina_list_append(obj_info->access_chain, ao);
-                               evas_object_data_set(to, "ao", ao);
-                               elm_object_focus_custom_chain_append(edje, ao, NULL);
-                               DbgPrint("[%s] Register access info: (%s)\n", part, text);
+                               handle->access_chain = eina_list_append(handle->access_chain, edje_part);
+                               evas_object_data_set(edje_part, "ao", ao);
                                evas_object_data_set(ao, "edje", edje);
+                               elm_object_focus_custom_chain_append(handle->parent, ao, NULL);
                                elm_access_activate_cb_set(ao, activate_cb, NULL);
+                               DbgPrint("[%s] Register access info: (%s) to, %p\n", part, text, handle->parent);
                        }
                }
        } else {
@@ -626,19 +606,19 @@ PUBLIC int script_operate_access(void *_h, Evas *e, const char *id, const char *
        /* OPERATION is defined in liblivebox package */
        if (!strcasecmp(operation, "set,hl")) {
                if (part) {
-                       Evas_Object *to;
+                       Evas_Object *edje_part;
                        Evas_Coord x;
                        Evas_Coord y;
                        Evas_Coord w;
                        Evas_Coord h;
 
-                       to = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
-                       if (!to) {
+                       edje_part = (Evas_Object *)edje_object_part_object_get(elm_layout_edje_get(edje), part);
+                       if (!edje_part) {
                                ErrPrint("Invalid part: %s\n", part);
                                goto out;
                        }
 
-                       evas_object_geometry_get(to, &x, &y, &w, &h);
+                       evas_object_geometry_get(edje_part, &x, &y, &w, &h);
 
                        action_info.x = x + w / 2;
                        action_info.y = x + h / 2;
@@ -729,14 +709,12 @@ PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *pa
                DbgPrint("delete object %s %p\n", part, img);
                ao = evas_object_data_del(img, "ao");
                if (ao) {
-                       obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
-                       evas_object_data_del(ao, "edje");
+                       handle->access_chain = eina_list_remove(handle->access_chain, img);
+                       (void)evas_object_data_del(ao, "edje");
                        elm_access_object_unregister(ao);
                        DbgPrint("Successfully unregistered\n");
                }
                evas_object_del(img);
-
-               rebuild_focus_chain(edje);
        }
 
        if (!path || !strlen(path) || access(path, R_OK) != 0) {
@@ -976,6 +954,7 @@ PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *pa
        }
 
        if (img_opt.shadow.enabled) {
+               /*
                ea_effect_h *ea_effect;
 
                ea_effect = ea_image_effect_create();
@@ -993,6 +972,7 @@ PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *pa
 
                        ea_image_effect_destroy(ea_effect);
                }
+               */
        }
 
        /*!
@@ -1050,7 +1030,11 @@ static void edje_del_cb(void *_info, Evas *e, Evas_Object *obj, void *event_info
        struct obj_info *obj_info;
        struct obj_info *parent_obj_info;
        struct child *child;
+       Eina_List *l;
+       Eina_List *n;
        Evas_Object *ao;
+       Evas_Object *edje_part;
+       Evas_Object *edje;
 
        handle->obj_list = eina_list_remove(handle->obj_list, obj);
 
@@ -1089,16 +1073,14 @@ static void edje_del_cb(void *_info, Evas *e, Evas_Object *obj, void *event_info
 
        elm_object_signal_callback_del(obj, "*", "*", script_signal_cb);
 
-       elm_object_focus_custom_chain_unset(obj);
-
        EINA_LIST_FREE(obj_info->children, child) {
                DbgPrint("delete object %s %p\n", child->part, child->obj);
                if (child->obj) {
-                       Evas_Object *ao;
                        ao = evas_object_data_del(child->obj, "ao");
                        if (ao) {
-                               obj_info->access_chain = eina_list_remove(obj_info->access_chain, ao);
-                               evas_object_data_del(ao, "edje");
+                               /* Accesssibility is enhanced object */
+                               handle->access_chain = eina_list_remove(handle->access_chain, child->obj);
+                               (void)evas_object_data_del(child->obj, "ao");
                                elm_access_object_unregister(ao);
                        }
                        evas_object_del(child->obj);
@@ -1107,9 +1089,24 @@ static void edje_del_cb(void *_info, Evas *e, Evas_Object *obj, void *event_info
                free(child);
        }
 
-       EINA_LIST_FREE(obj_info->access_chain, ao) {
-               evas_object_data_del(ao, "edje");
-               elm_access_object_unregister(ao);
+       EINA_LIST_FOREACH_SAFE(handle->access_chain, l, n, edje_part) {
+               ao = evas_object_data_get(edje_part, "ao");
+               if (ao) {
+                       edje = evas_object_data_get(ao, "edje");
+               } else {
+                       edje = evas_object_data_get(edje_part, "edje");
+               }
+
+               if (edje == obj) {
+                       if (ao) {
+                               (void)evas_object_data_del(edje_part, "ao");
+                               (void)evas_object_data_del(ao, "edje");
+                               elm_access_object_unregister(ao);
+                       } else {
+                               (void)evas_object_data_del(edje_part, "edje");
+                               elm_access_object_unregister(edje_part);
+                       }
+               }
        }
 
        free(obj_info->id);
@@ -1447,6 +1444,7 @@ PUBLIC int script_update_script(void *h, Evas *e, const char *src_id, const char
 
        obj_info = evas_object_data_get(edje, "obj_info");
        obj_info->children = eina_list_append(obj_info->children, child);
+
        return LB_STATUS_SUCCESS;
 }
 
@@ -1621,6 +1619,7 @@ PUBLIC int script_load(void *_handle, Evas *e, int w, int h)
        handle->e = e;
        handle->w = w;
        handle->h = h;
+       handle->parent = edje;
 
        elm_object_signal_callback_add(edje, "*", "*", script_signal_cb, handle);
        evas_object_event_callback_add(edje, EVAS_CALLBACK_DEL, edje_del_cb, handle);