diff options
author | Bruno Dilly <bdilly@profusion.mobi> | 2016-11-17 16:50:44 -0200 |
---|---|---|
committer | Bruno Dilly <bdilly@profusion.mobi> | 2016-12-14 18:17:28 -0200 |
commit | 40bd74d3052df6b5e04212efc4b98c0b93870a8a (patch) | |
tree | 369bb28c9ef88cea8f62658dc024e78571ba352b | |
parent | e444d43bbbbb916cf931ba3ba03a6b06744429c9 (diff) | |
download | efl-40bd74d3052df6b5e04212efc4b98c0b93870a8a.tar.gz |
evas: add getter for devices by name
Make it possible to get the evas device given
its name. It sounds useful for Edje since
programs will reference seats by name.
-rw-r--r-- | src/lib/evas/Evas_Common.h | 16 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_device.c | 26 |
2 files changed, 42 insertions, 0 deletions
diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index 2f54174121..8d2f85e006 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -1240,6 +1240,22 @@ EAPI void evas_device_pop(Evas *e); EAPI const Eina_List *evas_device_list(Evas *e, const Evas_Device *dev); /** + * Get a device by its name + * + * @param e The canvas to create the device node for. + * @param name The name of the device. + * + * Gets the first ocurrence of a device named as @p name + * on Evas @p e list of devices. + * + * @return the device or NULL if an error occurred, no name was provided, + * or no device with a matching name was found. + * + * @since 1.19 + */ +EAPI Evas_Device *evas_device_get(Evas *e, const char *name); + +/** * Set the name of a device as a string * * @p dev The device to set the name of diff --git a/src/lib/evas/canvas/evas_device.c b/src/lib/evas/canvas/evas_device.c index 4ab6d1532a..9a65d792fd 100644 --- a/src/lib/evas/canvas/evas_device.c +++ b/src/lib/evas/canvas/evas_device.c @@ -95,6 +95,32 @@ _del_cb(void *data, const Efl_Event *ev) } EAPI Evas_Device * +evas_device_get(Evas *eo_e, const char *name) +{ + const char *dev_name; + Evas_Public_Data *e; + Evas_Device *dev; + Eina_List *l; + + SAFETY_CHECK(eo_e, EVAS_CANVAS_CLASS, NULL); + + if (!name) + return NULL; + + e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); + + EINA_LIST_FOREACH(e->devices, l, dev) + { + dev_name = efl_input_device_name_get(dev); + + if (eina_streq(dev_name, name)) + return dev; + } + + return NULL; +} + +EAPI Evas_Device * evas_device_add(Evas *eo_e) { return evas_device_add_full(eo_e, NULL, NULL, NULL, NULL, |