raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=165efe2254ecd352011d28a351cd874c6eb0a181

commit 165efe2254ecd352011d28a351cd874c6eb0a181
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Wed Apr 2 20:29:03 2014 +0900

    ecore-evas - fix object cursor to not delete the same cursor when set
    
    this fixes a misbehavior with ecore evas object cursors when you set
    one, the old one is deleted, but if the old is the same, the new one
    you set gets deleted, rather than just updated.
    
    @fix
---
 .../ecore_evas/engines/cocoa/ecore_evas_cocoa.c    | 61 +++++++++++++---------
 .../ecore_evas/engines/drm/ecore_evas_drm.c        | 39 ++++++++------
 src/modules/ecore_evas/engines/fb/ecore_evas_fb.c  | 37 ++++++++-----
 .../engines/psl1ght/ecore_evas_psl1ght.c           | 37 ++++++++-----
 .../ecore_evas/engines/sdl/ecore_evas_sdl.c        | 37 ++++++++-----
 .../engines/wayland/ecore_evas_wayland_common.c    | 42 +++++++++------
 .../ecore_evas/engines/win32/ecore_evas_win32.c    | 47 +++++++++++------
 src/modules/ecore_evas/engines/x/ecore_evas_x.c    | 29 ++++++----
 8 files changed, 206 insertions(+), 123 deletions(-)

diff --git a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c 
b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c
index 6722f71..88e3ba1 100644
--- a/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c
+++ b/src/modules/ecore_evas/engines/cocoa/ecore_evas_cocoa.c
@@ -338,36 +338,45 @@ _ecore_evas_object_cursor_del(void *data, Evas *e, 
Evas_Object *obj, void *event
 static void
 _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int 
hot_x, int hot_y)
 {
-  int x, y;
-  DBG("Cursor Set");
-  if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
+   int x, y;
+   Evas_Object *old;
+   DBG("Cursor Set");
 
-  if (obj == NULL)
-    {
-      ee->prop.cursor.object = NULL;
-      ee->prop.cursor.layer = 0;
-      ee->prop.cursor.hot.x = 0;
-      ee->prop.cursor.hot.y = 0;
-      return;
-    }
-
-  ee->prop.cursor.object = obj;
-  ee->prop.cursor.layer = layer;
-  ee->prop.cursor.hot.x = hot_x;
-  ee->prop.cursor.hot.y = hot_y;
-
-  evas_pointer_output_xy_get(ee->evas, &x, &y);
-  evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+   old = ee->prop.cursor.object;
+   if (obj == NULL)
+     {
+        ee->prop.cursor.object = NULL;
+        ee->prop.cursor.layer = 0;
+        ee->prop.cursor.hot.x = 0;
+        ee->prop.cursor.hot.y = 0;
+        goto end;
+     }
+   
+   ee->prop.cursor.object = obj;
+   ee->prop.cursor.layer = layer;
+   ee->prop.cursor.hot.x = hot_x;
+   ee->prop.cursor.hot.y = hot_y;
+   
+   if (obj != old)
+     {
+        evas_pointer_output_xy_get(ee->evas, &x, &y);
+        evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+        evas_object_pass_events_set(ee->prop.cursor.object, 1);
+        if (evas_pointer_inside_get(ee->evas))
+          evas_object_show(ee->prop.cursor.object);
+        evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
+                                       _ecore_evas_object_cursor_del, ee);
+     }
   evas_object_move(ee->prop.cursor.object,
                   x - ee->prop.cursor.hot.x,
                   y - ee->prop.cursor.hot.y);
-
-  evas_object_pass_events_set(ee->prop.cursor.object, 1);
-
-  if (evas_pointer_inside_get(ee->evas))
-    evas_object_show(ee->prop.cursor.object);
-
-  evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, 
_ecore_evas_object_cursor_del, ee);
+end:
+   if ((old) && (obj != old))
+     {
+        evas_object_event_callback_del_full
+          (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
+        evas_object_del(old);
+     }
 }
 
 static int
