From 0de5ef55083eea1b20f5e69c3856fe58f9099263 Mon Sep 17 00:00:00 2001 From: Minchul Lee Date: Thu, 18 Aug 2016 15:41:38 +0900 Subject: [PATCH] cnp: modify to select proper mime type Change-Id: I1a500abecdc7c69f2d8f8cc16c7ad32120391bd7 Signed-off-by: Minchul Lee --- src/lib/elm_cnp.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c index 24373af..3dedf00 100644 --- a/src/lib/elm_cnp.c +++ b/src/lib/elm_cnp.c @@ -3151,6 +3151,7 @@ _wl_elm_cnp_selection_clear(Evas_Object *obj, Elm_Sel_Type selection EINA_UNUSED static Eina_Bool _wl_selection_send(void *udata, int type EINA_UNUSED, void *event) { + cnp_debug("In\n"); char *buf; int ret, len_remained; int len_written = 0; @@ -3205,7 +3206,8 @@ _wl_selection_send(void *udata, int type EINA_UNUSED, void *event) static Eina_Bool _wl_selection_receive(void *udata, int type EINA_UNUSED, void *event) { - char *mime_type; + cnp_debug("In\n"); + char *selected_mime = NULL; Wl_Cnp_Selection *sel = udata; Ecore_Wl_Event_Selection_Data_Ready *ev = event; @@ -3229,13 +3231,21 @@ _wl_selection_receive(void *udata, int type EINA_UNUSED, void *event) if ((!ev->num_types) || (!ev->types)) return ECORE_CALLBACK_PASS_ON; - for (i = 0; i < ev->num_types; i++) - DBG("mime type(%s)", ev->types[i]); + for (i = 0; i < ev->num_types && ev->types[i]; i++) + { + cnp_debug("mime type(%s)", ev->types[i]); + if (!strcmp("TARGETS", ev->types[i]) || !strcmp("ATOM", ev->types[i]) + || !strcmp("CLIPBOARD_BEGIN", ev->types[i]) + || !strcmp("CLIPBOARD_END", ev->types[i])) + continue; - mime_type = ev->types[0]; - if (!mime_type) + selected_mime = ev->types[i]; + break; + } + + if (!selected_mime) { - ERR("mime type NOT exist"); + ERR("mime type is invalid"); return ECORE_CALLBACK_PASS_ON; } @@ -3245,11 +3255,13 @@ _wl_selection_receive(void *udata, int type EINA_UNUSED, void *event) return ECORE_CALLBACK_PASS_ON; } + cnp_debug("selected mime(%s)", selected_mime); + if (!ev->done) { for (i = 0; i < CNP_N_ATOMS; ++i) { - if (!strcmp(mime_type, _atoms[i].name)) + if (!strcmp(selected_mime, _atoms[i].name)) { if (_atoms[i].wl_data_preparer) { -- 2.7.4