diff options
author | Thiep Ha <thiepha@gmail.com> | 2015-06-09 16:51:13 +0900 |
---|---|---|
committer | Thiep Ha <thiepha@gmail.com> | 2015-06-09 16:51:13 +0900 |
commit | 0ad02006ea209712a3ba761058c3a9a8ac9f6ccc (patch) | |
tree | 308c9baa03a4d064f66417732466f29be3c76ab9 | |
parent | 52c85b3e1b51c0bc1ba95e10c11a038367aa98aa (diff) | |
download | elementary-0ad02006ea209712a3ba761058c3a9a8ac9f6ccc.tar.gz |
Dnd/X11: add dnd support for image, uri types
There is no dnd callbacks for image, uri types.
This patch adds dnd callbacks for those types.
@fix
-rw-r--r-- | src/lib/elm_cnp.c | 73 |
1 files changed, 71 insertions, 2 deletions
diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c index 2916a6f55..fa6409ea8 100644 --- a/src/lib/elm_cnp.c +++ b/src/lib/elm_cnp.c @@ -1131,8 +1131,39 @@ _x11_notify_handler_uri(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify * } else { + if (sel == (_x11_selections + ELM_SEL_TYPE_XDND)) + { + Dropable *dropable; + Eina_List *l; + + EINA_LIST_FOREACH(drops, l, dropable) + { + if (dropable->obj == sel->requestwidget) break; + dropable = NULL; + } + if (dropable) + { + Dropable_Cbs *cbs; + Eina_Inlist *itr; + Elm_Selection_Data ddata; + + dropable = eina_list_data_get(l); + ddata.x = savedtypes.x; + ddata.y = savedtypes.y; + ddata.format = ELM_SEL_FORMAT_IMAGE; + ddata.data = stripstr; + ddata.len = strlen(stripstr); + ddata.action = sel->action; + EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs) + if ((cbs->types & dropable->last.format) && cbs->dropcb) + cbs->dropcb(cbs->dropdata, dropable->obj, &ddata); + } + } + else + { + _pasteimage_append(p, sel->requestwidget); + } savedtypes.imgfile = NULL; - _pasteimage_append(p, sel->requestwidget); free(stripstr); } return 0; @@ -1204,7 +1235,45 @@ _x11_notify_handler_image(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify data = notify->data; cnp_debug("Size if %d\n", data->length); - if (sel->datacb) + if (sel == (_x11_selections + ELM_SEL_TYPE_XDND)) + { + Eina_List *l; + Dropable *dropable; + + tmp = _tempfile_new(data->length); + if (!tmp) + { + ecore_x_dnd_send_finished(); + return 0; + } + memcpy(tmp->map, data->data, data->length); + munmap(tmp->map, data->length); + EINA_LIST_FOREACH(drops, l, dropable) + { + if (dropable->obj == sel->requestwidget) break; + dropable = NULL; + } + if (dropable) + { + Dropable_Cbs *cbs; + Eina_Inlist *itr; + Elm_Selection_Data ddata; + + ddata.x = savedtypes.x; + ddata.y = savedtypes.y; + ddata.format = ELM_SEL_FORMAT_IMAGE; + ddata.data = tmp->filename; + ddata.len = strlen(tmp->filename); + ddata.action = sel->action; + EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs) + if ((cbs->types & dropable->last.format) && cbs->dropcb) + cbs->dropcb(cbs->dropdata, dropable->obj, &ddata); + } + _tmpinfo_free(tmp); + ecore_x_dnd_send_finished(); + return 0; + } + else if (sel->datacb) { Elm_Selection_Data ddata; |