Hi, EFL developers.

In immodule, the cursor location is needed to move the word candidate
window.
In this patch, calling ecore_imf_context_cursor_location_set lets immodule
know the cursor location.

Would you please review this patch?

Index: edje_entry.c
===================================================================
--- edje_entry.c        (revision 61547)
+++ edje_entry.c        (working copy)
@@ -11,6 +11,9 @@ typedef struct _Entry Entry;
 typedef struct _Sel Sel;
 typedef struct _Anchor Anchor;
 
+static void _edje_entry_imf_cursor_info_set(Entry *en);
+static void _edje_entry_imf_context_reset(Entry *en);
+
 struct _Entry
 {
    Edje_Real_Part *rp;
@@ -103,6 +106,7 @@ _edje_entry_focus_in_cb(void *data, Evas_Object *o
    if (evas_object_focus_get(rp->edje->obj))
      {
         ecore_imf_context_reset(en->imf_context);
+        _edje_entry_imf_cursor_info_set(en);
         ecore_imf_context_focus_in(en->imf_context);
      }
 }
@@ -419,12 +423,7 @@ _sel_extend(Evas_Textblock_Cursor *c, Evas_Object
         en->selection = NULL;
      }
    _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
-
-#ifdef HAVE_ECORE_IMF
-   if (!en->imf_context) return;
-
-   ecore_imf_context_reset(en->imf_context);
-#endif
+   _edje_entry_imf_context_reset(en);
 }
 
 static void
@@ -440,11 +439,7 @@ _sel_preextend(Evas_Textblock_Cursor *c, Evas_Obje
         en->selection = NULL;
      }
    _edje_emit(en->rp->edje, "selection,changed", en->rp->part->name);
-
-#ifdef HAVE_ECORE_IMF
-   if (!en->imf_context) return;
-   ecore_imf_context_reset(en->imf_context);
-#endif
+   _edje_entry_imf_context_reset(en);
 }
 
 static void
@@ -1392,15 +1387,8 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__,
    if ((old_cur_pos != evas_textblock_cursor_pos_get(en->cursor)) && 
(!cursor_changed))
      _edje_emit(ed, "cursor,changed", rp->part->name);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_entry_real_part_configure(rp);
 }
 
@@ -1582,15 +1570,8 @@ _edje_part_mouse_down_cb(void *data, Evas *e __UNU
      _edje_emit(rp->edje, "cursor,changed", rp->part->name);
    evas_textblock_cursor_free(tc);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_entry_real_part_configure(rp);
 }
 
@@ -1692,15 +1673,8 @@ _edje_part_mouse_up_cb(void *data, Evas *e __UNUSE
      _edje_emit(rp->edje, "cursor,changed", rp->part->name);
    evas_textblock_cursor_free(tc);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_entry_real_part_configure(rp);
 }
 
@@ -1793,15 +1767,8 @@ _edje_part_mouse_move_cb(void *data, Evas *e __UNU
           _edje_emit(rp->edje, "cursor,changed", rp->part->name);
         evas_textblock_cursor_free(tc);
 
-#ifdef HAVE_ECORE_IMF
-        if (en->imf_context)
-          {
-             ecore_imf_context_reset(en->imf_context);
-             ecore_imf_context_cursor_position_set(en->imf_context,
-                                                   
evas_textblock_cursor_pos_get(en->cursor));
-          }
-#endif
-
+        _edje_entry_imf_context_reset(en);
+        _edje_entry_imf_cursor_info_set(en);
         _edje_entry_real_part_configure(rp);
      }
 }
@@ -2136,14 +2103,8 @@ _edje_entry_text_markup_insert(Edje_Real_Part *rp,
    _edje_emit(rp->edje, "entry,changed", rp->part->name);
    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_entry_real_part_configure(rp);
 }
 
@@ -2153,11 +2114,7 @@ _edje_entry_set_cursor_start(Edje_Real_Part *rp)
    Entry *en = rp->entry_data;
    if (!en) return;
    _curs_start(en->cursor, rp->object, en);
-
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     ecore_imf_context_cursor_position_set(en->imf_context, 0);
-#endif
+   _edje_entry_imf_cursor_info_set(en);
 }
 
 void
@@ -2166,12 +2123,7 @@ _edje_entry_set_cursor_end(Edje_Real_Part *rp)
    Entry *en = rp->entry_data;
    if (!en) return;
    _curs_end(en->cursor, rp->object, en);
-
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     ecore_imf_context_cursor_position_set(en->imf_context,
-                                           
evas_textblock_cursor_pos_get(en->cursor));
-#endif
+   _edje_entry_imf_cursor_info_set(en);
 }
 
 void
@@ -2194,15 +2146,8 @@ _edje_entry_select_all(Edje_Real_Part *rp)
    _curs_end(en->cursor, rp->object, en);
    _sel_extend(en->cursor, rp->object, en);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_entry_real_part_configure(rp);
 }
 
@@ -2216,15 +2161,8 @@ _edje_entry_select_begin(Edje_Real_Part *rp)
    _sel_start(en->cursor, rp->object, en);
    _sel_extend(en->cursor, rp->object, en);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_entry_real_part_configure(rp);
 }
 
@@ -2235,15 +2173,8 @@ _edje_entry_select_extend(Edje_Real_Part *rp)
    if (!en) return;
    _sel_extend(en->cursor, rp->object, en);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_entry_real_part_configure(rp);
 }
 
@@ -2382,15 +2313,8 @@ _edje_entry_select_abort(Edje_Real_Part *rp)
      {
         en->selecting = EINA_FALSE;
 
-#ifdef HAVE_ECORE_IMF
-        if (en->imf_context)
-          {
-             ecore_imf_context_reset(en->imf_context);
-             ecore_imf_context_cursor_position_set(en->imf_context,
-                                                   
evas_textblock_cursor_pos_get(en->cursor));
-          }
-#endif
-
+        _edje_entry_imf_context_reset(en);
+        _edje_entry_imf_cursor_info_set(en);
         _edje_entry_real_part_configure(rp);
      }
 }
@@ -2443,15 +2367,8 @@ _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_C
      }
    _sel_update(c, rp->object, rp->entry_data);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
    _edje_entry_real_part_configure(rp);
    return EINA_TRUE;
@@ -2471,15 +2388,8 @@ _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_C
 ok:
    _sel_update(c, rp->object, rp->entry_data);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
    _edje_entry_real_part_configure(rp);
    return EINA_TRUE;
@@ -2509,15 +2419,8 @@ _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cur
      }
    _sel_update(c, rp->object, rp->entry_data);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
    _edje_entry_real_part_configure(rp);
    return EINA_TRUE;
@@ -2546,15 +2449,8 @@ _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_C
      }
    _sel_update(c, rp->object, rp->entry_data);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
    _edje_entry_real_part_configure(rp);
    return EINA_TRUE;
@@ -2569,15 +2465,8 @@ _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_
    evas_textblock_cursor_paragraph_first(c);
    _sel_update(c, rp->object, rp->entry_data);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
    _edje_entry_real_part_configure(rp);
 }
@@ -2591,15 +2480,8 @@ _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cu
    _curs_end(c, rp->object, rp->entry_data);
    _sel_update(c, rp->object, rp->entry_data);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
    _edje_entry_real_part_configure(rp);
 }
@@ -2618,15 +2500,8 @@ _edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_C
    evas_textblock_cursor_copy(c, d);
    _sel_update(c, rp->object, rp->entry_data);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
    _edje_entry_real_part_configure(rp);
 }
@@ -2640,15 +2515,8 @@ _edje_entry_cursor_line_begin(Edje_Real_Part *rp,
    evas_textblock_cursor_line_char_first(c);
    _sel_update(c, rp->object, rp->entry_data);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
    _edje_entry_real_part_configure(rp);
 }
@@ -2662,15 +2530,8 @@ _edje_entry_cursor_line_end(Edje_Real_Part *rp, Ed
    evas_textblock_cursor_line_char_last(c);
    _sel_update(c, rp->object, rp->entry_data);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
    _edje_entry_real_part_configure(rp);
 }
@@ -2731,15 +2592,8 @@ _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edj
    evas_textblock_cursor_pos_set(c, pos);
    _sel_update(c, rp->object, rp->entry_data);
 
-#ifdef HAVE_ECORE_IMF
-   if (en->imf_context)
-     {
-        ecore_imf_context_reset(en->imf_context);
-        ecore_imf_context_cursor_position_set(en->imf_context,
-                                              
evas_textblock_cursor_pos_get(en->cursor));
-     }
-#endif
-
+   _edje_entry_imf_context_reset(en);
+   _edje_entry_imf_cursor_info_set(en);
    _edje_emit(rp->edje, "cursor,changed", rp->part->name);
    _edje_entry_real_part_configure(rp);
 }
@@ -2752,7 +2606,31 @@ _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edj
    return evas_textblock_cursor_pos_get(c);
 }
 
+static void
+_edje_entry_imf_context_reset(Entry *en)
+{
 #ifdef HAVE_ECORE_IMF
+   if (en->imf_context)
+     ecore_imf_context_reset(en->imf_context);
+#endif
+}
+
+static void
+_edje_entry_imf_cursor_info_set(Entry *en)
+{
+   Evas_Coord cx, cy, cw, ch;
+   if (!en || !en->rp || !en->imf_context) return;
+
+   _edje_entry_cursor_geometry_get(en->rp, &cx, &cy, &cw, &ch);
+
+#ifdef HAVE_ECORE_IMF
+   ecore_imf_context_cursor_position_set(en->imf_context,
+                                         
evas_textblock_cursor_pos_get(en->cursor));
+   ecore_imf_context_cursor_location_set(en->imf_context, cx, cy, cw, ch);
+#endif
+}
+
+#ifdef HAVE_ECORE_IMF
 static Eina_Bool
 _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_Context *ctx 
__UNUSED__, char **text, int *cursor_pos)
 {
@@ -2853,6 +2731,7 @@ _edje_entry_imf_event_commit_cb(void *data, int ty
 
    evas_textblock_cursor_free(tc);
 
+   _edje_entry_imf_cursor_info_set(en);
    _anchors_get(en->cursor, rp->object, en);
    _edje_emit(rp->edje, "entry,changed", rp->part->name);
    _edje_emit(ed, "cursor,changed", rp->part->name);
@@ -2920,6 +2799,7 @@ _edje_entry_imf_event_preedit_changed_cb(void *dat
      {
         _text_filter_markup_prepend(en, en->cursor, preedit_string);
      }
+
    if (!preedit_end_state)
      {
         /* set preedit start cursor */
@@ -2938,16 +2818,14 @@ _edje_entry_imf_event_preedit_changed_cb(void *dat
           {
              evas_textblock_cursor_char_prev(en->preedit_start);
           }
-     }
 
-   if (!preedit_end_state)
-     {
         en->have_preedit = EINA_TRUE;
 
         /* set cursor position */
         evas_textblock_cursor_pos_set(en->cursor, preedit_start_pos + 
cursor_pos);
      }
 
+   _edje_entry_imf_cursor_info_set(en);
    _anchors_get(en->cursor, rp->object, en);
    _edje_emit(rp->edje, "preedit,changed", rp->part->name);
    _edje_emit(ed, "cursor,changed", rp->part->name);

------------------------------------------------------------------------------
5 Ways to Improve & Secure Unified Communications
Unified Communications promises greater efficiencies for business. UC can 
improve internal communications as well as offer faster, more efficient ways
to interact with customers and streamline customer service. Learn more!
http://www.accelacomm.com/jaw/sfnl/114/51426253/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel

Reply via email to