zmike pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=3fd669376470e03ec7ebe33e0040bc186c7ce913
commit 3fd669376470e03ec7ebe33e0040bc186c7ce913 Author: Cedric Bail <[email protected]> Date: Thu Oct 31 13:20:39 2019 -0400 evas: move exposed internal structure of Efl_Input_Device to be private. Summary: Depends on D10489 Reviewers: zmike, raster, bu5hm4n, Hermet Reviewed By: zmike Subscribers: #reviewers, #committers Tags: #efl Maniphest Tasks: T8321 Differential Revision: https://phab.enlightenment.org/D10490 --- src/lib/evas/Evas_Internal.h | 22 ++++----- src/lib/evas/canvas/efl_input_device.c | 59 ++++++++++++++++++++++++ src/lib/evas/canvas/evas_device.c | 82 ++++++++++------------------------ 3 files changed, 91 insertions(+), 72 deletions(-) diff --git a/src/lib/evas/Evas_Internal.h b/src/lib/evas/Evas_Internal.h index baf7cd5b16..782742f5d9 100644 --- a/src/lib/evas/Evas_Internal.h +++ b/src/lib/evas/Evas_Internal.h @@ -32,16 +32,22 @@ extern "C" { #endif - #ifndef EFL_INTERNAL_UNSTABLE # error This file can not be included outside EFL #endif #include <Efl.h> +EOAPI const Eina_List *efl_input_device_children_get(const Eo *obj); + +EOAPI void efl_input_device_evas_set(Eo *obj, Evas *e); +EOAPI Evas *efl_input_device_evas_get(const Eo *obj); + +EOAPI void efl_input_device_subclass_set(Eo *obj, Evas_Device_Subclass sub_clas); +EOAPI Evas_Device_Subclass efl_input_device_subclass_get(const Eo *obj); + typedef struct _Efl_Input_Pointer_Data Efl_Input_Pointer_Data; typedef struct _Efl_Input_Key_Data Efl_Input_Key_Data; -typedef struct _Efl_Input_Device_Data Efl_Input_Device_Data; typedef struct _Efl_Input_Hold_Data Efl_Input_Hold_Data; typedef struct _Efl_Input_Focus_Data Efl_Input_Focus_Data; @@ -112,18 +118,6 @@ struct _Efl_Input_Key_Data Eina_Bool no_stringshare : 1; }; -struct _Efl_Input_Device_Data -{ - Eo *eo; - Eo *evas; /* Evas */ - Efl_Input_Device *source; /* ref */ - Eina_List *children; /* ref'ed by efl_parent, not by this list */ - unsigned int id; - Efl_Input_Device_Type klass; - unsigned int subclass; // Evas_Device_Subclass (unused) - unsigned int pointer_count; -}; - struct _Efl_Input_Hold_Data { Eo *eo; diff --git a/src/lib/evas/canvas/efl_input_device.c b/src/lib/evas/canvas/efl_input_device.c index 690db7698d..607ffd5f76 100644 --- a/src/lib/evas/canvas/efl_input_device.c +++ b/src/lib/evas/canvas/efl_input_device.c @@ -9,6 +9,18 @@ #define MY_CLASS EFL_INPUT_DEVICE_CLASS /* Efl Input Device = Evas Device */ +typedef struct _Efl_Input_Device_Data Efl_Input_Device_Data; +struct _Efl_Input_Device_Data +{ + Eo *eo; + Eo *evas; /* Evas */ + Efl_Input_Device *source; /* ref */ + Eina_List *children; /* ref'ed by efl_parent, not by this list */ + unsigned int id; + Efl_Input_Device_Type klass; + unsigned int subclass; // Evas_Device_Subclass (unused) + unsigned int pointer_count; +}; typedef struct _Child_Device_Iterator Child_Device_Iterator; @@ -226,5 +238,52 @@ _efl_input_device_is_pointer_type_get(const Eo *obj EINA_UNUSED, Efl_Input_Devic return _is_pointer(pd); } +static const Eina_List * +_efl_input_device_children_get(const Eo *obj EINA_UNUSED, Efl_Input_Device_Data *pd) +{ + return pd->children; +} + +EOAPI EFL_FUNC_BODY_CONST(efl_input_device_children_get, const Eina_List *, NULL); + +static Evas * +_efl_input_device_evas_get(const Eo *obj EINA_UNUSED, Efl_Input_Device_Data *pd) +{ + return pd->evas; +} + +EOAPI EFL_FUNC_BODY_CONST(efl_input_device_evas_get, Evas *, NULL); + +static void +_efl_input_device_evas_set(Eo *obj EINA_UNUSED, Efl_Input_Device_Data *pd, Evas *e) +{ + pd->evas = e; +} + +EOAPI EFL_VOID_FUNC_BODYV(efl_input_device_evas_set, EFL_FUNC_CALL(e), Evas *e); + +static Evas_Device_Subclass +_efl_input_device_subclass_get(const Eo *obj EINA_UNUSED, Efl_Input_Device_Data *pd) +{ + return pd->subclass; +} + +EOAPI EFL_FUNC_BODY_CONST(efl_input_device_subclass_get, Evas_Device_Subclass, 0); + +static void +_efl_input_device_subclass_set(Eo *obj EINA_UNUSED, Efl_Input_Device_Data *pd, + Evas_Device_Subclass sub_clas) +{ + pd->subclass = sub_clas; +} + +EOAPI EFL_VOID_FUNC_BODYV(efl_input_device_subclass_set, EFL_FUNC_CALL(sub_clas), Evas_Device_Subclass sub_clas); + +#define EFL_INPUT_DEVICE_EXTRA_OPS \ + EFL_OBJECT_OP_FUNC(efl_input_device_evas_get, _efl_input_device_evas_get), \ + EFL_OBJECT_OP_FUNC(efl_input_device_evas_set, _efl_input_device_evas_set), \ + EFL_OBJECT_OP_FUNC(efl_input_device_subclass_get, _efl_input_device_subclass_get), \ + EFL_OBJECT_OP_FUNC(efl_input_device_subclass_set, _efl_input_device_subclass_set), \ + EFL_OBJECT_OP_FUNC(efl_input_device_children_get, _efl_input_device_children_get), \ #include "efl_input_device.eo.c" diff --git a/src/lib/evas/canvas/evas_device.c b/src/lib/evas/canvas/evas_device.c index 5f5e1aaba8..af95619044 100644 --- a/src/lib/evas/canvas/evas_device.c +++ b/src/lib/evas/canvas/evas_device.c @@ -184,7 +184,6 @@ evas_device_add_full(Evas *eo_e, const char *name, const char *desc, Evas_Device *parent_dev, Evas_Device *emulation_dev, Evas_Device_Class clas, Evas_Device_Subclass sub_clas) { - Efl_Input_Device_Data *d; Evas_Public_Data *e; Evas_Device *dev; @@ -194,13 +193,9 @@ evas_device_add_full(Evas *eo_e, const char *name, const char *desc, efl_name_set(efl_added, name), efl_comment_set(efl_added, desc), efl_input_device_type_set(efl_added, clas), - efl_input_device_source_set(efl_added, emulation_dev)); - - d = efl_data_scope_get(dev, EFL_INPUT_DEVICE_CLASS); - d->evas = eo_e; - - // Legacy support, subclass is most likely unused - d->subclass = (unsigned) sub_clas; + efl_input_device_source_set(efl_added, emulation_dev), + efl_input_device_evas_set(efl_added, eo_e), + efl_input_device_subclass_set(efl_added, sub_clas)); e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); @@ -269,7 +264,6 @@ evas_device_add_full(Evas *eo_e, const char *name, const char *desc, EAPI void evas_device_del(Evas_Device *dev) { - SAFETY_CHECK(dev, EFL_INPUT_DEVICE_CLASS); if (!efl_invalidated_get(dev)) efl_del(dev); efl_unref(dev); @@ -278,10 +272,8 @@ evas_device_del(Evas_Device *dev) EAPI void evas_device_push(Evas *eo_e, Evas_Device *dev) { - SAFETY_CHECK(eo_e, EVAS_CANVAS_CLASS); - SAFETY_CHECK(dev, EFL_INPUT_DEVICE_CLASS); - - Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); + Evas_Public_Data *e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS); + if (!e) return; if (!e->cur_device) { e->cur_device = eina_array_new(4); @@ -296,9 +288,8 @@ evas_device_pop(Evas *eo_e) { Evas_Device *dev; - SAFETY_CHECK(eo_e, EVAS_CANVAS_CLASS); - - Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); + Evas_Public_Data *e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS); + if (e) return ; dev = eina_array_pop(e->cur_device); if (dev) efl_unref(dev); } @@ -306,29 +297,17 @@ evas_device_pop(Evas *eo_e) EAPI const Eina_List * evas_device_list(Evas *eo_e, const Evas_Device *dev) { - SAFETY_CHECK(eo_e, EVAS_CANVAS_CLASS, NULL); - - if (dev) - { - SAFETY_CHECK(dev, EFL_INPUT_DEVICE_CLASS, NULL); + if (dev) return efl_input_device_children_get(dev); - Efl_Input_Device_Data *d = efl_data_scope_get(dev, EFL_INPUT_DEVICE_CLASS); - return d->children; - } - - Evas_Public_Data *e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); - return e->devices; + Evas_Public_Data *e = efl_data_scope_safe_get(eo_e, EVAS_CANVAS_CLASS); + return e ? e->devices : NULL; } EAPI void evas_device_name_set(Evas_Device *dev, const char *name) { - SAFETY_CHECK(dev, EFL_INPUT_DEVICE_CLASS); - - Efl_Input_Device_Data *d = efl_data_scope_get(dev, EFL_INPUT_DEVICE_CLASS); - efl_name_set(dev, name); - evas_event_callback_call(d->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev); + evas_event_callback_call(efl_input_device_evas_get(dev), EVAS_CALLBACK_DEVICE_CHANGED, dev); } EAPI const char * @@ -340,12 +319,8 @@ evas_device_name_get(const Evas_Device *dev) EAPI void evas_device_description_set(Evas_Device *dev, const char *desc) { - SAFETY_CHECK(dev, EFL_INPUT_DEVICE_CLASS); - efl_comment_set(dev, desc); - - Efl_Input_Device_Data *d = efl_data_scope_get(dev, EFL_INPUT_DEVICE_CLASS); - evas_event_callback_call(d->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev); + evas_event_callback_call(efl_input_device_evas_get(dev), EVAS_CALLBACK_DEVICE_CHANGED, dev); } EAPI const char * @@ -363,7 +338,6 @@ evas_device_parent_set(Evas_Device *dev, Evas_Device *parent) SAFETY_CHECK(dev, EFL_INPUT_DEVICE_CLASS); - Efl_Input_Device_Data *d = efl_data_scope_get(dev, EFL_INPUT_DEVICE_CLASS); if (parent) { SAFETY_CHECK(parent, EFL_INPUT_DEVICE_CLASS); @@ -374,7 +348,7 @@ evas_device_parent_set(Evas_Device *dev, Evas_Device *parent) } efl_parent_set(dev, parent); - evas_event_callback_call(d->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev); + evas_event_callback_call(efl_input_device_evas_get(dev), EVAS_CALLBACK_DEVICE_CHANGED, dev); } EAPI const Evas_Device * @@ -391,16 +365,17 @@ evas_device_parent_get(const Evas_Device *dev) EAPI void evas_device_class_set(Evas_Device *dev, Evas_Device_Class clas) { - SAFETY_CHECK(dev, EFL_INPUT_DEVICE_CLASS); EINA_SAFETY_ON_TRUE_RETURN(efl_finalized_get(dev)); - Efl_Input_Device_Data *d = efl_data_scope_get(dev, EFL_INPUT_DEVICE_CLASS); - Evas_Public_Data *edata = efl_data_scope_get(d->evas, EVAS_CANVAS_CLASS); + Evas_Public_Data *edata = efl_data_scope_safe_get(efl_input_device_evas_get(dev), EVAS_CANVAS_CLASS); + Efl_Input_Device_Type klass = efl_input_device_type_get(dev); - if ((Evas_Device_Class)d->klass == clas) + if (!edata) return; + + if ((Evas_Device_Class)klass == clas) return; - if (_is_pointer(d->klass)) + if (_is_pointer(klass)) _evas_pointer_data_remove(edata, dev); efl_input_device_type_set(dev, clas); @@ -408,7 +383,7 @@ evas_device_class_set(Evas_Device *dev, Evas_Device_Class clas) if (_is_pointer(clas)) _evas_pointer_data_add(edata, dev); - evas_event_callback_call(d->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev); + evas_event_callback_call(efl_input_device_evas_get(dev), EVAS_CALLBACK_DEVICE_CHANGED, dev); } EAPI Evas_Device_Class @@ -420,30 +395,21 @@ evas_device_class_get(const Evas_Device *dev) EAPI void evas_device_subclass_set(Evas_Device *dev, Evas_Device_Subclass clas) { - SAFETY_CHECK(dev, EFL_INPUT_DEVICE_CLASS); - Efl_Input_Device_Data *d = efl_data_scope_get(dev, EFL_INPUT_DEVICE_CLASS); - - d->subclass = (unsigned) clas; - evas_event_callback_call(d->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev); + efl_input_device_subclass_set(dev, clas); + evas_event_callback_call(efl_input_device_evas_get(dev), EVAS_CALLBACK_DEVICE_CHANGED, dev); } EAPI Evas_Device_Subclass evas_device_subclass_get(const Evas_Device *dev) { - SAFETY_CHECK(dev, EFL_INPUT_DEVICE_CLASS, EVAS_DEVICE_SUBCLASS_NONE); - Efl_Input_Device_Data *d = efl_data_scope_get(dev, EFL_INPUT_DEVICE_CLASS); - - return (Evas_Device_Subclass) d->subclass; + return efl_input_device_subclass_get(dev); } EAPI void evas_device_emulation_source_set(Evas_Device *dev, Evas_Device *src) { - SAFETY_CHECK(dev, EFL_INPUT_DEVICE_CLASS); - Efl_Input_Device_Data *d = efl_data_scope_get(dev, EFL_INPUT_DEVICE_CLASS); - efl_input_device_source_set(dev, src); - evas_event_callback_call(d->evas, EVAS_CALLBACK_DEVICE_CHANGED, dev); + evas_event_callback_call(efl_input_device_evas_get(dev), EVAS_CALLBACK_DEVICE_CHANGED, dev); } EAPI const Evas_Device * --
