From: Sung-Jin Park Date: Sat, 24 Jul 2021 19:02:38 +0000 (+0900) Subject: mmi-manager: implemented focus/state change handlers X-Git-Tag: accepted/tizen/unified/20210914.053333~71 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=92c6ce75a1b294ba490edb816dccbf30338e14c7;p=platform%2Fcore%2Fuifw%2Fmmi-manager.git mmi-manager: implemented focus/state change handlers Change-Id: I4bd8c38f001798d7cc6a5d5e5e3623c95bc457d3 Signed-off-by: Sung-Jin Park --- diff --git a/src/mmi-manager.c b/src/mmi-manager.c index 81c8976..4d890ce 100644 --- a/src/mmi-manager.c +++ b/src/mmi-manager.c @@ -36,6 +36,7 @@ static Eina_Bool _init_done = false; static Eina_List *_focus_candidates = NULL; static int _focus_candidates_cnt = 0; static mmi_client* _cur_focus_client = NULL; +Ecore_Event_Handler *_event_handlers[2]; int MMI_MANAGER_EVENT_FOCUS_CHANGE = -1; int MMI_MANAGER_EVENT_STATE_CHANGE = -1; @@ -151,6 +152,101 @@ _event_shutdown() MMI_MANAGER_EVENT_STATE_CHANGE = -1; } +static Eina_Bool +_focus_change_cb(void *data EINA_UNUSED, int type, void *event) +{ + int r; + focus_event_arg arg; + + LOGI("..."); + + mmi_manager_event_focus_change *ev = (mmi_manager_event_focus_change *)event; + + arg.type = MMI_EVENT_FOCUS_TYPE_OUT; + arg.timestamp = ecore_time_get(); + arg.focus_in = false; + + if (ev->cur_focus) + { + r = client_manager_send_focus_event(ev->cur_focus, &arg); + if (r) + LOGE("Failed to send focus event(=%d) to client(%p) !\n", + MMI_EVENT_FOCUS_TYPE_OUT, ev->cur_focus); + } + + arg.type = MMI_EVENT_FOCUS_TYPE_IN; + arg.timestamp = ecore_time_get(); + arg.focus_in = true; + + if (ev->new_focus) + { + r = client_manager_send_focus_event(ev->new_focus, &arg); + if (r) + LOGE("Failed to send focus event(=%d) to client(%p) !\n", + MMI_EVENT_FOCUS_TYPE_IN, ev->new_focus); + } + + LOGI("Focused client has been changed. (%s -> %s)\n", + ev->cur_focus ? client_manager_get_client_sender(ev->cur_focus) : "NONE", + client_manager_get_client_sender(ev->new_focus)); + + if (ev->cur_focus) + { + _focus_candidates = eina_list_prepend(_focus_candidates, ev->cur_focus); + _focus_candidates_cnt++; + } + + _cur_focus_client = ev->new_focus; + + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_state_change_cb(void *data EINA_UNUSED, int type, void *event) +{ + int r; + state_change_event_arg arg; + + LOGI("..."); + + mmi_manager_event_state_change *ev = (mmi_manager_event_state_change *)event; + + //TODO : actually change state of given client + + arg.type = MMI_EVENT_STATE_CHANGE_TYPE_STATE_CHANGE; + arg.timestamp = ecore_time_get(); + arg.state = ev->to_state; + arg.old_state = ev->from_state; + + if (ev->client) + { + r = client_manager_send_state_change_event(ev->client, &arg); + if (r) + LOGE("Failed to send state cnahnge event(=%d) to client(%p) !\n", + MMI_EVENT_STATE_CHANGE_TYPE_STATE_CHANGE, ev->client); + } + + LOGI("State of client(%p) has been changed. (%d->%d)\n", ev->client, ev->from_state, ev->to_state); + + return ECORE_CALLBACK_PASS_ON; +} + +static void +_event_handler_init() +{ + _event_handlers[0] = ecore_event_handler_add(MMI_MANAGER_EVENT_FOCUS_CHANGE, + _focus_change_cb, NULL); + _event_handlers[1] = ecore_event_handler_add(MMI_MANAGER_EVENT_STATE_CHANGE, + _state_change_cb, NULL); +} + +static void +_event_handler_shutdown() +{ + ecore_event_handler_del(_event_handlers[0]); + ecore_event_handler_del(_event_handlers[1]); +} + void mmi_manager_init() { @@ -166,6 +262,7 @@ mmi_manager_init() client_manager_init(); mmi_api_handler_init(); + _event_handler_init(); _init_done = true; } @@ -186,6 +283,9 @@ mmi_manager_shutdown() { if (!_init_done) return; + + _event_handler_shutdown(); + mmi_api_handler_shutdown(); client_manager_shutdown(); modality_fusions_shutdown();