From 6dcb04d8b594953674e337fd9d41bc2d7ff600a8 Mon Sep 17 00:00:00 2001 From: Dave Shoreman Date: Tue, 18 Apr 2023 01:07:13 +0100 Subject: [PATCH] Add option to tweak inactive window blur opacity --- src/backend/backend.c | 6 +----- src/config.c | 1 + src/config.h | 4 +++- src/config_libconfig.c | 1 + src/options.c | 5 +++++ 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/backend/backend.c b/src/backend/backend.c index bc3017fc2c..0dbf527389 100644 --- a/src/backend/backend.c +++ b/src/backend/backend.c @@ -484,12 +484,8 @@ void paint_all_new(session_t *ps, struct managed_win *t, bool ignore_damage) { // Blur window if (w->blur_foreground) { assert(ps->o.blur_method != BLUR_METHOD_NONE); - // FIXME Think more about combining blur w/ opacity - // FIXME Don't hardcode opacity - // - needs to be set when focus_mode set to true - double blur_opacity = 1; ps->backend_data->ops->blur( - ps->backend_data, blur_opacity, + ps->backend_data, ps->o.inactive_blur_opacity, ps->backend_blur_fgcontext, w->mask_image, window_coord, ®_paint_in_bound, ®_visible); } diff --git a/src/config.c b/src/config.c index 49f1991460..d84f2f8226 100644 --- a/src/config.c +++ b/src/config.c @@ -766,6 +766,7 @@ char *parse_config(options_t *opt, const char *config_file, bool *shadow_enable, .inactive_blur = false, .inactive_blur_list = NULL, + .inactive_blur_opacity = 1.0, .inactive_dim = 0.0, .inactive_dim_fixed = false, .inactive_opacity = 1.0, diff --git a/src/config.h b/src/config.h index 10574287be..424009b04c 100644 --- a/src/config.h +++ b/src/config.h @@ -213,8 +213,10 @@ typedef struct options { char *window_shader_fg; /// Rules to change custom fragment shader for painting windows. c2_lptr_t *window_shader_fg_rules; - /// Whether to blur inactive windows + /// Whether to blur inactive window foregrounds bool inactive_blur; + // Opacity of inactive foreground blurs + double inactive_blur_opacity; /// List of windows that should be blurred out when inactive. c2_lptr_t *inactive_blur_list; /// How much to dim an inactive window. 0.0 - 1.0, 0 to disable. diff --git a/src/config_libconfig.c b/src/config_libconfig.c index bd97e4eebd..fa337173de 100644 --- a/src/config_libconfig.c +++ b/src/config_libconfig.c @@ -544,6 +544,7 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad // --inactive-blur if (lcfg_lookup_bool(&cfg, "inactive-blur", &opt->inactive_blur)) { parse_cfg_condlst(&cfg, &opt->inactive_blur_list, "inactive-blur-include"); + config_lookup_float(&cfg, "inactive-blur-opacity", &opt->inactive_blur_opacity); } // --resize-damage config_lookup_int(&cfg, "resize-damage", &opt->resize_damage); diff --git a/src/options.c b/src/options.c index 7a5aed2777..b11fc798c4 100644 --- a/src/options.c +++ b/src/options.c @@ -61,6 +61,7 @@ static const struct picom_option picom_options[] = { {"inactive-blur-include" , required_argument, 342, NULL , "Conditions for windows that should be fully blurred when inactive." "When --inactive-blur is enabled without an --inactive-blur-include" "condition, the foreground of ALL inactive windows will be blurred."}, + {"inactive-blur-opacity" , required_argument, 343, NULL , "Set the opacity of inactive foreground blurs"}, {"mark-wmwin-focused" , no_argument , 262, NULL , "Try to detect WM windows and mark them as active."}, {"shadow-exclude" , required_argument, 263, NULL , "Exclude conditions for shadows."}, {"mark-ovredir-focused" , no_argument , 264, NULL , "Mark windows that have no WM frame as active."}, @@ -750,6 +751,10 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable, // --inactive-blur-include condlst_add(&opt->inactive_blur_list, optarg); break; + case 343: + // --inactive-blur-opacity + opt->inactive_blur_opacity = normalize_d(atof(optarg)); + break; P_CASEBOOL(733, legacy_backends); P_CASEBOOL(800, monitor_repaint); case 801: