elm_cnp: add ECORE_WL_EVENT_DATA_SOURCE_CANCELLED callback for releasing drag resourc... 14/130614/3
authorTaehyub Kim <taehyub.kim@samsung.com>
Tue, 23 May 2017 06:22:39 +0000 (15:22 +0900)
committerGerrit Code Review <gerrit@review.ap-northeast-2.compute.internal>
Tue, 23 May 2017 06:39:43 +0000 (06:39 +0000)
Change-Id: I73a217820d454a7fecf2b485caa4d3a8e6d93935

src/lib/elm_cnp.c

index d86c687..6122aae 100644 (file)
@@ -2465,6 +2465,9 @@ static Eina_Bool _wl_dnd_drop(void *data EINA_UNUSED, int type EINA_UNUSED, void
 
 static Eina_Bool _wl_dnd_receive(void *data, int type EINA_UNUSED, void *event);
 static Eina_Bool _wl_dnd_end(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED);
+//TIZEN_ONLY(20170523): add dnd cancel event for releasing drag source
+static Eina_Bool _wl_dnd_cancel(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED);
+//
 static void _wl_dropable_data_handle(Wl_Cnp_Selection *sel, Ecore_Wl_Event_Selection_Data_Ready *ev);
 
 static Dropable *_wl_dropable_find(unsigned int win);
@@ -3605,6 +3608,11 @@ _wl_elm_dnd_init(void)
                            //_wl_dnd_end, &wl_cnp_selection);// TIZEN ONLY(20160627)
                            _wl_dnd_end, &wl_cnp_selections);// TIZEN ONLY(20160627)
 
+   //TIZEN_ONLY(20170523): add dnd cancel event for releasing drag source
+   ecore_event_handler_add(ECORE_WL_EVENT_DATA_SOURCE_CANCELLED,
+                           _wl_dnd_cancel, &wl_cnp_selections);
+   //
+
    return EINA_TRUE;
 }
 
@@ -4188,6 +4196,58 @@ _wl_dnd_end(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSE
    return ECORE_CALLBACK_PASS_ON;
 }
 
+//TIZEN_ONLY(20170523): add dnd cancel event for releasing drag source
+static Eina_Bool
+_wl_dnd_cancel(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSED)
+{
+   cnp_debug("In\n");
+   if (dragdonecb) dragdonecb(dragdonedata, dragwidget);
+
+   // Remove drag win when drop on non-dropable app
+   evas_object_event_callback_del_full(dragwidget, EVAS_CALLBACK_HIDE,
+                                       _wl_drag_parent_hide_cb, dragwin);
+   if (dragwin)
+     {
+        if (!doaccept)
+          {
+             /* Commit animation when drag cancelled */
+             /* Record final position of dragwin, then do animation */
+             ecore_animator_timeline_add(0.3, _drag_cancel_animate, dragwin);
+          }
+        else
+          {
+             /* No animation drop was committed */
+             evas_object_del(dragwin);
+          }
+
+        dragwin = NULL;  /* if not freed here, free in end of anim */
+     }
+
+   dragdonecb = NULL;
+   dragacceptcb = NULL;
+   dragposcb = NULL;
+   dragwidget = NULL;
+   doaccept = EINA_FALSE;
+
+   ecore_wl_input_ungrab(ecore_wl_input_get());
+
+   // support multiple selection types' buffer
+   Wl_Cnp_Selection *sels = data;
+   Wl_Cnp_Selection *sel = NULL;
+   if (sels) sel = sels + ELM_SEL_TYPE_XDND;
+   if (sel)
+     {
+        sel->active = EINA_FALSE;
+        evas_object_event_callback_del_full(sel->requestwidget,
+                                            EVAS_CALLBACK_DEL,
+                                            _wl_sel_obj_del2, sel);
+        sel->requestwidget = NULL;
+     }
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+//
+
 static void
 _wl_dropable_data_handle(Wl_Cnp_Selection *sel, Ecore_Wl_Event_Selection_Data_Ready *ev)
 {