diff --git a/src/config.c b/src/config.c index 95c7975..764dc55 100644 --- a/src/config.c +++ b/src/config.c @@ -540,6 +540,8 @@ char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable, .detect_client_opacity = false, .blur_method = BLUR_METHOD_NONE, + .blur_radius = -1, + .blur_deviation = 0.84089642, .blur_background_frame = false, .blur_background_fixed = false, .blur_background_blacklist = NULL, diff --git a/src/config_libconfig.c b/src/config_libconfig.c index 01fec4a..6389aa4 100644 --- a/src/config_libconfig.c +++ b/src/config_libconfig.c @@ -381,9 +381,24 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad // --unredir-if-possible-exclude parse_cfg_condlst(&cfg, &opt->unredir_if_possible_blacklist, "unredir-if-possible-exclude"); + // --blur-method + if (config_lookup_string(&cfg, "blur-method", &sval)) { + enum blur_method method = parse_blur_method(sval); + if (method >= BLUR_METHOD_INVALID) { + log_fatal("Invalid blur method %s", sval); + goto err; + } + opt->blur_method = method; + } + // --blur-size + config_lookup_int(&cfg, "blur-size", &opt->blur_radius); + // --blur-deviation + config_lookup_float(&cfg, "blur-deviation", &opt->blur_deviation); // --blur-background if (config_lookup_bool(&cfg, "blur-background", &ival) && ival) { - opt->blur_method = BLUR_METHOD_KERNEL; + if (opt->blur_method == BLUR_METHOD_NONE) { + opt->blur_method = BLUR_METHOD_KERNEL; + } } // --blur-background-frame lcfg_lookup_bool(&cfg, "blur-background-frame", &opt->blur_background_frame); @@ -426,8 +441,10 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad lcfg_lookup_bool(&cfg, "use-damage", &opt->use_damage); // --max-brightness - if (config_lookup_float(&cfg, "max-brightness", &opt->max_brightness) && opt->use_damage) { - log_warn("max-brightness requires use-damage = false. Falling back to 1.0"); + if (config_lookup_float(&cfg, "max-brightness", &opt->max_brightness) && + opt->use_damage) { + log_warn("max-brightness requires use-damage = false. Falling back to " + "1.0"); opt->max_brightness = 1.0; } @@ -479,7 +496,6 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad } } - opt->blur_radius = -1; config_setting_lookup_int(blur_cfg, "size", &opt->blur_radius); if (config_setting_lookup_string(blur_cfg, "kernel", &sval)) { @@ -490,7 +506,6 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad } } - opt->blur_deviation = 0.84089642; config_setting_lookup_float(blur_cfg, "deviation", &opt->blur_deviation); } diff --git a/src/options.c b/src/options.c index cef826f..8f44b43 100644 --- a/src/options.c +++ b/src/options.c @@ -200,6 +200,18 @@ static void usage(const char *argv0, int ret) { " the same group focused at the same time. WM_TRANSIENT_FOR has\n" " higher priority if --detect-transient is enabled, too.\n" "\n" + "--blur-method\n" + " The algorithm used for background bluring. Available choices are:\n" + " 'none' to disable, 'gaussian', 'box' or 'kernel' for custom\n" + " convolution blur with --blur-kern.\n" + " Note: 'gaussian' and 'box' require --experimental-backends.\n" + "\n" + "--blur-size\n" + " The radius of the blur kernel for 'box' and 'gaussian' blur method.\n" + "\n" + "--blur-deviation\n" + " The standard deviation for the 'gaussian' blur method.\n" + "\n" "--blur-background\n" " Blur background of semi-transparent / ARGB windows. Bad in\n" " performance. The switch name may change without prior\n" @@ -422,6 +434,9 @@ static const struct option longopts[] = { {"no-vsync", no_argument, NULL, 325}, {"max-brightness", required_argument, NULL, 326}, {"transparent-clipping", no_argument, NULL, 327}, + {"blur-method", required_argument, NULL, 328}, + {"blur-size", required_argument, NULL, 329}, + {"blur-deviation", required_argument, NULL, 330}, {"experimental-backends", no_argument, NULL, 733}, {"monitor-repaint", no_argument, NULL, 800}, {"diagnostics", no_argument, NULL, 801}, @@ -808,6 +823,24 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable, opt->max_brightness = atof(optarg); break; P_CASEBOOL(327, transparent_clipping); + case 328: { + // --blur-method + enum blur_method method = parse_blur_method(optarg); + if (method >= BLUR_METHOD_INVALID) { + log_warn("Invalid blur method %s, ignoring.", optarg); + } else { + opt->blur_method = method; + } + break; + } + case 329: + // --blur-size + opt->blur_radius = atoi(optarg); + break; + case 330: + // --blur-deviation + opt->blur_deviation = atof(optarg); + break; P_CASEBOOL(733, experimental_backends); P_CASEBOOL(800, monitor_repaint); @@ -877,7 +910,7 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable, set_default_winopts(opt, winopt_mask, shadow_enable, fading_enable); // --blur-background-frame implies --blur-background - if (opt->blur_background_frame && !opt->blur_method) { + if (opt->blur_background_frame && opt->blur_method == BLUR_METHOD_NONE) { opt->blur_method = BLUR_METHOD_KERNEL; }