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
This commit is contained in:
Carsten Haitzler 2014-04-02 20:29:03 +09:00
parent 2de5aaefac
commit 165efe2254
8 changed files with 206 additions and 123 deletions

View File

@ -338,36 +338,45 @@ _ecore_evas_object_cursor_del(void *data, Evas *e, Evas_Object *obj, void *event
static void static void
_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{ {
int x, y; int x, y;
DBG("Cursor Set"); Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object); DBG("Cursor Set");
if (obj == NULL) old = ee->prop.cursor.object;
{ if (obj == NULL)
ee->prop.cursor.object = NULL; {
ee->prop.cursor.layer = 0; ee->prop.cursor.object = NULL;
ee->prop.cursor.hot.x = 0; ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.y = 0; ee->prop.cursor.hot.x = 0;
return; ee->prop.cursor.hot.y = 0;
} goto end;
}
ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer; ee->prop.cursor.object = obj;
ee->prop.cursor.hot.x = hot_x; ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.y = hot_y; 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, evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x, x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y); y - ee->prop.cursor.hot.y);
end:
evas_object_pass_events_set(ee->prop.cursor.object, 1); if ((old) && (obj != old))
{
if (evas_pointer_inside_get(ee->evas)) evas_object_event_callback_del_full
evas_object_show(ee->prop.cursor.object); (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
evas_object_del(old);
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); }
} }
static int static int

View File

@ -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) _ecore_evas_drm_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{ {
int x, y; int x, y;
Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
old = ee->prop.cursor.object;
if (!obj) if (obj == NULL)
{ {
ee->prop.cursor.object = NULL; ee->prop.cursor.object = NULL;
ee->prop.cursor.layer = 0; ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0; ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0; ee->prop.cursor.hot.y = 0;
return; goto end;
} }
ee->prop.cursor.object = obj; ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer; ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x; ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y; ee->prop.cursor.hot.y = hot_y;
evas_pointer_output_xy_get(ee->evas, &x, &y); if (obj != old)
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); {
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, evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x, x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y); y - ee->prop.cursor.hot.y);
evas_object_pass_events_set(ee->prop.cursor.object, 1); end:
if (evas_pointer_inside_get(ee->evas)) if ((old) && (obj != old))
evas_object_show(ee->prop.cursor.object); {
evas_object_event_callback_del_full
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, (old, EVAS_CALLBACK_DEL, _ecore_evas_drm_object_cursor_del, ee);
_ecore_evas_drm_object_cursor_del, ee); evas_object_del(old);
}
} }
static void static void

View File

@ -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) _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{ {
int x, y; int x, y;
Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
old = ee->prop.cursor.object;
if (!obj) if (obj == NULL)
{ {
ee->prop.cursor.object = NULL; ee->prop.cursor.object = NULL;
ee->prop.cursor.layer = 0; ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0; ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0; ee->prop.cursor.hot.y = 0;
return; goto end;
} }
ee->prop.cursor.object = obj; ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer; ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x; ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y; 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, evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x, x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y); y - ee->prop.cursor.hot.y);
evas_object_pass_events_set(ee->prop.cursor.object, 1); end:
if (evas_pointer_inside_get(ee->evas)) if ((old) && (obj != old))
evas_object_show(ee->prop.cursor.object); {
evas_object_event_callback_del_full
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
evas_object_del(old);
}
} }
static void static void

View File

@ -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) _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{ {
int x, y; int x, y;
Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
old = ee->prop.cursor.object;
if (!obj) if (obj == NULL)
{ {
ee->prop.cursor.object = NULL; ee->prop.cursor.object = NULL;
ee->prop.cursor.layer = 0; ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0; ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0; ee->prop.cursor.hot.y = 0;
return; goto end;
} }
ee->prop.cursor.object = obj; ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer; ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x; ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y; 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, evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x, x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y); y - ee->prop.cursor.hot.y);
evas_object_pass_events_set(ee->prop.cursor.object, 1); end:
if (evas_pointer_inside_get(ee->evas)) if ((old) && (obj != old))
evas_object_show(ee->prop.cursor.object); {
evas_object_event_callback_del_full
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
evas_object_del(old);
}
} }
static Ecore_Evas_Engine_Func _ecore_psl1ght_engine_func = static Ecore_Evas_Engine_Func _ecore_psl1ght_engine_func =

View File

