summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2016-11-17 16:50:44 -0200
committerBruno Dilly <bdilly@profusion.mobi>2016-12-19 14:58:35 -0200
commit2958aba23a8dc99503fad8119eeffef82e410b42 (patch)
tree63628c818c4a2ef2be40b207d44a9a490a39e6f6 /src
parent25792d64165ad4f5f647a36f087af2d2206a6618 (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/lib/evas/Evas_Common.h16
-rw-r--r--src/lib/evas/canvas/evas_device.c26
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);
1240EAPI const Eina_List *evas_device_list(Evas *e, const Evas_Device *dev); 1240EAPI const Eina_List *evas_device_list(Evas *e, const Evas_Device *dev);
1241 1241
1242/** 1242/**
1243 * Get a device by its name
1244 *
1245 * @param e The canvas to create the device node for.
1246 * @param name The name of the device.
1247 *
1248 * Gets the first ocurrence of a device named as @p name
1249 * on Evas @p e list of devices.
1250 *
1251 * @return the device or NULL if an error occurred, no name was provided,
1252 * or no device with a matching name was found.
1253 *
1254 * @since 1.19
1255 */
1256EAPI Evas_Device *evas_device_get(Evas *e, const char *name);
1257
1258/**
1243 * Set the name of a device as a string 1259 * Set the name of a device as a string
1244 * 1260 *
1245 * @p dev The device to set the name of 1261 * @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)
95} 95}
96 96
97EAPI Evas_Device * 97EAPI Evas_Device *
98evas_device_get(Evas *eo_e, const char *name)
99{
100 const char *dev_name;
101 Evas_Public_Data *e;
102 Evas_Device *dev;
103 Eina_List *l;
104
105 SAFETY_CHECK(eo_e, EVAS_CANVAS_CLASS, NULL);
106
107 if (!name)
108 return NULL;
109
110 e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
111
112 EINA_LIST_FOREACH(e->devices, l, dev)
113 {
114 dev_name = efl_input_device_name_get(dev);
115
116 if (eina_streq(dev_name, name))
117 return dev;
118 }
119
120 return NULL;
121}
122
123EAPI Evas_Device *
98evas_device_add(Evas *eo_e) 124evas_device_add(Evas *eo_e)
99{ 125{
100 return evas_device_add_full(eo_e, NULL, NULL, NULL, NULL, 126 return evas_device_add_full(eo_e, NULL, NULL, NULL, NULL,