From a2ae36c1d679ee5a7e48fd65754dddfb0f2170e8 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Mon, 4 Mar 2019 22:58:11 +0000 Subject: [PATCH] backend_common: fix shadow generation with opacity Signed-off-by: Yuxuan Shui --- src/backend/backend.h | 2 +- src/backend/backend_common.c | 6 +++--- src/backend/backend_common.h | 2 +- src/compton.c | 2 +- src/win.c | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/backend/backend.h b/src/backend/backend.h index 574cba2..90c8d65 100644 --- a/src/backend/backend.h +++ b/src/backend/backend.h @@ -98,7 +98,7 @@ struct backend_operations { /// Create a shadow image based on the parameters void *(*render_shadow)(backend_t *backend_data, int width, int height, - const conv *kernel, double r, double g, double b); + const conv *kernel, double r, double g, double b, double a); // ============ Resource management =========== diff --git a/src/backend/backend_common.c b/src/backend/backend_common.c index 57592d7..1b3ef19 100644 --- a/src/backend/backend_common.c +++ b/src/backend/backend_common.c @@ -148,7 +148,7 @@ make_shadow(xcb_connection_t *c, const conv *kernel, double opacity, int width, // Fill part 3 for (int y = r; y < height + r; y++) { - memset(data + sstride * y + r, 255, width); + memset(data + sstride * y + r, 255 * opacity, width); } // Part 1 @@ -257,13 +257,13 @@ shadow_picture_err: } void *default_backend_render_shadow(backend_t *backend_data, int width, int height, - const conv *kernel, double r, double g, double b) { + const conv *kernel, double r, double g, double b, double a) { xcb_pixmap_t shadow_pixel = solid_picture(backend_data->c, backend_data->root, true, 1, r, g, b), shadow = XCB_NONE; xcb_render_picture_t pict = XCB_NONE; - build_shadow(backend_data->c, backend_data->root, 1, width, height, kernel, + build_shadow(backend_data->c, backend_data->root, a, width, height, kernel, shadow_pixel, &shadow, &pict); auto visual = x_get_visual_for_standard(backend_data->c, XCB_PICT_STANDARD_ARGB_32); diff --git a/src/backend/backend_common.h b/src/backend/backend_common.h index 2c4342a..d0e9136 100644 --- a/src/backend/backend_common.h +++ b/src/backend/backend_common.h @@ -32,4 +32,4 @@ bool default_is_win_transparent(void *, win *, void *); bool default_is_frame_transparent(void *, win *, void *); void *default_backend_render_shadow(backend_t *backend_data, int width, int height, - const conv *kernel, double r, double g, double b); + const conv *kernel, double r, double g, double b, double a); diff --git a/src/compton.c b/src/compton.c index 0f99106..871848d 100644 --- a/src/compton.c +++ b/src/compton.c @@ -2010,7 +2010,7 @@ redir_start(session_t *ps) { ps->backend_data->ops->render_shadow(ps->backend_data, w->widthb, w->heightb, ps->gaussian_map, ps->o.shadow_red, ps->o.shadow_green, - ps->o.shadow_blue); + ps->o.shadow_blue, ps->o.shadow_opacity); } } } diff --git a/src/win.c b/src/win.c index a9dd82d..4fdf092 100644 --- a/src/win.c +++ b/src/win.c @@ -632,7 +632,7 @@ void win_on_win_size_change(session_t *ps, win *w) { w->shadow_image = ps->backend_data->ops->render_shadow(ps->backend_data, w->widthb, w->heightb, ps->gaussian_map, ps->o.shadow_red, ps->o.shadow_green, - ps->o.shadow_blue); + ps->o.shadow_blue, ps->o.shadow_opacity); } } else { assert(w->state == WSTATE_UNMAPPED); @@ -1270,7 +1270,7 @@ void win_update_bounding_shape(session_t *ps, win *w) { w->shadow_image = ps->backend_data->ops->render_shadow(ps->backend_data, w->widthb, w->heightb, ps->gaussian_map, ps->o.shadow_red, ps->o.shadow_green, - ps->o.shadow_blue); + ps->o.shadow_blue, ps->o.shadow_opacity); } } } else { @@ -1661,7 +1661,7 @@ void map_win(session_t *ps, win *w) { ps->backend_data->ops->render_shadow(ps->backend_data, w->widthb, w->heightb, ps->gaussian_map, ps->o.shadow_red, ps->o.shadow_green, - ps->o.shadow_blue); + ps->o.shadow_blue, ps->o.shadow_opacity); } } log_debug("Window %#010x has opacity %f, opacity target is %f", w->id, w->opacity, w->opacity_tgt);