diff options
author | Chris Michael <cp.michael@samsung.com> | 2017-02-28 10:22:58 -0500 |
---|---|---|
committer | Chris Michael <cp.michael@samsung.com> | 2017-02-28 10:22:58 -0500 |
commit | e6b26d2279059834da42797331ba5fb3f388caf8 (patch) | |
tree | 0726ac0ce7c8f257f99126a8be26a76e21c6cff8 /src/modules/ecore_imf | |
parent | 5b9374583e3fd450ac53c566095c398f0d6c5cfe (diff) | |
download | efl-e6b26d2279059834da42797331ba5fb3f388caf8.tar.gz |
ecore-imf-wayland: Reduce calls to set_cursor_rectangle
Avoid calls to zwp_text_input_v1_set_cursor_rectangle if we do not
need to. Previous code here would always call this function even if
the cursor rectangle was in the same position. Now we set a flag on
the cursor_location field to let us know that it needs updating.
ref T5226
@fix
Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/modules/ecore_imf')
-rw-r--r-- | src/modules/ecore_imf/wayland/wayland_imcontext.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/modules/ecore_imf/wayland/wayland_imcontext.c b/src/modules/ecore_imf/wayland/wayland_imcontext.c index a5f9f5b189..6c740123f3 100644 --- a/src/modules/ecore_imf/wayland/wayland_imcontext.c +++ b/src/modules/ecore_imf/wayland/wayland_imcontext.c @@ -72,6 +72,7 @@ struct _WaylandIMContext int y; int width; int height; + Eina_Bool do_set : 1; } cursor_location; xkb_mod_mask_t control_mask; @@ -106,6 +107,7 @@ update_state(WaylandIMContext *imcontext) int cursor_pos; Ecore_Evas *ee; int canvas_x = 0, canvas_y = 0; + Eina_Bool changed = EINA_FALSE; if (!imcontext->ctx) return; @@ -114,8 +116,12 @@ update_state(WaylandIMContext *imcontext) if (ecore_imf_context_surrounding_get(imcontext->ctx, &surrounding, &cursor_pos)) { if (imcontext->text_input) - zwp_text_input_v1_set_surrounding_text(imcontext->text_input, surrounding, - cursor_pos, cursor_pos); + { + zwp_text_input_v1_set_surrounding_text(imcontext->text_input, + surrounding, + cursor_pos, cursor_pos); + changed = EINA_TRUE; + } if (surrounding) free(surrounding); @@ -133,15 +139,21 @@ update_state(WaylandIMContext *imcontext) if (imcontext->text_input) { - zwp_text_input_v1_set_cursor_rectangle(imcontext->text_input, - imcontext->cursor_location.x + canvas_x, - imcontext->cursor_location.y + canvas_y, - imcontext->cursor_location.width, - imcontext->cursor_location.height); - - zwp_text_input_v1_commit_state(imcontext->text_input, ++imcontext->serial); + if (imcontext->cursor_location.do_set) + { + zwp_text_input_v1_set_cursor_rectangle(imcontext->text_input, + imcontext->cursor_location.x + canvas_x, + imcontext->cursor_location.y + canvas_y, + imcontext->cursor_location.width, + imcontext->cursor_location.height); + imcontext->cursor_location.do_set = EINA_FALSE; + changed = EINA_TRUE; + } } + if (changed) + zwp_text_input_v1_commit_state(imcontext->text_input, ++imcontext->serial); + _clear_hide_timer(); } @@ -949,6 +961,7 @@ wayland_im_context_cursor_location_set(Ecore_IMF_Context *ctx, int x, int y, int imcontext->cursor_location.y = y; imcontext->cursor_location.width = width; imcontext->cursor_location.height = height; + imcontext->cursor_location.do_set = EINA_TRUE; update_state(imcontext); } |