From c9ca9de55e59a4334007ed91704f35342c7ab447 Mon Sep 17 00:00:00 2001 From: Bernd Busse Date: Thu, 27 Aug 2020 18:44:58 +0200 Subject: [PATCH] core: update stale images AFTER checking focus Partially revert 32754b02625d7c19407af8285348e88fe4763be0. We start with mapping the window (`win_process_update_flags()`). Then check if focus has changed and process focus updates. Finally refresh stale images (`win_process_image_flags`) because rules based on focus may have invalidated them or require them to be created. Fixes #465 with the following rule: ``` shadow-exclude = [ "focused" != 1" ] ``` --- src/picom.c | 13 +++++++++++-- src/win.c | 6 +++++- src/win.h | 6 ++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/picom.c b/src/picom.c index d2649021..d30cec0d 100644 --- a/src/picom.c +++ b/src/picom.c @@ -1318,7 +1318,13 @@ static void handle_new_windows(session_t *ps) { static void refresh_windows(session_t *ps) { win_stack_foreach_managed(w, &ps->window_stack) { - win_process_flags(ps, w); + win_process_update_flags(ps, w); + } +} + +static void refresh_images(session_t *ps) { + win_stack_foreach_managed(w, &ps->window_stack) { + win_process_image_flags(ps, w); } } @@ -1359,7 +1365,7 @@ static void handle_pending_updates(EV_P_ struct session *ps) { // stale. handle_root_flags(ps); - // Process window flags + // Process window flags (window mapping) refresh_windows(ps); { @@ -1371,6 +1377,9 @@ static void handle_pending_updates(EV_P_ struct session *ps) { free(r); } + // Process window flags (stale images) + refresh_images(ps); + e = xcb_request_check(ps->c, xcb_ungrab_server_checked(ps->c)); if (e) { log_fatal_x_error(e, "failed to ungrab x server"); diff --git a/src/win.c b/src/win.c index a7c547de..610e8ca8 100644 --- a/src/win.c +++ b/src/win.c @@ -320,11 +320,15 @@ void win_release_images(struct backend_base *backend, struct managed_win *w) { } } -void win_process_flags(session_t *ps, struct managed_win *w) { +void win_process_update_flags(session_t *ps, struct managed_win *w) { if (win_check_flags_all(w, WIN_FLAGS_MAPPED)) { map_win_start(ps, w); win_clear_flags(w, WIN_FLAGS_MAPPED); } +} + +void win_process_image_flags(session_t *ps, struct managed_win *w) { + assert(!win_check_flags_all(w, WIN_FLAGS_MAPPED)); // Not a loop while (win_check_flags_any(w, WIN_FLAGS_IMAGES_STALE) && diff --git a/src/win.h b/src/win.h index 92dc4bae..2171ad18 100644 --- a/src/win.h +++ b/src/win.h @@ -254,8 +254,10 @@ struct managed_win { #endif }; -/// Process pending images flags on a window. Has to be called in X critical section -void win_process_flags(session_t *ps, struct managed_win *w); +/// Process pending updates/images flags on a window. Has to be called in X critical +/// section +void win_process_update_flags(session_t *ps, struct managed_win *w); +void win_process_image_flags(session_t *ps, struct managed_win *w); /// 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);