summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2017-02-28 10:22:58 -0500
committerChris Michael <cp.michael@samsung.com>2017-02-28 10:22:58 -0500
commite6b26d2279059834da42797331ba5fb3f388caf8 (patch)
tree0726ac0ce7c8f257f99126a8be26a76e21c6cff8
parent5b9374583e3fd450ac53c566095c398f0d6c5cfe (diff)
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>
-rw-r--r--src/modules/ecore_imf/wayland/wayland_imcontext.c31
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
72 int y; 72 int y;
73 int width; 73 int width;
74 int height; 74 int height;
75 Eina_Bool do_set : 1;
75 } cursor_location; 76 } cursor_location;
76 77
77 xkb_mod_mask_t control_mask; 78 xkb_mod_mask_t control_mask;
@@ -106,6 +107,7 @@ update_state(WaylandIMContext *imcontext)
106 int cursor_pos; 107 int cursor_pos;
107 Ecore_Evas *ee; 108 Ecore_Evas *ee;
108 int canvas_x = 0, canvas_y = 0; 109 int canvas_x = 0, canvas_y = 0;
110 Eina_Bool changed = EINA_FALSE;
109 111
110 if (!imcontext->ctx) 112 if (!imcontext->ctx)
111 return; 113 return;
@@ -114,8 +116,12 @@ update_state(WaylandIMContext *imcontext)
114 if (ecore_imf_context_surrounding_get(imcontext->ctx, &surrounding, &cursor_pos)) 116 if (ecore_imf_context_surrounding_get(imcontext->ctx, &surrounding, &cursor_pos))
115 { 117 {
116 if (imcontext->text_input) 118 if (imcontext->text_input)
117 zwp_text_input_v1_set_surrounding_text(imcontext->text_input, surrounding, 119 {
118 cursor_pos, cursor_pos); 120 zwp_text_input_v1_set_surrounding_text(imcontext->text_input,
121 surrounding,
122 cursor_pos, cursor_pos);
123 changed = EINA_TRUE;
124 }
119 125
120 if (surrounding) 126 if (surrounding)
121 free(surrounding); 127 free(surrounding);
@@ -133,15 +139,21 @@ update_state(WaylandIMContext *imcontext)
133 139
134 if (imcontext->text_input) 140 if (imcontext->text_input)
135 { 141 {
136 zwp_text_input_v1_set_cursor_rectangle(imcontext->text_input, 142 if (imcontext->cursor_location.do_set)
137 imcontext->cursor_location.x + canvas_x, 143 {
138 imcontext->cursor_location.y + canvas_y, 144 zwp_text_input_v1_set_cursor_rectangle(imcontext->text_input,
139 imcontext->cursor_location.width, 145 imcontext->cursor_location.x + canvas_x,
140 imcontext->cursor_location.height); 146 imcontext->cursor_location.y + canvas_y,
141 147 imcontext->cursor_location.width,
142 zwp_text_input_v1_commit_state(imcontext->text_input, ++imcontext->serial); 148 imcontext->cursor_location.height);
149 imcontext->cursor_location.do_set = EINA_FALSE;
150 changed = EINA_TRUE;
151 }
143 } 152 }
144 153
154 if (changed)
155 zwp_text_input_v1_commit_state(imcontext->text_input, ++imcontext->serial);
156
145 _clear_hide_timer(); 157 _clear_hide_timer();
146} 158}
147 159
@@ -949,6 +961,7 @@ wayland_im_context_cursor_location_set(Ecore_IMF_Context *ctx, int x, int y, int
949 imcontext->cursor_location.y = y; 961 imcontext->cursor_location.y = y;
950 imcontext->cursor_location.width = width; 962 imcontext->cursor_location.width = width;
951 imcontext->cursor_location.height = height; 963 imcontext->cursor_location.height = height;
964 imcontext->cursor_location.do_set = EINA_TRUE;
952 965
953 update_state(imcontext); 966 update_state(imcontext);
954 } 967 }