Add support for documented `--blur-*` options

Handle parsing of `--blur-method`, `--blur-size` and `--blur-deviation`
in config file and as command line options as documented in the manpage.
This commit is contained in:
Bernd Busse 2019-12-20 19:07:35 +01:00
parent d8d9fdf11f
commit df1a852442
3 changed files with 56 additions and 6 deletions

View File

@ -540,6 +540,8 @@ char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable,
.detect_client_opacity = false, .detect_client_opacity = false,
.blur_method = BLUR_METHOD_NONE, .blur_method = BLUR_METHOD_NONE,
.blur_radius = -1,
.blur_deviation = 0.84089642,
.blur_background_frame = false, .blur_background_frame = false,
.blur_background_fixed = false, .blur_background_fixed = false,
.blur_background_blacklist = NULL, .blur_background_blacklist = NULL,

View File

@ -381,10 +381,25 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad
// --unredir-if-possible-exclude // --unredir-if-possible-exclude
parse_cfg_condlst(&cfg, &opt->unredir_if_possible_blacklist, parse_cfg_condlst(&cfg, &opt->unredir_if_possible_blacklist,
"unredir-if-possible-exclude"); "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 // --blur-background
if (config_lookup_bool(&cfg, "blur-background", &ival) && ival) { if (config_lookup_bool(&cfg, "blur-background", &ival) && ival) {
if (opt->blur_method == BLUR_METHOD_NONE) {
opt->blur_method = BLUR_METHOD_KERNEL; opt->blur_method = BLUR_METHOD_KERNEL;
} }
}
// --blur-background-frame // --blur-background-frame
lcfg_lookup_bool(&cfg, "blur-background-frame", &opt->blur_background_frame); lcfg_lookup_bool(&cfg, "blur-background-frame", &opt->blur_background_frame);
// --blur-background-fixed // --blur-background-fixed
@ -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); lcfg_lookup_bool(&cfg, "use-damage", &opt->use_damage);
// --max-brightness // --max-brightness
if (config_lookup_float(&cfg, "max-brightness", &opt->max_brightness) && opt->use_damage) { if (config_lookup_float(&cfg, "max-brightness", &opt->max_brightness) &&
log_warn("max-brightness requires use-damage = false. Falling back to 1.0"); opt->use_damage) {
log_warn("max-brightness requires use-damage = false. Falling back to "
"1.0");
opt->max_brightness = 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); config_setting_lookup_int(blur_cfg, "size", &opt->blur_radius);
if (config_setting_lookup_string(blur_cfg, "kernel", &sval)) { 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); config_setting_lookup_float(blur_cfg, "deviation", &opt->blur_deviation);
} }

View File

@ -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" " the same group focused at the same time. WM_TRANSIENT_FOR has\n"
" higher priority if --detect-transient is enabled, too.\n" " higher priority if --detect-transient is enabled, too.\n"
"\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\n"
" Blur background of semi-transparent / ARGB windows. Bad in\n" " Blur background of semi-transparent / ARGB windows. Bad in\n"
" performance. The switch name may change without prior\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}, {"no-vsync", no_argument, NULL, 325},
{"max-brightness", required_argument, NULL, 326}, {"max-brightness", required_argument, NULL, 326},
{"transparent-clipping", no_argument, NULL, 327}, {"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}, {"experimental-backends", no_argument, NULL, 733},
{"monitor-repaint", no_argument, NULL, 800}, {"monitor-repaint", no_argument, NULL, 800},
{"diagnostics", no_argument, NULL, 801}, {"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); opt->max_brightness = atof(optarg);
break; break;
P_CASEBOOL(327, transparent_clipping); 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(733, experimental_backends);
P_CASEBOOL(800, monitor_repaint); 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); set_default_winopts(opt, winopt_mask, shadow_enable, fading_enable);
// --blur-background-frame implies --blur-background // --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; opt->blur_method = BLUR_METHOD_KERNEL;
} }