From cd2dd1b9098ec6d0a203536a63a9932200e847bf Mon Sep 17 00:00:00 2001 From: devilhorns Date: Thu, 4 Aug 2011 20:46:44 +0000 Subject: [PATCH] Ecore_X: Fix dnd for shaped windows. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/ecore@62105 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/ecore_x/xcb/ecore_xcb_window_shadow.c | 33 ++++++++++++++++++++++++++- src/lib/ecore_x/xcb/ecore_xcb_window_shape.c | 2 -- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/lib/ecore_x/xcb/ecore_xcb_window_shadow.c b/src/lib/ecore_x/xcb/ecore_xcb_window_shadow.c index 931ffc6..c1ff849 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_window_shadow.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_window_shadow.c @@ -10,6 +10,8 @@ struct _Shadow unsigned short w, h; }; +static Eina_Bool _inside_rects(Shadow *s, int x, int y, int bx, int by, Ecore_X_Rectangle *rects, int num); + //static int shadow_count = 0; static Shadow **shadow_base = NULL; static int shadow_num = 0; @@ -224,13 +226,20 @@ static Ecore_X_Window _ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow *s, int bx, int by, int x, int y, Ecore_X_Window *skip, int skip_num) { Ecore_X_Window child; - int i = 0, j = 0, wx = 0, wy = 0; + Ecore_X_Rectangle *rects; + int i = 0, j = 0, wx = 0, wy = 0, num = 0; wx = s->x + bx; wy = s->y + by; if (!((x >= wx) && (y >= wy) && (x < (wx + s->w)) && (y < (wy + s->h)))) return 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) { int skipit = 0; @@ -281,6 +290,28 @@ _ecore_x_window_shadow_tree_at_xy_get(Ecore_X_Window base, int bx, int by, int x return _ecore_x_window_shadow_tree_at_xy_get_shadow(s, bx, by, x, y, skip, skip_num); } +static Eina_Bool +_inside_rects(Shadow *s, int x, int y, int bx, int by, Ecore_X_Rectangle *rects, int num) +{ + Eina_Bool inside = EINA_FALSE; + int i = 0; + + if (!rects) return EINA_FALSE; + 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].x + rects[i].width)) && + (y < (int)(s->y + by + rects[i].y + rects[i].height))) + { + inside = EINA_TRUE; + break; + } + } + free(rects); + return inside; +} + /** * Retrieves the top, visible window at the given location, * but skips the windows in the list. This uses a shadow tree built from the diff --git a/src/lib/ecore_x/xcb/ecore_xcb_window_shape.c b/src/lib/ecore_x/xcb/ecore_xcb_window_shape.c index 04f1641..58e3370 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_window_shape.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_window_shape.c @@ -25,7 +25,6 @@ ecore_x_window_shape_input_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask) #ifdef ECORE_XCB_SHAPE xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, win, 0, 0, mask); - #else return; win = 0; @@ -48,7 +47,6 @@ ecore_x_window_shape_mask_set(Ecore_X_Window win, Ecore_X_Pixmap mask) #ifdef ECORE_XCB_SHAPE xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, win, 0, 0, mask); - #else return; win = 0; -- 2.7.4