hermet pushed a commit to branch master.

http://git.enlightenment.org/tools/enventor.git/commit/?id=47bbaf731b391c399cd4fda4b176ba5ff210a091

commit 47bbaf731b391c399cd4fda4b176ba5ff210a091
Author: Hermet Park <her...@hermet.pe.kr>
Date:   Sun May 8 02:55:46 2016 +0900

    edc_edit: fix broken ctrl+z, ctrl+r short-cut key events.
    
    This was introduced from previous patches.
    Now initialization point of edit_data is next to the efl lib initialization.
    This broke this and now i fixed this with dispatching way.
---
 src/lib/edc_editor.c       | 95 ++++++++++++++++++++--------------------------
 src/lib/enventor_private.h |  2 +
 src/lib/enventor_smart.c   | 14 ++++++-
 3 files changed, 55 insertions(+), 56 deletions(-)

diff --git a/src/lib/edc_editor.c b/src/lib/edc_editor.c
index e06604b..342b8a4 100644
--- a/src/lib/edc_editor.c
+++ b/src/lib/edc_editor.c
@@ -901,57 +901,6 @@ syntax_color_full_update(edit_data *ed, Eina_Bool thread)
      }
 }
 
-static Eina_Bool
-key_down_cb(void *data, int type EINA_UNUSED, void *ev)
-{
-   Ecore_Event_Key *event = ev;
-   edit_data *ed = data;
-
-   /* FIXME: seems event fd handler is broken. so key down event
-      is triggered multiple times, to make enventor stable,
-      we put the workaround code here. please remove if this won't
-      be problem anymore */
-   if (event->timestamp == 0) return ECORE_CALLBACK_PASS_ON;
-
-   //Control Key
-   if (!strcmp("Control_L", event->key))
-     {
-        ed->ctrl_pressed = EINA_TRUE;
-        return ECORE_CALLBACK_PASS_ON;
-     }
-
-   if (ed->ctrl_pressed)
-     {
-        //Undo
-        if (!strcmp(event->key, "z") || !strcmp(event->key, "Z"))
-          {
-             edit_redoundo(ed, EINA_TRUE);
-             return ECORE_CALLBACK_DONE;
-          }
-        //Redo
-        if (!strcmp(event->key, "r") || !strcmp(event->key, "R"))
-          {
-             edit_redoundo(ed, EINA_FALSE);
-             return ECORE_CALLBACK_DONE;
-          }
-     }
-
-   return ECORE_CALLBACK_PASS_ON;
-}
-
-static Eina_Bool
-key_up_cb(void *data, int type EINA_UNUSED, void *ev)
-{
-   Ecore_Event_Key *event = ev;
-   edit_data *ed = data;
-
-   //Control Key
-   if (!strcmp("Control_L", event->key))
-     ed->ctrl_pressed = EINA_FALSE;
-
-   return ECORE_CALLBACK_PASS_ON;
-}
-
 static void
 scroller_scroll_cb(void *data, Evas_Object *obj EINA_UNUSED,
                    void *event_info EINA_UNUSED)
@@ -1407,9 +1356,6 @@ edit_init(Enventor_Object *enventor)
    ed->bracket.left = -1;
    ed->bracket.right = -1;
 
-   ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, key_down_cb, ed);
-   ecore_event_handler_add(ECORE_EVENT_KEY_UP, key_up_cb, ed);
-
    //Scroller
    Evas_Object *scroller = elm_scroller_add(enventor);
    elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_AUTO,
@@ -1806,3 +1752,44 @@ edit_redoundo(edit_data *ed, Eina_Bool undo)
 
    return EINA_TRUE;
 }
+
+Eina_Bool
+edit_key_down_event_dispatch(edit_data *ed, const char *key)
+{
+   //Control Key
+   if (!strcmp("Control_L", key))
+     {
+        ed->ctrl_pressed = EINA_TRUE;
+        return EINA_FALSE;
+     }
+
+   if (ed->ctrl_pressed)
+     {
+        //Undo
+        if (!strcmp(key, "z") || !strcmp(key, "Z"))
+          {
+             edit_redoundo(ed, EINA_TRUE);
+             return EINA_TRUE;
+          }
+        //Redo
+        if (!strcmp(key, "r") || !strcmp(key, "R"))
+          {
+             edit_redoundo(ed, EINA_FALSE);
+             return EINA_TRUE;
+          }
+     }
+
+   return EINA_FALSE;
+}
+
+Eina_Bool
+edit_key_up_event_dispatch(edit_data *ed, const char *key)
+{
+   //Control Key
+   if (!strcmp("Control_L", key))
+     ed->ctrl_pressed = EINA_FALSE;
+
+   return EINA_FALSE;
+}
+
+
diff --git a/src/lib/enventor_private.h b/src/lib/enventor_private.h
index 861e2e2..eb637ae 100644
--- a/src/lib/enventor_private.h
+++ b/src/lib/enventor_private.h
@@ -227,6 +227,8 @@ Evas_Object *ctxpopup_img_preview_create(edit_data*ed, 
const char *imgpath, Evas
 void ctxpopup_img_preview_reload(Evas_Object *ctxpopup, const char *imgpath);
 
 /* edc_editor */
+Eina_Bool edit_key_down_event_dispatch(edit_data *ed, const char *key);
+Eina_Bool edit_key_up_event_dispatch(edit_data *ed, const char *key);
 edit_data *edit_init(Enventor_Object *enventor);
 void edit_term(edit_data *ed);
 Evas_Object *edit_obj_get(edit_data *ed);
diff --git a/src/lib/enventor_smart.c b/src/lib/enventor_smart.c
index d5fa757..212f28c 100644
--- a/src/lib/enventor_smart.c
+++ b/src/lib/enventor_smart.c
@@ -82,10 +82,15 @@ _enventor_main_item_free(Enventor_Object_Data *pd)
 }
 
 static Eina_Bool
-key_up_cb(void *data, int type EINA_UNUSED, void *ev EINA_UNUSED)
+key_up_cb(void *data, int type EINA_UNUSED, void *ev)
 {
    Enventor_Object_Data *pd = data;
+   Ecore_Event_Key *event = ev;
+
    pd->key_down = EINA_FALSE;
+
+   edit_key_down_event_dispatch(pd->main_it.ed, event->key);
+
    return ECORE_CALLBACK_DONE;
 }
 
@@ -102,7 +107,12 @@ key_down_cb(void *data, int type EINA_UNUSED, void *ev)
    if (pd->key_down) return ECORE_CALLBACK_PASS_ON;
    pd->key_down = EINA_TRUE;
 
-   if (autocomp_event_dispatch(event->key)) return ECORE_CALLBACK_DONE;
+   if (edit_key_down_event_dispatch(pd->main_it.ed, event->key))
+     return ECORE_CALLBACK_DONE;
+
+   if (autocomp_event_dispatch(event->key))
+     return ECORE_CALLBACK_DONE;
+
    return ECORE_CALLBACK_PASS_ON;
 }
 

-- 


Reply via email to