diff --git a/src/backend/backend.c b/src/backend/backend.c index 0547cd5f..7febbe69 100644 --- a/src/backend/backend.c +++ b/src/backend/backend.c @@ -203,14 +203,12 @@ void paint_all_new(session_t *ps, win *const t, bool ignore_damage) { ®_bound_local); // A region covers the entire window - region_t reg_win; - pixman_region32_init_rect(®_win, 0, 0, w->g.width, w->g.height); auto new_img = ps->backend_data->ops->copy( ps->backend_data, w->win_image, ®_visible_local); if (w->invert_color) { ps->backend_data->ops->image_op( - ps->backend_data, IMAGE_OP_INVERT_COLOR, new_img, - ®_win, ®_visible_local, NULL); + ps->backend_data, IMAGE_OP_INVERT_COLOR_ALL, new_img, + NULL, ®_visible_local, NULL); } if (w->dim) { double dim_opacity = ps->o.inactive_dim; @@ -218,7 +216,7 @@ void paint_all_new(session_t *ps, win *const t, bool ignore_damage) { dim_opacity *= w->opacity; } ps->backend_data->ops->image_op( - ps->backend_data, IMAGE_OP_DIM, new_img, ®_win, + ps->backend_data, IMAGE_OP_DIM_ALL, new_img, NULL, ®_visible_local, (double[]){dim_opacity}); } if (w->frame_opacity != 1) { @@ -236,7 +234,6 @@ void paint_all_new(session_t *ps, win *const t, bool ignore_damage) { ps->backend_data->ops->compose(ps->backend_data, new_img, w->g.x, w->g.y, ®_paint, ®_visible); ps->backend_data->ops->release_image(ps->backend_data, new_img); - pixman_region32_fini(®_win); pixman_region32_fini(®_visible_local); pixman_region32_fini(®_bound_local); } diff --git a/src/backend/backend.h b/src/backend/backend.h index b213ae9f..104d6caa 100644 --- a/src/backend/backend.h +++ b/src/backend/backend.h @@ -23,10 +23,10 @@ typedef struct backend_base { } backend_t; enum image_operations { - // Invert the color of the image - IMAGE_OP_INVERT_COLOR, - // Dim the image, argument is the percentage - IMAGE_OP_DIM, + // Invert the color of the entire image, `reg_op` ignored + IMAGE_OP_INVERT_COLOR_ALL, + // Dim the entire image, argument is the percentage. `reg_op` ignored + IMAGE_OP_DIM_ALL, // Multiply the alpha channel by the argument IMAGE_OP_APPLY_ALPHA, // Same as APPLY_ALPHA, but `reg_op` is ignored and the operation applies to the diff --git a/src/backend/xrender.c b/src/backend/xrender.c index da75d462..cdd38788 100644 --- a/src/backend/xrender.c +++ b/src/backend/xrender.c @@ -351,15 +351,10 @@ static bool image_op(backend_t *base, enum image_operations op, void *image, } pixman_region32_init(®); - pixman_region32_intersect(®, (region_t *)reg_op, (region_t *)reg_visible); - if (!pixman_region32_not_empty(®)) { - pixman_region32_fini(®); - return true; - } switch (op) { - case IMAGE_OP_INVERT_COLOR: - x_set_picture_clip_region(base->c, img->pict, 0, 0, ®); + case IMAGE_OP_INVERT_COLOR_ALL: + x_set_picture_clip_region(base->c, img->pict, 0, 0, reg_visible); if (img->has_alpha) { auto tmp_pict = x_create_picture_with_visual(base->c, base->root, img->width, @@ -383,8 +378,8 @@ static bool image_op(backend_t *base, enum image_operations op, void *image, 0, 0, 0, 0, img->width, img->height); } break; - case IMAGE_OP_DIM: - x_set_picture_clip_region(base->c, img->pict, 0, 0, ®); + case IMAGE_OP_DIM_ALL: + x_set_picture_clip_region(base->c, img->pict, 0, 0, reg_visible); dim_opacity = *(double *)arg; xcb_render_color_t color = { @@ -402,6 +397,12 @@ static bool image_op(backend_t *base, enum image_operations op, void *image, color, 1, &rect); break; case IMAGE_OP_APPLY_ALPHA: + assert(reg_op); + pixman_region32_intersect(®, (region_t *)reg_op, (region_t *)reg_visible); + if (!pixman_region32_not_empty(®)) { + break; + } + alpha_multiplier = *(double *)arg; if (alpha_multiplier == 1) { break;