summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjinwoo.shin <jw0227.shin@samsung.com>2015-09-09 21:23:45 +0900
committerjinwoo.shin <jw0227.shin@samsung.com>2015-09-10 14:18:41 +0900
commitb91df1bcae3e185b381283a04f02c8afa9170619 (patch)
treed228095d20812816f775aeb4a553a8dcefa58545
parentd0579bc65a13b832594675da02b78f2006504c6b (diff)
downloadair_livetv-b91df1bcae3e185b381283a04f02c8afa9170619.tar.gz
air_livetv-b91df1bcae3e185b381283a04f02c8afa9170619.tar.bz2
air_livetv-b91df1bcae3e185b381283a04f02c8afa9170619.zip
Update key event handler
- Replaces ecore event handler to elm event handler Change-Id: I3824e5e219006cf6713ef9526a56a1f312e7d08e Signed-off-by: jinwoo.shin <jw0227.shin@samsung.com>
-rw-r--r--src/layout_channelinfo_search.c1
-rw-r--r--src/main.c88
-rw-r--r--src/view_action_menu.c4
-rw-r--r--src/view_channelnumber.c8
4 files changed, 33 insertions, 68 deletions
diff --git a/src/layout_channelinfo_search.c b/src/layout_channelinfo_search.c
index 3849fdf..6aaa01e 100644
--- a/src/layout_channelinfo_search.c
+++ b/src/layout_channelinfo_search.c
@@ -61,7 +61,6 @@ 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,
diff --git a/src/main.c b/src/main.c
index 324e5d3..4c74363 100644
--- a/src/main.c
+++ b/src/main.c
@@ -77,84 +77,50 @@ static struct key_map g_kmap[] = {
},
};
-static Eina_Bool _key_down_cb(void *data, int type, void *ei)
+static Eina_Bool _event(void *data, Evas_Object *obj, Evas_Object *src,
+ Evas_Callback_Type type, void *ei)
{
struct _appdata *ad;
- Evas_Event_Key_Down *ev = ei;
size_t i, j;
+ char *keyname;
+ int update_type;
if (!data) {
_ERR("failed to get data");
- return false;
+ return EINA_FALSE;
}
ad = data;
- if (!ad->is_channel)
- return ECORE_CALLBACK_DONE;
-
- if (viewmgr_get_view_state(VIEW_PIN) ==
- VIEW_STATE_VISIBLE)
- return ECORE_CALLBACK_PASS_ON;
-
- 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_update_view(g_kmap[i].view,
- UPDATE_TYPE_INPUT_KEY_DOWN, ev);
- return ECORE_CALLBACK_DONE;
- }
- j++;
- }
- }
- return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool _key_up_cb(void *data, int type, void *ei)
-{
- struct _appdata *ad;
- Evas_Event_Key_Up *ev = ei;
- size_t i, j;
-
- if (!data) {
- _ERR("failed to get data");
- return false;
- }
-
- ad = data;
if (!ad->is_channel)
- return ECORE_CALLBACK_DONE;
-
- if (viewmgr_get_view_state(VIEW_PIN) ==
- VIEW_STATE_VISIBLE)
- return ECORE_CALLBACK_PASS_ON;
-
- if (!strcmp(ev->keyname, KEY_ENTER) ||
- !strcmp(ev->keyname, KEY_ENTER_REMOTE)) {
- if (viewmgr_active_view_count() > 0)
- return ECORE_CALLBACK_PASS_ON;
+ return EINA_TRUE;
+
+ switch (type) {
+ case EVAS_CALLBACK_KEY_DOWN:
+ keyname = ((Evas_Event_Key_Down *)ei)->keyname;
+ update_type = UPDATE_TYPE_INPUT_KEY_DOWN;
+ break;
+ case EVAS_CALLBACK_KEY_UP:
+ keyname = ((Evas_Event_Key_Up *)ei)->keyname;
+ update_type = UPDATE_TYPE_INPUT_KEY_UP;
+ break;
+ default:
+ return EINA_FALSE;
}
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])) {
+ if (!strcmp(keyname, g_kmap[i].key[j])) {
viewmgr_update_view(g_kmap[i].view,
- UPDATE_TYPE_INPUT_KEY_UP, ev);
- return ECORE_CALLBACK_DONE;
+ update_type, ei);
+ return EINA_TRUE;
}
j++;
}
}
- return ECORE_CALLBACK_PASS_ON;
+ return EINA_FALSE;
}
static Evas_Object *_add_win(const char *name)
@@ -360,10 +326,7 @@ static bool _create(void *data)
ad->win = win;
tv_signal_cb_set(_tv_signal_cb, ad);
- ad->key_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
- _key_down_cb, ad);
- ad->key_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
- _key_up_cb, ad);
+ elm_object_event_callback_add(win, _event, ad);
elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_IN);
@@ -389,10 +352,7 @@ static void _terminate(void *data)
if (ad->win) {
tv_destroy();
- if (ad->key_down)
- ecore_event_handler_del(ad->key_down);
- if (ad->key_up)
- ecore_event_handler_del(ad->key_up);
+ elm_object_event_callback_del(ad->win, _event, ad);
viewmgr_remove_view(VIEW_CHANNELINFO);
viewmgr_remove_view(VIEW_CHANNELNUMBER);
diff --git a/src/view_action_menu.c b/src/view_action_menu.c
index bee69a3..6c21921 100644
--- a/src/view_action_menu.c
+++ b/src/view_action_menu.c
@@ -278,6 +278,8 @@ static void _key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
if (!strcmp(ev->keyname, KEY_BACK) ||
!strcmp(ev->keyname, KEY_BACK_REMOTE))
viewmgr_hide_view(VIEW_ACTION_MENU);
+
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
}
static input_handler key_handler = {
@@ -363,6 +365,8 @@ static void _favorite_clicked_cb(int id, void *data, Evas_Object *obj)
{
if (id > 0)
tv_channel_tune_with_service_id(id);
+
+ viewmgr_hide_view(VIEW_ACTION_MENU);
}
static input_handler favorite_handler = {
diff --git a/src/view_channelnumber.c b/src/view_channelnumber.c
index 6a63655..bf1ce0c 100644
--- a/src/view_channelnumber.c
+++ b/src/view_channelnumber.c
@@ -75,7 +75,6 @@ static Eina_Bool _done_input(void *data)
_ERR("invalid channel");
viewmgr_hide_view(VIEW_CHANNELNUMBER);
- viewmgr_show_view(VIEW_CHANNELINFO);
return ECORE_CALLBACK_CANCEL;
}
@@ -115,8 +114,11 @@ static void _channel_key_down_cb(int id, void *data, Evas *e, Evas_Object *obj,
Evas_Event_Key_Down *ev)
{
if (!strcmp(ev->keyname, KEY_ENTER) ||
- !strcmp(ev->keyname, KEY_ENTER_REMOTE))
+ !strcmp(ev->keyname, KEY_ENTER_REMOTE)) {
+ ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
+
_tune_channel(data);
+ }
}
static void _channel_mouse_down_cb(int id, void *data, Evas *e,
@@ -245,7 +247,7 @@ static void _update_number_info(struct _priv *priv)
static int _get_number(const char *keyname)
{
- static const char const *keys[] = {
+ static const char * const keys[] = {
KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
KEY_5, KEY_6, KEY_7, KEY_8, KEY_9
};