summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2015-02-25 10:36:38 +0200
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2015-02-25 10:36:38 +0200
commit5ed6e233db67f89b5c2f954ab15b2e0282545ee3 (patch)
tree86fc72c9fde66344005f025e3bdc05736f3ac8e4
parenta0678c0bdd6296274538d25c817510ed94378aba (diff)
downloadelementary-5ed6e233db67f89b5c2f954ab15b2e0282545ee3.tar.gz
DnD/X11: improve callbacks invocations.
There is no reason why drop targets callbacks registered for a specific type would be invoked when a not supported data is dragged. This patch fixes it by comparing the data type and the callback type of the drop target. Only the callbacks supporting the data type are invoked.
-rw-r--r--src/lib/elm_cnp.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index 597ce2444..c5daef718 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -839,7 +839,7 @@ _x11_notify_handler_text(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify
ddata.len = data->length;
ddata.action = sel->action;
EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
- if (cbs->dropcb)
+ if ((cbs->types & dropable->last.format) && cbs->dropcb)
cbs->dropcb(cbs->dropdata, dropable->obj, &ddata);
goto end;
}
@@ -1046,7 +1046,7 @@ _x11_vcard_receive(X11_Cnp_Selection *sel, Ecore_X_Event_Selection_Notify *notif
ddata.len = data->length;
ddata.action = sel->action;
EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
- if (cbs->dropcb)
+ if ((cbs->types & dropable->last.format) && cbs->dropcb)
cbs->dropcb(cbs->dropdata, dropable->obj, &ddata);
ecore_x_dnd_send_finished();
}
@@ -1410,7 +1410,7 @@ _x11_dnd_dropable_handle(Dropable *dropable, Evas_Coord x, Evas_Coord y, Elm_Xdn
{
cnp_debug("same obj dropable %p\n", dropable->obj);
EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
- if (cbs->poscb)
+ if ((cbs->types & dropable->last.format) && cbs->poscb)
cbs->poscb(cbs->posdata, dropable->obj, x, y, action);
}
else
@@ -1423,10 +1423,10 @@ _x11_dnd_dropable_handle(Dropable *dropable, Evas_Coord x, Evas_Coord y, Elm_Xdn
last_dropable->last.type = NULL;
dropable->last.in = EINA_TRUE;
EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
- if (cbs->entercb)
+ if ((cbs->types & dropable->last.format) && cbs->entercb)
cbs->entercb(cbs->enterdata, dropable->obj);
EINA_INLIST_FOREACH_SAFE(last_dropable->cbs_list, itr, cbs)
- if (cbs->leavecb)
+ if ((cbs->types & last_dropable->last.format) && cbs->leavecb)
cbs->leavecb(cbs->leavedata, last_dropable->obj);
}
else // leave last obj
@@ -1435,7 +1435,7 @@ _x11_dnd_dropable_handle(Dropable *dropable, Evas_Coord x, Evas_Coord y, Elm_Xdn
last_dropable->last.in = EINA_FALSE;
last_dropable->last.type = NULL;
EINA_INLIST_FOREACH_SAFE(last_dropable->cbs_list, itr, cbs)
- if (cbs->leavecb)
+ if ((cbs->types & last_dropable->last.format) && cbs->leavecb)
cbs->leavecb(cbs->leavedata, last_dropable->obj);
}
}
@@ -1448,10 +1448,13 @@ _x11_dnd_dropable_handle(Dropable *dropable, Evas_Coord x, Evas_Coord y, Elm_Xdn
dropable->last.in = EINA_TRUE;
EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
{
- if (cbs->entercb)
- cbs->entercb(cbs->enterdata, dropable->obj);
- if (cbs->poscb)
- cbs->poscb(cbs->posdata, dropable->obj, x, y, action);
+ if (cbs->types & dropable->last.format)
+ {
+ if (cbs->entercb)
+ cbs->entercb(cbs->enterdata, dropable->obj);
+ if (cbs->poscb)
+ cbs->poscb(cbs->posdata, dropable->obj, x, y, action);
+ }
}
}
else
@@ -1724,7 +1727,7 @@ found:
snprintf(entrytag, len + 1, tagstring, savedtypes.imgfile);
ddata.data = entrytag;
cnp_debug("Insert %s\n", (char *)ddata.data);
- if (cbs->dropcb)
+ if ((cbs->types & dropable->last.format) && cbs->dropcb)
cbs->dropcb(cbs->dropdata, dropable->obj, &ddata);
}
else if (cbs->types & ELM_SEL_FORMAT_IMAGE)
@@ -1732,7 +1735,7 @@ found:
cnp_debug("Doing image insert (%s)\n", savedtypes.imgfile);
ddata.format = ELM_SEL_FORMAT_IMAGE;
ddata.data = (char *)savedtypes.imgfile;
- if (cbs->dropcb)
+ if ((cbs->types & dropable->last.format) && cbs->dropcb)
cbs->dropcb(cbs->dropdata, dropable->obj, &ddata);
}
else