summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2015-03-11 20:08:42 +0200
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2015-03-11 20:08:42 +0200
commitf45c8565b246c115ba89e7972905cafe10b50edf (patch)
tree1dd9e31ed641010440e36bc9456b8b5c0bd6bf4c
parent66aa17f17c2bf5644497349087a560f190c7f39c (diff)
DnD/Wl: extend types support to all the atoms.devs/jackdanielz/Wayland
uri-list type was always sent as source data type.
-rw-r--r--src/lib/elm_cnp.c66
1 files changed, 41 insertions, 25 deletions
diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index dd3c54706..072859ef0 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -2924,7 +2924,7 @@ _wl_elm_drag_action_set(Evas_Object *obj, Elm_Xdnd_Action action)
2924} 2924}
2925 2925
2926static Eina_Bool 2926static Eina_Bool
2927_wl_elm_drag_start(Evas_Object *obj, Elm_Sel_Format format EINA_UNUSED, const char *data, 2927_wl_elm_drag_start(Evas_Object *obj, Elm_Sel_Format format, const char *data,
2928 Elm_Xdnd_Action action, 2928 Elm_Xdnd_Action action,
2929 Elm_Drag_Icon_Create_Cb createicon, void *createdata, 2929 Elm_Drag_Icon_Create_Cb createicon, void *createdata,
2930 Elm_Drag_Pos dragpos, void *dragdata, 2930 Elm_Drag_Pos dragpos, void *dragdata,
@@ -2934,7 +2934,8 @@ _wl_elm_drag_start(Evas_Object *obj, Elm_Sel_Format format EINA_UNUSED, const ch
2934 Ecore_Evas *ee; 2934 Ecore_Evas *ee;
2935 Evas_Object *icon = NULL; 2935 Evas_Object *icon = NULL;
2936 int x, y, x2 = 0, y2 = 0, x3, y3, w = 0, h = 0; 2936 int x, y, x2 = 0, y2 = 0, x3, y3, w = 0, h = 0;
2937 const char *types[2] = { "text/uri-list", NULL }; 2937 const char *types[CNP_N_ATOMS + 1];
2938 int i, nb_types = 0;
2938 Ecore_Wl_Window *parent = NULL; 2939 Ecore_Wl_Window *parent = NULL;
2939 2940
2940 _wl_elm_dnd_init(); 2941 _wl_elm_dnd_init();
@@ -2942,6 +2943,23 @@ _wl_elm_drag_start(Evas_Object *obj, Elm_Sel_Format format EINA_UNUSED, const ch
2942 /* if we already have a drag, get out */ 2943 /* if we already have a drag, get out */
2943 if (dragwin) return EINA_FALSE; 2944 if (dragwin) return EINA_FALSE;
2944 2945
2946 for (i = 0; i < CNP_N_ATOMS; i++)
2947 {
2948 if (_atoms[i].formats == ELM_SEL_FORMAT_TARGETS)
2949 {
2950 if (format == ELM_SEL_FORMAT_TARGETS)
2951 {
2952 types[nb_types++] = _atoms[i].name;
2953 cnp_debug("set dnd type: %s\n", _atoms[i].name);
2954 }
2955 }
2956 else if (_atoms[i].formats & format)
2957 {
2958 types[nb_types++] = _atoms[i].name;
2959 cnp_debug("set dnd type: %s\n", _atoms[i].name);
2960 }
2961 }
2962 types[nb_types] = NULL;
2945 ecore_wl_dnd_drag_types_set(ecore_wl_input_get(), types); 2963 ecore_wl_dnd_drag_types_set(ecore_wl_input_get(), types);
2946 2964
2947 /* set the drag data used when a drop occurs */ 2965 /* set the drag data used when a drop occurs */
@@ -3325,15 +3343,12 @@ _wl_dnd_end(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSE
3325static void 3343static void
3326_wl_dropable_data_handle(Wl_Cnp_Selection *sel, char *data) 3344_wl_dropable_data_handle(Wl_Cnp_Selection *sel, char *data)
3327{ 3345{
3346 cnp_debug("In\n");
3328 Dropable *drop; 3347 Dropable *drop;
3329 Elm_Selection_Data sdata; 3348 Elm_Selection_Data sdata;
3330 int len = 0; 3349 int len = 0;
3331 char *s = NULL; 3350 char *s = NULL;
3332 3351
3333 Evas *evas = evas_object_evas_get(sel->requestwidget);
3334 Eina_List *dropable_list = evas ? _dropable_list_geom_find(evas, savedtypes.x, savedtypes.y) : NULL, *l;
3335 Eina_Bool drop_found = EINA_FALSE;
3336
3337 len = strlen(data); 3352 len = strlen(data);
3338 if (!(s = malloc(len + 1))) return; 3353 if (!(s = malloc(len + 1))) return;
3339 memcpy(s, data, len); 3354 memcpy(s, data, len);
@@ -3349,35 +3364,36 @@ _wl_dropable_data_handle(Wl_Cnp_Selection *sel, char *data)
3349 sdata.x = savedtypes.x; 3364 sdata.x = savedtypes.x;
3350 sdata.y = savedtypes.y; 3365 sdata.y = savedtypes.y;
3351 3366
3352 if (!savedtypes.imgfile) return; 3367 eo_do(sel->requestwidget, drop = eo_key_data_get("__elm_dropable"));
3353 3368 if (drop)
3354 EINA_LIST_FOREACH(dropable_list, l, drop)
3355 { 3369 {
3356 Eina_Inlist *itr; 3370 Eina_Inlist *itr;
3357 Dropable_Cbs *cbs; 3371 Dropable_Cbs *cbs;
3358 if (drop_found) continue;
3359 EINA_INLIST_FOREACH_SAFE(drop->cbs_list, itr, cbs) 3372 EINA_INLIST_FOREACH_SAFE(drop->cbs_list, itr, cbs)
3360 { 3373 {
3361 /* If it's markup that also supports images */ 3374 if (cbs->types && drop->last.format)
3362 if ((cbs->types & ELM_SEL_FORMAT_MARKUP) &&
3363 (cbs->types & ELM_SEL_FORMAT_IMAGE))
3364 {
3365 sdata.format = ELM_SEL_FORMAT_MARKUP;
3366 sdata.data = (char *)savedtypes.imgfile;
3367 if (cbs->dropcb) cbs->dropcb(cbs->dropdata, drop->obj, &sdata);
3368 ecore_wl_dnd_drag_end(ecore_wl_input_get());
3369 drop_found = EINA_TRUE;
3370 }
3371 else if (cbs->types & ELM_SEL_FORMAT_IMAGE)
3372 { 3375 {
3373 sdata.format = ELM_SEL_FORMAT_IMAGE; 3376 /* If it's markup that also supports images */
3374 sdata.data = (char *)savedtypes.imgfile; 3377 if (cbs->types & (ELM_SEL_FORMAT_MARKUP | ELM_SEL_FORMAT_IMAGE))
3378 {
3379 sdata.format = ELM_SEL_FORMAT_MARKUP;
3380 sdata.data = (char *)savedtypes.imgfile;
3381 }
3382 else if (cbs->types & ELM_SEL_FORMAT_IMAGE)
3383 {
3384 sdata.format = ELM_SEL_FORMAT_IMAGE;
3385 sdata.data = (char *)savedtypes.imgfile;
3386 }
3387 else
3388 {
3389 sdata.format = drop->last.format;
3390 sdata.data = s;
3391 }
3375 if (cbs->dropcb) cbs->dropcb(cbs->dropdata, drop->obj, &sdata); 3392 if (cbs->dropcb) cbs->dropcb(cbs->dropdata, drop->obj, &sdata);
3376 ecore_wl_dnd_drag_end(ecore_wl_input_get());
3377 drop_found = EINA_TRUE;
3378 } 3393 }
3379 } 3394 }
3380 } 3395 }
3396 ecore_wl_dnd_drag_end(ecore_wl_input_get());
3381 ELM_SAFE_FREE(savedtypes.imgfile, free); 3397 ELM_SAFE_FREE(savedtypes.imgfile, free);
3382} 3398}
3383 3399