@ -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) _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{ {
int x, y; int x, y;
Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
old = ee->prop.cursor.object;
if (!obj) if (obj == NULL)
{ {
ee->prop.cursor.object = NULL; ee->prop.cursor.object = NULL;
ee->prop.cursor.layer = 0; ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0; ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0; ee->prop.cursor.hot.y = 0;
return; goto end;
} }
ee->prop.cursor.object = obj; ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer; ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x; ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y; 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, evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x, x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y); y - ee->prop.cursor.hot.y);
evas_object_pass_events_set(ee->prop.cursor.object, 1); end:
if (evas_pointer_inside_get(ee->evas)) if ((old) && (obj != old))
evas_object_show(ee->prop.cursor.object); {
evas_object_event_callback_del_full
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
evas_object_del(old);
}
} }
static Ecore_Evas_Engine_Func _ecore_sdl_engine_func = static Ecore_Evas_Engine_Func _ecore_sdl_engine_func =

View File

@ -1181,37 +1181,45 @@ _ecore_evas_wl_common_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int la
{ {
int x, y, fx, fy; int x, y, fx, fy;
Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data; Ecore_Evas_Engine_Wl_Data *wdata = ee->engine.data;
Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
old = ee->prop.cursor.object;
if (!obj) if (obj == NULL)
{ {
ee->prop.cursor.object = NULL; ee->prop.cursor.object = NULL;
ee->prop.cursor.layer = 0; ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0; ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0; ee->prop.cursor.hot.y = 0;
ecore_wl_window_cursor_default_restore(wdata->win); goto end;
return;
} }
ee->prop.cursor.object = obj; ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer; ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x; ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y; ee->prop.cursor.hot.y = hot_y;
ecore_wl_window_pointer_set(wdata->win, NULL, 0, 0); if (obj != old)
{
evas_pointer_output_xy_get(ee->evas, &x, &y); 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_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, evas_object_move(ee->prop.cursor.object,
x - fx - ee->prop.cursor.hot.x, x - fx - ee->prop.cursor.hot.x,
y - fy - ee->prop.cursor.hot.y); y - fy - ee->prop.cursor.hot.y);
evas_object_pass_events_set(ee->prop.cursor.object, 1); end:
if (evas_pointer_inside_get(ee->evas)) if ((old) && (obj != old))
evas_object_show(ee->prop.cursor.object); {
evas_object_event_callback_del_full
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee); (old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
evas_object_del(old);
}
} }
void void

View File

@ -808,40 +808,57 @@ _ecore_evas_win32_size_step_set(Ecore_Evas *ee, int width, int height)
width, 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 static void
_ecore_evas_win32_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y) _ecore_evas_win32_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{ {
#if 0
int x, y; int x, y;
Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
old = ee->prop.cursor.object;
if (obj == NULL) if (obj == NULL)
{ {
ee->prop.cursor.object = NULL; ee->prop.cursor.object = NULL;
ee->prop.cursor.layer = 0; ee->prop.cursor.layer = 0;
ee->prop.cursor.hot.x = 0; ee->prop.cursor.hot.x = 0;
ee->prop.cursor.hot.y = 0; ee->prop.cursor.hot.y = 0;
ecore_win32_window_cursor_show(ee->prop.window, 1); goto end;
return;
} }
ee->prop.cursor.object = obj; ee->prop.cursor.object = obj;
ee->prop.cursor.layer = layer; ee->prop.cursor.layer = layer;
ee->prop.cursor.hot.x = hot_x; ee->prop.cursor.hot.x = hot_x;
ee->prop.cursor.hot.y = hot_y; ee->prop.cursor.hot.y = hot_y;
ecore_win32_window_cursor_show(ee->prop.window, 0); if (obj != old)
{
evas_pointer_output_xy_get(ee->evas, &x, &y); ecore_win32_window_cursor_show(ee->prop.window, 0);
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); 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, evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x, x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y); y - ee->prop.cursor.hot.y);
evas_object_pass_events_set(ee->prop.cursor.object, 1); end:
if (evas_pointer_inside_get(ee->evas)) if ((old) && (obj != old))
evas_object_show(ee->prop.cursor.object); {
#endif evas_object_event_callback_del_full
(old, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
evas_object_del(old);
}
} }
static void static void

View File

@ -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) _ecore_evas_x_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{ {
int x, y; int x, y;
Evas_Object* old; Evas_Object *old;
old = ee->prop.cursor.object; old = ee->prop.cursor.object;
if (!obj) 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.x = hot_x;
ee->prop.cursor.hot.y = hot_y; ee->prop.cursor.hot.y = hot_y;
ecore_x_window_cursor_show(ee->prop.window, 0); if (obj != old)
{
evas_pointer_output_xy_get(ee->evas, &x, &y); ecore_x_window_cursor_show(ee->prop.window, 0);
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); 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, evas_object_move(ee->prop.cursor.object,
x - ee->prop.cursor.hot.x, x - ee->prop.cursor.hot.x,
y - ee->prop.cursor.hot.y); 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: 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);
}
} }
/* /*