diff options
author | Marcel Hollerbach <marcel@osg.samsung.com> | 2021-12-05 17:27:06 +0100 |
---|---|---|
committer | Marcel Hollerbach <marcel@osg.samsung.com> | 2021-12-17 13:12:02 +0100 |
commit | b23776416118cc96348b4cde4ce0e88a35b8ef87 (patch) | |
tree | 539bd88889a491c6454694ec45375518e67c8d04 /src/bin | |
parent | 36eafd9a0ee18b0b780e7560f55a9b4d6821815d (diff) | |
download | enlightenment-b23776416118cc96348b4cde4ce0e88a35b8ef87.tar.gz |
e_pointer: improve overall
do not allow a dangling pointer, and check all entities that require the
pointer object to be alive.
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/e_pointer.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/bin/e_pointer.c b/src/bin/e_pointer.c index 22a040fb44..dd4df9b90e 100644 --- a/src/bin/e_pointer.c +++ b/src/bin/e_pointer.c @@ -250,15 +250,26 @@ _e_pointer_cb_hot_show(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA } static void +_del_cb(void *data, const Efl_Event *ev EINA_UNUSED) { + E_Pointer *ptr = data; + INF("Cursor-Object (%p) of %p was removed!", ptr->o_ptr, data); + ptr->o_ptr = NULL; + return; +} + +static void _e_pointer_pointer_canvas_init(E_Pointer *ptr, Evas *e, Evas_Object **o_ptr, Evas_Object **o_hot) { /* create pointer object */ *o_ptr = edje_object_add(e); + efl_event_callback_add(*o_ptr, EFL_EVENT_DEL, _del_cb, ptr); + /* create hotspot object */ *o_hot = evas_object_rectangle_add(e); evas_object_color_set(*o_hot, 0, 0, 0, 0); + evas_object_event_callback_add(*o_hot, EVAS_CALLBACK_MOVE, _e_pointer_cb_hot_move, ptr); evas_object_event_callback_add(*o_ptr, EVAS_CALLBACK_MOVE, @@ -622,6 +633,9 @@ e_pointer_hide(E_Pointer *ptr) E_API void e_pointer_show(E_Pointer *ptr) { + EINA_SAFETY_ON_NULL_RETURN(ptr); + EINA_SAFETY_ON_NULL_RETURN(ptr->o_ptr); + if ((!ptr->buffer_evas) && ptr->win) _e_pointer_canvas_add(ptr); if (ptr->canvas) evas_object_show(ptr->o_ptr); @@ -633,6 +647,7 @@ e_pointer_type_push(E_Pointer *ptr, void *obj, const char *type) E_Pointer_Stack *stack; EINA_SAFETY_ON_NULL_RETURN(ptr); + EINA_SAFETY_ON_NULL_RETURN(obj); _e_pointer_type_set(ptr, type); @@ -788,6 +803,10 @@ e_pointer_idler_before(void) { if ((!ptr->e_cursor) || (!ptr->buffer_evas)) continue; + if (!ptr->o_ptr) { + EINA_SAFETY_ERROR("ptr->o_ptr is NULL should not be NULL!"); + } + if (ptr->hot.update) _e_pointer_type_set(ptr, ptr->type); @@ -826,6 +845,9 @@ e_pointer_object_set(E_Pointer *ptr, Evas_Object *obj, int x, int y) E_Client *ec; int px, py; + EINA_SAFETY_ON_NULL_RETURN(ptr); + EINA_SAFETY_ON_NULL_RETURN(ptr->o_ptr); + ecore_evas_cursor_get(ptr->ee, &o, NULL, &px, &py); if (o) { @@ -872,6 +894,9 @@ e_pointer_window_add(E_Pointer *ptr, Ecore_Window win) E_API void e_pointer_grab_set(E_Pointer *ptr, Eina_Bool grab) { + EINA_SAFETY_ON_NULL_RETURN(ptr); + EINA_SAFETY_ON_NULL_RETURN(ptr->o_ptr); + if (grab) ptr->grabcount++; else { |