summaryrefslogtreecommitdiff
path: root/src/lib/elementary
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-04-14 11:29:39 -0400
committerMike Blumenkrantz <zmike@samsung.com>2020-04-14 11:29:39 -0400
commitf2ed538d41c8ce8b25430dd209770e6dc1b133af (patch)
tree522e01b806a528793425a2756629711a46b5e710 /src/lib/elementary
parent7288e98b9ea0b94285f1adbb3711ed050757e29b (diff)
elm_dnd: support target setting on none evas_objects
Summary: before this only worked for elm widgets. This however is the same behaviour as in efl_ui_selection_manager.c. So this restores the behaviour prior to selection_manager. Depends on D11697 Reviewers: zmike, stefan_schmidt, raster Reviewed By: zmike Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D11698
Diffstat (limited to 'src/lib/elementary')
-rw-r--r--src/lib/elementary/efl_ui_win.c40
-rw-r--r--src/lib/elementary/elm_dnd.c5
-rw-r--r--src/lib/elementary/elm_priv.h1
3 files changed, 34 insertions, 12 deletions
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index 51806d15d5..0f5bbdbc25 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -9398,12 +9398,37 @@ _remove(void *data, void *gdata)
9398 return EINA_TRUE; 9398 return EINA_TRUE;
9399} 9399}
9400 9400
9401Efl_Ui_Win*
9402efl_ui_win_get(Evas_Object *obj)
9403{
9404 Efl_Ui_Win *win = efl_provider_find(obj, MY_CLASS);
9405 if (!win)
9406 {
9407 Evas *e = evas_object_evas_get(obj);
9408 Ecore_Evas *ee = ecore_evas_ecore_evas_get(e);
9409
9410 win = ecore_evas_data_get(ee, "elm_win");
9411 }
9412 EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL);
9413 return win;
9414}
9415
9416static Efl_Ui_Win_Data*
9417_fetch_win_data_from_arbitary_obj(Efl_Canvas_Object *obj)
9418{
9419 Efl_Ui_Win *win = efl_ui_win_get(obj);
9420 EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL);
9421 Efl_Ui_Win_Data *pd = efl_data_scope_safe_get(win, MY_CLASS);
9422 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL);
9423 return pd;
9424}
9425
9401void 9426void
9402_drop_event_register(Eo *obj) 9427_drop_event_register(Eo *obj)
9403{ 9428{
9404 Ui_Dnd_Target target = {obj, EINA_FALSE}; 9429 Ui_Dnd_Target target = {obj, EINA_FALSE};
9405 Efl_Ui_Win_Data *pd = efl_data_scope_safe_get(efl_provider_find(obj, MY_CLASS), MY_CLASS); 9430 Efl_Ui_Win_Data *pd = _fetch_win_data_from_arbitary_obj(obj);
9406 EINA_SAFETY_ON_NULL_RETURN(pd); 9431 if (!pd) return;
9407 9432
9408 eina_inarray_push(pd->drop_target, &target); 9433 eina_inarray_push(pd->drop_target, &target);
9409} 9434}
@@ -9412,9 +9437,8 @@ void
9412_drop_event_unregister(Eo *obj) 9437_drop_event_unregister(Eo *obj)
9413{ 9438{
9414 int idx = -1; 9439 int idx = -1;
9415 Efl_Ui_Win_Data *pd;
9416 9440
9417 pd = efl_data_scope_safe_get(efl_provider_find(obj, MY_CLASS), MY_CLASS); 9441 Efl_Ui_Win_Data *pd = _fetch_win_data_from_arbitary_obj(obj);
9418 if (!pd) return; 9442 if (!pd) return;
9419 9443
9420 for (unsigned int i = 0; i < eina_inarray_count(pd->drop_target); ++i) 9444 for (unsigned int i = 0; i < eina_inarray_count(pd->drop_target); ++i)
@@ -9434,9 +9458,7 @@ _drop_event_unregister(Eo *obj)
9434void 9458void
9435_selection_changed_event_register(Eo *obj) 9459_selection_changed_event_register(Eo *obj)
9436{ 9460{
9437 Efl_Ui_Win_Data *pd; 9461 Efl_Ui_Win_Data *pd = _fetch_win_data_from_arbitary_obj(obj);
9438
9439 pd = efl_data_scope_safe_get(efl_provider_find(obj, MY_CLASS), MY_CLASS);
9440 if (!pd) return; 9462 if (!pd) return;
9441 9463
9442 eina_array_push(pd->selection_changed, obj); 9464 eina_array_push(pd->selection_changed, obj);
@@ -9444,9 +9466,7 @@ _selection_changed_event_register(Eo *obj)
9444void 9466void
9445_selection_changed_event_unregister(Eo *obj) 9467_selection_changed_event_unregister(Eo *obj)
9446{ 9468{
9447 Efl_Ui_Win_Data *pd; 9469 Efl_Ui_Win_Data *pd = _fetch_win_data_from_arbitary_obj(obj);
9448
9449 pd = efl_data_scope_safe_get(efl_provider_find(obj, MY_CLASS), MY_CLASS);
9450 if (!pd) return; 9470 if (!pd) return;
9451 9471
9452 eina_array_remove(pd->selection_changed, _remove, obj); 9472 eina_array_remove(pd->selection_changed, _remove, obj);
diff --git a/src/lib/elementary/elm_dnd.c b/src/lib/elementary/elm_dnd.c
index bc765fdbb6..891fe4da92 100644
--- a/src/lib/elementary/elm_dnd.c
+++ b/src/lib/elementary/elm_dnd.c
@@ -103,7 +103,7 @@ _drop_cb(void *data, const Efl_Event *ev)
103 Efl_Ui_Drop_Dropped_Event *event = ev->info; 103 Efl_Ui_Drop_Dropped_Event *event = ev->info;
104 Elm_Drop_Target *target = data; 104 Elm_Drop_Target *target = data;
105 target->action = _string_to_action(event->action); 105 target->action = _string_to_action(event->action);
106 efl_future_then(ev->object, efl_ui_dnd_drop_data_get(ev->object, _default_seat(ev->object), eina_array_iterator_new(target->mime_types)), 106 efl_future_then(ev->object, efl_ui_dnd_drop_data_get(elm_widget_is(ev->object) ? ev->object : efl_ui_win_get(ev->object), _default_seat(ev->object), eina_array_iterator_new(target->mime_types)),
107 .success = _deliver_content, 107 .success = _deliver_content,
108 .data = target 108 .data = target
109 ); 109 );
@@ -178,7 +178,7 @@ elm_drop_target_add(Evas_Object *obj, Elm_Sel_Format format,
178 target->format = format; 178 target->format = format;
179 179
180 efl_event_callback_array_add(obj, drop_target_cb(), target); 180 efl_event_callback_array_add(obj, drop_target_cb(), target);
181 181 _drop_event_register(obj); //this is ensuring that we are also supporting none widgets
182 if (!target_register) 182 if (!target_register)
183 target_register = eina_hash_pointer_new(NULL); 183 target_register = eina_hash_pointer_new(NULL);
184 eina_hash_list_append(target_register, &obj, target); 184 eina_hash_list_append(target_register, &obj, target);
@@ -223,6 +223,7 @@ elm_drop_target_del(Evas_Object *obj, Elm_Sel_Format format,
223 efl_event_callback_array_del(obj, drop_target_cb(), eina_list_data_get(found)); 223 efl_event_callback_array_del(obj, drop_target_cb(), eina_list_data_get(found));
224 eina_hash_list_remove(target_register, &obj, target); 224 eina_hash_list_remove(target_register, &obj, target);
225 eina_array_free(target->mime_types); 225 eina_array_free(target->mime_types);
226 _drop_event_unregister(obj); //this is ensuring that we are also supporting none widgets
226 free(target); 227 free(target);
227 } 228 }
228 229
diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h
index 8cfc7c952a..5f3efd8bb5 100644
--- a/src/lib/elementary/elm_priv.h
+++ b/src/lib/elementary/elm_priv.h
@@ -1061,5 +1061,6 @@ void _selection_changed_event_unregister(Eo *obj);
1061void _drop_event_register(Eo *obj); 1061void _drop_event_register(Eo *obj);
1062void _drop_event_unregister(Eo *obj); 1062void _drop_event_unregister(Eo *obj);
1063void _register_selection_changed(Efl_Ui_Selection *selection); 1063void _register_selection_changed(Efl_Ui_Selection *selection);
1064Efl_Ui_Win* efl_ui_win_get(Evas_Object *obj);
1064 1065
1065#endif 1066#endif