davemds pushed a commit to branch master.

http://git.enlightenment.org/core/elementary.git/commit/?id=b8afe3f03dbbca5c5382d8c2946d0480f8c41917

commit b8afe3f03dbbca5c5382d8c2946d0480f8c41917
Author: Dave Andreoli <d...@gurumeditation.it>
Date:   Wed May 20 21:31:53 2015 +0200

    Immediatly change the cursor if changed from inside the widget
    
    @fix elm_object_cursor_set() to work also when used with the mouse pointer
    yet inside the widget, otherwise you need to mouseout/mousein to actually 
see
    the new setted cursor.
    
    Please give a short review on this one, maybe there is a simpler way to 
check
    if the pointer is inside the widget...
    
    Also added a button in the cursor test for this use case
---
 src/bin/test_cursor.c | 24 ++++++++++++++++++++++++
 src/lib/elm_priv.h    |  4 ++++
 src/lib/els_cursor.c  |  6 ++++++
 3 files changed, 34 insertions(+)

diff --git a/src/bin/test_cursor.c b/src/bin/test_cursor.c
index 04f3b87..1e6401a 100644
--- a/src/bin/test_cursor.c
+++ b/src/bin/test_cursor.c
@@ -15,6 +15,7 @@ typedef struct _Testitem
 } Testitem;
 
 static Elm_Gengrid_Item_Class gic;
+static Eina_Bool cursor_setted = EINA_FALSE;
 
 char *
 grd_lbl_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part 
EINA_UNUSED)
@@ -94,6 +95,23 @@ glt_text_get(void *data, Evas_Object *obj EINA_UNUSED, const 
char *part EINA_UNU
    return strdup(buf);
 }
 
+static void
+bt_clicked(void *data EINA_UNUSED, Evas_Object *obj, void *event_info 
EINA_UNUSED)
+{
+   if (cursor_setted)
+     {
+        elm_object_cursor_unset(obj);
+        cursor_setted = EINA_FALSE;
+        elm_object_text_set(obj, "Cursor set on click");
+     }
+   else
+     {
+        elm_object_cursor_set(obj, ELM_CURSOR_HAND1);
+        cursor_setted = EINA_TRUE;
+        elm_object_text_set(obj, "Cursor unset on click");
+     }
+}
+
 void
 test_cursor(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void 
*event_info EINA_UNUSED)
 {
@@ -133,6 +151,12 @@ test_cursor(void *data EINA_UNUSED, Evas_Object *obj 
EINA_UNUSED, void *event_in
    elm_box_pack_end(bx, bt);
    evas_object_show(bt);
 
+   bt = elm_button_add(win);
+   elm_object_text_set(bt, "Cursor set on click");
+   evas_object_smart_callback_add(bt, "clicked", bt_clicked, NULL);
+   elm_box_pack_end(bx, bt);
+   evas_object_show(bt);
+
    list = elm_list_add(win);
    elm_box_pack_end(bx, list);
    evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
index 1378d9b..9e7bc42 100644
--- a/src/lib/elm_priv.h
+++ b/src/lib/elm_priv.h
@@ -164,6 +164,10 @@ extern const char *_elm_engines[];
 #define MAX(x, y) (((x) > (y)) ? (x) : (y))
 #undef CEIL
 #define CEIL(a)   (((a) % 2 != 0) ? ((a) / 2 + 1) : ((a) / 2))
+#undef IS_INSIDE
+#define IS_INSIDE(x, y, xx, yy, ww, hh) \
+  (((x) < ((xx) + (ww))) && ((y) < ((yy) + (hh))) && \
+  ((x) >= (xx)) && ((y) >= (yy)))
 
 
 #define ELM_SAFE_FREE(_h, _fn) do { _fn((void*)_h); _h = NULL; } while (0)
diff --git a/src/lib/els_cursor.c b/src/lib/els_cursor.c
index c4eae47..c28994b 100644
--- a/src/lib/els_cursor.c
+++ b/src/lib/els_cursor.c
@@ -406,6 +406,12 @@ _elm_cursor_cur_set(Elm_Cursor *cur)
 #endif
           }
      }
+
+   Evas_Coord x, y, w, h, px, py;
+   evas_object_geometry_get(cur->eventarea, &x, &y, &w, &h);
+   evas_pointer_canvas_xy_get(cur->evas, &px, &py);
+   if (IS_INSIDE(px, py, x, y, w, h))
+     _elm_cursor_set(cur);
 }
 
 /**

-- 


Reply via email to