diff options
author | Sung-jae Park <nicesj.park@samsung.com> | 2013-10-22 12:48:43 +0900 |
---|---|---|
committer | Sung-jae Park <nicesj.park@samsung.com> | 2013-10-22 12:48:43 +0900 |
commit | aa9bf4455e98aead8a4db5f99d431e8b7ab28d29 (patch) | |
tree | f24540183a75676eae64f3d52a4df13e18d54b79 | |
parent | e8b8c9e87fc13c7b3f09b3175e8a9e9c5aa86c39 (diff) | |
parent | b607ed3450b16d6af94808a61c84242b2bc2699e (diff) | |
download | livebox-edje-accepted/tizen/ivi/release.tar.gz livebox-edje-accepted/tizen/ivi/release.tar.bz2 livebox-edje-accepted/tizen/ivi/release.zip |
Merge branch 'tizen_2.2' of ssh://review.tizendev.org:29418/apps/livebox/livebox-edje into worksubmit/tizen/20131022.040045accepted/tizen/20131112.015354accepted/tizen/20131028.165912accepted/tizen/20131022.083652accepted/tizen/ivi/release
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | include/debug.h | 16 | ||||
-rw-r--r-- | include/script_port.h | 3 | ||||
-rw-r--r-- | packaging/liblivebox-edje.spec | 9 | ||||
-rw-r--r-- | src/script_port.c | 544 |
5 files changed, 427 insertions, 146 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7120572..a96a48f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ ADD_DEFINITIONS("-DPACKAGE=\"${PROJECT_NAME}\"") ADD_DEFINITIONS("${EXTRA_CFLAGS} -g -Wall") ADD_DEFINITIONS("-DNDEBUG") +ADD_DEFINITIONS("-D_USE_ECORE_TIME_GET") ADD_DEFINITIONS("-DLOG_TAG=\"LIVEBOX_EDJE\"") ADD_LIBRARY(${PROJECT_NAME} SHARED diff --git a/include/debug.h b/include/debug.h index 5904b4c..9a20ef4 100644 --- a/include/debug.h +++ b/include/debug.h @@ -14,6 +14,18 @@ * limitations under the License. */ -#define DbgPrint(format, arg...) LOGD("[[32m%s/%s[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg) -#define ErrPrint(format, arg...) LOGE("[[32m%s/%s[0m:%d] " format, basename(__FILE__), __func__, __LINE__, ##arg) +#if !defined(SECURE_LOGD) +#define SECURE_LOGD LOGD +#endif + +#if !defined(SECURE_LOGE) +#define SECURE_LOGE LOGE +#endif + +#if !defined(SECURE_LOGW) +#define SECURE_LOGW LOGW +#endif + +#define DbgPrint(format, arg...) SECURE_LOGD(format, ##arg) +#define ErrPrint(format, arg...) SECURE_LOGE(format, ##arg) /* End of a file */ diff --git a/include/script_port.h b/include/script_port.h index 221b020..b5e821a 100644 --- a/include/script_port.h +++ b/include/script_port.h @@ -29,6 +29,7 @@ extern int script_update_color(void *h, Evas *e, const char *id, const char *par extern int script_update_text(void *h, Evas *e, const char *id, const char *part, const char *text); extern int script_update_image(void *h, Evas *e, const char *id, const char *part, const char *path, const char *option); extern int script_update_access(void *h, Evas *e, const char *id, const char *part, const char *text, const char *option); +extern int script_operate_access(void *_h, Evas *e, const char *id, const char *part, const char *operation, const char *option); extern int script_update_script(void *h, Evas *e, const char *src_id, const char *target_id, const char *part, const char *path, const char *group); extern int script_update_signal(void *h, Evas *e, const char *id, const char *part, const char *signal); extern int script_update_drag(void *h, Evas *e, const char *id, const char *part, double x, double y); @@ -51,7 +52,7 @@ extern int script_unload(void *handle, Evas *e); */ extern int script_feed_event(void *h, Evas *e, int event_type, int x, int y, int down, double timestamp); -extern int script_init(void); +extern int script_init(double scale); extern int script_fini(void); extern const char *script_magic_id(void); diff --git a/packaging/liblivebox-edje.spec b/packaging/liblivebox-edje.spec index 8ef9f35..29d4621 100644 --- a/packaging/liblivebox-edje.spec +++ b/packaging/liblivebox-edje.spec @@ -1,6 +1,6 @@ Name: liblivebox-edje Summary: EDJE Script loader for the data provider master -Version: 0.5.5 +Version: 0.5.20 Release: 1 Group: HomeTF/Livebox License: Flora License @@ -25,7 +25,12 @@ Plugin for the data provider master to load the edje scripts %setup -q %build -cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} +%if 0%{?tizen_build_binary_release_type_eng} +export CFLAGS="${CFLAGS} -DTIZEN_ENGINEER_MODE" +export CXXFLAGS="${CXXFLAGS} -DTIZEN_ENGINEER_MODE" +export FFLAGS="${FFLAGS} -DTIZEN_ENGINEER_MODE" +%endif +%cmake . make %{?jobs:-j%jobs} %install diff --git a/src/script_port.c b/src/script_port.c index 1c2de06..8c6f675 100644 --- a/src/script_port.c +++ b/src/script_port.c @@ -41,7 +41,6 @@ #define TEXT_CLASS "tizen" #define DEFAULT_FONT_SIZE -100 -#define BASE_WIDTH 720.0f #define PUBLIC __attribute__((visibility("default"))) @@ -51,7 +50,7 @@ struct image_option { enum { FILL_DISABLE, FILL_IN_SIZE, - FILL_OVER_SIZE, + FILL_OVER_SIZE } fill; int width; @@ -65,6 +64,8 @@ struct info { int w; int h; + int is_mouse_down; + Evas *e; Eina_List *obj_list; @@ -85,18 +86,14 @@ struct obj_info { static struct { char *font_name; int font_size; + + Eina_List *handle_list; } s_info = { .font_name = NULL, .font_size = -100, -}; -static inline double scale_get(void) -{ - int width; - int height; - ecore_x_window_size_get(0, &width, &height); - return (double)width / BASE_WIDTH; -} + .handle_list = NULL, +}; static inline Evas_Object *find_edje(struct info *handle, const char *id) { @@ -112,16 +109,18 @@ static inline Evas_Object *find_edje(struct info *handle, const char *id) } if (!id) { - if (!obj_info->id) + if (!obj_info->id) { return edje; + } continue; } else if (!obj_info->id) { continue; } - if (!strcmp(obj_info->id, id)) + if (!strcmp(obj_info->id, id)) { return edje; + } } DbgPrint("EDJE[%s] is not found\n", id); @@ -142,12 +141,10 @@ static inline void rebuild_focus_chain(Evas_Object *obj) elm_object_focus_custom_chain_unset(obj); - DbgPrint("Rebuild focus chain begin\n"); EINA_LIST_FOREACH(obj_info->access_chain, l, ao) { DbgPrint("Append %p\n", ao); elm_object_focus_custom_chain_append(obj, ao, NULL); } - DbgPrint("Rebuild focus chain done\n"); } PUBLIC const char *script_magic_id(void) @@ -163,8 +160,9 @@ PUBLIC int script_update_color(void *h, Evas *e, const char *id, const char *par int ret; edje = find_edje(handle, id); - if (!edje) + if (!edje) { return LB_STATUS_ERROR_NOT_EXIST; + } ret = sscanf(rgba, "%d %d %d %d %d %d %d %d %d %d %d %d", r, g, b, a, /* OBJECT */ @@ -193,34 +191,40 @@ static void activate_cb(void *data, Evas_Object *part_obj, Elm_Object_Item *item int y; int w; int h; - struct timeval tv; double timestamp; ao = evas_object_data_get(part_obj, "ao"); - if (!ao) + if (!ao) { return; + } edje = evas_object_data_get(ao, "edje"); - if (!edje) + if (!edje) { return; + } e = evas_object_evas_get(part_obj); evas_object_geometry_get(part_obj, &x, &y, &w, &h); x += w / 2; y += h / 2; +#if defined(_USE_ECORE_TIME_GET) + timestamp = ecore_time_get(); +#else + struct timeval tv; if (gettimeofday(&tv, NULL) < 0) { ErrPrint("Failed to get time\n"); timestamp = 0.0f; } else { timestamp = (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0f); } +#endif DbgPrint("Cursor is on %dx%d\n", x, y); - evas_event_feed_mouse_move(e, x, y, timestamp, NULL); - evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL); - evas_event_feed_mouse_move(e, x, y, timestamp + 0.02f, NULL); - evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.03f, NULL); + evas_event_feed_mouse_move(e, x, y, timestamp * 1000, NULL); + evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, (timestamp + 0.01f) * 1000, NULL); + evas_event_feed_mouse_move(e, x, y, (timestamp + 0.02f) * 1000, NULL); + evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, (timestamp + 0.03f) * 1000, NULL); } PUBLIC int script_update_text(void *h, Evas *e, const char *id, const char *part, const char *text) @@ -289,7 +293,6 @@ PUBLIC int script_update_text(void *h, Evas *e, const char *id, const char *part } elm_access_info_set(ao, ELM_ACCESS_INFO, utf8); - DbgPrint("[%s] Update access object (%s)\n", part, utf8); free(utf8); } else { ErrPrint("Unable to get text part[%s]\n", part); @@ -306,8 +309,9 @@ static void parse_aspect(struct image_option *img_opt, const char *value, int le len--; } - if (len < 4) + if (len < 4) { return; + } img_opt->aspect = !strncasecmp(value, "true", 4); DbgPrint("Parsed ASPECT: %d (%s)\n", img_opt->aspect, value); @@ -320,8 +324,9 @@ static void parse_orient(struct image_option *img_opt, const char *value, int le len--; } - if (len < 4) + if (len < 4) { return; + } img_opt->orient = !strncasecmp(value, "true", 4); DbgPrint("Parsed ORIENT: %d (%s)\n", img_opt->orient, value); @@ -362,12 +367,13 @@ static void parse_fill(struct image_option *img_opt, const char *value, int len) len--; } - if (!strncasecmp(value, "in-size", len)) + if (!strncasecmp(value, "in-size", len)) { img_opt->fill = FILL_IN_SIZE; - else if (!strncasecmp(value, "over-size", len)) + } else if (!strncasecmp(value, "over-size", len)) { img_opt->fill = FILL_OVER_SIZE; - else + } else { img_opt->fill = FILL_DISABLE; + } DbgPrint("Parsed FILL: %d (%s)\n", img_opt->fill, value); } @@ -404,13 +410,14 @@ static inline void parse_image_option(const char *option, struct image_option *i STATE_DATA, STATE_IGNORE, STATE_ERROR, - STATE_END, + STATE_END } state; int idx; int tag; - if (!option || !*option) + if (!option || !*option) { return; + } state = STATE_START; /*! @@ -484,10 +491,11 @@ static inline void parse_image_option(const char *option, struct image_option *i } break; case STATE_ERROR: - if (*ptr == ';') + if (*ptr == ';') { state = STATE_START; - else if (*ptr == '\0') + } else if (*ptr == '\0') { state = STATE_END; + } break; default: break; @@ -520,7 +528,6 @@ PUBLIC int script_update_access(void *_h, Evas *e, const char *id, const char *p ao = evas_object_data_get(to, "ao"); if (ao) { - DbgPrint("[%s] Update access object (%s)\n", part, text); if (text && strlen(text)) { elm_access_info_set(ao, ELM_ACCESS_INFO, text); } else { @@ -553,6 +560,86 @@ PUBLIC int script_update_access(void *_h, Evas *e, const char *id, const char *p return LB_STATUS_SUCCESS; } +PUBLIC int script_operate_access(void *_h, Evas *e, const char *id, const char *part, const char *operation, const char *option) +{ + struct info *handle = _h; + Evas_Object *edje; + struct obj_info *obj_info; + Elm_Access_Action_Info action_info; + int ret; + + if (!operation || !strlen(operation)) { + return LB_STATUS_ERROR_INVALID; + } + + edje = find_edje(handle, id); + if (!edje) { + ErrPrint("No such object: %s\n", id); + return LB_STATUS_ERROR_NOT_EXIST; + } + + obj_info = evas_object_data_get(edje, "obj_info"); + if (!obj_info) { + ErrPrint("Object info is not available\n"); + return LB_STATUS_ERROR_FAULT; + } + + memset(&action_info, 0, sizeof(action_info)); + + /* OPERATION is defined in liblivebox package */ + if (!strcasecmp(operation, "set,hl")) { + if (part) { + Evas_Object *to; + 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) { + ErrPrint("Invalid part: %s\n", part); + goto out; + } + + evas_object_geometry_get(to, &x, &y, &w, &h); + + action_info.x = x + w / 2; + action_info.y = x + h / 2; + } else if (option && sscanf(option, "%dx%d", &action_info.x, &action_info.y) == 2) { + } else { + ErrPrint("Insufficient info for HL\n"); + goto out; + } + + DbgPrint("TXxTY: %dx%d\n", action_info.x, action_info.y); + ret = elm_access_action(edje, ELM_ACCESS_ACTION_HIGHLIGHT, &action_info); + if (ret == EINA_FALSE) { + ErrPrint("Action error\n"); + } + } else if (!strcasecmp(operation, "unset,hl")) { + ret = elm_access_action(edje, ELM_ACCESS_ACTION_UNHIGHLIGHT, &action_info); + if (ret == EINA_FALSE) { + ErrPrint("Action error\n"); + } + } else if (!strcasecmp(operation, "next,hl")) { + action_info.highlight_cycle = (!!option) && (!!strcasecmp(option, "no,cycle")); + + ret = elm_access_action(edje, ELM_ACCESS_ACTION_HIGHLIGHT_NEXT, &action_info); + if (ret == EINA_FALSE) { + ErrPrint("Action error\n"); + } + } else if (!strcasecmp(operation, "prev,hl")) { + action_info.highlight_cycle = EINA_TRUE; + ret = elm_access_action(edje, ELM_ACCESS_ACTION_HIGHLIGHT_PREV, &action_info); + if (ret == EINA_FALSE) { + ErrPrint("Action error\n"); + } + } + +out: + return LB_STATUS_SUCCESS; +} + PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *part, const char *path, const char *option) { struct info *handle = _h; @@ -589,8 +676,9 @@ PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *pa Evas_Object *ao; EINA_LIST_FOREACH_SAFE(obj_info->children, l, n, child) { - if (child->obj != img) + if (child->obj != img) { continue; + } obj_info->children = eina_list_remove(obj_info->children, child); free(child->part); @@ -658,8 +746,8 @@ PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *pa Evas_Coord part_h; if (img_opt.width >= 0 && img_opt.height >= 0) { - part_w = img_opt.width * scale_get(); - part_h = img_opt.height * scale_get(); + part_w = img_opt.width * elm_config_scale_get(); + part_h = img_opt.height * elm_config_scale_get(); } else { part_w = 0; part_h = 0; @@ -682,19 +770,127 @@ PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *pa w = (double)w * fh; } } - DbgPrint("Size: %dx%d\n", w, h); - evas_object_image_load_size_set(img, w, h); - evas_object_image_load_region_set(img, (w - part_w) / 2, (h - part_h) / 2, part_w, part_h); - evas_object_image_fill_set(img, 0, 0, part_w, part_h); - evas_object_image_reload(img); + if (!part_w || !part_h || !w || !h) { + evas_object_del(img); + free(child->part); + free(child); + return LB_STATUS_ERROR_INVALID; + } + + if (evas_object_image_region_support_get(img)) { + evas_object_image_load_region_set(img, (w - part_w) / 2, (h - part_h) / 2, part_w, part_h); + evas_object_image_load_size_set(img, part_w, part_h); + evas_object_image_filled_set(img, EINA_TRUE); + //evas_object_image_fill_set(img, 0, 0, part_w, part_h); + DbgPrint("Size: %dx%d (region: %dx%d - %dx%d)\n", w, h, (w - part_w) / 2, (h - part_h) / 2, part_w, part_h); + } else { + Ecore_Evas *ee; + Evas *e; + Evas_Object *src_img; + Evas_Coord rw, rh; + const void *data; + + DbgPrint("Part loading is not supported\n"); + ee = ecore_evas_buffer_new(part_w, part_h); + if (!ee) { + ErrPrint("Failed to create a EE\n"); + evas_object_del(img); + free(child->part); + free(child); + return LB_STATUS_ERROR_FAULT; + } + + ecore_evas_alpha_set(ee, EINA_TRUE); + + e = ecore_evas_get(ee); + if (!e) { + ErrPrint("Unable to get Evas\n"); + ecore_evas_free(ee); + + evas_object_del(img); + free(child->part); + free(child); + return LB_STATUS_ERROR_FAULT; + } + + src_img = evas_object_image_filled_add(e); + if (!src_img) { + ErrPrint("Unable to add an image\n"); + ecore_evas_free(ee); + + evas_object_del(img); + free(child->part); + free(child); + return LB_STATUS_ERROR_FAULT; + } + + evas_object_image_alpha_set(src_img, EINA_TRUE); + evas_object_image_colorspace_set(src_img, EVAS_COLORSPACE_ARGB8888); + evas_object_image_smooth_scale_set(src_img, EINA_TRUE); + evas_object_image_load_orientation_set(src_img, img_opt.orient); + evas_object_image_file_set(src_img, path, NULL); + err = evas_object_image_load_error_get(src_img); + if (err != EVAS_LOAD_ERROR_NONE) { + ErrPrint("Load error: %s\n", evas_load_error_str(err)); + evas_object_del(src_img); + ecore_evas_free(ee); + + evas_object_del(img); + free(child->part); + free(child); + return LB_STATUS_ERROR_IO; + } + evas_object_image_size_get(src_img, &rw, &rh); + evas_object_image_fill_set(src_img, 0, 0, rw, rh); + evas_object_resize(src_img, w, h); + evas_object_move(src_img, -(w - part_w) / 2, -(h - part_h) / 2); + evas_object_show(src_img); + + data = ecore_evas_buffer_pixels_get(ee); + if (!data) { + ErrPrint("Unable to get pixels\n"); + evas_object_del(src_img); + ecore_evas_free(ee); + + evas_object_del(img); + free(child->part); + free(child); + return LB_STATUS_ERROR_IO; + } + + e = evas_object_evas_get(img); + evas_object_del(img); + img = evas_object_image_filled_add(e); + if (!img) { + evas_object_del(src_img); + ecore_evas_free(ee); + + free(child->part); + free(child); + return LB_STATUS_ERROR_MEMORY; + } + + evas_object_image_colorspace_set(img, EVAS_COLORSPACE_ARGB8888); + evas_object_image_smooth_scale_set(img, EINA_TRUE); + evas_object_image_alpha_set(img, EINA_TRUE); + evas_object_image_data_set(img, NULL); + evas_object_image_size_set(img, part_w, part_h); + evas_object_resize(img, part_w, part_h); + evas_object_image_data_copy_set(img, (void *)data); + evas_object_image_fill_set(img, 0, 0, part_w, part_h); + evas_object_image_data_update_add(img, 0, 0, part_w, part_h); + + evas_object_del(src_img); + ecore_evas_free(ee); + } } else if (img_opt.fill == FILL_IN_SIZE) { Evas_Coord part_w; Evas_Coord part_h; if (img_opt.width >= 0 && img_opt.height >= 0) { - part_w = img_opt.width * scale_get(); - part_h = img_opt.height * scale_get(); + part_w = img_opt.width * elm_config_scale_get(); + part_h = img_opt.height * elm_config_scale_get(); } else { part_w = 0; part_h = 0; @@ -736,6 +932,7 @@ PUBLIC int script_update_image(void *_h, Evas *e, const char *id, const char *pa evas_object_image_fill_set(img, 0, 0, w, h); evas_object_size_hint_fill_set(img, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_size_hint_weight_set(img, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_image_filled_set(img, EINA_TRUE); } /*! @@ -784,7 +981,6 @@ static void script_signal_cb(void *data, Evas_Object *obj, const char *emission, ey = (double)(py + ph) / (double)h; } - DbgPrint("Signal emit: source[%s], emission[%s]\n", source, emission); script_signal_emit(handle->e, source, emission, sx, sy, ex, ey); } @@ -811,8 +1007,9 @@ static void edje_del_cb(void *_info, Evas *e, Evas_Object *obj, void *event_info Eina_List *n; EINA_LIST_FOREACH_SAFE(parent_obj_info->children, l, n, child) { - if (child->obj != obj) + if (child->obj != obj) { continue; + } /*! * \note @@ -859,6 +1056,17 @@ static void edje_del_cb(void *_info, Evas *e, Evas_Object *obj, void *event_info free(obj_info); } +static inline Evas_Object *get_highlighted_object(Evas_Object *obj) +{ + Evas_Object *o, *ho; + + o = evas_object_name_find(evas_object_evas_get(obj), "_elm_access_disp"); + if (!o) return NULL; + + ho = evas_object_data_get(o, "_elm_access_target"); + return ho; +} + /*! LB_ACCESS_HIGHLIGHT 0 LB_ACCESS_HIGHLIGHT_NEXT 1 @@ -874,8 +1082,6 @@ PUBLIC int script_feed_event(void *h, Evas *e, int event_type, int x, int y, int struct obj_info *obj_info; int ret = LB_STATUS_SUCCESS; - DbgPrint("event: %d, x: %d, y: %d\n", event_type, x, y); - edje = find_edje(handle, NULL); /*!< Get the base layout */ if (!edje) { ErrPrint("Base layout is not exist\n"); @@ -889,52 +1095,55 @@ PUBLIC int script_feed_event(void *h, Evas *e, int event_type, int x, int y, int } if (event_type & LB_SCRIPT_ACCESS_EVENT) { - Elm_Access_Action_Info *info; + Elm_Access_Action_Info info; Elm_Access_Action_Type action; - const Eina_List *chain; - - info = calloc(1, sizeof(*info)); - if (!info) { - ErrPrint("Error: %s\n", strerror(errno)); - return LB_STATUS_ERROR_MEMORY; - } - chain = elm_object_focus_custom_chain_get(edje); - DbgPrint("Focus chain : %d\n", eina_list_count(chain)); + memset(&info, 0, sizeof(info)); if ((event_type & LB_SCRIPT_ACCESS_HIGHLIGHT) == LB_SCRIPT_ACCESS_HIGHLIGHT) { action = ELM_ACCESS_ACTION_HIGHLIGHT; - info->x = x; - info->y = y; - ret = elm_access_action(edje, action, info); + info.x = x; + info.y = y; + ret = elm_access_action(edje, action, &info); DbgPrint("ACCESS_HIGHLIGHT: %dx%d returns %d\n", x, y, ret); - ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE; + if (ret == EINA_TRUE) { + if (!get_highlighted_object(edje)) { + ErrPrint("Highlighted object is not found\n"); + ret = LB_ACCESS_STATUS_ERROR; + } else { + DbgPrint("Highlighted object is found\n"); + ret = LB_ACCESS_STATUS_DONE; + } + } else { + ErrPrint("Action error\n"); + ret = LB_ACCESS_STATUS_ERROR; + } } else if ((event_type & LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT) == LB_SCRIPT_ACCESS_HIGHLIGHT_NEXT) { action = ELM_ACCESS_ACTION_HIGHLIGHT_NEXT; - info->highlight_cycle = EINA_FALSE; - ret = elm_access_action(edje, action, info); + info.highlight_cycle = EINA_FALSE; + ret = elm_access_action(edje, action, &info); DbgPrint("ACCESS_HIGHLIGHT_NEXT, returns %d\n", ret); ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_LAST : LB_ACCESS_STATUS_DONE; } else if ((event_type & LB_SCRIPT_ACCESS_HIGHLIGHT_PREV) == LB_SCRIPT_ACCESS_HIGHLIGHT_PREV) { action = ELM_ACCESS_ACTION_HIGHLIGHT_PREV; - info->highlight_cycle = EINA_FALSE; - ret = elm_access_action(edje, action, info); + info.highlight_cycle = EINA_FALSE; + ret = elm_access_action(edje, action, &info); DbgPrint("ACCESS_HIGHLIGHT_PREV, returns %d\n", ret); ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_FIRST : LB_ACCESS_STATUS_DONE; } else if ((event_type & LB_SCRIPT_ACCESS_ACTIVATE) == LB_SCRIPT_ACCESS_ACTIVATE) { action = ELM_ACCESS_ACTION_ACTIVATE; - ret = elm_access_action(edje, action, info); + ret = elm_access_action(edje, action, &info); DbgPrint("ACCESS_ACTIVATE, returns %d\n", ret); ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE; } else if ((event_type & LB_SCRIPT_ACCESS_ACTION) == LB_SCRIPT_ACCESS_ACTION) { if (down == 0) { action = ELM_ACCESS_ACTION_UP; - ret = elm_access_action(edje, action, info); + ret = elm_access_action(edje, action, &info); DbgPrint("ACCESS_ACTION(%d), returns %d\n", down, ret); ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE; } else if (down == 1) { action = ELM_ACCESS_ACTION_DOWN; - ret = elm_access_action(edje, action, info); + ret = elm_access_action(edje, action, &info); DbgPrint("ACCESS_ACTION(%d), returns %d\n", down, ret); ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE; } else { @@ -943,24 +1152,24 @@ PUBLIC int script_feed_event(void *h, Evas *e, int event_type, int x, int y, int } } else if ((event_type & LB_SCRIPT_ACCESS_SCROLL) == LB_SCRIPT_ACCESS_SCROLL) { action = ELM_ACCESS_ACTION_SCROLL; - info->x = x; - info->y = y; + info.x = x; + info.y = y; switch (down) { case 0: - info->mouse_type = 0; - ret = elm_access_action(edje, action, info); + info.mouse_type = 0; + ret = elm_access_action(edje, action, &info); DbgPrint("ACCESS_HIGHLIGHT_SCROLL, returns %d\n", ret); ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE; break; case -1: - info->mouse_type = 1; - ret = elm_access_action(edje, action, info); + info.mouse_type = 1; + ret = elm_access_action(edje, action, &info); DbgPrint("ACCESS_HIGHLIGHT_SCROLL, returns %d\n", ret); ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE; break; case 1: - info->mouse_type = 2; - ret = elm_access_action(edje, action, info); + info.mouse_type = 2; + ret = elm_access_action(edje, action, &info); DbgPrint("ACCESS_HIGHLIGHT_SCROLL, returns %d\n", ret); ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE; break; @@ -970,7 +1179,7 @@ PUBLIC int script_feed_event(void *h, Evas *e, int event_type, int x, int y, int } } else if ((event_type & LB_SCRIPT_ACCESS_UNHIGHLIGHT) == LB_SCRIPT_ACCESS_UNHIGHLIGHT) { action = ELM_ACCESS_ACTION_UNHIGHLIGHT; - ret = elm_access_action(edje, action, info); + ret = elm_access_action(edje, action, &info); DbgPrint("ACCESS_UNHIGHLIGHT, returns %d\n", ret); ret = (ret == EINA_FALSE) ? LB_ACCESS_STATUS_ERROR : LB_ACCESS_STATUS_DONE; } else { @@ -978,25 +1187,48 @@ PUBLIC int script_feed_event(void *h, Evas *e, int event_type, int x, int y, int ret = LB_ACCESS_STATUS_ERROR; } - free(info); } else if (event_type & LB_SCRIPT_MOUSE_EVENT) { + double cur_timestamp; + +#if defined(_USE_ECORE_TIME_GET) + cur_timestamp = ecore_time_get(); +#else + struct timeval tv; + if (gettimeofday(&tv, NULL) < 0) { + ErrPrint("Failed to get time\n"); + cur_timestamp = 0.0f; + } else { + cur_timestamp = (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0f); + } +#endif + if (cur_timestamp - timestamp > 0.1f && handle->is_mouse_down == 0) { + DbgPrint("Discard lazy event : %lf\n", cur_timestamp - timestamp); + return LB_STATUS_SUCCESS; + } + switch (event_type) { case LB_SCRIPT_MOUSE_DOWN: - evas_event_feed_mouse_move(e, x, y, timestamp, NULL); - evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, timestamp + 0.01f, NULL); + if (handle->is_mouse_down == 0) { + evas_event_feed_mouse_move(e, x, y, timestamp * 1000, NULL); + evas_event_feed_mouse_down(e, 1, EVAS_BUTTON_NONE, (timestamp + 0.01f) * 1000, NULL); + handle->is_mouse_down = 1; + } break; case LB_SCRIPT_MOUSE_MOVE: - evas_event_feed_mouse_move(e, x, y, timestamp, NULL); + evas_event_feed_mouse_move(e, x, y, timestamp * 1000, NULL); break; case LB_SCRIPT_MOUSE_UP: - evas_event_feed_mouse_move(e, x, y, timestamp, NULL); - evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, timestamp + 0.1f, NULL); + if (handle->is_mouse_down == 1) { + evas_event_feed_mouse_move(e, x, y, timestamp * 1000, NULL); + evas_event_feed_mouse_up(e, 1, EVAS_BUTTON_NONE, (timestamp + 0.01f) * 1000, NULL); + handle->is_mouse_down = 0; + } break; case LB_SCRIPT_MOUSE_IN: - evas_event_feed_mouse_in(e, timestamp, NULL); + evas_event_feed_mouse_in(e, timestamp * 1000, NULL); break; case LB_SCRIPT_MOUSE_OUT: - evas_event_feed_mouse_out(e, timestamp, NULL); + evas_event_feed_mouse_out(e, timestamp * 1000, NULL); break; default: return LB_STATUS_ERROR_INVALID; @@ -1018,11 +1250,9 @@ PUBLIC int script_update_script(void *h, Evas *e, const char *src_id, const char struct child *child; char _target_id[32]; - DbgPrint("src_id[%s] target_id[%s] part[%s] path[%s] group[%s]\n", src_id, target_id, part, path, group); - edje = find_edje(handle, src_id); if (!edje) { - ErrPrint("Edje is not exists\n"); + ErrPrint("Edje is not exists (%s)\n", src_id); return LB_STATUS_ERROR_NOT_EXIST; } @@ -1038,8 +1268,9 @@ PUBLIC int script_update_script(void *h, Evas *e, const char *src_id, const char Eina_List *n; EINA_LIST_FOREACH_SAFE(obj_info->children, l, n, child) { - if (child->obj != obj) + if (child->obj != obj) { continue; + } obj_info->children = eina_list_remove(obj_info->children, child); @@ -1065,15 +1296,19 @@ PUBLIC int script_update_script(void *h, Evas *e, const char *src_id, const char if (!target_id) { if (find_edje(handle, part)) { double timestamp; - struct timeval tv; do { +#if defined(_USE_ECORE_TIME_GET) + timestamp = ecore_time_get(); +#else + struct timeval tv; if (gettimeofday(&tv, NULL) < 0) { static int local_idx = 0; timestamp = (double)(local_idx++); } else { timestamp = (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0f); } +#endif snprintf(_target_id, sizeof(_target_id), "%lf", timestamp); } while (find_edje(handle, _target_id)); @@ -1092,13 +1327,12 @@ PUBLIC int script_update_script(void *h, Evas *e, const char *src_id, const char return LB_STATUS_ERROR_FAULT; } + edje_object_scale_set(elm_layout_edje_get(obj), elm_config_scale_get()); + if (!elm_layout_file_set(obj, path, group)) { int err; - const char *errmsg; - err = edje_object_load_error_get(elm_layout_edje_get(obj)); - errmsg = edje_load_error_str(err); - ErrPrint("Could not load %s from %s: %s\n", group, path, errmsg); + ErrPrint("Could not load %s from %s: %s\n", group, path, edje_load_error_str(err)); evas_object_del(obj); return LB_STATUS_ERROR_IO; } @@ -1161,11 +1395,10 @@ PUBLIC int script_update_signal(void *h, Evas *e, const char *id, const char *pa struct info *handle = h; Evas_Object *edje; - DbgPrint("id[%s], part[%s], signal[%s]\n", id, part, signal); - edje = find_edje(handle, id); - if (!edje) + if (!edje) { return LB_STATUS_ERROR_NOT_EXIST; + } elm_object_signal_emit(edje, signal, part); return LB_STATUS_SUCCESS; @@ -1176,11 +1409,10 @@ PUBLIC int script_update_drag(void *h, Evas *e, const char *id, const char *part struct info *handle = h; Evas_Object *edje; - DbgPrint("id[%s], part[%s], %lfx%lf\n", id, part, x, y); - edje = find_edje(handle, id); - if (!edje) + if (!edje) { return LB_STATUS_ERROR_NOT_EXIST; + } edje_object_part_drag_value_set(elm_layout_edje_get(edje), part, x, y); return LB_STATUS_SUCCESS; @@ -1192,8 +1424,9 @@ PUBLIC int script_update_size(void *han, Evas *e, const char *id, int w, int h) Evas_Object *edje; edje = find_edje(handle, id); - if (!edje) + if (!edje) { return LB_STATUS_ERROR_NOT_EXIST; + } if (!id) { handle->w = w; @@ -1209,15 +1442,14 @@ PUBLIC int script_update_category(void *h, Evas *e, const char *id, const char * { struct info *handle = h; - DbgPrint("id[%s], category[%s]\n", id, category); - if (handle->category) { free(handle->category); handle->category = NULL; } - if (!category) + if (!category) { return LB_STATUS_SUCCESS; + } handle->category = strdup(category); if (!handle->category) { @@ -1232,8 +1464,6 @@ PUBLIC void *script_create(const char *file, const char *group) { struct info *handle; - DbgPrint("file[%s], group[%s]\n", file, group); - handle = calloc(1, sizeof(*handle)); if (!handle) { ErrPrint("Error: %s\n", strerror(errno)); @@ -1255,6 +1485,8 @@ PUBLIC void *script_create(const char *file, const char *group) return NULL; } + s_info.handle_list = eina_list_append(s_info.handle_list, handle); + return handle; } @@ -1265,9 +1497,17 @@ PUBLIC int script_destroy(void *_handle) handle = _handle; + if (!eina_list_data_find(s_info.handle_list, handle)) { + DbgPrint("Not found (already deleted?)\n"); + return LB_STATUS_ERROR_NOT_EXIST; + } + + s_info.handle_list = eina_list_remove(s_info.handle_list, handle); + edje = eina_list_nth(handle->obj_list, 0); - if (edje) + if (edje) { evas_object_del(edje); + } free(handle->category); free(handle->file); @@ -1305,14 +1545,13 @@ PUBLIC int script_load(void *_handle, Evas *e, int w, int h) return LB_STATUS_ERROR_FAULT; } - DbgPrint("Load edje: %s - %s\n", handle->file, handle->group); + edje_object_scale_set(elm_layout_edje_get(edje), elm_config_scale_get()); + if (!elm_layout_file_set(edje, handle->file, handle->group)) { int err; - const char *errmsg; err = edje_object_load_error_get(elm_layout_edje_get(edje)); - errmsg = edje_load_error_str(err); - ErrPrint("Could not load %s from %s: %s\n", handle->group, handle->file, errmsg); + ErrPrint("Could not load %s from %s: %s\n", handle->group, handle->file, edje_load_error_str(err)); evas_object_del(edje); evas_object_del(obj_info->parent); free(obj_info); @@ -1343,14 +1582,14 @@ PUBLIC int script_unload(void *_handle, Evas *e) handle = _handle; - DbgPrint("Unload edje: %s - %s\n", handle->file, handle->group); edje = eina_list_nth(handle->obj_list, 0); if (edje) { struct obj_info *obj_info; obj_info = evas_object_data_get(edje, "obj_info"); - if (obj_info) + if (obj_info) { parent = obj_info->parent; + } evas_object_del(edje); } @@ -1390,22 +1629,33 @@ static void font_changed_cb(keynode_t *node, void *user_data) { char *font_name; - font_name = vconf_get_str("db/setting/accessibility/font_name"); - if (!font_name) { - ErrPrint("Invalid font name (NULL)\n"); - return; - } + if (s_info.font_name) { + font_name = vconf_get_str("db/setting/accessibility/font_name"); + if (!font_name) { + ErrPrint("Invalid font name (NULL)\n"); + return; + } - if (s_info.font_name && !strcmp(s_info.font_name, font_name)) { - DbgPrint("Font is not changed (Old: %s(%p) <> New: %s(%p))\n", s_info.font_name, s_info.font_name, font_name, font_name); - free(font_name); - return; - } + if (!strcmp(s_info.font_name, font_name)) { + DbgPrint("Font is not changed (Old: %s(%p) <> New: %s(%p))\n", s_info.font_name, s_info.font_name, font_name, font_name); + free(font_name); + return; + } - if (s_info.font_name) { DbgPrint("Release old font name: %s(%p)\n", s_info.font_name, s_info.font_name); free(s_info.font_name); - s_info.font_name = NULL; + } else { + int ret; + + /*! + * Get the first font name using system_settings API. + */ + font_name = NULL; + ret = system_settings_get_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, &font_name); + if (ret != SYSTEM_SETTINGS_ERROR_NONE || !font_name) { + ErrPrint("System setting get: %d, font_name[%p]\n", ret, font_name); + return; + } } s_info.font_name = font_name; @@ -1449,8 +1699,9 @@ static void font_size_cb(system_settings_key_e key, void *user_data) { int size; - if (system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &size) != SYSTEM_SETTINGS_ERROR_NONE) + if (system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &size) != SYSTEM_SETTINGS_ERROR_NONE) { return; + } size = convert_font_size(size); @@ -1463,23 +1714,21 @@ static void font_size_cb(system_settings_key_e key, void *user_data) DbgPrint("Font size is changed to %d, but don't update the font info\n", size); } -PUBLIC int script_init(void) +PUBLIC int script_init(double scale) { int ret; - int size = DEFAULT_FONT_SIZE; char *argv[] = { "livebox.edje", NULL, }; + /* ecore is already initialized */ elm_init(1, argv); - elm_config_scale_set(scale_get()); + elm_config_scale_set(scale); + DbgPrint("Scale is updated: %lf\n", scale); ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, access_cb, NULL); - if (ret < 0) - ErrPrint("Failed to access cb\n"); - - access_cb(NULL, NULL); + DbgPrint("TTS changed: %d\n", ret); ret = vconf_notify_key_changed("db/setting/accessibility/font_name", font_changed_cb, NULL); DbgPrint("System font is changed: %d\n", ret); @@ -1487,23 +1736,36 @@ PUBLIC int script_init(void) ret = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE, font_size_cb, NULL); DbgPrint("System font size is changed: %d\n", ret); - s_info.font_name = vconf_get_str("db/setting/accessibility/font_name"); - DbgPrint("Current font: %s\n", s_info.font_name); - - ret = system_settings_get_value_int(SYSTEM_SETTINGS_KEY_FONT_SIZE, &size); - s_info.font_size = convert_font_size(size); - DbgPrint("Current size: %d\n", s_info.font_size); - + access_cb(NULL, NULL); + font_changed_cb(NULL, NULL); + font_size_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE, NULL); return LB_STATUS_SUCCESS; } PUBLIC int script_fini(void) { int ret; + Eina_List *l; + Eina_List *n; + struct info *handle; + + EINA_LIST_FOREACH_SAFE(s_info.handle_list, l, n, handle) { + script_destroy(handle); + } + ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_SIZE); - ret = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_FONT_TYPE); + DbgPrint("Unset font size change event callback: %d\n", ret); + + ret = vconf_ignore_key_changed("db/setting/accessibility/font_name", font_changed_cb); + DbgPrint("Unset font name change event callback: %d\n", ret); + ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_ACCESSIBILITY_TTS, access_cb); + DbgPrint("Unset tts: %d\n", ret); + elm_shutdown(); + + free(s_info.font_name); + s_info.font_name = NULL; return LB_STATUS_SUCCESS; } |