config: add wintypes option `blur-background`

This commit is contained in:
Bernd Busse 2020-10-01 22:51:15 +02:00
parent e92e250237
commit fb3760bbe3
No known key found for this signature in database
GPG Key ID: 6DD2A3C48E63A5AB
6 changed files with 31 additions and 8 deletions

View File

@ -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.

View File

@ -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;

View File

@ -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:

View File

@ -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;

View File

@ -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

View File

@ -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);
}