diff --git a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c 
b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
index fc8bd6c..9e6904d 100644
--- a/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
+++ b/src/modules/ecore_evas/engines/drm/ecore_evas_drm.c
@@ -577,34 +577,43 @@ static void
 _ecore_evas_drm_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, 
int hot_x, int hot_y)
 {
    int x, y;
-
-   if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
-
-   if (!obj)
+   Evas_Object *old;
+   
+   old = ee->prop.cursor.object;
+   if (obj == NULL)
      {
         ee->prop.cursor.object = NULL;
         ee->prop.cursor.layer = 0;
         ee->prop.cursor.hot.x = 0;
         ee->prop.cursor.hot.y = 0;
-        return;
+        goto end;
      }
-
+   
    ee->prop.cursor.object = obj;
    ee->prop.cursor.layer = layer;
    ee->prop.cursor.hot.x = hot_x;
    ee->prop.cursor.hot.y = hot_y;
-
-   evas_pointer_output_xy_get(ee->evas, &x, &y);
-   evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+   
+   if (obj != old)
+     {
+        evas_pointer_output_xy_get(ee->evas, &x, &y);
+        evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+        evas_object_pass_events_set(ee->prop.cursor.object, 1);
+        if (evas_pointer_inside_get(ee->evas))
+          evas_object_show(ee->prop.cursor.object);
+        evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
+                                       _ecore_evas_drm_object_cursor_del, ee);
+     }
    evas_object_move(ee->prop.cursor.object,
                     x - ee->prop.cursor.hot.x,
                     y - ee->prop.cursor.hot.y);
-   evas_object_pass_events_set(ee->prop.cursor.object, 1);
-   if (evas_pointer_inside_get(ee->evas))
-     evas_object_show(ee->prop.cursor.object);
-
-   evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, 
-                                  _ecore_evas_drm_object_cursor_del, ee);
+end:
+   if ((old) && (obj != old))
+     {
+        evas_object_event_callback_del_full
+          (old, EVAS_CALLBACK_DEL, _ecore_evas_drm_object_cursor_del, ee);
+        evas_object_del(old);
+     }
 }
 
 static void 
diff --git a/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c 
b/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c
index 4b3fd5c..b8dc756 100644
--- a/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c
+++ b/src/modules/ecore_evas/engines/fb/ecore_evas_fb.c
@@ -425,32 +425,43 @@ static void
 _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int 
hot_x, int hot_y)
 {
    int x, y;
-
-   if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
-
-   if (!obj)
+   Evas_Object *old;
+   
+   old = ee->prop.cursor.object;
+   if (obj == NULL)
      {
         ee->prop.cursor.object = NULL;
         ee->prop.cursor.layer = 0;
         ee->prop.cursor.hot.x = 0;
         ee->prop.cursor.hot.y = 0;
-        return;
+        goto end;
      }
-
+   
    ee->prop.cursor.object = obj;
    ee->prop.cursor.layer = layer;
    ee->prop.cursor.hot.x = hot_x;
    ee->prop.cursor.hot.y = hot_y;
-   evas_pointer_output_xy_get(ee->evas, &x, &y);
-   evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+   
+   if (obj != old)
+     {
+        evas_pointer_output_xy_get(ee->evas, &x, &y);
+        evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+        evas_object_pass_events_set(ee->prop.cursor.object, 1);
+        if (evas_pointer_inside_get(ee->evas))
+          evas_object_show(ee->prop.cursor.object);
+        evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
+                                       _ecore_evas_object_cursor_del, ee);
+     }
    evas_object_move(ee->prop.cursor.object,
                     x - ee->prop.cursor.hot.x,
                     y - ee->prop.cursor.hot.y);
