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
_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;
}
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;
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 int

View File

@ -577,16 +577,16 @@ 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;
Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
if (!obj)
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;
@ -594,17 +594,26 @@ _ecore_evas_drm_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, i
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

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)
{
int x, y;
Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
if (!obj)
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

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)
{
int x, y;
Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
if (!obj)
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 =

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)
{
int x, y;
Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
if (!obj)
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 =

View File

@ -1181,17 +1181,16 @@ _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;
Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
if (!obj)
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;
@ -1199,19 +1198,28 @@ _ecore_evas_wl_common_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int la
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

View File

@ -808,22 +808,29 @@ _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;
Evas_Object *old;
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
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;
@ -831,17 +838,27 @@ _ecore_evas_win32_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int ho
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

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)
{
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);
}
}
/*