ecore_wl: support multiple mime types 52/82952/5
authorMinchul Lee <slotus.lee@samsung.com>
Mon, 8 Aug 2016 09:02:57 +0000 (18:02 +0900)
committerMinchul Lee <slotus.lee@samsung.com>
Wed, 17 Aug 2016 05:18:47 +0000 (14:18 +0900)
deliver mime type to data reading callback

Change-Id: I5adad7ba60f0332ebe64b6e8e513fd6e395cf788
Signed-off-by: Minchul Lee <slotus.lee@samsung.com>
src/lib/ecore_wayland/Ecore_Wayland.h
src/lib/ecore_wayland/ecore_wl_dnd.c

index 5a26384..606dbc8 100644 (file)
@@ -305,7 +305,8 @@ struct _Ecore_Wl_Event_Window_Lower
 // TIZEN_ONLY(20160706): To distinguish clipboard selection in cbhm
 struct _Ecore_Wl_Event_Dnd_Selection
 {
-   char *mime_types[10];
+   char **types;
+   int num_types;
 };
 //
 
@@ -375,6 +376,8 @@ struct _Ecore_Wl_Event_Selection_Data_Ready
    char *data;
    int len;
    Eina_Bool done;
+   char **types;
+   int num_types;
 };
 
 struct _Ecore_Wl_Event_Interfaces_Bound
index 11a1dd1..f321bf8 100644 (file)
@@ -555,6 +555,8 @@ _ecore_wl_dnd_selection(void *data, struct wl_data_device *data_device EINA_UNUS
    Ecore_Wl_Input *input;
    // TIZEN_ONLY(20160707): To distinguish clipboard selection in cbhm
    Ecore_Wl_Event_Dnd_Selection *ev;
+   char **types;
+   int num = 0;
    //
 
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
@@ -577,12 +579,11 @@ _ecore_wl_dnd_selection(void *data, struct wl_data_device *data_device EINA_UNUS
         *t = NULL;
 
         // TIZEN_ONLY(20160707): To distinguish clipboard selection in cbhm
-        int i = 0;
-        for (t = input->selection_source->types.data; *t; t++)
-          {
-             ev->mime_types[i++] = strdup(*t);
-          }
+        num = (input->selection_source->types.size / sizeof(char *));
+        types = input->selection_source->types.data;
 
+        ev->num_types = num;
+        ev->types = types;
         ecore_event_add(ECORE_WL_EVENT_DND_OFFER, ev, _ecore_wl_dnd_selection_cb_free, NULL);
         //
      }
@@ -599,10 +600,6 @@ _ecore_wl_dnd_selection_cb_free(void *data EINA_UNUSED, void *event)
 
    if (!(ev = event)) return;
 
-   for (t = ev->mime_types; *t; t++)
-     {
-        free(*t);
-     }
    free(ev);
 }
 //
@@ -709,6 +706,10 @@ _ecore_wl_dnd_selection_data_read(void *data, Ecore_Fd_Handler *fd_handler EINA_
      }
    else
      {
+        // TIZEN_ONLY(20160707): To distinguish clipboard selection in cbhm
+        char **types;
+        int num = 0;
+        //
         event->data = malloc(len);
         if (!event->data)
           {
@@ -716,6 +717,14 @@ _ecore_wl_dnd_selection_data_read(void *data, Ecore_Fd_Handler *fd_handler EINA_
              return ECORE_CALLBACK_CANCEL;
           }
         memcpy(event->data, buffer, len);
+
+        // TIZEN_ONLY(20160707): To distinguish clipboard selection in cbhm
+        num = (source->types.size / sizeof(char *));
+        types = source->types.data;
+
+        event->num_types = num;
+        event->types = types;
+        //
         event->len = len;
         event->done = EINA_FALSE;
         ret = ECORE_CALLBACK_RENEW;
@@ -736,7 +745,9 @@ _ecore_wl_dnd_selection_data_ready_cb_free(void *data EINA_UNUSED, void *event)
 
    if (!(ev = event)) return;
 
-   free(ev->data);
+   // TIZEN_ONLY(20160707): To distinguish clipboard selection in cbhm
+   if (ev->data) free(ev->data);
+   //
    free(ev);
 }