From e5020512d45c1de348c2b6f21099d5c37d078990 Mon Sep 17 00:00:00 2001 From: "Enrico Weigelt, metux IT consult" Date: Mon, 5 Aug 2024 15:07:30 +0200 Subject: [PATCH] (!1654) Xnest: replace XSetClipRectangles() by xnset_set_clip_rectangles() Use XCB for setting clip rectangles. Signed-off-by: Enrico Weigelt, metux IT consult --- hw/xnest/GC.c | 84 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/hw/xnest/GC.c b/hw/xnest/GC.c index d8c0eea89..722846005 100644 --- a/hw/xnest/GC.c +++ b/hw/xnest/GC.c @@ -204,10 +204,6 @@ xnestDestroyGC(GCPtr pGC) void xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects) { - int i; - BoxPtr pBox; - XRectangle *pRects; - xnestDestroyClip(pGC); switch (type) { @@ -217,18 +213,32 @@ xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects) break; case CT_REGION: - nRects = RegionNumRects((RegionPtr) pValue); - pRects = xallocarray(nRects, sizeof(*pRects)); - pBox = RegionRects((RegionPtr) pValue); - for (i = nRects; i-- > 0;) { - pRects[i].x = pBox[i].x1; - pRects[i].y = pBox[i].y1; - pRects[i].width = pBox[i].x2 - pBox[i].x1; - pRects[i].height = pBox[i].y2 - pBox[i].y1; + { + nRects = RegionNumRects((RegionPtr) pValue); + xcb_rectangle_t *rects= calloc(nRects, sizeof(xcb_rectangle_t)); + if (rects == NULL) { + ErrorF("xnestChangeClip: memory alloc failure"); + return; + } + BoxPtr pBox = RegionRects((RegionPtr) pValue); + for (int i = nRects; i-- > 0;) + rects[i] = (xcb_rectangle_t) { + .x = pBox[i].x1, + .y = pBox[i].y1, + .width = pBox[i].x2 - pBox[i].x1, + .height = pBox[i].y2 - pBox[i].y1, + }; + xcb_set_clip_rectangles( + xnestUpstreamInfo.conn, + XCB_CLIP_ORDERING_UNSORTED, + xnest_upstream_gc(pGC), + 0, + 0, + nRects, + rects); + + free(rects); } - XSetClipRectangles(xnestDisplay, xnestGC(pGC), 0, 0, - pRects, nRects, Unsorted); - free((char *) pRects); break; case CT_PIXMAP: @@ -244,27 +254,47 @@ xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects) break; case CT_UNSORTED: - XSetClipRectangles(xnestDisplay, xnestGC(pGC), - pGC->clipOrg.x, pGC->clipOrg.y, - (XRectangle *) pValue, nRects, Unsorted); + xcb_set_clip_rectangles( + xnestUpstreamInfo.conn, + XCB_CLIP_ORDERING_UNSORTED, + xnest_upstream_gc(pGC), + pGC->clipOrg.x, pGC->clipOrg.y, + nRects, + (xcb_rectangle_t*)pValue); break; case CT_YSORTED: - XSetClipRectangles(xnestDisplay, xnestGC(pGC), - pGC->clipOrg.x, pGC->clipOrg.y, - (XRectangle *) pValue, nRects, YSorted); + xcb_set_clip_rectangles( + xnestUpstreamInfo.conn, + XCB_CLIP_ORDERING_Y_SORTED, + xnest_upstream_gc(pGC), + pGC->clipOrg.x, + pGC->clipOrg.y, + nRects, + (xcb_rectangle_t*)pValue); break; case CT_YXSORTED: - XSetClipRectangles(xnestDisplay, xnestGC(pGC), - pGC->clipOrg.x, pGC->clipOrg.y, - (XRectangle *) pValue, nRects, YXSorted); + xcb_set_clip_rectangles( + xnestUpstreamInfo.conn, + XCB_CLIP_ORDERING_YX_SORTED, + xnest_upstream_gc(pGC), + pGC->clipOrg.x, + pGC->clipOrg.y, + nRects, + (xcb_rectangle_t*)pValue); + break; case CT_YXBANDED: - XSetClipRectangles(xnestDisplay, xnestGC(pGC), - pGC->clipOrg.x, pGC->clipOrg.y, - (XRectangle *) pValue, nRects, YXBanded); + xcb_set_clip_rectangles( + xnestUpstreamInfo.conn, + XCB_CLIP_ORDERING_YX_BANDED, + xnest_upstream_gc(pGC), + pGC->clipOrg.x, + pGC->clipOrg.y, + nRects, + (xcb_rectangle_t*)pValue); break; }