Ecore_Xcb: Make ecore_xcb_window_shape reflect the xlib version more
authordevilhorns <devilhorns@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 2 Aug 2011 09:07:52 +0000 (09:07 +0000)
committerdevilhorns <devilhorns@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 2 Aug 2011 09:07:52 +0000 (09:07 +0000)
(in the hunt to fix engage issue(s))...tho this still does not fix the
issue(s) with engage :/

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/ecore@61986 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/ecore_x/xcb/ecore_xcb_window_shape.c

index 82b9a2f..04f1641 100644 (file)
@@ -91,11 +91,13 @@ ecore_x_window_shape_window_set_xy(Ecore_X_Window win, Ecore_X_Window shape_win,
 EAPI void 
 ecore_x_window_shape_rectangle_set(Ecore_X_Window win, int x, int y, int w, int h) 
 {
-   LOGFN(__FILE__, __LINE__, __FUNCTION__);
-
 #ifdef ECORE_XCB_SHAPE
    xcb_rectangle_t rect;
+#endif
 
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+#ifdef ECORE_XCB_SHAPE
    rect.x = x;
    rect.y = y;
    rect.width = w;
@@ -116,17 +118,35 @@ ecore_x_window_shape_rectangle_set(Ecore_X_Window win, int x, int y, int w, int
 EAPI void 
 ecore_x_window_shape_rectangles_set(Ecore_X_Window win, Ecore_X_Rectangle *rects, int num) 
 {
+#ifdef ECORE_XCB_SHAPE
+   xcb_rectangle_t *rect = NULL;
+#endif
+
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
+   if (!rects) return;
+
 #ifdef ECORE_XCB_SHAPE
    if (num > 0) 
-     xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, 
-                          XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, 
-                          win, 0, 0, num, (xcb_rectangle_t *)&rects);
-   else
-     xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, 
-                          XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, 
-                          win, 0, 0, 0, NULL);
+     {
+        int i = 0;
+
+        if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
+          return;
+
+        for (i = 0; i < num; i++) 
+          {
+             rect[i].x = rects[i].x;
+             rect[i].y = rects[i].y;
+             rect[i].width = rects[i].width;
+             rect[i].height = rects[i].height;
+          }
+     }
+   xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, 
+                        XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, 
+                        win, 0, 0, num, (xcb_rectangle_t *)&rect);
+
+   if (rect) free(rect);
 #else
    return;
    win = 0;
@@ -172,11 +192,13 @@ ecore_x_window_shape_window_add_xy(Ecore_X_Window win, Ecore_X_Window shape_win,
 EAPI void 
 ecore_x_window_shape_rectangle_add(Ecore_X_Window win, int x, int y, int w, int h) 
 {
-   LOGFN(__FILE__, __LINE__, __FUNCTION__);
-
 #ifdef ECORE_XCB_SHAPE
    xcb_rectangle_t rect;
+#endif
 
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+#ifdef ECORE_XCB_SHAPE
    rect.x = x;
    rect.y = y;
    rect.width = w;
@@ -197,11 +219,13 @@ ecore_x_window_shape_rectangle_add(Ecore_X_Window win, int x, int y, int w, int
 EAPI void 
 ecore_x_window_shape_rectangle_subtract(Ecore_X_Window win, int x, int y, int w, int h) 
 {
-   LOGFN(__FILE__, __LINE__, __FUNCTION__);
-
 #ifdef ECORE_XCB_SHAPE
    xcb_rectangle_t rect;
+#endif
 
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+#ifdef ECORE_XCB_SHAPE
    rect.x = x;
    rect.y = y;
    rect.width = w;
@@ -249,17 +273,34 @@ ecore_x_window_shape_rectangle_clip(Ecore_X_Window win, int x, int y, int w, int
 EAPI void 
 ecore_x_window_shape_rectangles_add(Ecore_X_Window win, Ecore_X_Rectangle *rects, int num) 
 {
+#ifdef ECORE_XCB_SHAPE
+   xcb_rectangle_t *rect = NULL;
+#endif
+
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
 #ifdef ECORE_XCB_SHAPE
    if (num > 0) 
-     xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, 
-                          XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, 
-                          win, 0, 0, num, (xcb_rectangle_t *)&rects);
-   else
-     xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, 
-                          XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, 
-                          win, 0, 0, 0, NULL);
+     {
+        int i = 0;
+
+        if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
+          return;
+
+        for (i = 0; i < num; i++) 
+          {
+             rect[i].x = rects[i].x;
+             rect[i].y = rects[i].y;
+             rect[i].width = rects[i].width;
+             rect[i].height = rects[i].height;
+          }
+     }
+
+   xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, 
+                        XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, 
+                        win, 0, 0, num, (xcb_rectangle_t *)&rect);
+
+   if (rect) free(rect);
 #else
    return;
    win = 0;
@@ -272,17 +313,18 @@ EAPI Ecore_X_Rectangle *
 ecore_x_window_shape_rectangles_get(Ecore_X_Window win, int *num_ret) 
 {
    Ecore_X_Rectangle *rects = NULL;
-
-   LOGFN(__FILE__, __LINE__, __FUNCTION__);
-
-   if (num_ret) *num_ret = 0;
-
 #ifdef ECORE_XCB_SHAPE
    xcb_shape_get_rectangles_cookie_t cookie;
    xcb_shape_get_rectangles_reply_t *reply;
    xcb_rectangle_t *r;
    unsigned int i = 0;
+#endif
 
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+   if (num_ret) *num_ret = 0;
+
+#ifdef ECORE_XCB_SHAPE
    cookie = 
      xcb_shape_get_rectangles(_ecore_xcb_conn, win, XCB_SHAPE_SK_BOUNDING);
    reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL);
@@ -339,17 +381,18 @@ EAPI Ecore_X_Rectangle *
 ecore_x_window_shape_input_rectangles_get(Ecore_X_Window win, int *num_ret) 
 {
    Ecore_X_Rectangle *rects = NULL;
-
-   LOGFN(__FILE__, __LINE__, __FUNCTION__);
-
-   if (num_ret) *num_ret = 0;
-
 #ifdef ECORE_XCB_SHAPE
    xcb_shape_get_rectangles_cookie_t cookie;
    xcb_shape_get_rectangles_reply_t *reply;
    xcb_rectangle_t *r;
    unsigned int i = 0;
+#endif
+
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
+   if (num_ret) *num_ret = 0;
+
+#ifdef ECORE_XCB_SHAPE
    cookie = 
      xcb_shape_get_rectangles(_ecore_xcb_conn, win, XCB_SHAPE_SK_INPUT);
    reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL);
@@ -383,22 +426,60 @@ ecore_x_window_shape_input_rectangles_get(Ecore_X_Window win, int *num_ret)
 
    return rects;
 #else
+   xcb_get_geometry_cookie_t cookie;
+   xcb_get_geometry_reply_t *reply;
+
+   if (!(rects = malloc(sizeof(Ecore_X_Rectangle))))
+     return NULL;
+
+   /* get geometry */
+   cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win);
+   reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL);
+   if (reply) 
+     {
+        rects[0].x = reply->x;
+        rects[0].y = reply->y;
+        rects[0].width = reply->width;
+        rects[0].height = reply->height;
+        free(reply);
+     }
+   if (num_ret) *num_ret = 1;
    return rects;
-   win = 0;
 #endif
 }
 
 EAPI void 
 ecore_x_window_shape_input_rectangles_set(Ecore_X_Window win, Ecore_X_Rectangle *rects, int num) 
 {
+#ifdef ECORE_XCB_SHAPE
+   xcb_rectangle_t *rect = NULL;
+#endif
+
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-#ifdef ECORE_XCB_SHAPE
    if (!rects) return;
 
+#ifdef ECORE_XCB_SHAPE
+   if (num > 0) 
+     {
+        int i = 0;
+
+        if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
+          return;
+
+        for (i = 0; i < num; i++) 
+          {
+             rect[i].x = rects[i].x;
+             rect[i].y = rects[i].y;
+             rect[i].width = rects[i].width;
+             rect[i].height = rects[i].height;
+          }
+     }
    xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, 
                         XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, 
-                        win, 0, 0, num, (xcb_rectangle_t *)rects);
+                        win, 0, 0, num, (xcb_rectangle_t *)&rect);
+
+   if (rect) free(rect);
 #else
    return;
    win = 0;
