mirror of https://github.com/yshui/picom.git
x: add the x_set_region function
it sets an x region to a pixman region
This commit is contained in:
parent
d111e1640a
commit
efb7a1430f
28
src/x.c
28
src/x.c
|
@ -459,6 +459,34 @@ bool x_fetch_region(struct x_connection *c, xcb_xfixes_region_t r, pixman_region
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool x_set_region(struct x_connection *c, xcb_xfixes_region_t dst, const region_t *src) {
|
||||||
|
if (!src || dst == XCB_NONE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t nrects = 0;
|
||||||
|
const rect_t *rects = pixman_region32_rectangles((region_t *)src, &nrects);
|
||||||
|
if (!rects || nrects < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
xcb_rectangle_t *xrects = ccalloc(nrects, xcb_rectangle_t);
|
||||||
|
for (int32_t i = 0; i < nrects; i++) {
|
||||||
|
xrects[i] =
|
||||||
|
(xcb_rectangle_t){.x = to_i16_checked(rects[i].x1),
|
||||||
|
.y = to_i16_checked(rects[i].y1),
|
||||||
|
.width = to_u16_checked(rects[i].x2 - rects[i].x1),
|
||||||
|
.height = to_u16_checked(rects[i].y2 - rects[i].y1)};
|
||||||
|
}
|
||||||
|
|
||||||
|
bool success =
|
||||||
|
XCB_AWAIT_VOID(xcb_xfixes_set_region, c->c, dst, to_u32_checked(nrects), xrects);
|
||||||
|
|
||||||
|
free(xrects);
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t x_create_region(struct x_connection *c, const region_t *reg) {
|
uint32_t x_create_region(struct x_connection *c, const region_t *reg) {
|
||||||
if (!reg) {
|
if (!reg) {
|
||||||
return XCB_NONE;
|
return XCB_NONE;
|
||||||
|
|
3
src/x.h
3
src/x.h
|
@ -321,6 +321,9 @@ x_create_picture_with_visual(struct x_connection *, int w, int h, xcb_visualid_t
|
||||||
/// Fetch a X region and store it in a pixman region
|
/// Fetch a X region and store it in a pixman region
|
||||||
bool x_fetch_region(struct x_connection *, xcb_xfixes_region_t r, region_t *res);
|
bool x_fetch_region(struct x_connection *, xcb_xfixes_region_t r, region_t *res);
|
||||||
|
|
||||||
|
/// Set an X region to a pixman region
|
||||||
|
bool x_set_region(struct x_connection *c, xcb_xfixes_region_t dst, const region_t *src);
|
||||||
|
|
||||||
/// Create a X region from a pixman region
|
/// Create a X region from a pixman region
|
||||||
uint32_t x_create_region(struct x_connection *c, const region_t *reg);
|
uint32_t x_create_region(struct x_connection *c, const region_t *reg);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue