diff --git a/legacy/edje/src/lib/edje_entry.c b/legacy/edje/src/lib/edje_entry.c index 0837366977..fcd7185129 100644 --- a/legacy/edje/src/lib/edje_entry.c +++ b/legacy/edje/src/lib/edje_entry.c @@ -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 __UNUSED__, const char *emiss 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 *o, Entry *en) 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_Object *o, Entry *en) 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 @@ -1403,15 +1398,8 @@ _edje_key_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, v 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); } @@ -1588,15 +1576,9 @@ _edje_part_mouse_down_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUS if (evas_textblock_cursor_compare(tc, en->cursor)) _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); if (ev->button == 2) @@ -1704,15 +1686,8 @@ _edje_part_mouse_up_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED _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); } @@ -1805,14 +1780,8 @@ _edje_part_mouse_move_cb(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUS _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); } @@ -1960,7 +1929,10 @@ _edje_entry_real_part_init(Edje_Real_Part *rp) if (!en->imf_context) goto done; - ecore_imf_context_client_window_set(en->imf_context, ecore_evas_window_get(ecore_evas_ecore_evas_get(rp->edje->base.evas))); + ecore_imf_context_client_window_set + (en->imf_context, + (void *)ecore_evas_window_get + (ecore_evas_ecore_evas_get(rp->edje->base.evas))); ecore_imf_context_client_canvas_set(en->imf_context, rp->edje->base.evas); ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context, @@ -2148,14 +2120,9 @@ _edje_entry_text_markup_insert(Edje_Real_Part *rp, const char *text) _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); } @@ -2166,10 +2133,7 @@ _edje_entry_set_cursor_start(Edje_Real_Part *rp) 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 @@ -2179,11 +2143,7 @@ _edje_entry_set_cursor_end(Edje_Real_Part *rp) 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 @@ -2206,15 +2166,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); } @@ -2228,14 +2181,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); } @@ -2247,14 +2194,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); } @@ -2394,15 +2335,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); } } @@ -2455,14 +2389,8 @@ _edje_entry_cursor_next(Edje_Real_Part *rp, Edje_Cursor 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); @@ -2483,14 +2411,8 @@ _edje_entry_cursor_prev(Edje_Real_Part *rp, Edje_Cursor cur) 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); @@ -2521,14 +2443,8 @@ _edje_entry_cursor_up(Edje_Real_Part *rp, Edje_Cursor 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); @@ -2558,15 +2474,8 @@ _edje_entry_cursor_down(Edje_Real_Part *rp, Edje_Cursor 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; @@ -2581,15 +2490,8 @@ _edje_entry_cursor_begin(Edje_Real_Part *rp, Edje_Cursor cur) 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); } @@ -2603,14 +2505,8 @@ _edje_entry_cursor_end(Edje_Real_Part *rp, Edje_Cursor cur) _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); @@ -2630,15 +2526,8 @@ _edje_entry_cursor_copy(Edje_Real_Part *rp, Edje_Cursor cur, Edje_Cursor dst) 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); } @@ -2652,14 +2541,8 @@ _edje_entry_cursor_line_begin(Edje_Real_Part *rp, Edje_Cursor cur) 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); @@ -2674,15 +2557,8 @@ _edje_entry_cursor_line_end(Edje_Real_Part *rp, Edje_Cursor cur) 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); } @@ -2743,15 +2619,8 @@ _edje_entry_cursor_pos_set(Edje_Real_Part *rp, Edje_Cursor cur, int pos) 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); } @@ -2764,6 +2633,30 @@ _edje_entry_cursor_pos_get(Edje_Real_Part *rp, Edje_Cursor cur) 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) @@ -2865,6 +2758,7 @@ _edje_entry_imf_event_commit_cb(void *data, int type __UNUSED__, void *event) 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); @@ -2933,6 +2827,7 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, int type __UNUSED__, void * { _text_filter_markup_prepend(en, en->cursor, preedit_string); } + if (!preedit_end_state) { /* set preedit start cursor */ @@ -2951,16 +2846,14 @@ _edje_entry_imf_event_preedit_changed_cb(void *data, int type __UNUSED__, void * { 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);