ref-fusion: implement basic MMI_MANAGER_EVENT_FOCUS/STATE_CHANGE event handlers 74/264074/1
authorSung-Jin Park <sj76.park@samsung.com>
Fri, 3 Sep 2021 12:30:48 +0000 (21:30 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Mon, 13 Sep 2021 11:25:48 +0000 (20:25 +0900)
Change-Id: I6686e9f5034bcc1799909da7e715ff9c52adee21
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/modules/ref_fusion/meson.build
src/modules/ref_fusion/mmi-ref-fusion.c

index 33fb946..eb54831 100644 (file)
@@ -1,6 +1,7 @@
 ref_fusion_srcs = [
        'mmi-ref-fusion.h',
        'mmi-ref-fusion.c',
+       '../../mmi-common.c',
        ]
 
 install_headers(
@@ -13,12 +14,13 @@ ref_fusion_include_dirs = include_directories(
 
 glib_dep = dependency('glib-2.0')
 dlog_dep = dependency('dlog')
+ecore_dep = dependency('ecore', method : 'pkg-config')
 
 mmi_fusion_prefix_libdir = join_paths(mmi_manager_prefix_libdir, 'fusion')
 
 ref_fusion_shared = shared_library('mmi_ref_fusion',
                ref_fusion_srcs,
                include_directories : [ ref_fusion_include_dirs, mmi_manager_include_dirs ],
-               dependencies : [glib_dep, dlog_dep ],
+               dependencies : [glib_dep, dlog_dep, ecore_dep ],
                install_dir : mmi_fusion_prefix_libdir,
                install : true)
index 5a11ebb..c215e92 100644 (file)
 */
 
 #include "mmi-ref-fusion.h"
+#include <mmi-client.h>
+#include <mmi-manager.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <Ecore.h>
+
+mmi_client *_prev_focus_client = NULL;
+mmi_client *_focus_client = NULL;
+mmi_state _prev_state = MMI_STATE_NONE;
+mmi_state _state = MMI_STATE_NONE;
+Ecore_Event_Handler *_event_handlers[2];
+
+static Eina_Bool
+_focus_change_cb(void *data EINA_UNUSED, int type, void *event)
+{
+       LOGI("...");
+
+       mmi_manager_event_focus_change *ev = (mmi_manager_event_focus_change *)event;
+
+       _prev_focus_client = ev->cur_focus;
+       _focus_client = ev->new_focus;
+
+       //TODO : check if there is anything to do
+
+       return ECORE_CALLBACK_PASS_ON;
+}
+
+static Eina_Bool
+_state_change_cb(void *data EINA_UNUSED, int type, void *event)
+{
+       LOGI("...");
+
+       mmi_manager_event_state_change *ev = (mmi_manager_event_state_change *)event;
+
+       if (ev->client != _focus_client)
+       {
+               LOGE("Invalid state change event ! (client:%p, focus_client:%p)\n",
+                               ev->client, _focus_client);
+               return ECORE_CALLBACK_PASS_ON;
+       }
+
+       _prev_state = ev->from_state;
+       _state = ev->to_state;
+
+       //TODO : do needed things for the given state
+
+       return ECORE_CALLBACK_PASS_ON;
+}
+
 static mmi_fusion_module_data *
 ref_fusion_init(void)
 {
@@ -42,6 +89,11 @@ ref_fusion_init(void)
        ref_fusion_data->get_state = ref_fusion_get_state;
        ref_fusion_data->set_state = ref_fusion_set_state;
 
+       _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);
+
        return ref_fusion_data;
 }
 
@@ -70,6 +122,9 @@ ref_fusion_deinit(mmi_fusion_module_data *module_data)
 
        LOGD("ref_fusion_deinit\n");
 
+       ecore_event_handler_del(_event_handlers[0]);
+       ecore_event_handler_del(_event_handlers[1]);
+
        module_data->get_state = NULL;
        module_data->set_state = NULL;