From 51034249cc15f0a455166a13cc1f2d580b573b5a Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Fri, 7 Feb 2020 21:35:34 +0000 Subject: [PATCH] win: handle shadow image errors more gracefully Currently if the shadow image fails to bind, the entire window is marked as having image errors. So nothing of that window will render, even if the window image itself is fine. The commit cause shadow to be disabled when shadow image fails, instead of marking the window. Signed-off-by: Yuxuan Shui --- src/backend/backend_common.c | 6 ++++-- src/win.c | 12 ++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/backend/backend_common.c b/src/backend/backend_common.c index 68b2759..c5b9866 100644 --- a/src/backend/backend_common.c +++ b/src/backend/backend_common.c @@ -298,8 +298,10 @@ default_backend_render_shadow(backend_t *backend_data, int width, int height, shadow = XCB_NONE; xcb_render_picture_t pict = XCB_NONE; - build_shadow(backend_data->c, backend_data->root, a, width, height, kernel, - shadow_pixel, &shadow, &pict); + if (!build_shadow(backend_data->c, backend_data->root, a, width, height, kernel, + shadow_pixel, &shadow, &pict)) { + return NULL; + } auto visual = x_get_visual_for_standard(backend_data->c, XCB_PICT_STANDARD_ARGB_32); void *ret = backend_data->ops->bind_pixmap( diff --git a/src/win.c b/src/win.c index 281a153..ac321aa 100644 --- a/src/win.c +++ b/src/win.c @@ -20,10 +20,10 @@ #include "c2.h" #include "common.h" #include "compiler.h" -#include "picom.h" #include "config.h" #include "list.h" #include "log.h" +#include "picom.h" #include "region.h" #include "render.h" #include "string_utils.h" @@ -302,8 +302,11 @@ bool win_bind_shadow(struct backend_base *b, struct managed_win *w, struct color w->shadow_image = b->ops->render_shadow(b, w->widthb, w->heightb, kernel, c.red, c.green, c.blue, c.alpha); if (!w->shadow_image) { - log_error("Failed to bind shadow image"); - w->flags |= WIN_FLAGS_IMAGE_ERROR; + log_error("Failed to bind shadow image, shadow will be disabled for " + "%#010x (%s)", + w->base.id, w->name); + w->flags |= WIN_FLAGS_SHADOW_NONE; + w->shadow = false; return false; } @@ -1182,7 +1185,8 @@ struct win *fill_win(session_t *ps, struct win *w) { .in_openclose = true, // set to false after first map is done, // true here because window is just created .reg_ignore_valid = false, // set to true when damaged - .flags = WIN_FLAGS_IMAGES_NONE, // updated by property/attributes/etc change + .flags = WIN_FLAGS_IMAGES_NONE, // updated by property/attributes/etc + // change // Runtime variables, updated by dbus .fade_force = UNSET,