Fix issue key event handler does not work in case ecore_imf_init () is not called... 56/49756/1
authorJihoon Kim <jihoon48.kim@samsung.com>
Tue, 13 Oct 2015 05:26:21 +0000 (14:26 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Tue, 20 Oct 2015 04:59:40 +0000 (13:59 +0900)
When ecore_imf_init () is called in runtime not initial time,
ecore event handler doesn't work as filter.
ecore_event_filter_add () will replace ecore_event_handler_add ()

Change-Id: I88782a6bbca41569a88fca052cd5bda006554eec

ism/extras/efl_immodule/isf_imf_context.cpp
ism/extras/efl_immodule/isf_imf_context.h

index c0700d6..3b2b7cb 100644 (file)
@@ -57,7 +57,6 @@
 # define CODESET "INVALID"
 #endif
 
-#define ENABLE_BACKKEY 1
 #define SHIFT_MODE_OFF  0xffe1
 #define SHIFT_MODE_ON   0xffe2
 #define SHIFT_MODE_LOCK 0xffe6
@@ -380,8 +379,7 @@ static Ecore_Fd_Handler                                *_panel_iochannel_err_han
 
 static Ecore_X_Window                                   _input_win                  = 0;
 static Ecore_X_Window                                   _client_window              = 0;
-static Ecore_Event_Handler                             *_key_down_handler           = 0;
-static Ecore_Event_Handler                             *_key_up_handler             = 0;
+static Ecore_Event_Filter                              *_ecore_event_filter_handler = NULL;
 
 static bool                                             _on_the_spot                = true;
 static bool                                             _shared_input_method        = false;
@@ -567,10 +565,10 @@ _key_down_cb (void *data, int type, void *event)
     Eina_Bool ret = EINA_FALSE;
     Ecore_Event_Key *ev = (Ecore_Event_Key *)event;
     Ecore_IMF_Context *active_ctx = get_using_ic (ECORE_IMF_INPUT_PANEL_STATE_EVENT, ECORE_IMF_INPUT_PANEL_STATE_SHOW);
-    if (!ev || !ev->keyname || !active_ctx) return ECORE_CALLBACK_PASS_ON;
+    if (!ev || !ev->keyname || !active_ctx) return EINA_TRUE;
 
     EcoreIMFContextISF *ic = (EcoreIMFContextISF*) ecore_imf_context_data_get (active_ctx);
-    if (!ic) return ECORE_CALLBACK_PASS_ON;
+    if (!ic) return EINA_TRUE;
 
     Ecore_X_Window client_win = client_window_id_get (active_ctx);
     Ecore_X_Window focus_win = ecore_x_window_focus_get ();
@@ -579,7 +577,7 @@ _key_down_cb (void *data, int type, void *event)
         if (filter_keys (ev->keyname, hide_ise_keys)) {
             if (get_keyboard_mode () == TOOLBAR_HELPER_MODE) {
                 if (ecore_imf_context_input_panel_state_get (active_ctx) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
-                    return ECORE_CALLBACK_PASS_ON;
+                    return EINA_TRUE;
             }
             LOGD ("%s key is pressed.\n", ev->keyname);
             if (_active_helper_option & ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT) {
@@ -592,17 +590,17 @@ _key_down_cb (void *data, int type, void *event)
                 _panel_client.send ();
             }
             if (ret) {
-                return ECORE_CALLBACK_DONE;
+                return EINA_FALSE;
             }
             else {
                 Ecore_IMF_Input_Panel_State state = ecore_imf_context_input_panel_state_get (active_ctx);
                 if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW ||
                     state == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW)
-                    return ECORE_CALLBACK_DONE;
+                    return EINA_FALSE;
             }
         }
     }
-    return ECORE_CALLBACK_PASS_ON;
+    return EINA_TRUE;
 }
 
 static Eina_Bool
@@ -614,10 +612,10 @@ _key_up_cb (void *data, int type, void *event)
     Eina_Bool ret = EINA_FALSE;
     Ecore_Event_Key *ev = (Ecore_Event_Key *)event;
     Ecore_IMF_Context *active_ctx = get_using_ic (ECORE_IMF_INPUT_PANEL_STATE_EVENT, ECORE_IMF_INPUT_PANEL_STATE_SHOW);
