From 915839c3d3010740b33fc8ee270ec6303c4535c1 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 30 Sep 2018 14:21:05 +0100 Subject: [PATCH] Convert XFixesCreateRegionFromWindow to use Shape directly Fetch the rectangles directly use the Shape extension. Signed-off-by: Yuxuan Shui --- src/win.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/win.c b/src/win.c index 402506c..cbb7eca 100644 --- a/src/win.c +++ b/src/win.c @@ -1150,21 +1150,24 @@ void win_update_bounding_shape(session_t *ps, win *w) { if (w->bounding_shaped) { /* * if window doesn't exist anymore, this will generate an error - * as well as not generate a region. Perhaps a better XFixes - * architecture would be to have a request that copies instead - * of creates, that way you'd just end up with an empty region - * instead of an invalid XID. + * as well as not generate a region. */ - XserverRegion border = XFixesCreateRegionFromWindow( - ps->dpy, w->id, WindowRegionBounding); + xcb_connection_t *c = XGetXCBConnection(ps->dpy); + xcb_shape_get_rectangles_reply_t *r = xcb_shape_get_rectangles_reply(c, + xcb_shape_get_rectangles(c, w->id, XCB_SHAPE_SK_BOUNDING), NULL); - if (!border) + if (!r) return; + xcb_rectangle_t *xrects = xcb_shape_get_rectangles_rectangles(r); + int nrects = xcb_shape_get_rectangles_rectangles_length(r); + rect_t *rects = from_x_rects(nrects, xrects); + free(r); + region_t br; - pixman_region32_init(&br); - x_fetch_region(ps, border, &br); + pixman_region32_init_rects(&br, rects, nrects); + free(rects); // Add border width because we are using a different origin. // X thinks the top left of the inner window is the origin,