summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Zaoui <daniel.zaoui@yahoo.com>2015-03-10 19:05:42 +0200
committerDaniel Zaoui <daniel.zaoui@yahoo.com>2015-03-16 09:42:02 +0200
commit2e1e65f56dde8bb37c1bdbebe1af5cfeb62d992a (patch)
tree02dbbc4fa3a82555fb687a01e3515115db9ab36c
parentf1f4c7c790d2a8fe277b4fc24208e07a1490acc6 (diff)
DnD/Wl: add a better support to data types.
The types management mechanisms for X11 and Wayland use the same infrastructures.
-rw-r--r--src/lib/elm_cnp.c91
1 files changed, 27 insertions, 64 deletions
diff --git a/src/lib/elm_cnp.c b/src/lib/elm_cnp.c
index 9df996c2f..168d78f4d 100644
--- a/src/lib/elm_cnp.c
+++ b/src/lib/elm_cnp.c
@@ -3126,76 +3126,55 @@ _wl_dnd_position(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
3126 /* check if there is dropable (obj) can accept this drop */ 3126 /* check if there is dropable (obj) can accept this drop */
3127 if (dropable_list) 3127 if (dropable_list)
3128 { 3128 {
3129 Elm_Sel_Format saved_format = _dnd_types_to_format(savedtypes.types, savedtypes.ntypes);
3129 Eina_List *l; 3130 Eina_List *l;
3130 Eina_Bool found = EINA_FALSE; 3131 Eina_Bool found = EINA_FALSE;
3131 Dropable *dropable = NULL; 3132 Dropable *dropable = NULL;
3132 3133
3133 EINA_LIST_FOREACH(dropable_list, l, dropable) 3134 EINA_LIST_FOREACH(dropable_list, l, dropable)
3134 { 3135 {
3135#if 0
3136FIXME: add types support
3137 int i, j;
3138 Eina_Inlist *itr;
3139 Dropable_Cbs *cbs; 3136 Dropable_Cbs *cbs;
3137 Eina_Inlist *itr;
3140 EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs) 3138 EINA_INLIST_FOREACH_SAFE(dropable->cbs_list, itr, cbs)
3141 { 3139 {
3142 const char *types[CNP_N_ATOMS]; 3140 Elm_Sel_Format common_fmt = saved_format & cbs->types;
3143 int types_no = _x11_dnd_types_get(cbs->types, types); 3141 if (common_fmt)
3144 for (j = 0; j < types_no; j++)
3145 { 3142 {
3143 /* We found a target that can accept this type of data */
3144 int i, min_index = CNP_N_ATOMS;
3145 /* We have to find the first atom that corresponds to one
3146 * of the supported data types. */
3146 for (i = 0; i < savedtypes.ntypes; i++) 3147 for (i = 0; i < savedtypes.ntypes; i++)
3147 { 3148 {
3148 if (!strcmp(types[j], savedtypes.types[i])) 3149 Cnp_Atom *atom = eina_hash_find(_types_hash, savedtypes.types[i]);
3150 if (atom && (atom->formats & common_fmt))
3149 { 3151 {
3150 found = EINA_TRUE; 3152 int atom_idx = (atom - _atoms);
3151 dropable->last.type = savedtypes.types[i]; 3153 if (min_index > atom_idx) min_index = atom_idx;
3152 dropable->last.format = cbs->types;
3153 break;
3154 } 3154 }
3155 } 3155 }
3156 if (found) break; 3156 if (min_index != CNP_N_ATOMS)
3157 {
3158 cnp_debug("Found atom %s\n", _atoms[min_index].name);
3159 found = EINA_TRUE;
3160 dropable->last.type = _atoms[min_index].name;
3161 dropable->last.format = common_fmt;
3162 break;
3163 }
3157 } 3164 }
3158 if (found) break;
3159 } 3165 }
3160#else
3161 found = EINA_TRUE;
3162#endif
3163 if (found) break; 3166 if (found) break;
3164 } 3167 }
3165 if (found) 3168 if (found)
3166 { 3169 {
3167 Evas_Coord ox = 0, oy = 0; 3170 Evas_Coord ox = 0, oy = 0;
3168 int i = 0;
3169 3171
3170 evas_object_geometry_get(dropable->obj, &ox, &oy, NULL, NULL); 3172 evas_object_geometry_get(dropable->obj, &ox, &oy, NULL, NULL);
3171 3173
3172 cnp_debug("Candidate on %i %i: %p\n", x - ox, y - oy, dropable); 3174 cnp_debug("Candidate on %i %i: %p\n", x - ox, y - oy, dropable);
3173 _wl_dropable_handle(dropable, x - ox, y - oy); 3175 _wl_dropable_handle(dropable, x - ox, y - oy);
3174 // CCCCCCC: call dnd exit on last obj if obj != last 3176 wl_cnp_selection.requestwidget = dropable->obj;
3175 // CCCCCCC: call drop position on obj 3177 will_accept = EINA_TRUE;
3176
3177 for (i = 0; i < savedtypes.ntypes; i++)
3178 {
3179 Dropable_Cbs *cbs;
3180 EINA_INLIST_FOREACH(drop->cbs_list, cbs)
3181 {
3182 switch (cbs->types)
3183 {
3184 case ELM_SEL_FORMAT_TARGETS:
3185 case ELM_SEL_FORMAT_IMAGE:
3186 if ((!strncmp(savedtypes.types[i], "text/uri", 8)) ||
3187 (!strncmp(savedtypes.types[i], "image/", 6)))
3188 {
3189 wl_cnp_selection.requestwidget = drop->obj;
3190 will_accept = EINA_TRUE;
3191 }
3192 break;
3193 default:
3194 break;
3195 }
3196 }
3197 if (will_accept) break;
3198 }
3199 } 3178 }
3200 else 3179 else
3201 { 3180 {
@@ -3220,8 +3199,8 @@ _wl_dnd_drop(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
3220{ 3199{
3221 Ecore_Wl_Event_Dnd_Drop *ev; 3200 Ecore_Wl_Event_Dnd_Drop *ev;
3222 Dropable *drop; 3201 Dropable *drop;
3223 int i = 0;
3224 3202
3203 cnp_debug("In\n");
3225 ev = event; 3204 ev = event;
3226 3205
3227 if (!(drop = _wl_dropable_find(ev->win))) 3206 if (!(drop = _wl_dropable_find(ev->win)))
@@ -3238,35 +3217,17 @@ _wl_dnd_drop(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
3238 if (dropable_list) 3217 if (dropable_list)
3239 { 3218 {
3240 Eina_List *l; 3219 Eina_List *l;
3241 Eina_Bool found = EINA_FALSE;
3242
3243 EINA_LIST_FOREACH(dropable_list, l, drop) 3220 EINA_LIST_FOREACH(dropable_list, l, drop)
3244 { 3221 {
3245 if (drop->last.in) 3222 if (drop->last.in)
3246 { 3223 {
3247 found = EINA_TRUE;
3248 break;
3249 }
3250 }
3251 if (!found) return ECORE_CALLBACK_PASS_ON;
3252 }
3253
3254 for (i = 0; i < savedtypes.ntypes; i++)
3255 {
3256 Dropable_Cbs *cbs;
3257 EINA_INLIST_FOREACH(drop->cbs_list, cbs)
3258 {
3259 if ((savedtypes.types[i] == text_uri) &&
3260 (cbs->types & ELM_SEL_FORMAT_MARKUP) &&
3261 (cbs->types & ELM_SEL_FORMAT_IMAGE))
3262 {
3263 wl_cnp_selection.requestwidget = drop->obj; 3224 wl_cnp_selection.requestwidget = drop->obj;
3264 evas_object_event_callback_add(wl_cnp_selection.requestwidget, 3225 evas_object_event_callback_add(wl_cnp_selection.requestwidget,
3265 EVAS_CALLBACK_DEL, 3226 EVAS_CALLBACK_DEL,
3266 _wl_sel_obj_del2, 3227 _wl_sel_obj_del2,
3267 &wl_cnp_selection); 3228 &wl_cnp_selection);
3268 ecore_wl_dnd_drag_get(ecore_wl_input_get(), text_uri); 3229 ecore_wl_dnd_drag_get(ecore_wl_input_get(), drop->last.type);
3269 return ECORE_CALLBACK_PASS_ON; 3230 break;
3270 } 3231 }
3271 } 3232 }
3272 } 3233 }
@@ -3283,6 +3244,7 @@ _wl_dnd_send(void *data, int type EINA_UNUSED, void *event)
3283 Wl_Cnp_Selection *sel; 3244 Wl_Cnp_Selection *sel;
3284 Ecore_Wl_Event_Data_Source_Send *ev; 3245 Ecore_Wl_Event_Data_Source_Send *ev;
3285 3246
3247 cnp_debug("In\n");
3286 ev = event; 3248 ev = event;
3287 sel = data; 3249 sel = data;
3288 3250
@@ -3330,6 +3292,7 @@ _wl_dnd_receive(void *data, int type EINA_UNUSED, void *event)
3330static Eina_Bool 3292static Eina_Bool
3331_wl_dnd_end(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED) 3293_wl_dnd_end(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
3332{ 3294{
3295 cnp_debug("In\n");
3333 /* Ecore_Wl_Event_Dnd_End *ev; */ 3296 /* Ecore_Wl_Event_Dnd_End *ev; */
3334 3297
3335 /* ev = event; */ 3298 /* ev = event; */