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;
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()
{
client_manager_init();
mmi_api_handler_init();
+ _event_handler_init();
_init_done = true;
}
{
if (!_init_done)
return;
+
+ _event_handler_shutdown();
+
mmi_api_handler_shutdown();
client_manager_shutdown();
modality_fusions_shutdown();