From 165efe2254ecd352011d28a351cd874c6eb0a181 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Wed, 2 Apr 2014 20:29:03 +0900 Subject: [PATCH] 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 --- .../engines/cocoa/ecore_evas_cocoa.c | 61 +++++++++++-------- .../ecore_evas/engines/drm/ecore_evas_drm.c | 39 +++++++----- .../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 +++++++---- .../wayland/ecore_evas_wayland_common.c | 42 +++++++------ .../engines/win32/ecore_evas_win32.c | 47 +++++++++----- .../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 6722f71977..88e3ba105f 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 fc8bd6c96b..9e6904d6e9 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 4b3fd5c3dd..b8dc756af8 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 032dbba5c3..bc71654315 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 98bd98a6f3..6dfd7d6b2b 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 dd0edd71c3..ef5ec4a6a7 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 2ff8998f8b..93f87d2040 100644 --- a/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c +++ b/src/modules/ecore_evas/engines/win32/ecore_evas_win32.c @@ -808,40 +808,57 @@ _ecore_evas_win32_size_step_set(Ecore_Evas *ee, int width, int height) width, 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 0079c4897a..97086cfb2b 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); + } } /*