fix shape and shape input handling for dnd shadow tree.
authorCarsten Haitzler <raster@rasterman.com>
Wed, 18 May 2011 23:55:21 +0000 (23:55 +0000)
committerCarsten Haitzler <raster@rasterman.com>
Wed, 18 May 2011 23:55:21 +0000 (23:55 +0000)
SVN revision: 59517

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

index e252db3e22d896b1849e4b4e7c877f79606a4c80..444271ce3e813ac7012067bdbaf3768d488a2d42 100644 (file)
 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 f13652bfbc1962332ff7e62aee35f6ab66175318..c5f3c352399d4f960f4c470baffcd929fc7bb053 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 b9dd944d390de48cf4962e7debbf050646031632..51c2010acb861875bad145868c8b4b7b54a94aa8 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 */