From dba60dbfb6a9526edd1f40c9a80a35611c14da57 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 31 Mar 2019 22:49:40 +0100 Subject: [PATCH] new backend: fix crash when window's shadow state change Create a shadow image for a mapped window when it's shadow become enabled. For unmapped window, the shadow image is created during mapping. Also, if the window has IMAGE_ERROR flag, it won't be render anyway. So shadow image won't be created in that case either. Signed-off-by: Yuxuan Shui --- src/win.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/win.c b/src/win.c index faa46bce..3a094b2b 100644 --- a/src/win.c +++ b/src/win.c @@ -528,8 +528,24 @@ void win_update_prop_shadow(session_t *ps, win *w) { } void win_set_shadow(session_t *ps, win *w, bool shadow_new) { - if (w->shadow == shadow_new) + if (w->shadow == shadow_new) { return; + } + + log_debug("Updating shadow property of window %#010x (%s) to %d", w->id, w->name, + shadow_new); + if (ps->o.experimental_backends && ps->redirected && + w->state != WSTATE_UNMAPPED && !(w->flags & WIN_FLAGS_IMAGE_ERROR)) { + assert(!w->shadow_image); + // Create shadow image + 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_opacity); + if (!w->shadow_image) { + log_error("Failed to bind shadow image"); + w->shadow_force = OFF; + } + } region_t extents; pixman_region32_init(&extents); @@ -573,7 +589,7 @@ void win_determine_shadow(session_t *ps, win *w) { log_debug("Shadow disabled by shadow-exclude"); shadow_new = false; } else if (ps->o.shadow_ignore_shaped && w->bounding_shaped && - !w->rounded_corners) { + !w->rounded_corners) { log_debug("Shadow disabled by shadow-ignore-shaped"); shadow_new = false; } else if (ps->o.respect_prop_shadow && w->prop_shadow == 0) {