From 0fc6f9aee2626c1ada537878d6643551dcf53a7a Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 29 Sep 2019 00:04:09 +0100 Subject: [PATCH] core: bind shadow immediate in initialize_backend This simplifies the logic a bit since we know a shadow is always bound (if needed) when the screen is redirected. Signed-off-by: Yuxuan Shui --- src/compton.c | 13 ++++++++++++- src/win.c | 4 ++-- src/win.h | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/compton.c b/src/compton.c index 016a27c..445d363 100644 --- a/src/compton.c +++ b/src/compton.c @@ -758,7 +758,18 @@ static bool initialize_backend(session_t *ps) { log_debug("Marking window %#010x (%s) for update after " "redirection", w->base.id, w->name); - w->flags |= WIN_FLAGS_IMAGES_STALE; + if (w->shadow) { + struct color c = { + .red = ps->o.shadow_red, + .green = ps->o.shadow_green, + .blue = ps->o.shadow_blue, + .alpha = ps->o.shadow_opacity, + }; + win_bind_shadow(ps->backend_data, w, c, + ps->gaussian_map); + } + + w->flags |= WIN_FLAGS_PIXMAP_STALE; ps->pending_updates = true; } } diff --git a/src/win.c b/src/win.c index 88e33e0..ff3bf69 100644 --- a/src/win.c +++ b/src/win.c @@ -292,8 +292,8 @@ static inline bool win_bind_pixmap(struct backend_base *b, struct managed_win *w return true; } -static inline bool win_bind_shadow(struct backend_base *b, struct managed_win *w, - struct color c, struct conv *kernel) { +bool win_bind_shadow(struct backend_base *b, struct managed_win *w, struct color c, + struct conv *kernel) { assert(!w->shadow_image); assert(w->shadow); w->shadow_image = b->ops->render_shadow(b, w->widthb, w->heightb, kernel, c.red, diff --git a/src/win.h b/src/win.h index 3979ecf..6a492ec 100644 --- a/src/win.h +++ b/src/win.h @@ -256,6 +256,9 @@ void win_process_updates(struct session *ps, struct managed_win *_w); void win_process_flags(session_t *ps, struct managed_win *w); /// Queue an update on a window. A series of sanity checks are performed void win_queue_update(struct managed_win *_w, enum win_update update); +/// Bind a shadow to the window, with color `c` and shadow kernel `kernel` +bool win_bind_shadow(struct backend_base *b, struct managed_win *w, struct color c, + struct conv *kernel); /// Start the unmap of a window. We cannot unmap immediately since we might need to fade /// the window out.