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 <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2020-02-07 21:35:34 +00:00
parent 69b3eee76b
commit 51034249cc
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
2 changed files with 12 additions and 6 deletions

View File

@ -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(

View File

@ -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,