summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <mail@marcel-hollerbach.de>2020-04-12 11:58:36 +0200
committerMarcel Hollerbach <mail@marcel-hollerbach.de>2020-04-12 11:58:36 +0200
commit139115fd90ee08fd14ca52576c79f5a5c7755781 (patch)
treede3daae9a85ce6a210896670c21731b4c5cc2837
parentb142fb0b32f687db8be53040135f858be1960008 (diff)
elm_dnd: support target setting on none evas_objectsdevs/bu5hm4n/travis-cnp
before this only worked for elm widgets. This however mirrored the behaviour from efl_ui_selection_manager.c. So this restores the behaviour prior to selection_manager.
-rw-r--r--src/lib/elementary/efl_ui_win.c32
-rw-r--r--src/lib/elementary/elm_dnd.c22
2 files changed, 42 insertions, 12 deletions
diff --git a/src/lib/elementary/efl_ui_win.c b/src/lib/elementary/efl_ui_win.c
index 51806d15d5..7a58ddfc81 100644
--- a/src/lib/elementary/efl_ui_win.c
+++ b/src/lib/elementary/efl_ui_win.c
@@ -9398,12 +9398,29 @@ _remove(void *data, void *gdata)
9398 return EINA_TRUE; 9398 return EINA_TRUE;
9399} 9399}
9400 9400
9401static Efl_Ui_Win_Data*
9402_fetch_win_data_from_arbitary_obj(Efl_Canvas_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 Efl_Ui_Win_Data *pd = efl_data_scope_safe_get(win, MY_CLASS);
9414 EINA_SAFETY_ON_NULL_RETURN_VAL(pd, NULL);
9415 return pd;
9416}
9417
9401void 9418void
9402_drop_event_register(Eo *obj) 9419_drop_event_register(Eo *obj)
9403{ 9420{
9404 Ui_Dnd_Target target = {obj, EINA_FALSE}; 9421 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); 9422 Efl_Ui_Win_Data *pd = _fetch_win_data_from_arbitary_obj(obj);
9406 EINA_SAFETY_ON_NULL_RETURN(pd); 9423 if (!pd) return;
9407 9424
9408 eina_inarray_push(pd->drop_target, &target); 9425 eina_inarray_push(pd->drop_target, &target);
9409} 9426}
@@ -9412,9 +9429,8 @@ void
9412_drop_event_unregister(Eo *obj) 9429_drop_event_unregister(Eo *obj)
9413{ 9430{
9414 int idx = -1; 9431 int idx = -1;
9415 Efl_Ui_Win_Data *pd;
9416 9432
9417 pd = efl_data_scope_safe_get(efl_provider_find(obj, MY_CLASS), MY_CLASS); 9433 Efl_Ui_Win_Data *pd = _fetch_win_data_from_arbitary_obj(obj);
9418 if (!pd) return; 9434 if (!pd) return;
9419 9435
9420 for (unsigned int i = 0; i < eina_inarray_count(pd->drop_target); ++i) 9436 for (unsigned int i = 0; i < eina_inarray_count(pd->drop_target); ++i)
@@ -9434,9 +9450,7 @@ _drop_event_unregister(Eo *obj)
9434void 9450void
9435_selection_changed_event_register(Eo *obj) 9451_selection_changed_event_register(Eo *obj)
9436{ 9452{
9437 Efl_Ui_Win_Data *pd; 9453 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; 9454 if (!pd) return;
9441 9455
9442 eina_array_push(pd->selection_changed, obj); 9456 eina_array_push(pd->selection_changed, obj);
@@ -9444,9 +9458,7 @@ _selection_changed_event_register(Eo *obj)
9444void 9458void
9445_selection_changed_event_unregister(Eo *obj) 9459_selection_changed_event_unregister(Eo *obj)
9446{ 9460{
9447 Efl_Ui_Win_Data *pd; 9461 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; 9462 if (!pd) return;
9451 9463
9452 eina_array_remove(pd->selection_changed, _remove, obj); 9464 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 243c1b8ce9..3dcc02b3ec 100644
--- a/src/lib/elementary/elm_dnd.c
+++ b/src/lib/elementary/elm_dnd.c
@@ -97,13 +97,30 @@ _deliver_content(Eo *obj, void *data, const Eina_Value value)
97 return EINA_VALUE_EMPTY; 97 return EINA_VALUE_EMPTY;
98} 98}
99 99
100
101static Efl_Ui_Win*
102_fetch_win(Efl_Canvas_Object *obj)
103{
104 Efl_Ui_Win *win = efl_provider_find(obj, EFL_UI_WIN_CLASS);
105 if (!win)
106 {
107 Evas *e = evas_object_evas_get(obj);
108 Ecore_Evas *ee = ecore_evas_ecore_evas_get(e);
109
110 win = ecore_evas_data_get(ee, "elm_win");
111 }
112 EINA_SAFETY_ON_NULL_RETURN_VAL(win, NULL);
113 return win;
114}
115
116
100static void 117static void
101_drop_cb(void *data, const Efl_Event *ev) 118_drop_cb(void *data, const Efl_Event *ev)
102{ 119{
103 Efl_Ui_Drop_Dropped_Event *event = ev->info; 120 Efl_Ui_Drop_Dropped_Event *event = ev->info;
104 Elm_Drop_Target *target = data; 121 Elm_Drop_Target *target = data;
105 target->action = _string_to_action(event->action); 122 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)), 123 efl_future_then(ev->object, efl_ui_dnd_drop_data_get(elm_widget_is(ev->object) ? ev->object : _fetch_win(ev->object), _default_seat(ev->object), eina_array_iterator_new(target->mime_types)),
107 .success = _deliver_content, 124 .success = _deliver_content,
108 .data = target 125 .data = target
109 ); 126 );
@@ -182,7 +199,7 @@ elm_drop_target_add(Evas_Object *obj, Elm_Sel_Format format,
182 target->format = format; 199 target->format = format;
183 200
184 efl_event_callback_array_add(obj, drop_target_cb(), target); 201 efl_event_callback_array_add(obj, drop_target_cb(), target);
185 202 _drop_event_register(obj); //this is ensuring that we are also supporting none widgets
186 if (!target_register) 203 if (!target_register)
187 target_register = eina_hash_pointer_new(NULL); 204 target_register = eina_hash_pointer_new(NULL);
188 eina_hash_list_append(target_register, &obj, target); 205 eina_hash_list_append(target_register, &obj, target);
@@ -227,6 +244,7 @@ elm_drop_target_del(Evas_Object *obj, Elm_Sel_Format format,
227 efl_event_callback_array_del(obj, drop_target_cb(), eina_list_data_get(found)); 244 efl_event_callback_array_del(obj, drop_target_cb(), eina_list_data_get(found));
228 eina_hash_list_remove(target_register, &obj, target); 245 eina_hash_list_remove(target_register, &obj, target);
229 eina_array_free(target->mime_types); 246 eina_array_free(target->mime_types);
247 _drop_event_unregister(obj); //this is ensuring that we are also supporting none widgets
230 free(target); 248 free(target);
231 } 249 }
232 250