elm_cnp: remove drag window when drop on non-dropable win 49/78649/2 accepted/tizen/common/20160707.171423 accepted/tizen/ivi/20160707.042801 accepted/tizen/mobile/20160707.042833 accepted/tizen/tv/20160707.042815 accepted/tizen/wearable/20160707.042822 submit/tizen/20160706.230322
authorThiep Ha <thiep.ha@samsung.com>
Wed, 6 Jul 2016 09:30:37 +0000 (18:30 +0900)
committerThiep Ha <thiep.ha@samsung.com>
Wed, 6 Jul 2016 09:54:34 +0000 (18:54 +0900)
When we do dnd between two applications and the drop application
is non-dropable application, the drag window is not removed.
This patch fixes this issue by a workaround way:
remove drag window when the object is hidden or deleted.

@tizen_fix

Change-Id: I4415f2730dbe875fe3de6510a23e9e64df1d6dd8
Signed-off-by: Thiep Ha <thiep.ha@samsung.com>
src/lib/elm_cnp.c

index 973e66f..9528c0c 100644 (file)
@@ -2934,6 +2934,17 @@ _wl_win_rotation_changed_cb(void *data,
    return EINA_TRUE;
 }
 //
+//TIZEN ONLY (20160706): Remove drag win when drop on non-dropable app
+static void
+_wl_drag_parent_hide_cb(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED)
+{
+   if (!dragwin) return;
+   evas_object_event_callback_del_full(obj, EVAS_CALLBACK_HIDE,
+                                       _wl_drag_parent_hide_cb, dragwin);
+   doaccept = EINA_TRUE;
+   ecore_wl_dnd_drag_end(ecore_wl_input_get());
+}
+//
 
 static Eina_Bool
 _wl_elm_drag_start(Evas_Object *obj, Elm_Sel_Format format, const char *data,
@@ -3035,6 +3046,16 @@ _wl_elm_drag_start(Evas_Object *obj, Elm_Sel_Format format, const char *data,
         elm_win_wm_rotation_available_rotations_set(dragwin, rots, 3);
      }
    //
+   //TIZEN ONLY (20160706): Remove drag win when drop on non-dropable app
+   //Issue: when we do dnd between two applications and drag win is dropped
+   //on non-dropable area (e.g. isf), then drag window is not removed.
+   //Reason: the dnd_end callback is not fired for drag app.
+   //FIXME: This is a workaround since the current wayland protocol does not
+   //supported this feature. It should be removed after the protocol is
+   //changed and reflected.
+   evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE,
+                                  _wl_drag_parent_hide_cb, dragwin);
+   //
    evas_object_move(dragwin, x, y);
    evas_object_resize(dragwin, w, h);
    evas_object_show(dragwin);
@@ -3393,6 +3414,10 @@ _wl_dnd_end(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSE
 
    if (dragdonecb) dragdonecb(dragdonedata, dragwidget);
 
+   //TIZEN ONLY (20160706): 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)
@@ -3419,7 +3444,8 @@ _wl_dnd_end(void *data EINA_UNUSED, int type EINA_UNUSED, void *event EINA_UNUSE
    ecore_wl_input_ungrab(ecore_wl_input_get());
    // TIZEN ONLY(20160627): support multiple selection types' buffer
    Wl_Cnp_Selection *sels = data;
-   Wl_Cnp_Selection *sel = sels + ELM_SEL_TYPE_XDND;
+   Wl_Cnp_Selection *sel = NULL;
+   if (sels) sel = sels + ELM_SEL_TYPE_XDND;
    if (sel)
      {
         sel->active = EINA_FALSE;