From ac376ad6cb55a1c0c0def0c9aae685df28ba0072 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Mon, 19 Feb 2024 23:30:53 +0000 Subject: [PATCH] core: move the many c2_list_postprocess calls into a function Signed-off-by: Yuxuan Shui --- src/options.c | 24 +++++++++++++++++++++--- src/options.h | 2 ++ src/picom.c | 16 +--------------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/options.c b/src/options.c index 148760cc..13343ab4 100644 --- a/src/options.c +++ b/src/options.c @@ -19,6 +19,7 @@ #include "options.h" #include "utils.h" #include "win.h" +#include "x.h" #pragma GCC diagnostic error "-Wunused-parameter" @@ -381,9 +382,7 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable, while (-1 != (o = getopt_long(argc, argv, shortopts, longopts, &longopt_idx))) { switch (o) { #define P_CASEBOOL(idx, option) \ - case idx: \ - opt->option = true; \ - break + case idx: opt->option = true; break #define P_CASELONG(idx, option) \ case idx: \ if (!parse_long(optarg, &opt->option)) { \ @@ -897,4 +896,23 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable, return true; } +void options_postprocess_c2_lists(struct c2_state *state, struct x_connection *c, + struct options *option) { + if (!(c2_list_postprocess(state, c->c, option->unredir_if_possible_blacklist) && + c2_list_postprocess(state, c->c, option->paint_blacklist) && + c2_list_postprocess(state, c->c, option->shadow_blacklist) && + c2_list_postprocess(state, c->c, option->shadow_clip_list) && + c2_list_postprocess(state, c->c, option->fade_blacklist) && + c2_list_postprocess(state, c->c, option->blur_background_blacklist) && + c2_list_postprocess(state, c->c, option->invert_color_list) && + c2_list_postprocess(state, c->c, option->window_shader_fg_rules) && + c2_list_postprocess(state, c->c, option->opacity_rules) && + c2_list_postprocess(state, c->c, option->rounded_corners_blacklist) && + c2_list_postprocess(state, c->c, option->corner_radius_rules) && + c2_list_postprocess(state, c->c, option->focus_blacklist))) { + log_error("Post-processing of conditionals failed, some of your rules " + "might not work"); + } +} + // vim: set noet sw=8 ts=8 : diff --git a/src/options.h b/src/options.h index 08aa15eb..3384db81 100644 --- a/src/options.h +++ b/src/options.h @@ -33,5 +33,7 @@ bool get_early_config(int argc, char *const *argv, char **config_file, bool *all bool must_use get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable, bool fading_enable, bool conv_kern_hasneg, win_option_mask_t *winopt_mask); +void options_postprocess_c2_lists(struct c2_state *state, struct x_connection *c, + struct options *option); // vim: set noet sw=8 ts=8: diff --git a/src/picom.c b/src/picom.c index 8df5a11a..1f5961e2 100644 --- a/src/picom.c +++ b/src/picom.c @@ -2258,21 +2258,7 @@ static session_t *session_init(int argc, char **argv, Display *dpy, ps->c2_state = c2_state_new(ps->atoms); // Get needed atoms for c2 condition lists - if (!(c2_list_postprocess(ps->c2_state, ps->c.c, ps->o.unredir_if_possible_blacklist) && - c2_list_postprocess(ps->c2_state, ps->c.c, ps->o.paint_blacklist) && - c2_list_postprocess(ps->c2_state, ps->c.c, ps->o.shadow_blacklist) && - c2_list_postprocess(ps->c2_state, ps->c.c, ps->o.shadow_clip_list) && - c2_list_postprocess(ps->c2_state, ps->c.c, ps->o.fade_blacklist) && - c2_list_postprocess(ps->c2_state, ps->c.c, ps->o.blur_background_blacklist) && - c2_list_postprocess(ps->c2_state, ps->c.c, ps->o.invert_color_list) && - c2_list_postprocess(ps->c2_state, ps->c.c, ps->o.window_shader_fg_rules) && - c2_list_postprocess(ps->c2_state, ps->c.c, ps->o.opacity_rules) && - c2_list_postprocess(ps->c2_state, ps->c.c, ps->o.rounded_corners_blacklist) && - c2_list_postprocess(ps->c2_state, ps->c.c, ps->o.corner_radius_rules) && - c2_list_postprocess(ps->c2_state, ps->c.c, ps->o.focus_blacklist))) { - log_error("Post-processing of conditionals failed, some of your rules " - "might not work"); - } + options_postprocess_c2_lists(ps->c2_state, &ps->c, &ps->o); // Load shader source file specified in the shader rules if (c2_list_foreach(ps->o.window_shader_fg_rules, load_shader_source_for_condition, ps)) {