-    if (!ev || !ev->keyname || !active_ctx) return ECORE_CALLBACK_PASS_ON;
+    if (!ev || !ev->keyname || !active_ctx) return EINA_TRUE;
 
     EcoreIMFContextISF *ic = (EcoreIMFContextISF*) ecore_imf_context_data_get (active_ctx);
-    if (!ic) return ECORE_CALLBACK_PASS_ON;
+    if (!ic) return EINA_TRUE;
 
     Ecore_X_Window client_win = client_window_id_get (active_ctx);
     Ecore_X_Window focus_win = ecore_x_window_focus_get ();
@@ -626,7 +624,7 @@ _key_up_cb (void *data, int type, void *event)
         if (filter_keys (ev->keyname, hide_ise_keys)) {
             if (get_keyboard_mode () == TOOLBAR_HELPER_MODE) {
                 if (ecore_imf_context_input_panel_state_get (active_ctx) == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
-                    return ECORE_CALLBACK_PASS_ON;
+                    return EINA_TRUE;
             }
             LOGD ("%s key is released.\n", ev->keyname);
             if (_active_helper_option & ISM_HELPER_PROCESS_KEYBOARD_KEYEVENT) {
@@ -641,7 +639,7 @@ _key_up_cb (void *data, int type, void *event)
                 _panel_client.send ();
             }
             if (ret) {
-                return ECORE_CALLBACK_DONE;
+                return EINA_FALSE;
             }
             else {
                 Ecore_IMF_Input_Panel_State state = ecore_imf_context_input_panel_state_get (active_ctx);
@@ -649,7 +647,7 @@ _key_up_cb (void *data, int type, void *event)
                     state == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW) {
                     isf_imf_context_reset (active_ctx);
                     isf_imf_context_input_panel_instant_hide (active_ctx);
-                    return ECORE_CALLBACK_DONE;
+                    return EINA_FALSE;
                 }
             }
         }
@@ -675,41 +673,40 @@ _key_up_cb (void *data, int type, void *event)
         }
     }
 
-    return ECORE_CALLBACK_PASS_ON;
+    return EINA_TRUE;
 }
 
-int
-register_key_handler ()
+static Eina_Bool
+_ecore_event_filter_cb (void *data, void *loop_data, int type, void *event)
 {
-    SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
+    if (type == ECORE_EVENT_KEY_DOWN) {
+        return _key_down_cb (data, type, event);
+    }
+    else if (type == ECORE_EVENT_KEY_UP) {
+        return _key_up_cb (data, type, event);
+    }
 
-#ifdef ENABLE_BACKKEY
-    if (!_key_down_handler)
-        _key_down_handler = ecore_event_handler_add (ECORE_EVENT_KEY_DOWN, _key_down_cb, NULL);
+    return EINA_TRUE;
+}
 
-    if (!_key_up_handler)
-        _key_up_handler = ecore_event_handler_add (ECORE_EVENT_KEY_UP, _key_up_cb, NULL);
-#endif
+void
+register_key_handler ()
+{
+    SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
 
-    return EXIT_SUCCESS;
+    if (!_ecore_event_filter_handler)
+        _ecore_event_filter_handler = ecore_event_filter_add (NULL, _ecore_event_filter_cb, NULL, NULL);
 }
 
-int
+void
 unregister_key_handler ()
 {
     SCIM_DEBUG_FRONTEND(1) << __FUNCTION__ << "...\n";
 
-    if (_key_down_handler) {
-        ecore_event_handler_del (_key_down_handler);
-        _key_down_handler = NULL;
-    }
-
-    if (_key_up_handler) {
-        ecore_event_handler_del (_key_up_handler);
-        _key_up_handler = NULL;
+    if (_ecore_event_filter_handler) {
+        ecore_event_filter_del (_ecore_event_filter_handler);
+        _ecore_event_filter_handler = NULL;
     }
-
-    return EXIT_SUCCESS;
 }
 
 static void
index 87fc568..0199881 100644 (file)
@@ -53,8 +53,8 @@ struct _EcoreIMFContextISF {
     _EcoreIMFContextISF () : ctx(NULL), impl(NULL), id(0), next(NULL) {}
 };
 
-int register_key_handler ();
-int unregister_key_handler ();
+void register_key_handler ();
+void unregister_key_handler ();
 
 int get_panel_client_id ();
 Eina_Bool caps_mode_check (Ecore_IMF_Context *ctx, Eina_Bool force, Eina_Bool noti);