DnD: fix callbacks deletion for inline windows.
authorDaniel Zaoui <daniel.zaoui@samsung.com>
Thu, 8 Jan 2015 09:54:04 +0000 (11:54 +0200)
committerDaniel Zaoui <daniel.zaoui@samsung.com>
Mon, 12 Jan 2015 06:23:35 +0000 (08:23 +0200)
During deletion of a window, widgets considered as droppable targets
have to remove their DnD callbacks. To achieve this, elm_drop_target_del
is called from the DEL callback (destructor). This function has to
determine if X11 or Wayland is used. Since the parent is already unknown
at this stage, only checking the engine name can give this
information.
On a regular window, the engine name is related to the target display.

The problem happens when an inline window is used. The engine is a
buffer and no information is given regarding the target display.

The patch fixes it by checking the nature of the Ecore Evas parents. It
supports nested windows (inline inside inline... inside XWin).

@fix

src/lib/elm_cnp.c

index ee44a3c..363d851 100644 (file)
@@ -1901,7 +1901,23 @@ _x11_elm_widget_xwin_get(const Evas_Object *obj)
         if (!evas) return 0;
         ee = ecore_evas_ecore_evas_get(evas);
         if (!ee) return 0;
-        xwin = _elm_ee_xwin_get(ee);
+
+        while(!xwin)
+          {
+             const char *engine_name = ecore_evas_engine_name_get(ee);
+             if (!strcmp(engine_name, ELM_BUFFER))
+               {
+                  ee = ecore_evas_buffer_ecore_evas_parent_get(ee);
+                  if (!ee) return 0;
+                  xwin = _elm_ee_xwin_get(ee);
+               }
+             else
+               {
+                  /* In case the engine is not a buffer, we want to check once. */
+                  xwin = _elm_ee_xwin_get(ee);
+                  if (!xwin) return 0;
+               }
+          }
      }
    return xwin;
 }
@@ -3492,7 +3508,22 @@ _wl_elm_widget_window_get(Evas_Object *obj)
         if (!(ee = ecore_evas_ecore_evas_get(evas)))
           return 0;
 
-        win = ecore_evas_wayland_window_get(ee);
+        while(!win)
+          {
+             const char *engine_name = ecore_evas_engine_name_get(ee);
+             if (!strcmp(engine_name, ELM_BUFFER))
+               {
+                  ee = ecore_evas_buffer_ecore_evas_parent_get(ee);
+                  if (!ee) return 0;
+                  win = ecore_evas_wayland_window_get(ee);
+               }
+             else
+               {
+                  /* In case the engine is not a buffer, we want to check once. */
+                  win = ecore_evas_wayland_window_get(ee);
+                  if (!win) return 0;
+               }
+          }
      }
 
    return ecore_wl_window_id_get(win);