diff --git a/src/config.c b/src/config.c index ae8a168..db9d237 100644 --- a/src/config.c +++ b/src/config.c @@ -350,22 +350,11 @@ condlst_add(c2_lptr_t **pcondlst, const char *pattern) { return true; } -char *parse_config(options_t *opt, const char *config_file, - bool *shadow_enable, bool *fading_enable, bool *hasneg, - win_option_mask_t *winopt_mask) { - char *ret = NULL; -#ifdef CONFIG_LIBCONFIG - ret = parse_config_libconfig(opt, config_file, shadow_enable, fading_enable, - hasneg, winopt_mask); -#endif - - // Apply default wintype options that does not depends on global options. - // For example, wintype shadow option will depend on the global shadow - // option, so it is not set here. - // - // Except desktop windows are always drawn without shadow. - if (!winopt_mask[WINTYPE_DESKTOP].shadow) { - winopt_mask[WINTYPE_DESKTOP].shadow = true; +void set_default_winopts(options_t *opt, win_option_mask_t *mask, bool shadow_enable, bool fading_enable) { + // Apply default wintype options. + if (!mask[WINTYPE_DESKTOP].shadow) { + // Desktop windows are always drawn without shadow by default. + mask[WINTYPE_DESKTOP].shadow = true; opt->wintype_option[WINTYPE_DESKTOP].shadow = false; } @@ -374,30 +363,48 @@ char *parse_config(options_t *opt, const char *config_file, const wintype_t nofocus_type[] = { WINTYPE_UNKNOWN, WINTYPE_NORMAL, WINTYPE_UTILITY }; for (unsigned long i = 0; i < ARR_SIZE(nofocus_type); i++) { - if (!winopt_mask[nofocus_type[i]].focus) { - winopt_mask[nofocus_type[i]].focus = true; + if (!mask[nofocus_type[i]].focus) { + mask[nofocus_type[i]].focus = true; opt->wintype_option[nofocus_type[i]].focus = false; } } for (unsigned long i = 0; i < NUM_WINTYPES; i++) { - if (!winopt_mask[i].focus) { - winopt_mask[i].focus = true; + if (!mask[i].shadow) { + mask[i].shadow = true; + opt->wintype_option[i].shadow = shadow_enable; + } + if (!mask[i].fade) { + mask[i].fade = true; + opt->wintype_option[i].fade = fading_enable; + } + if (!mask[i].focus) { + mask[i].focus = true; opt->wintype_option[i].focus = true; } - if (!winopt_mask[i].full_shadow) { - winopt_mask[i].full_shadow = true; + if (!mask[i].full_shadow) { + mask[i].full_shadow = true; opt->wintype_option[i].full_shadow = false; } - if (!winopt_mask[i].redir_ignore) { - winopt_mask[i].redir_ignore = true; + if (!mask[i].redir_ignore) { + mask[i].redir_ignore = true; opt->wintype_option[i].redir_ignore = false; } - if (!winopt_mask[i].opacity) { - winopt_mask[i].opacity = true; + if (!mask[i].opacity) { + mask[i].opacity = true; // Opacity is not set to a concrete number here because the opacity logic // is complicated, and needs an "unset" state opt->wintype_option[i].opacity = NAN; } } +} + +char *parse_config(options_t *opt, const char *config_file, + bool *shadow_enable, bool *fading_enable, bool *hasneg, + win_option_mask_t *winopt_mask) { + char *ret = NULL; +#ifdef CONFIG_LIBCONFIG + ret = parse_config_libconfig(opt, config_file, shadow_enable, fading_enable, + hasneg, winopt_mask); +#endif return ret; } diff --git a/src/config.h b/src/config.h index 04deea2..d7f4467 100644 --- a/src/config.h +++ b/src/config.h @@ -269,6 +269,7 @@ parse_config_libconfig(options_t *, const char *config_file, bool *shadow_enable bool *fading_enable, bool *hasneg, win_option_mask_t *winopt_mask); #endif +void set_default_winopts(options_t *, win_option_mask_t *, bool shadow_enable, bool fading_enable); /// Parse a configuration file is that is enabled, also initialize the winopt_mask with /// default values /// Outputs and returns: diff --git a/src/options.c b/src/options.c index bf14135..b2fb523 100644 --- a/src/options.c +++ b/src/options.c @@ -551,11 +551,11 @@ void get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable, case 'c': shadow_enable = true; break; case 'C': winopt_mask[WINTYPE_DOCK].shadow = true; - opt->wintype_option[WINTYPE_DOCK].shadow = true; + opt->wintype_option[WINTYPE_DOCK].shadow = false; break; case 'G': winopt_mask[WINTYPE_DND].shadow = true; - opt->wintype_option[WINTYPE_DND].shadow = true; + opt->wintype_option[WINTYPE_DND].shadow = false; break; case 'm':; double tmp; @@ -793,18 +793,7 @@ void get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable, opt->refresh_rate = normalize_i_range(opt->refresh_rate, 0, 300); // Apply default wintype options that are dependent on global options - for (int i = 0; i < NUM_WINTYPES; i++) { - auto wo = &opt->wintype_option[i]; - auto mask = &winopt_mask[i]; - if (!mask->shadow) { - wo->shadow = shadow_enable; - mask->shadow = true; - } - if (!mask->fade) { - wo->fade = fading_enable; - mask->fade = true; - } - } + set_default_winopts(opt, winopt_mask, shadow_enable, fading_enable); // --blur-background-frame implies --blur-background if (opt->blur_background_frame)