diff options
| author | allusive-dev <[email protected]> | 2023-10-13 15:37:56 +1100 |
|---|---|---|
| committer | allusive-dev <[email protected]> | 2023-10-13 15:37:56 +1100 |
| commit | c157fa368e01f6f2cf2c1257d55da01cfd605ccf (patch) | |
| tree | 7c0ded9d1e2312fe915326d7445317ad988e292e | |
| parent | Update README.md (diff) | |
| download | compfy-c157fa368e01f6f2cf2c1257d55da01cfd605ccf.tar.xz compfy-c157fa368e01f6f2cf2c1257d55da01cfd605ccf.zip | |
testing corner-rules
| -rw-r--r-- | src/config.h | 3 | ||||
| -rw-r--r-- | src/config_libconfig.c | 27 | ||||
| -rw-r--r-- | src/options.c | 6 | ||||
| -rw-r--r-- | src/picom.c | 2 | ||||
| -rw-r--r-- | src/win.c | 3 |
5 files changed, 41 insertions, 0 deletions
diff --git a/src/config.h b/src/config.h index ba0dcbc..0ed0357 100644 --- a/src/config.h +++ b/src/config.h @@ -270,6 +270,8 @@ typedef struct options { c2_lptr_t *invert_color_list; /// Rules to change window opacity. c2_lptr_t *opacity_rules; + + c2_lptr_t *corner_rules; /// Limit window brightness double max_brightness; // Radius of rounded window corners @@ -314,6 +316,7 @@ bool must_use parse_int(const char *, int *); struct conv **must_use parse_blur_kern_lst(const char *, bool *hasneg, int *count); bool must_use parse_geometry(session_t *, const char *, region_t *); bool must_use parse_rule_opacity(c2_lptr_t **, const char *); +bool must_use parse_rule_corners(c2_lptr_t **, const char *); enum blur_method must_use parse_blur_method(const char *src); enum open_window_animation must_use parse_open_window_animation(const char *src); diff --git a/src/config_libconfig.c b/src/config_libconfig.c index 4bb4cbf..2494e0e 100644 --- a/src/config_libconfig.c +++ b/src/config_libconfig.c @@ -250,6 +250,31 @@ parse_cfg_condlst_opct(options_t *opt, const config_t *pcfg, const char *name) { } } +/** + * Parse a corner rule list in configuration file. + */ +static inline void +parse_cfg_condlst_corner(options_t *opt, const config_t *pcfg, const char *name) { + config_setting_t *setting = config_lookup(pcfg, name); + if (setting) { + // Parse an array of options + if (config_setting_is_array(setting)) { + int i = config_setting_length(setting); + while (i--) + if (!parse_rule_corners( + &opt->corner_rules, + config_setting_get_string_elem(setting, i))) + exit(1); + } + // Treat it as a single pattern if it's a string + else if (config_setting_type(setting) == CONFIG_TYPE_STRING) { + if (!parse_rule_corners(&opt->corner_rules, + config_setting_get_string(setting))) + exit(1); + } + } +} + static inline void parse_wintype_config(const config_t *cfg, const char *member_name, win_option_t *o, win_option_mask_t *mask) { char *str = mstrjoin("wintypes.", member_name); @@ -620,6 +645,8 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad parse_cfg_condlst(&cfg, &opt->animation_open_blacklist, "animation-open-exclude"); // animation exclude parse_cfg_condlst(&cfg, &opt->animation_unmap_blacklist, "animation-unmap-exclude"); + // --corners-rule + parse_cfg_condlst_corner(opt, &cfg, "corners-rule"); // --invert-color-include parse_cfg_condlst(&cfg, &opt->invert_color_list, "invert-color-include"); // --blur-background-exclude diff --git a/src/options.c b/src/options.c index 948d60f..785adb4 100644 --- a/src/options.c +++ b/src/options.c @@ -529,6 +529,7 @@ static const struct option longopts[] = { {"animation-for-transient-window", required_argument, NULL, 810}, {"animation-open-exclude", required_argument, NULL, 830}, {"animation-unmap-exclude", required_argument, NULL, 831}, + {"corners-rule", required_argument, NULL, 840}, // Must terminate with a NULL entry {NULL, 0, NULL, 0}, }; @@ -993,6 +994,11 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable, case 831: condlst_add(&opt->animation_unmap_blacklist, optarg); break; + case 840: + // --opacity-rule + if (!parse_rule_corners(&opt->corner_rules, optarg)) + exit(1); + break; case 810: { // --animation-for-transient-window enum open_window_animation animation = parse_open_window_animation(optarg); diff --git a/src/picom.c b/src/picom.c index 83716cb..24d5ece 100644 --- a/src/picom.c +++ b/src/picom.c @@ -2143,6 +2143,7 @@ static session_t *session_init(int argc, char **argv, Display *dpy, c2_list_postprocess(ps, ps->o.blur_background_blacklist) && c2_list_postprocess(ps, ps->o.invert_color_list) && c2_list_postprocess(ps, ps->o.opacity_rules) && + c2_list_postprocess(ps, ps->o.corner_rules) && c2_list_postprocess(ps, ps->o.rounded_corners_blacklist) && c2_list_postprocess(ps, ps->o.animation_open_blacklist) && c2_list_postprocess(ps, ps->o.animation_unmap_blacklist) && @@ -2523,6 +2524,7 @@ static void session_destroy(session_t *ps) { free_wincondlst(&ps->o.invert_color_list); free_wincondlst(&ps->o.blur_background_blacklist); free_wincondlst(&ps->o.opacity_rules); + free_wincondlst(&ps->o.corner_rules); free_wincondlst(&ps->o.paint_blacklist); free_wincondlst(&ps->o.unredir_if_possible_blacklist); free_wincondlst(&ps->o.rounded_corners_blacklist); @@ -1399,6 +1399,9 @@ static void win_determine_rounded_corners(session_t *ps, struct managed_win *w) c2_match(ps, w, ps->o.rounded_corners_blacklist, NULL)) { w->corner_radius = 0; log_debug("Not rounding corners for window %#010x", w->base.id); + } else if (c2_match(ps, w, ps->o.corner_rules, &val)) { + void *val = NULL; + w->corner_radius = val; } else { w->corner_radius = ps->o.corner_radius; log_debug("Rounding corners for window %#010x", w->base.id); |