@@ -410,11 +491,13 @@ ecore_x_window_shape_input_rectangles_set(Ecore_X_Window win, Ecore_X_Rectangle
 EAPI void 
 ecore_x_window_shape_input_rectangle_subtract(Ecore_X_Window win, int x, int y, int w, int h) 
 {
-   LOGFN(__FILE__, __LINE__, __FUNCTION__);
-
 #ifdef ECORE_XCB_SHAPE
    xcb_rectangle_t rect;
+#endif
 
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+#ifdef ECORE_XCB_SHAPE
    rect.x = x;
    rect.y = y;
    rect.width = w;
@@ -435,11 +518,13 @@ ecore_x_window_shape_input_rectangle_subtract(Ecore_X_Window win, int x, int y,
 EAPI void 
 ecore_x_window_shape_input_rectangle_add(Ecore_X_Window win, int x, int y, int w, int h) 
 {
-   LOGFN(__FILE__, __LINE__, __FUNCTION__);
-
 #ifdef ECORE_XCB_SHAPE
    xcb_rectangle_t rect;
+#endif
 
+   LOGFN(__FILE__, __LINE__, __FUNCTION__);
+
+#ifdef ECORE_XCB_SHAPE
    rect.x = x;
    rect.y = y;
    rect.width = w;
@@ -487,8 +572,6 @@ ecore_x_window_shape_input_window_set_xy(Ecore_X_Window win, Ecore_X_Window shap
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-//   DBG("Window Shape Input Window Set XY: %d %d %d %d", win, shape_win, x, y);
-
 #ifdef ECORE_XCB_SHAPE
    xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, 
                      XCB_SHAPE_SK_INPUT, win, x, y, shape_win);
@@ -506,8 +589,6 @@ ecore_x_window_shape_input_window_add_xy(Ecore_X_Window win, Ecore_X_Window shap
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-//   DBG("Window Shape Input Window Add XY: %d %d %d %d", win, shape_win, x, y);
-
 #ifdef ECORE_XCB_SHAPE
    xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_INPUT, 
                      XCB_SHAPE_SK_INPUT, win, x, y, shape_win);
@@ -525,8 +606,6 @@ ecore_x_window_shape_input_window_set(Ecore_X_Window win, Ecore_X_Window shape_w
 {
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
-//   DBG("Window Shape Input Window Set: %d %d", win, shape_win);
-
 #ifdef ECORE_XCB_SHAPE
    xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, 
                      XCB_SHAPE_SK_INPUT, win, 0, 0, shape_win);
@@ -567,17 +646,34 @@ ecore_x_window_shape_input_rectangle_clip(Ecore_X_Window win, int x, int y, int
 EAPI void 
 ecore_x_window_shape_input_rectangles_add(Ecore_X_Window win, Ecore_X_Rectangle *rects, int num) 
 {
+#ifdef ECORE_XCB_SHAPE
+   xcb_rectangle_t *rect = NULL;
+#endif
+
    LOGFN(__FILE__, __LINE__, __FUNCTION__);
 
 #ifdef ECORE_XCB_SHAPE
    if (num > 0) 
-     xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, 
-                          XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, 
-                          win, 0, 0, num, (xcb_rectangle_t *)&rects);
-   else
-     xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, 
-                          XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, 
-                          win, 0, 0, 0, NULL);
+     {
+        int i = 0;
+
+        if (!(rect = malloc(sizeof(xcb_rectangle_t) * num)))
+          return;
+
+        for (i = 0; i < num; i++) 
+          {
+             rect[i].x = rects[i].x;
+             rect[i].y = rects[i].y;
+             rect[i].width = rects[i].width;
+             rect[i].height = rects[i].height;
+          }
+     }
+
+   xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, 
+                        XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, 
+                        win, 0, 0, num, (xcb_rectangle_t *)&rect);
+
+   if (rect) free(rect);
 #else
    return;
    win = 0;