devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=00fd750d7d442067c81e7e2fb50d6d7ba2b4df15

commit 00fd750d7d442067c81e7e2fb50d6d7ba2b4df15
Author: Chris Michael <cp.mich...@samsung.com>
Date:   Tue Sep 29 12:02:15 2015 -0400

    ecore-wl2: Add API function to set a dnd selection
    
    Signed-off-by: Chris Michael <cp.mich...@samsung.com>
---
 src/lib/ecore_wl2/Ecore_Wl2.h     |  3 +++
 src/lib/ecore_wl2/ecore_wl2_dnd.c | 50 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/src/lib/ecore_wl2/Ecore_Wl2.h b/src/lib/ecore_wl2/Ecore_Wl2.h
index 1c21f60..f2ca6e8 100644
--- a/src/lib/ecore_wl2/Ecore_Wl2.h
+++ b/src/lib/ecore_wl2/Ecore_Wl2.h
@@ -496,6 +496,9 @@ EAPI void ecore_wl2_dnd_drag_end(Ecore_Wl2_Input *input);
 /* TODO: doxy */
 EAPI Eina_Bool ecore_wl2_dnd_selection_owner_has(Ecore_Wl2_Input *input);
 
+/* TODO: doxy */
+EAPI Eina_Bool ecore_wl2_dnd_selection_set(Ecore_Wl2_Input *input, const char 
**types);
+
 /* # ifdef __cplusplus */
 /* } */
 /* # endif */
diff --git a/src/lib/ecore_wl2/ecore_wl2_dnd.c 
b/src/lib/ecore_wl2/ecore_wl2_dnd.c
index 2519e32..7855bd5 100644
--- a/src/lib/ecore_wl2/ecore_wl2_dnd.c
+++ b/src/lib/ecore_wl2/ecore_wl2_dnd.c
@@ -316,3 +316,53 @@ ecore_wl2_dnd_selection_owner_has(Ecore_Wl2_Input *input)
 
    return (input->selection.source != NULL);
 }
+
+EAPI Eina_Bool
+ecore_wl2_dnd_selection_set(Ecore_Wl2_Input *input, const char **types)
+{
+   struct wl_data_device_manager *manager;
+   const char **type;
+   char **t;
+
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input, EINA_FALSE);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(input->display, EINA_FALSE);
+
+   manager = input->display->wl.data_device_manager;
+
+   if (input->data.types.data)
+     {
+        wl_array_for_each(t, &input->data.types)
+          free(*t);
+        wl_array_release(&input->data.types);
+        wl_array_init(&input->data.types);
+     }
+
+   input->data.source = NULL;
+
+   if (!types[0]) return EINA_FALSE;
+
+   input->data.source = wl_data_device_manager_create_data_source(manager);
+   if (!input->data.source)
+     {
+        ERR("Could not create data source: %m");
+        return EINA_FALSE;
+     }
+
+   for (type = types; *type; type++)
+     {
+        if (!*type) continue;
+        t = wl_array_add(&input->data.types, sizeof(*t));
+        if (t)
+          {
+             *t = strdup(*type);
+             wl_data_source_offer(input->data.source, *t);
+          }
+     }
+
+   wl_data_source_add_listener(input->data.source, &_source_listener, input);
+
+   wl_data_device_set_selection(input->data.device, input->data.source,
+                                input->display->serial);
+
+   return EINA_TRUE;
+}

-- 


Reply via email to