Merge pull request #286 from tryone144/fix/blur-method_options

Parse `--blur-*` options as documented in manpage
This commit is contained in:
yshui 2020-01-17 16:35:26 +00:00 committed by GitHub
commit 463bf09d0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 18 deletions

View File

@ -1,5 +1,5 @@
picom(1) picom(1)
========== ========
:doctype: manpage :doctype: manpage
:man source: picom :man source: picom
:man version: {picom-version} :man version: {picom-version}
@ -98,7 +98,7 @@ OPTIONS
Blue color value of shadow (0.0 - 1.0, defaults to 0). Blue color value of shadow (0.0 - 1.0, defaults to 0).
*--inactive-opacity-override*:: *--inactive-opacity-override*::
Let inactive opacity set by *-i* overrides the windows' '_NET_WM_OPACITY' values. Let inactive opacity set by *-i* override the '_NET_WM_OPACITY' values of windows.
*--active-opacity* 'OPACITY':: *--active-opacity* 'OPACITY'::
Default opacity for active windows. (0.0 - 1.0, defaults to 1.0) Default opacity for active windows. (0.0 - 1.0, defaults to 1.0)
@ -107,10 +107,10 @@ OPTIONS
Dim inactive windows. (0.0 - 1.0, defaults to 0.0) Dim inactive windows. (0.0 - 1.0, defaults to 0.0)
*--mark-wmwin-focused*:: *--mark-wmwin-focused*::
Try to detect WM windows (a non-override-redirect window with no child that has `WM_STATE`) and mark them as active. Try to detect WM windows (a non-override-redirect window with no child that has 'WM_STATE') and mark them as active.
*--mark-ovredir-focused*:: *--mark-ovredir-focused*::
Mark override-redirect windows that doesn't have a child window with `WM_STATE` focused. Mark override-redirect windows that doesn't have a child window with 'WM_STATE' focused.
*--no-fading-openclose*:: *--no-fading-openclose*::
Do not fade on window open/close. Do not fade on window open/close.
@ -189,7 +189,7 @@ In other words, the matrix is formatted as a list of comma separated numbers. Th
+ +
The elements are finite floating point numbers. The decimal pointer has to be '.' (a period), scientific notation is not supported. The elements are finite floating point numbers. The decimal pointer has to be '.' (a period), scientific notation is not supported.
+ +
The element in the center will either be 1.0 or varying based on opacity, depending on whether you have `--blur-background-fixed`. Yet the automatic adjustment of blur factor may not work well with a custom blur kernel. The element in the center will either be 1.0 or varying based on opacity, depending on whether you have *--blur-background-fixed*. Yet the automatic adjustment of blur factor may not work well with a custom blur kernel.
+ +
A 7x7 Gaussian blur kernel (sigma = 0.84089642) looks like: A 7x7 Gaussian blur kernel (sigma = 0.84089642) looks like:
+ +
@ -203,7 +203,7 @@ May also be one of the predefined kernels: `3x3box` (default), `5x5box`, `7x7box
Exclude conditions for background blur. Exclude conditions for background blur.
*--resize-damage* 'INTEGER':: *--resize-damage* 'INTEGER'::
Resize damaged region by a specific number of pixels. A positive value enlarges it while a negative one shrinks it. If the value is positive, those additional pixels will not be actually painted to screen, only used in blur calculation, and such. (Due to technical limitations, with *--use-damage*, those pixels will still be incorrectly painted to screen.) Primarily used to fix the line corruption issues of blur, in which case you should use the blur radius value here (e.g. with a 3x3 kernel, you should use *--resize-damage* 1, with a 5x5 one you use *--resize-damage* 2, and so on). May or may not work with `--glx-no-stencil`. Shrinking doesn't function correctly. Resize damaged region by a specific number of pixels. A positive value enlarges it while a negative one shrinks it. If the value is positive, those additional pixels will not be actually painted to screen, only used in blur calculation, and such. (Due to technical limitations, with *--use-damage*, those pixels will still be incorrectly painted to screen.) Primarily used to fix the line corruption issues of blur, in which case you should use the blur radius value here (e.g. with a 3x3 kernel, you should use `--resize-damage 1`, with a 5x5 one you use `--resize-damage 2`, and so on). May or may not work with *--glx-no-stencil*. Shrinking doesn't function correctly.
*--invert-color-include* 'CONDITION':: *--invert-color-include* 'CONDITION'::
Specify a list of conditions of windows that should be painted with inverted color. Resource-hogging, and is not well tested. Specify a list of conditions of windows that should be painted with inverted color. Resource-hogging, and is not well tested.
@ -222,8 +222,8 @@ May also be one of the predefined kernels: `3x3box` (default), `5x5box`, `7x7box
+ +
-- --
* `xrender` backend performs all rendering operations with X Render extension. It is what `xcompmgr` uses, and is generally a safe fallback when you encounter rendering artifacts or instability. * `xrender` backend performs all rendering operations with X Render extension. It is what `xcompmgr` uses, and is generally a safe fallback when you encounter rendering artifacts or instability.
* `glx` (OpenGL) backend performs all rendering operations with OpenGL. It is more friendly to some VSync methods, and has significantly superior performance on color inversion (`--invert-color-include`) or blur (`--blur-background`). It requires proper OpenGL 2.0 support from your driver and hardware. You may wish to look at the GLX performance optimization options below. `--xrender-sync-fence` might be needed on some systems to avoid delay in changes of screen contents. * `glx` (OpenGL) backend performs all rendering operations with OpenGL. It is more friendly to some VSync methods, and has significantly superior performance on color inversion (*--invert-color-include*) or blur (*--blur-background*). It requires proper OpenGL 2.0 support from your driver and hardware. You may wish to look at the GLX performance optimization options below. *--xrender-sync-fence* might be needed on some systems to avoid delay in changes of screen contents.
* `xr_glx_hybrid` backend renders the updated screen contents with X Render and presents it on the screen with GLX. It attempts to address the rendering issues some users encountered with GLX backend and enables the better VSync of GLX backends. `--vsync-use-glfinish` might fix some rendering issues with this backend. * `xr_glx_hybrid` backend renders the updated screen contents with X Render and presents it on the screen with GLX. It attempts to address the rendering issues some users encountered with GLX backend and enables the better VSync of GLX backends. *--vsync-use-glfinish* might fix some rendering issues with this backend.
-- --
*--glx-no-stencil*:: *--glx-no-stencil*::
@ -396,18 +396,18 @@ blur:
Available options of the 'blur' section are: :: Available options of the 'blur' section are: ::
*method*::: *method*:::
A string. Controls the blur method. Corresponds to the `--blur-method` command line option. Available choices are: A string. Controls the blur method. Corresponds to the *--blur-method* command line option. Available choices are:
'none' to disable blurring; 'gaussian' for gaussian blur; 'box' for box blur; 'kernel' for convolution blur with a custom kernel. 'none' to disable blurring; 'gaussian' for gaussian blur; 'box' for box blur; 'kernel' for convolution blur with a custom kernel.
Note: 'gaussian' and 'box' blur methods are only supported by the experimental backends. Note: 'gaussian' and 'box' blur methods are only supported by the experimental backends.
*size*::: *size*:::
An integer. The size of the blur kernel, required by 'gaussian' and 'box' blur methods. For the 'kernel' method, the size is included in the kernel. Corresponds to the `--blur-size` command line option. An integer. The size of the blur kernel, required by 'gaussian' and 'box' blur methods. For the 'kernel' method, the size is included in the kernel. Corresponds to the *--blur-size* command line option.
*deviation*::: *deviation*:::
A floating point number. The standard deviation for the 'gaussian' blur method. Corresponds to the `--blur-deviation` command line option. A floating point number. The standard deviation for the 'gaussian' blur method. Corresponds to the *--blur-deviation* command line option.
*kernel*::: *kernel*:::
A string. The kernel to use for the 'kernel' blur method, specified in the same format as the `--blur-kerns` option. Corresponds to the `--blur-kerns` command line option. A string. The kernel to use for the 'kernel' blur method, specified in the same format as the *--blur-kerns* option. Corresponds to the *--blur-kerns* command line option.
SIGNALS SIGNALS
------- -------

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,9 +381,24 @@ 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) {
opt->blur_method = BLUR_METHOD_KERNEL; if (opt->blur_method == BLUR_METHOD_NONE) {
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);
@ -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;
} }