-   evas_object_pass_events_set(ee->prop.cursor.object, 1);
-   if (evas_pointer_inside_get(ee->evas))
-     evas_object_show(ee->prop.cursor.object);
-
-   evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, 
_ecore_evas_object_cursor_del, ee);
+end:
+   if ((old) && (obj != old))
+     {
+        evas_object_event_callback_del_full
+          (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
+        evas_object_del(old);
+     }
 }
 
 static void
diff --git a/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c 
b/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c
index 032dbba..bc71654 100644
--- a/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c
+++ b/src/modules/ecore_evas/engines/psl1ght/ecore_evas_psl1ght.c
@@ -317,32 +317,43 @@ static void
 _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int 
hot_x, int hot_y)
 {
    int x, y;
-
-   if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
-
-   if (!obj)
+   Evas_Object *old;
+   
+   old = ee->prop.cursor.object;
+   if (obj == NULL)
      {
         ee->prop.cursor.object = NULL;
         ee->prop.cursor.layer = 0;
         ee->prop.cursor.hot.x = 0;
         ee->prop.cursor.hot.y = 0;
-        return;
+        goto end;
      }
-
+   
    ee->prop.cursor.object = obj;
    ee->prop.cursor.layer = layer;
    ee->prop.cursor.hot.x = hot_x;
    ee->prop.cursor.hot.y = hot_y;
-   evas_pointer_output_xy_get(ee->evas, &x, &y);
-   evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+   
+   if (obj != old)
+     {
+        evas_pointer_output_xy_get(ee->evas, &x, &y);
+        evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+        evas_object_pass_events_set(ee->prop.cursor.object, 1);
+        if (evas_pointer_inside_get(ee->evas))
+          evas_object_show(ee->prop.cursor.object);
+        evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
+                                       _ecore_evas_object_cursor_del, ee);
+     }
    evas_object_move(ee->prop.cursor.object,
                     x - ee->prop.cursor.hot.x,
                     y - ee->prop.cursor.hot.y);
-   evas_object_pass_events_set(ee->prop.cursor.object, 1);
-   if (evas_pointer_inside_get(ee->evas))
-     evas_object_show(ee->prop.cursor.object);
-
-   evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, 
_ecore_evas_object_cursor_del, ee);
+end:
+   if ((old) && (obj != old))
+     {
+        evas_object_event_callback_del_full
+          (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
+        evas_object_del(old);
+     }
 }
 
 static Ecore_Evas_Engine_Func _ecore_psl1ght_engine_func =
diff --git a/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c 
b/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c
index 98bd98a..6dfd7d6 100644
--- a/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c
+++ b/src/modules/ecore_evas/engines/sdl/ecore_evas_sdl.c
@@ -357,32 +357,43 @@ static void
 _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int 
hot_x, int hot_y)
 {
    int x, y;
-
-   if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
-
-   if (!obj)
+   Evas_Object *old;
+   
+   old = ee->prop.cursor.object;
+   if (obj == NULL)
      {
         ee->prop.cursor.object = NULL;
         ee->prop.cursor.layer = 0;
         ee->prop.cursor.hot.x = 0;
         ee->prop.cursor.hot.y = 0;
-        return;
+        goto end;
      }
-
+   
    ee->prop.cursor.object = obj;
    ee->prop.cursor.layer = layer;
    ee->prop.cursor.hot.x = hot_x;
    ee->prop.cursor.hot.y = hot_y;
-   evas_pointer_output_xy_get(ee->evas, &x, &y);
-   evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+   
+   if (obj != old)
+     {
+        evas_pointer_output_xy_get(ee->evas, &x, &y);
+        evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+        evas_object_pass_events_set(ee->prop.cursor.object, 1);
+        if (evas_pointer_inside_get(ee->evas))
+          evas_object_show(ee->prop.cursor.object);
+        evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
+                                       _ecore_evas_object_cursor_del, ee);
+     }
    evas_object_move(ee->prop.cursor.object,
                     x - ee->prop.cursor.hot.x,
                     y - ee->prop.cursor.hot.y);
