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:
		
							parent
							
								
									dbf6a04f8f
								
							
						
					
					
						commit
						edd0d03e0b
					
				|  | @ -14,6 +14,7 @@ is" without express or implied warranty. | |||
| #include <dix-config.h> | ||||
| 
 | ||||
| #include <xcb/xcb.h> | ||||
| #include <xcb/shape.h> | ||||
| #include <xcb/xcb_aux.h> | ||||
| 
 | ||||
| #include <X11/X.h> | ||||
|  | @ -460,11 +461,6 @@ xnestRegionEqual(RegionPtr pReg1, RegionPtr pReg2) | |||
| void | ||||
| xnestShapeWindow(WindowPtr pWin) | ||||
| { | ||||
|     Region reg; | ||||
|     BoxPtr pBox; | ||||
|     XRectangle rect; | ||||
|     int i; | ||||
| 
 | ||||
|     if (!xnestRegionEqual(xnestWindowPriv(pWin)->bounding_shape, | ||||
|                           wBoundingShape(pWin))) { | ||||
| 
 | ||||
|  | @ -472,26 +468,27 @@ xnestShapeWindow(WindowPtr pWin) | |||
|             RegionCopy(xnestWindowPriv(pWin)->bounding_shape, | ||||
|                        wBoundingShape(pWin)); | ||||
| 
 | ||||
|             reg = XCreateRegion(); | ||||
|             pBox = RegionRects(xnestWindowPriv(pWin)->bounding_shape); | ||||
|             for (i = 0; | ||||
|                  i < RegionNumRects(xnestWindowPriv(pWin)->bounding_shape); | ||||
|                  i++) { | ||||
|                 rect.x = pBox[i].x1; | ||||
|                 rect.y = pBox[i].y1; | ||||
|                 rect.width = pBox[i].x2 - pBox[i].x1; | ||||
|                 rect.height = pBox[i].y2 - pBox[i].y1; | ||||
|                 XUnionRectWithRegion(&rect, reg, reg); | ||||
|             int const num_rects = RegionNumRects(xnestWindowPriv(pWin)->bounding_shape); | ||||
|             BoxPtr const pBox = RegionRects(xnestWindowPriv(pWin)->bounding_shape); | ||||
|             xcb_rectangle_t *rects = calloc(num_rects, sizeof(xcb_rectangle_t)); | ||||
| 
 | ||||
|             for (int i = 0; i < num_rects; i++) { | ||||
|                 rects[i].x = pBox[i].x1; | ||||
|                 rects[i].y = pBox[i].y1; | ||||
|                 rects[i].width = pBox[i].x2 - pBox[i].x1; | ||||
|                 rects[i].height = pBox[i].y2 - pBox[i].y1; | ||||
|             } | ||||
|             XShapeCombineRegion(xnestDisplay, xnestWindow(pWin), | ||||
|                                 ShapeBounding, 0, 0, reg, ShapeSet); | ||||
|             XDestroyRegion(reg); | ||||
| 
 | ||||
|             xcb_shape_rectangles(xnestUpstreamInfo.conn, XCB_SHAPE_SO_SET, | ||||
|                                  XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_YX_BANDED, | ||||
|                                  xnestWindow(pWin), 0, 0, num_rects, rects); | ||||
|             free(rects); | ||||
|         } | ||||
|         else { | ||||
|             RegionEmpty(xnestWindowPriv(pWin)->bounding_shape); | ||||
| 
 | ||||
|             XShapeCombineMask(xnestDisplay, xnestWindow(pWin), | ||||
|                               ShapeBounding, 0, 0, XCB_PIXMAP_NONE, ShapeSet); | ||||
|             xcb_shape_mask(xnestUpstreamInfo.conn, XCB_SHAPE_SO_SET, | ||||
|                            XCB_SHAPE_SK_BOUNDING, xnestWindow(pWin), | ||||
|                            0, 0, XCB_PIXMAP_NONE); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|  | @ -500,25 +497,26 @@ xnestShapeWindow(WindowPtr pWin) | |||
|         if (wClipShape(pWin)) { | ||||
|             RegionCopy(xnestWindowPriv(pWin)->clip_shape, wClipShape(pWin)); | ||||
| 
 | ||||
|             reg = XCreateRegion(); | ||||
|             pBox = RegionRects(xnestWindowPriv(pWin)->clip_shape); | ||||
|             for (i = 0; | ||||
|                  i < RegionNumRects(xnestWindowPriv(pWin)->clip_shape); i++) { | ||||
|                 rect.x = pBox[i].x1; | ||||
|                 rect.y = pBox[i].y1; | ||||
|                 rect.width = pBox[i].x2 - pBox[i].x1; | ||||
|                 rect.height = pBox[i].y2 - pBox[i].y1; | ||||
|                 XUnionRectWithRegion(&rect, reg, reg); | ||||
|             int const num_rects = RegionNumRects(xnestWindowPriv(pWin)->clip_shape); | ||||
|             BoxPtr const pBox = RegionRects(xnestWindowPriv(pWin)->clip_shape); | ||||
|             xcb_rectangle_t *rects = calloc(num_rects, sizeof(xcb_rectangle_t)); | ||||
| 
 | ||||
|             for (int i = 0; i < num_rects; i++) { | ||||
|                 rects[i].x = pBox[i].x1; | ||||
|                 rects[i].y = pBox[i].y1; | ||||
|                 rects[i].width = pBox[i].x2 - pBox[i].x1; | ||||
|                 rects[i].height = pBox[i].y2 - pBox[i].y1; | ||||
|             } | ||||
|             XShapeCombineRegion(xnestDisplay, xnestWindow(pWin), | ||||
|                                 ShapeClip, 0, 0, reg, ShapeSet); | ||||
|             XDestroyRegion(reg); | ||||
| 
 | ||||
|             xcb_shape_rectangles(xnestUpstreamInfo.conn, XCB_SHAPE_SO_SET, | ||||
|                                  XCB_SHAPE_SK_CLIP, XCB_CLIP_ORDERING_YX_BANDED, | ||||
|                                  xnestWindow(pWin), 0, 0, num_rects, rects); | ||||
|             free(rects); | ||||
|         } | ||||
|         else { | ||||
|             RegionEmpty(xnestWindowPriv(pWin)->clip_shape); | ||||
| 
 | ||||
|             XShapeCombineMask(xnestDisplay, xnestWindow(pWin), | ||||
|                               ShapeClip, 0, 0, XCB_PIXMAP_NONE, ShapeSet); | ||||
|             xcb_shape_mask(xnestUpstreamInfo.conn, XCB_SHAPE_SO_SET, | ||||
|                            XCB_SHAPE_SK_CLIP, xnestWindow(pWin), 0, 0, XCB_PIXMAP_NONE); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -70,7 +70,6 @@ typedef XID KeySym64; | |||
| #include <X11/Xlib.h> | ||||
| #include <X11/Xlibint.h> | ||||
| #include <X11/Xutil.h> | ||||
| #include <X11/extensions/shape.h> | ||||
| #include <X11/Xlib-xcb.h> | ||||
| 
 | ||||
| #ifdef _XSERVER64_tmp | ||||
|  |  | |||
|  | @ -23,6 +23,7 @@ srcs = [ | |||
| x11_xcb_dep = dependency('x11-xcb', required: true) | ||||
| xcb_dep = dependency('xcb', required: true) | ||||
| xcb_aux_dep = dependency('xcb-aux', required: true) | ||||
| xcb_shape_dep = dependency('xcb-shape', required: true) | ||||
| 
 | ||||
| executable( | ||||
|     'Xnest', | ||||
|  | @ -33,6 +34,7 @@ executable( | |||
|         xnest_dep, | ||||
|         xcb_dep, | ||||
|         xcb_aux_dep, | ||||
|         xcb_shape_dep, | ||||
|         x11_xcb_dep, | ||||
|     ], | ||||
|     link_with: [ | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue