Xnest: use xcb instead of XShapeCombineRegion() and XShapeCombineMask()

Using xcb_shape_rectangles() and xcb_shape_mask() instead of Xlib's
XShapeCombineRegion() and XShapeCombineMask().

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult 2024-07-31 17:57:49 +02:00
parent dbf6a04f8f
commit edd0d03e0b
3 changed files with 36 additions and 37 deletions

View File

@ -14,6 +14,7 @@ is" without express or implied warranty.
#include <dix-config.h> #include <dix-config.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <xcb/shape.h>
#include <xcb/xcb_aux.h> #include <xcb/xcb_aux.h>
#include <X11/X.h> #include <X11/X.h>
@ -460,11 +461,6 @@ xnestRegionEqual(RegionPtr pReg1, RegionPtr pReg2)
void void
xnestShapeWindow(WindowPtr pWin) xnestShapeWindow(WindowPtr pWin)
{ {
Region reg;
BoxPtr pBox;
XRectangle rect;
int i;
if (!xnestRegionEqual(xnestWindowPriv(pWin)->bounding_shape, if (!xnestRegionEqual(xnestWindowPriv(pWin)->bounding_shape,
wBoundingShape(pWin))) { wBoundingShape(pWin))) {
@ -472,26 +468,27 @@ xnestShapeWindow(WindowPtr pWin)
RegionCopy(xnestWindowPriv(pWin)->bounding_shape, RegionCopy(xnestWindowPriv(pWin)->bounding_shape,
wBoundingShape(pWin)); wBoundingShape(pWin));
reg = XCreateRegion(); int const num_rects = RegionNumRects(xnestWindowPriv(pWin)->bounding_shape);
pBox = RegionRects(xnestWindowPriv(pWin)->bounding_shape); BoxPtr const pBox = RegionRects(xnestWindowPriv(pWin)->bounding_shape);
for (i = 0; xcb_rectangle_t *rects = calloc(num_rects, sizeof(xcb_rectangle_t));
i < RegionNumRects(xnestWindowPriv(pWin)->bounding_shape);
i++) { for (int i = 0; i < num_rects; i++) {
rect.x = pBox[i].x1; rects[i].x = pBox[i].x1;
rect.y = pBox[i].y1; rects[i].y = pBox[i].y1;
rect.width = pBox[i].x2 - pBox[i].x1; rects[i].width = pBox[i].x2 - pBox[i].x1;
rect.height = pBox[i].y2 - pBox[i].y1; rects[i].height = pBox[i].y2 - pBox[i].y1;
XUnionRectWithRegion(&rect, reg, reg);
} }
XShapeCombineRegion(xnestDisplay, xnestWindow(pWin),
ShapeBounding, 0, 0, reg, ShapeSet); xcb_shape_rectangles(xnestUpstreamInfo.conn, XCB_SHAPE_SO_SET,
XDestroyRegion(reg); XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_YX_BANDED,
xnestWindow(pWin), 0, 0, num_rects, rects);
free(rects);
} }
else { else {
RegionEmpty(xnestWindowPriv(pWin)->bounding_shape); RegionEmpty(xnestWindowPriv(pWin)->bounding_shape);
xcb_shape_mask(xnestUpstreamInfo.conn, XCB_SHAPE_SO_SET,
XShapeCombineMask(xnestDisplay, xnestWindow(pWin), XCB_SHAPE_SK_BOUNDING, xnestWindow(pWin),
ShapeBounding, 0, 0, XCB_PIXMAP_NONE, ShapeSet); 0, 0, XCB_PIXMAP_NONE);
} }
} }
@ -500,25 +497,26 @@ xnestShapeWindow(WindowPtr pWin)
if (wClipShape(pWin)) { if (wClipShape(pWin)) {
RegionCopy(xnestWindowPriv(pWin)->clip_shape, wClipShape(pWin)); RegionCopy(xnestWindowPriv(pWin)->clip_shape, wClipShape(pWin));
reg = XCreateRegion(); int const num_rects = RegionNumRects(xnestWindowPriv(pWin)->clip_shape);
pBox = RegionRects(xnestWindowPriv(pWin)->clip_shape); BoxPtr const pBox = RegionRects(xnestWindowPriv(pWin)->clip_shape);
for (i = 0; xcb_rectangle_t *rects = calloc(num_rects, sizeof(xcb_rectangle_t));
i < RegionNumRects(xnestWindowPriv(pWin)->clip_shape); i++) {
rect.x = pBox[i].x1; for (int i = 0; i < num_rects; i++) {
rect.y = pBox[i].y1; rects[i].x = pBox[i].x1;
rect.width = pBox[i].x2 - pBox[i].x1; rects[i].y = pBox[i].y1;
rect.height = pBox[i].y2 - pBox[i].y1; rects[i].width = pBox[i].x2 - pBox[i].x1;
XUnionRectWithRegion(&rect, reg, reg); rects[i].height = pBox[i].y2 - pBox[i].y1;
} }
XShapeCombineRegion(xnestDisplay, xnestWindow(pWin),
ShapeClip, 0, 0, reg, ShapeSet); xcb_shape_rectangles(xnestUpstreamInfo.conn, XCB_SHAPE_SO_SET,
XDestroyRegion(reg); XCB_SHAPE_SK_CLIP, XCB_CLIP_ORDERING_YX_BANDED,
xnestWindow(pWin), 0, 0, num_rects, rects);
free(rects);
} }
else { else {
RegionEmpty(xnestWindowPriv(pWin)->clip_shape); RegionEmpty(xnestWindowPriv(pWin)->clip_shape);
xcb_shape_mask(xnestUpstreamInfo.conn, XCB_SHAPE_SO_SET,
XShapeCombineMask(xnestDisplay, xnestWindow(pWin), XCB_SHAPE_SK_CLIP, xnestWindow(pWin), 0, 0, XCB_PIXMAP_NONE);
ShapeClip, 0, 0, XCB_PIXMAP_NONE, ShapeSet);
} }
} }
} }

View File

@ -70,7 +70,6 @@ typedef XID KeySym64;
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <X11/Xlibint.h> #include <X11/Xlibint.h>
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/extensions/shape.h>
#include <X11/Xlib-xcb.h> #include <X11/Xlib-xcb.h>
#ifdef _XSERVER64_tmp #ifdef _XSERVER64_tmp

View File

@ -23,6 +23,7 @@ srcs = [
x11_xcb_dep = dependency('x11-xcb', required: true) x11_xcb_dep = dependency('x11-xcb', required: true)
xcb_dep = dependency('xcb', required: true) xcb_dep = dependency('xcb', required: true)
xcb_aux_dep = dependency('xcb-aux', required: true) xcb_aux_dep = dependency('xcb-aux', required: true)
xcb_shape_dep = dependency('xcb-shape', required: true)
executable( executable(
'Xnest', 'Xnest',
@ -33,6 +34,7 @@ executable(
xnest_dep, xnest_dep,
xcb_dep, xcb_dep,
xcb_aux_dep, xcb_aux_dep,
xcb_shape_dep,
x11_xcb_dep, x11_xcb_dep,
], ],
link_with: [ link_with: [