diff options
author | jinwoo.shin <jw0227.shin@samsung.com> | 2015-07-17 18:35:10 +0900 |
---|---|---|
committer | jinwoo.shin <jw0227.shin@samsung.com> | 2015-07-17 19:18:13 +0900 |
commit | 316a7bbd83927bd357f765e0b83a9f87e79ae4e3 (patch) | |
tree | c98e5aea58a1ed474aa615ec64eb7a54968953f4 | |
parent | 3df30c5812af648c8cf4c33f6009a925d8a60df6 (diff) | |
download | air_livetv-316a7bbd83927bd357f765e0b83a9f87e79ae4e3.tar.gz air_livetv-316a7bbd83927bd357f765e0b83a9f87e79ae4e3.tar.bz2 air_livetv-316a7bbd83927bd357f765e0b83a9f87e79ae4e3.zip |
Change of global key event and focus handling
Change-Id: If902c7bf2462132e2c5fad4f36521d0029f8a87d
Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
-rw-r--r-- | src/layout_channelinfo.c | 2 | ||||
-rw-r--r-- | src/layout_channelinfo_search.c | 1 | ||||
-rw-r--r-- | src/main.c | 49 | ||||
-rw-r--r-- | src/view_channelinfo.c | 91 | ||||
-rw-r--r-- | src/view_channelnumber.c | 20 |
5 files changed, 95 insertions, 68 deletions
diff --git a/src/layout_channelinfo.c b/src/layout_channelinfo.c index 5cdb323..d74ce81 100644 --- a/src/layout_channelinfo.c +++ b/src/layout_channelinfo.c @@ -117,8 +117,6 @@ static void _show(void *layout_data) elm_object_content_set(priv->base, priv->layout); evas_object_show(priv->layout); - - elm_object_focus_allow_set(priv->base, EINA_TRUE); } static void _hide(void *layout_data) diff --git a/src/layout_channelinfo_search.c b/src/layout_channelinfo_search.c index bdaabae..0382a6f 100644 --- a/src/layout_channelinfo_search.c +++ b/src/layout_channelinfo_search.c @@ -61,6 +61,7 @@ static void _tune_channel(void *data) _ERR("failed to tune with service id"); viewmgr_hide_view(VIEW_CHANNELINFO); + viewmgr_show_view(VIEW_CHANNELINFO); } static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, @@ -32,6 +32,8 @@ SET_TAG(PACKAGE) struct _appdata { const char *name; Evas_Object *win; + Ecore_Event_Handler *key_down; + Ecore_Event_Handler *key_up; int is_signal; }; @@ -60,48 +62,58 @@ static struct key_map g_kmap[] = { }, }; -static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, - Evas_Event_Key_Down *ev) +static Eina_Bool _key_down_cb(void *data, int type, void *ei) { + Evas_Event_Key_Down *ev = ei; size_t i, j; + if (!strcmp(ev->keyname, KEY_ENTER) || + !strcmp(ev->keyname, KEY_ENTER_REMOTE)) { + if (viewmgr_active_view_count() > 0) + return ECORE_CALLBACK_PASS_ON; + } + for (i = 0; i < sizeof(g_kmap) / sizeof(*g_kmap); i++) { j = 0; while (g_kmap[i].key[j]) { if (!strcmp(ev->keyname, g_kmap[i].key[j])) { - viewmgr_show_view(g_kmap[i].view); viewmgr_update_view(g_kmap[i].view, UPDATE_TYPE_INPUT_KEY_DOWN, ev); - return; + viewmgr_show_view(g_kmap[i].view); + return ECORE_CALLBACK_DONE; } j++; } } + + return ECORE_CALLBACK_PASS_ON; } -static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj, - Evas_Event_Key_Up *ev) +static Eina_Bool _key_up_cb(void *data, int type, void *ei) { + Evas_Event_Key_Up *ev = ei; size_t i, j; + if (!strcmp(ev->keyname, KEY_ENTER) || + !strcmp(ev->keyname, KEY_ENTER_REMOTE)) { + if (viewmgr_active_view_count() > 0) + return ECORE_CALLBACK_PASS_ON; + } + for (i = 0; i < sizeof(g_kmap) / sizeof(*g_kmap); i++) { j = 0; while (g_kmap[i].key[j]) { if (!strcmp(ev->keyname, g_kmap[i].key[j])) { - viewmgr_show_view(g_kmap[i].view); viewmgr_update_view(g_kmap[i].view, UPDATE_TYPE_INPUT_KEY_UP, ev); - return; + return ECORE_CALLBACK_DONE; } j++; } } -} -static input_handler key_handler = { - .key_down = _key_down_cb, - .key_up = _key_up_cb, -}; + return ECORE_CALLBACK_PASS_ON; +} static Evas_Object *_add_win(const char *name) { @@ -248,7 +260,11 @@ static bool _create(void *data) ad->win = win; tv_signal_cb_set(_tv_signal_cb, ad); - inputmgr_add_callback(ad->win, 0, &key_handler, NULL); + ad->key_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, + _key_down_cb, NULL); + ad->key_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, + _key_up_cb, NULL); + return true; } @@ -266,7 +282,10 @@ static void _terminate(void *data) if (ad->win) { tv_destroy(); - inputmgr_remove_callback(ad->win, &key_handler); + if (ad->key_down) + ecore_event_handler_del(ad->key_down); + if (ad->key_up) + ecore_event_handler_del(ad->key_up); viewmgr_remove_view(VIEW_CHANNELINFO); viewmgr_remove_view(VIEW_CHANNELNUMBER); diff --git a/src/view_channelinfo.c b/src/view_channelinfo.c index 86618e7..c607039 100644 --- a/src/view_channelinfo.c +++ b/src/view_channelinfo.c @@ -44,18 +44,51 @@ struct _priv { layoutmgr *lmgr; }; -static void _update(void *view_data, int type, void *data); +static void _hide_current_layout(struct _priv *priv) +{ + if (!priv->current_layout) + return; -static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, - Evas_Event_Key_Down *ev) + layoutmgr_hide_layout(priv->lmgr, priv->current_layout); + priv->current_layout = NULL; +} + +static void _set_current_layout(struct _priv *priv, const char *layout_id) { - _update(data, UPDATE_TYPE_INPUT_KEY_DOWN, ev); + if (priv->current_layout && layout_id && + !strcmp(priv->current_layout, layout_id)) + return; + + if (priv->current_layout) + layoutmgr_hide_layout(priv->lmgr, priv->current_layout); + + layoutmgr_show_layout(priv->lmgr, layout_id); + priv->current_layout = layout_id; } -static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj, - Evas_Event_Key_Up *ev) +static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, + Evas_Event_Key_Down *ev) { - _update(data, UPDATE_TYPE_INPUT_KEY_UP, ev); + struct _priv *priv; + + if (!data) { + _ERR("failed to get data"); + return; + } + + priv = data; + + if (!strcmp(ev->keyname, KEY_ENTER) || + !strcmp(ev->keyname, KEY_ENTER_REMOTE)) { + _set_current_layout(priv, LAYOUT_CHANNELINFO_SEARCH); + } else if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE) || + !strcmp(ev->keyname, KEY_EXIT)) { + viewmgr_hide_view(VIEW_CHANNELINFO); + } else { + viewmgr_update_view(VIEW_CHANNELINFO, + UPDATE_TYPE_TIMER, START_HIDE_TIMER); + } } static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj, @@ -67,7 +100,6 @@ static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj, static input_handler key_handler = { .key_down = _key_down_cb, - .key_up = _key_up_cb, .mouse_move = _mouse_move_cb, }; @@ -275,28 +307,6 @@ void draw_channel_info(Evas_Object *obj, UPDATE_TYPE_TIMER, START_HIDE_TIMER); } -static void _hide_current_layout(struct _priv *priv) -{ - if (!priv->current_layout) - return; - - layoutmgr_hide_layout(priv->lmgr, priv->current_layout); - priv->current_layout = NULL; -} - -static void _set_current_layout(struct _priv *priv, const char *layout_id) -{ - if (priv->current_layout && layout_id && - !strcmp(priv->current_layout, layout_id)) - return; - - if (priv->current_layout) - layoutmgr_hide_layout(priv->lmgr, priv->current_layout); - - layoutmgr_show_layout(priv->lmgr, layout_id); - priv->current_layout = layout_id; -} - static Evas_Object *_create(Evas_Object *win, void *data) { struct _priv *priv; @@ -319,6 +329,7 @@ static Evas_Object *_create(Evas_Object *win, void *data) return NULL; } elm_layout_file_set(priv->base, EDJEFILE, GRP_VIEW_CHANNELINFO); + elm_object_focus_allow_set(priv->base, EINA_TRUE); evas_object_size_hint_weight_set(priv->base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); @@ -350,6 +361,10 @@ static void _show(void *view_data) priv = view_data; evas_object_show(priv->base); + elm_object_focus_set(priv->base, EINA_TRUE); + + if (!priv->current_layout) + _set_current_layout(priv, LAYOUT_CHANNELINFO); } static void _hide(void *view_data) @@ -430,11 +445,14 @@ static void _update(void *view_data, int type, void *data) !strcmp(ev->keyname, KEY_CHANNELUP_REMOTE) || !strcmp(ev->keyname, KEY_CHANNELDOWN) || !strcmp(ev->keyname, KEY_CHANNELDOWN_REMOTE)) { + if (priv->current_layout && + !strcmp(priv->current_layout, + LAYOUT_CHANNELINFO_SEARCH)) + return; + _set_current_layout(priv, LAYOUT_CHANNELINFO_LIST); layoutmgr_update_layout(priv->lmgr, LAYOUT_CHANNELINFO_LIST, type, ev); - } else { - _start_hide_timer(priv); } } else if (type == UPDATE_TYPE_INPUT_KEY_UP) { Evas_Event_Key_Up *ev = data; @@ -448,13 +466,14 @@ static void _update(void *view_data, int type, void *data) !strcmp(ev->keyname, KEY_CHANNELUP_REMOTE) || !strcmp(ev->keyname, KEY_CHANNELDOWN) || !strcmp(ev->keyname, KEY_CHANNELDOWN_REMOTE)) { + if (priv->current_layout && + !strcmp(priv->current_layout, + LAYOUT_CHANNELINFO_SEARCH)) + return; + _set_current_layout(priv, LAYOUT_CHANNELINFO_LIST); layoutmgr_update_layout(priv->lmgr, LAYOUT_CHANNELINFO_LIST, type, ev); - } else if (!strcmp(ev->keyname, KEY_BACK) || - !strcmp(ev->keyname, KEY_BACK_REMOTE) || - !strcmp(ev->keyname, KEY_EXIT)) { - viewmgr_hide_view(VIEW_CHANNELINFO); } } } diff --git a/src/view_channelnumber.c b/src/view_channelnumber.c index ada44ad..f016f86 100644 --- a/src/view_channelnumber.c +++ b/src/view_channelnumber.c @@ -26,6 +26,7 @@ #define HIDE_DUR 3.0 #define BUF_MAX 128 +#define NUMBER_MAX 3 struct _priv { Evas_Object *base; @@ -36,18 +37,13 @@ struct _priv { int minor; }; -static void _update(void *view_data, int type, void *data); - static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) { - _update(data, UPDATE_TYPE_INPUT_KEY_DOWN, ev); -} - -static void _key_up_cb(int id, void *data, Evas *e, Evas_Object *obj, - Evas_Event_Key_Up *ev) -{ - _update(data, UPDATE_TYPE_INPUT_KEY_UP, ev); + if (!strcmp(ev->keyname, KEY_BACK) || + !strcmp(ev->keyname, KEY_BACK_REMOTE)) { + viewmgr_hide_view(VIEW_CHANNELNUMBER); + } } static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj, @@ -59,7 +55,6 @@ static void _mouse_move_cb(int id, void *data, Evas *e, Evas_Object *obj, static input_handler key_handler = { .key_down = _key_down_cb, - .key_up = _key_up_cb, .mouse_move = _mouse_move_cb, }; @@ -435,11 +430,6 @@ static void _update(void *view_data, int type, void *data) _ERR("failed to get ev"); return; } - - if (!strcmp(ev->keyname, KEY_BACK) || - !strcmp(ev->keyname, KEY_BACK_REMOTE)) { - viewmgr_hide_view(VIEW_CHANNELNUMBER); - } } } |