summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2015-10-10 13:39:40 +0900
committerNicolas Aguirre <aguirre.nicolas@gmail.com>2015-11-12 10:15:03 +0100
commitc32848907a118861307d9e2c0e4b2f98caf4eec0 (patch)
tree9eb71fca7b1943962630a6a06ffc0a5d3433848e
parent02fc30deac9f5f422913bd25aa441f6665cf403c (diff)
elm cursor - fix hotspot tracking to actually work right
hotspot tracking was broken. this fixes it. @fix
-rw-r--r--src/lib/els_cursor.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/lib/els_cursor.c b/src/lib/els_cursor.c
index 62c00a2b7..4e6a44327 100644
--- a/src/lib/els_cursor.c
+++ b/src/lib/els_cursor.c
@@ -139,6 +139,7 @@ struct _Elm_Cursor
139 int hot_x, hot_y; 139 int hot_x, hot_y;
140 Ecore_Evas *ee; 140 Ecore_Evas *ee;
141 Evas *evas; 141 Evas *evas;
142 Ecore_Job *hotupdate_job;
142#ifdef HAVE_ELEMENTARY_X 143#ifdef HAVE_ELEMENTARY_X
143 struct { 144 struct {
144 Ecore_X_Cursor cursor; 145 Ecore_X_Cursor cursor;
@@ -171,16 +172,19 @@ _elm_cursor_obj_del(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UN
171} 172}
172 173
173static void 174static void
174_elm_cursor_set_hot_spots(Elm_Cursor *cur) 175_elm_cursor_set_hot_spots(void *data)
175{ 176{
177 Elm_Cursor *cur = data;
176 const char *str; 178 const char *str;
177 Evas_Coord cx, cy, x, y, w, h; 179 Evas_Coord cx, cy, cw, ch, x, y, w, h;
178 int prev_hot_x, prev_hot_y; 180 int prev_hot_x, prev_hot_y;
179 181
182 cur->hotupdate_job = NULL;
183
180 prev_hot_x = cur->hot_x; 184 prev_hot_x = cur->hot_x;
181 prev_hot_y = cur->hot_y; 185 prev_hot_y = cur->hot_y;
182 186
183 evas_object_geometry_get(cur->obj, &cx, &cy, NULL, NULL); 187 evas_object_geometry_get(cur->obj, &cx, &cy, &cw, &ch);
184 evas_object_geometry_get(cur->hotobj, &x, &y, &w, &h); 188 evas_object_geometry_get(cur->hotobj, &x, &y, &w, &h);
185 cur->hot_x = (x + (w / 2)) - cx; 189 cur->hot_x = (x + (w / 2)) - cx;
186 cur->hot_y = (y + (h / 2)) - cy; 190 cur->hot_y = (y + (h / 2)) - cy;
@@ -189,17 +193,21 @@ _elm_cursor_set_hot_spots(Elm_Cursor *cur)
189 if (str) cur->hot_x = atoi(str); 193 if (str) cur->hot_x = atoi(str);
190 str = edje_object_data_get(cur->obj, "hot_y"); 194 str = edje_object_data_get(cur->obj, "hot_y");
191 if (str) cur->hot_y = atoi(str); 195 if (str) cur->hot_y = atoi(str);
192 196
193 if ((cur->visible) && 197 if ((cur->visible) &&
194 ((prev_hot_x != cur->hot_x) || (prev_hot_y != cur->hot_y))) 198 ((prev_hot_x != cur->hot_x) || (prev_hot_y != cur->hot_y)))
195 ecore_evas_object_cursor_set(cur->ee, cur->obj, ELM_OBJECT_LAYER_CURSOR, 199 {
196 cur->hot_x, cur->hot_y); 200 ecore_evas_object_cursor_set(cur->ee, cur->obj,
201 ELM_OBJECT_LAYER_CURSOR,
202 cur->hot_x, cur->hot_y);
203 }
197} 204}
198 205
199static void 206static void
200_elm_cursor_hot_change(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 207_elm_cursor_hot_change(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
201{ 208{
202 _elm_cursor_set_hot_spots(data); 209 Elm_Cursor *cur = data;
210 cur->hotupdate_job = ecore_job_add(_elm_cursor_set_hot_spots, data);
203} 211}
204 212
205static Eina_Bool 213static Eina_Bool
@@ -219,11 +227,15 @@ _elm_cursor_obj_add(Evas_Object *obj, Elm_Cursor *cur)
219 } 227 }
220 cur->hotobj = evas_object_rectangle_add(cur->evas); 228 cur->hotobj = evas_object_rectangle_add(cur->evas);
221 evas_object_color_set(cur->hotobj, 0, 0, 0, 0); 229 evas_object_color_set(cur->hotobj, 0, 0, 0, 0);
222 edje_object_part_swallow(cur->obj, "elm.content.hotspot", cur->hotobj);
223 evas_object_event_callback_add(cur->obj, EVAS_CALLBACK_MOVE, 230 evas_object_event_callback_add(cur->obj, EVAS_CALLBACK_MOVE,
224 _elm_cursor_hot_change, cur); 231 _elm_cursor_hot_change, cur);
225 evas_object_event_callback_add(cur->obj, EVAS_CALLBACK_RESIZE, 232 evas_object_event_callback_add(cur->obj, EVAS_CALLBACK_RESIZE,
226 _elm_cursor_hot_change, cur); 233 _elm_cursor_hot_change, cur);
234 evas_object_event_callback_add(cur->hotobj, EVAS_CALLBACK_MOVE,
235 _elm_cursor_hot_change, cur);
236 evas_object_event_callback_add(cur->hotobj, EVAS_CALLBACK_RESIZE,
237 _elm_cursor_hot_change, cur);
238 edje_object_part_swallow(cur->obj, "elm.content.hotspot", cur->hotobj);
227 239
228 evas_object_event_callback_add(cur->obj, EVAS_CALLBACK_DEL, 240 evas_object_event_callback_add(cur->obj, EVAS_CALLBACK_DEL,
229 _elm_cursor_obj_del, cur); 241 _elm_cursor_obj_del, cur);
@@ -502,8 +514,13 @@ elm_object_cursor_unset(Evas_Object *obj)
502{ 514{
503 ELM_CURSOR_GET_OR_RETURN(cur, obj); 515 ELM_CURSOR_GET_OR_RETURN(cur, obj);
504 516
517 if (cur->hotupdate_job) ecore_job_del(cur->hotupdate_job);
518 cur->hotupdate_job = NULL;
519
505 eina_stringshare_del(cur->cursor_name); 520 eina_stringshare_del(cur->cursor_name);
521 cur->cursor_name = NULL;
506 eina_stringshare_del(cur->style); 522 eina_stringshare_del(cur->style);
523 cur->style = NULL;
507 524
508 if (cur->owner) 525 if (cur->owner)
509 elm_widget_cursor_del(cur->owner, cur); 526 elm_widget_cursor_del(cur->owner, cur);