-   evas_object_pass_events_set(ee->prop.cursor.object, 1);
-   if (evas_pointer_inside_get(ee->evas))
-     evas_object_show(ee->prop.cursor.object);
-
-   evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, 
_ecore_evas_object_cursor_del, ee);
+end:
+   if ((old) && (obj != old))
+     {
+        evas_object_event_callback_del_full
+          (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
+        evas_object_del(old);
+     }
 }
 
 static Ecore_Evas_Engine_Func _ecore_sdl_engine_func =
diff --git a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c 
b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
index dd0edd7..ef5ec4a 100644
--- a/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
+++ b/src/modules/ecore_evas/engines/wayland/ecore_evas_wayland_common.c
@@ -1181,37 +1181,45 @@ _ecore_evas_wl_common_object_cursor_set(Ecore_Evas *ee, 
Evas_Object *obj, int la
 {
    int x, y, fx, fy;
    Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
-
-   if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
-
-   if (!obj)
+   Evas_Object *old;
+   
+   old = ee->prop.cursor.object;
+   if (obj == NULL)
      {
         ee->prop.cursor.object = NULL;
         ee->prop.cursor.layer = 0;
         ee->prop.cursor.hot.x = 0;
         ee->prop.cursor.hot.y = 0;
-        ecore_wl_window_cursor_default_restore(wdata->win);
-        return;
+        goto end;
      }
-
+   
    ee->prop.cursor.object = obj;
    ee->prop.cursor.layer = layer;
    ee->prop.cursor.hot.x = hot_x;
    ee->prop.cursor.hot.y = hot_y;
-
-   ecore_wl_window_pointer_set(wdata->win, NULL, 0, 0);
-
-   evas_pointer_output_xy_get(ee->evas, &x, &y);
+   
+   if (obj != old)
+     {
+        ecore_wl_window_pointer_set(wdata->win, NULL, 0, 0);
+        evas_pointer_output_xy_get(ee->evas, &x, &y);
+        evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+        evas_object_pass_events_set(ee->prop.cursor.object, 1);
+        if (evas_pointer_inside_get(ee->evas))
+          evas_object_show(ee->prop.cursor.object);
+        evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
+                                       _ecore_evas_object_cursor_del, ee);
+     }
    evas_output_framespace_get(ee->evas, &fx, &fy, NULL, NULL);
-   evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
    evas_object_move(ee->prop.cursor.object,
                     x - fx - ee->prop.cursor.hot.x,
                     y - fy - ee->prop.cursor.hot.y);
-   evas_object_pass_events_set(ee->prop.cursor.object, 1);
-   if (evas_pointer_inside_get(ee->evas))
-     evas_object_show(ee->prop.cursor.object);
-
-   evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, 
_ecore_evas_object_cursor_del, ee);
+end:
+   if ((old) && (obj != old))
+     {
+        evas_object_event_callback_del_full
+          (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
+        evas_object_del(old);
+     }
 }
 
 void
diff --git a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c 
b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
index 2ff8998..93f87d2 100644
--- a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
+++ b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c
@@ -809,39 +809,56 @@ _ecore_evas_win32_size_step_set(Ecore_Evas *ee, int 
width, int height)
 }
 
 static void
+_ecore_evas_object_cursor_del(void *data, Evas *e EINA_UNUSED, Evas_Object 
*obj EINA_UNUSED, void *event_info EINA_UNUSED)
+{
+   Ecore_Evas *ee;
+   
+   ee = data;
+   if (ee) ee->prop.cursor.object = NULL;
+}
+                              
+static void
 _ecore_evas_win32_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int 
