fix shape and shape input handling for dnd shadow tree.
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 18 May 2011 23:55:21 +0000 (23:55 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Wed, 18 May 2011 23:55:21 +0000 (23:55 +0000)
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@59517 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

ChangeLog
src/lib/ecore_x/xlib/ecore_x_window.c
src/lib/ecore_x/xlib/ecore_x_window_shape.c

index e252db3..444271c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
 2011-05-17  Cedric Bail
 
        * Add ecore_timer_dump.
+
+2011-05-19  Carsten Haitzler (The Rasterman)
+
+        * Fix Ecore_X shadow tree search handling to respect shape and
+        shape input of windows.
+
index f13652b..c5f3c35 100644 (file)
@@ -1003,6 +1003,28 @@ _ecore_x_window_shadow_tree_find(Window base)
    return NULL;
 } /* _ecore_x_window_shadow_tree_find */
 
+static int
+_inside_rects(Shadow *s, int x, int y, int bx, int by, Ecore_X_Rectangle *rects, int num)
+{
+   int i, inside;
+        
+   if (!rects) return 0;
+   inside = 0;
+   for (i = 0; i < num; i++)
+     {
+        if ((x >= s->x + bx + rects[i].x) && 
+            (y >= s->y + by + rects[i].y) && 
+            (x < (int)(s->x + bx + rects[i].width)) && 
+            (y < (int)(s->y + by + rects[i].height)))
+          {
+             inside = 1;
+             break;
+          }
+     }
+   free(rects);
+   return inside;
+}
+
 static Window
 _ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow         *s,
                                              int             bx,
@@ -1020,6 +1042,19 @@ _ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow         *s,
    wy = s->y + by;
    if (!((x >= wx) && (y >= wy) && (x < (wx + s->w)) && (y < (wy + s->h))))
       return 0;
+   
+   /* FIXME: get shape */
+     {
+        int num;
+        Ecore_X_Rectangle *rects;
+
+        num = 0;
+        rects = ecore_x_window_shape_rectangles_get(s->win, &num);
+        if (!_inside_rects(s, x, y, bx, by, rects, num)) return 0;
+        num = 0;
+        rects = ecore_x_window_shape_input_rectangles_get(s->win, &num);
+        if (!_inside_rects(s, x, y, bx, by, rects, num)) return 0;
+     }
 
    if (s->children)
      {
index b9dd944..51c2010 100644 (file)
@@ -619,9 +619,23 @@ ecore_x_window_shape_input_rectangles_get(Ecore_X_Window win, int *num_ret)
    if (num_ret) *num_ret = num;
    return rects;
 #else
+   // have to return fake shape input rect of size of window
+   Window dw;
+   unsigned int di;
+   
    if (num_ret) *num_ret = 0;
-   return NULL;
-   win = 0;
+   rects = malloc(sizeof(Ecore_X_Rectangle));
+   if (!rects) return NULL;
+   if (!XGetGeometry(_ecore_x_disp, win, &dw,
+                     &(rects[i].x), &(rects[i].y),
+                     &(rects[i].width), &(rects[i].height),
+                     &di, &di))
+     {
+        free(rects);
+        return NULL;
+     }
+   if (num_ret) *num_ret = 1;
+   return rects;
 #endif
 } /* ecore_x_window_shape_input_rectangles_get */