From fb3760bbe32d54d5238b7d5cf053aabfabd3d0f3 Mon Sep 17 00:00:00 2001 From: Bernd Busse Date: Thu, 1 Oct 2020 22:51:15 +0200 Subject: [PATCH] config: add wintypes option `blur-background` --- man/picom.1.asciidoc | 5 ++++- src/config.c | 6 +++++- src/config.h | 4 +++- src/config_libconfig.c | 4 ++++ src/options.c | 7 ++++--- src/win.c | 13 +++++++++++-- 6 files changed, 31 insertions(+), 8 deletions(-) diff --git a/man/picom.1.asciidoc b/man/picom.1.asciidoc index 9f560dde..2612eceb 100644 --- a/man/picom.1.asciidoc +++ b/man/picom.1.asciidoc @@ -351,7 +351,7 @@ Window-type-specific settings are exposed only in configuration file and has the ------------ wintypes: { - WINDOW_TYPE = { fade = BOOL; shadow = BOOL; opacity = FLOAT; focus = BOOL; full-shadow = BOOL; redir-ignore = BOOL; }; + WINDOW_TYPE = { fade = BOOL; shadow = BOOL; opacity = FLOAT; focus = BOOL; blur-background = BOOL; full-shadow = BOOL; redir-ignore = BOOL; }; }; ------------ @@ -368,6 +368,9 @@ Following per window-type options are available: :: focus::: Controls whether the window of this type is to be always considered focused. (By default, all window types except "normal" and "dialog" has this on.) + blur-background::: + Controls wether the window of this type will have its transparent background blurred. + full-shadow::: Controls whether shadow is drawn under the parts of the window that you normally won't be able to see. Useful when the window has parts of it transparent, and you want shadows in those areas. diff --git a/src/config.c b/src/config.c index c8690b7c..e10ec341 100644 --- a/src/config.c +++ b/src/config.c @@ -452,7 +452,7 @@ bool condlst_add(c2_lptr_t **pcondlst, const char *pattern) { } void set_default_winopts(options_t *opt, win_option_mask_t *mask, bool shadow_enable, - bool fading_enable) { + bool fading_enable, bool blur_enable) { // Apply default wintype options. if (!mask[WINTYPE_DESKTOP].shadow) { // Desktop windows are always drawn without shadow by default. @@ -482,6 +482,10 @@ void set_default_winopts(options_t *opt, win_option_mask_t *mask, bool shadow_en mask[i].focus = true; opt->wintype_option[i].focus = true; } + if (!mask[i].blur_background) { + mask[i].blur_background = true; + opt->wintype_option[i].blur_background = blur_enable; + } if (!mask[i].full_shadow) { mask[i].full_shadow = true; opt->wintype_option[i].full_shadow = false; diff --git a/src/config.h b/src/config.h index 267239a5..d8741a5e 100644 --- a/src/config.h +++ b/src/config.h @@ -41,6 +41,7 @@ typedef struct win_option_mask { bool shadow : 1; bool fade : 1; bool focus : 1; + bool blur_background : 1; bool full_shadow : 1; bool redir_ignore : 1; bool opacity : 1; @@ -50,6 +51,7 @@ typedef struct win_option { bool shadow; bool fade; bool focus; + bool blur_background; bool full_shadow; bool redir_ignore; double opacity; @@ -271,7 +273,7 @@ parse_config_libconfig(options_t *, const char *config_file, bool *shadow_enable #endif void set_default_winopts(options_t *, win_option_mask_t *, bool shadow_enable, - bool fading_enable); + bool fading_enable, bool blur_enable); /// Parse a configuration file is that is enabled, also initialize the winopt_mask with /// default values /// Outputs and returns: diff --git a/src/config_libconfig.c b/src/config_libconfig.c index d223665f..8d6b7ae7 100644 --- a/src/config_libconfig.c +++ b/src/config_libconfig.c @@ -270,6 +270,10 @@ static inline void parse_wintype_config(const config_t *cfg, const char *member_ o->focus = ival; mask->focus = true; } + if (config_setting_lookup_bool(setting, "blur-background", &ival)) { + o->blur_background = ival; + mask->blur_background = true; + } if (config_setting_lookup_bool(setting, "full-shadow", &ival)) { o->full_shadow = ival; mask->full_shadow = true; diff --git a/src/options.c b/src/options.c index 974040ad..54ef937c 100644 --- a/src/options.c +++ b/src/options.c @@ -921,14 +921,15 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable, } } - // Apply default wintype options that are dependent on global options - set_default_winopts(opt, winopt_mask, shadow_enable, fading_enable); - // --blur-background-frame implies --blur-background if (opt->blur_background_frame && opt->blur_method == BLUR_METHOD_NONE) { opt->blur_method = BLUR_METHOD_KERNEL; } + // Apply default wintype options that are dependent on global options + set_default_winopts(opt, winopt_mask, shadow_enable, fading_enable, + opt->blur_method != BLUR_METHOD_NONE); + // Other variables determined by options // Determine whether we track window grouping diff --git a/src/win.c b/src/win.c index 610e8ca8..471c093d 100644 --- a/src/win.c +++ b/src/win.c @@ -873,11 +873,20 @@ win_set_blur_background(session_t *ps, struct managed_win *w, bool blur_backgrou * Determine if a window should have background blurred. */ static void win_determine_blur_background(session_t *ps, struct managed_win *w) { + log_debug("Determining blur-background of window %#010x (%s)", w->base.id, w->name); if (w->a.map_state != XCB_MAP_STATE_VIEWABLE) return; - bool blur_background_new = - ps->o.blur_method && !c2_match(ps, w, ps->o.blur_background_blacklist, NULL); + bool blur_background_new = ps->o.blur_method != BLUR_METHOD_NONE; + if (blur_background_new) { + if (!ps->o.wintype_option[w->window_type].blur_background) { + log_debug("Blur background disabled by wintypes"); + blur_background_new = false; + } else if (c2_match(ps, w, ps->o.blur_background_blacklist, NULL)) { + log_debug("Blur background disabled by blur-background-exclude"); + blur_background_new = false; + } + } win_set_blur_background(ps, w, blur_background_new); }