hot_x, int hot_y)
 {
-#if 0
    int x, y;
-
-   if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
-
+   Evas_Object *old;
+   
+   old = ee->prop.cursor.object;
    if (obj == NULL)
      {
         ee->prop.cursor.object = NULL;
         ee->prop.cursor.layer = 0;
         ee->prop.cursor.hot.x = 0;
         ee->prop.cursor.hot.y = 0;
-        ecore_win32_window_cursor_show(ee->prop.window, 1);
-        return;
+        goto end;
      }
-
+   
    ee->prop.cursor.object = obj;
    ee->prop.cursor.layer = layer;
    ee->prop.cursor.hot.x = hot_x;
    ee->prop.cursor.hot.y = hot_y;
 
-   ecore_win32_window_cursor_show(ee->prop.window, 0);
-
-   evas_pointer_output_xy_get(ee->evas, &x, &y);
-   evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+   if (obj != old)
+     {
+        ecore_win32_window_cursor_show(ee->prop.window, 0);
+        evas_pointer_output_xy_get(ee->evas, &x, &y);
+        evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+        evas_object_pass_events_set(ee->prop.cursor.object, 1);
+        if (evas_pointer_inside_get(ee->evas))
+          evas_object_show(ee->prop.cursor.object);
+        evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
+                                       _ecore_evas_object_cursor_del, ee);
+     }
    evas_object_move(ee->prop.cursor.object,
                     x - ee->prop.cursor.hot.x,
                     y - ee->prop.cursor.hot.y);
-   evas_object_pass_events_set(ee->prop.cursor.object, 1);
-   if (evas_pointer_inside_get(ee->evas))
-     evas_object_show(ee->prop.cursor.object);
-#endif
+end:
+   if ((old) && (obj != old))
+     {
+        evas_object_event_callback_del_full
+          (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
+        evas_object_del(old);
+     }
 }
 
 static void
diff --git a/src/modules/ecore_evas/engines/x/ecore_evas_x.c 
b/src/modules/ecore_evas/engines/x/ecore_evas_x.c
index 0079c48..97086cf 100644
--- a/src/modules/ecore_evas/engines/x/ecore_evas_x.c
+++ b/src/modules/ecore_evas/engines/x/ecore_evas_x.c
@@ -2971,7 +2971,7 @@ static void
 _ecore_evas_x_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, 
int hot_x, int hot_y)
 {
    int x, y;
-   Evas_Object* old;
+   Evas_Object *old;
 
    old = ee->prop.cursor.object;
    if (!obj)
@@ -2989,21 +2989,28 @@ _ecore_evas_x_object_cursor_set(Ecore_Evas *ee, 
Evas_Object *obj, int layer, int
    ee->prop.cursor.hot.x = hot_x;
    ee->prop.cursor.hot.y = hot_y;
 
-   ecore_x_window_cursor_show(ee->prop.window, 0);
-
-   evas_pointer_output_xy_get(ee->evas, &x, &y);
-   evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+   if (obj != old)
+     {
+        ecore_x_window_cursor_show(ee->prop.window, 0);
+        evas_pointer_output_xy_get(ee->evas, &x, &y);
+        evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+        evas_object_pass_events_set(ee->prop.cursor.object, 1);
+        if (evas_pointer_inside_get(ee->evas))
+          evas_object_show(ee->prop.cursor.object);
+        evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
+                                       _ecore_evas_object_cursor_del, ee);
+     }
    evas_object_move(ee->prop.cursor.object,
                     x - ee->prop.cursor.hot.x,
                     y - ee->prop.cursor.hot.y);
-   evas_object_pass_events_set(ee->prop.cursor.object, 1);
-   if (evas_pointer_inside_get(ee->evas))
-     evas_object_show(ee->prop.cursor.object);
-
-   evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, 
_ecore_evas_object_cursor_del, ee);
 
 end:
-   if (old) evas_object_del(old);
+   if ((old) && (obj != old))
+     {
+        evas_object_event_callback_del_full
+          (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
+        evas_object_del(old);
+     }
 }
 
 /*

-- 


Reply via email to