core: move the many c2_list_postprocess calls into a function

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2024-02-19 23:30:53 +00:00
parent bc7b697915
commit ac376ad6cb
No known key found for this signature in database
GPG Key ID: D3A4405BE6CC17F4
3 changed files with 24 additions and 18 deletions

View File

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

View File

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

View File

@ -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)) {