From f510d8dd6207e2c21a94a6cbac8a147b8e945d4a Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 12 May 2024 12:24:32 +0100 Subject: [PATCH] config: remove --shadow-exclude-reg Deprecated in v2, and we added a better alternative to it. Signed-off-by: Yuxuan Shui --- CHANGELOG.md | 4 ++ man/picom.1.asciidoc | 3 - picom.sample.conf | 7 --- src/common.h | 2 - src/config.c | 101 -------------------------------- src/config.h | 3 - src/config_libconfig.c | 4 +- src/options.c | 5 +- src/picom.c | 15 +---- src/render.c | 5 -- src/renderer/command_builder.c | 15 ++--- src/renderer/command_builder.h | 7 +-- src/renderer/renderer.c | 11 ++-- src/renderer/renderer.h | 8 +-- tests/configs/parsing_test.conf | 7 --- 15 files changed, 27 insertions(+), 170 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71150ced..b788aee6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,10 @@ * Marginally improve performance when resizing/opening/closing windows. (#1190) * Type and format specifiers are no longer used in rules. These specifiers are what you put after the colon (':') in rules, e.g. the `:32c` in `"_GTK_FRAME_EXTENTS@:32c"`. Now this information is ignored and the property is matched regardless of format or type. +## Deprecated features + +* Setting `--shadow-exclude-reg` is now a hard error. It was deprecated almost since the start of `picom`. `--clip-shadow-above` is the better alternative. (#1254) + ## Bug fixes * Fix ghosting artifacts that sometimes occur when window manager is restarted (#1081) diff --git a/man/picom.1.asciidoc b/man/picom.1.asciidoc index 31a520ee..cdd98a3c 100644 --- a/man/picom.1.asciidoc +++ b/man/picom.1.asciidoc @@ -217,9 +217,6 @@ May also be one of the predefined kernels: `3x3box` (default), `5x5box`, `7x7box *--opacity-rule* 'OPACITY':'CONDITION':: Specify a list of opacity rules, in the format `PERCENT:PATTERN`, like `50:name *= "Firefox"`. picom-trans is recommended over this. Note we don't make any guarantee about possible conflicts with other programs that set '_NET_WM_WINDOW_OPACITY' on frame or client windows. -*--shadow-exclude-reg* 'GEOMETRY':: - Specify a X geometry that describes the region in which shadow should not be painted in, such as a dock window region. Use `--shadow-exclude-reg x10+0-0`, for example, if the 10 pixels on the bottom of the screen should not have shadows painted on. - *--crop-shadow-to-monitor*:: Crop shadow of a window fully on a particular monitor to that monitor. This is currently implemented using the X RandR extension. diff --git a/picom.sample.conf b/picom.sample.conf index abe82840..c605af15 100644 --- a/picom.sample.conf +++ b/picom.sample.conf @@ -50,13 +50,6 @@ shadow-exclude = [ # Specify a list of conditions of windows that should have no shadow painted over, such as a dock window. # clip-shadow-above = [] -# Specify a X geometry that describes the region in which shadow should not -# be painted in, such as a dock window region. Use -# shadow-exclude-reg = "x10+0+0" -# for example, if the 10 pixels on the bottom of the screen should not have shadows painted on. -# -# shadow-exclude-reg = "" - # Crop shadow of a window fully on a particular monitor to that monitor. This is # currently implemented using the X RandR extension. # crop-shadow-to-monitor = false diff --git a/src/common.h b/src/common.h index 32baeb45..a612f63f 100644 --- a/src/common.h +++ b/src/common.h @@ -307,8 +307,6 @@ typedef struct session { /// Backend shadow context. struct backend_shadow_context *shadow_context; // for shadow precomputation - /// A region in which shadow is not painted on. - region_t shadow_exclude_reg; // === Software-optimization-related === /// Nanosecond offset of the first painting. diff --git a/src/config.c b/src/config.c index 7b00bc09..73d43832 100644 --- a/src/config.c +++ b/src/config.c @@ -412,107 +412,6 @@ struct conv **parse_blur_kern_lst(const char *src, bool *hasneg, int *count) { return ret; } -/** - * Parse a X geometry. - * - * ps->root_width and ps->root_height must be valid - */ -bool parse_geometry(session_t *ps, const char *src, region_t *dest) { - pixman_region32_clear(dest); - if (!src) { - return true; - } - if (!ps->root_width || !ps->root_height) { - return true; - } - - long x = 0, y = 0; - long width = ps->root_width, height = ps->root_height; - long val = 0L; - char *endptr = NULL; - - src = skip_space(src); - if (!*src) { - goto parse_geometry_end; - } - - // Parse width - // Must be base 10, because "0x0..." may appear - if (*src != '+' && *src != '-') { - val = strtol(src, &endptr, 10); - assert(endptr); - if (src != endptr) { - if (val < 0) { - log_error("Invalid width: %s", src); - return false; - } - width = val; - src = endptr; - } - src = skip_space(src); - } - - // Parse height - if (*src == 'x') { - ++src; - val = strtol(src, &endptr, 10); - assert(endptr); - if (src != endptr) { - if (val < 0) { - log_error("Invalid height: %s", src); - return false; - } - height = val; - src = endptr; - } - src = skip_space(src); - } - - // Parse x - if (*src == '+' || *src == '-') { - val = strtol(src, &endptr, 10); - if (endptr && src != endptr) { - x = val; - if (*src == '-') { - x += ps->root_width - width; - } - src = endptr; - } - src = skip_space(src); - } - - // Parse y - if (*src == '+' || *src == '-') { - val = strtol(src, &endptr, 10); - if (endptr && src != endptr) { - y = val; - if (*src == '-') { - y += ps->root_height - height; - } - src = endptr; - } - src = skip_space(src); - } - - if (*src) { - log_error("Trailing characters: %s", src); - return false; - } - -parse_geometry_end: - if (x < INT_MIN || x > INT_MAX || y < INT_MIN || y > INT_MAX) { - log_error("Geometry coordinates exceeded limits: %s", src); - return false; - } - if (width > UINT_MAX || height > UINT_MAX) { - // less than 0 is checked for earlier - log_error("Geometry size exceeded limits: %s", src); - return false; - } - pixman_region32_union_rect(dest, dest, (int)x, (int)y, (uint)width, (uint)height); - return true; -} - void *parse_numeric_prefix(const char *src, const char **end, void *user_data) { int *minmax = user_data; *end = NULL; diff --git a/src/config.h b/src/config.h index e5bfcf6d..def28967 100644 --- a/src/config.h +++ b/src/config.h @@ -176,8 +176,6 @@ typedef struct options { int shadow_radius; int shadow_offset_x, shadow_offset_y; double shadow_opacity; - /// argument string to shadow-exclude-reg option - char *shadow_exclude_reg_str; /// Shadow blacklist. A linked list of conditions. c2_lptr_t *shadow_blacklist; /// Whether bounding-shaped window should be ignored. @@ -296,7 +294,6 @@ extern const char *const BACKEND_STRS[NUM_BKEND + 1]; bool must_use parse_long(const char *, long *); bool must_use parse_int(const char *, int *); struct conv **must_use parse_blur_kern_lst(const char *, bool *hasneg, int *count); -bool must_use parse_geometry(session_t *, const char *, region_t *); void *parse_window_shader_prefix(const char *src, const char **end, void *user_data); void *parse_numeric_prefix(const char *src, const char **end, void *user_data); char *must_use locate_auxiliary_file(const char *scope, const char *path, diff --git a/src/config_libconfig.c b/src/config_libconfig.c index c1b213fd..038cc14d 100644 --- a/src/config_libconfig.c +++ b/src/config_libconfig.c @@ -357,7 +357,9 @@ char *parse_config_libconfig(options_t *opt, const char *config_file, bool *shad } // --shadow-exclude-reg if (config_lookup_string(&cfg, "shadow-exclude-reg", &sval)) { - opt->shadow_exclude_reg_str = strdup(sval); + log_error("shadow-exclude-reg is deprecated. Please use " + "clip-shadow-above for more flexible shadow exclusion."); + goto err; } // --inactive-opacity-override lcfg_lookup_bool(&cfg, "inactive-opacity-override", &opt->inactive_opacity_override); diff --git a/src/options.c b/src/options.c index 01f1d3cc..b34199f4 100644 --- a/src/options.c +++ b/src/options.c @@ -629,10 +629,9 @@ bool get_cfg(options_t *opt, int argc, char *const *argv, bool shadow_enable, break; case 305: // --shadow-exclude-reg - free(opt->shadow_exclude_reg_str); - opt->shadow_exclude_reg_str = strdup(optarg); - log_warn("--shadow-exclude-reg is deprecated. You are likely " + log_error("--shadow-exclude-reg is deprecated. You are likely " "better off using --clip-shadow-above anyway"); + failed = true; break; case 306: // --paint-exclude diff --git a/src/picom.c b/src/picom.c index d3e0a2be..9b5f7581 100644 --- a/src/picom.c +++ b/src/picom.c @@ -594,16 +594,6 @@ static void rebuild_screen_reg(session_t *ps) { get_screen_region(ps, &ps->screen_reg); } -/** - * Rebuild shadow_exclude_reg. - */ -static void rebuild_shadow_exclude_reg(session_t *ps) { - bool ret = parse_geometry(ps, ps->o.shadow_exclude_reg_str, &ps->shadow_exclude_reg); - if (!ret) { - exit(1); - } -} - /// Free up all the images and deinit the backend static void destroy_backend(session_t *ps) { win_stack_foreach_managed_safe(w, wm_stack_end(ps->wm)) { @@ -808,7 +798,6 @@ static void configure_root(session_t *ps) { free(r); rebuild_screen_reg(ps); - rebuild_shadow_exclude_reg(ps); // Invalidate reg_ignore from the top auto top_w = wm_stack_next_managed(ps->wm, wm_stack_end(ps->wm)); @@ -1854,7 +1843,7 @@ static void draw_callback_impl(EV_P_ session_t *ps, int revents attr_unused) { ps->backend_blur_context, render_start_us, ps->sync_fence, ps->o.use_damage, ps->o.monitor_repaint, ps->o.force_win_blend, ps->o.blur_background_frame, ps->o.inactive_dim_fixed, - ps->o.max_brightness, ps->o.inactive_dim, &ps->shadow_exclude_reg, + ps->o.max_brightness, ps->o.inactive_dim, ps->o.crop_shadow_to_monitor ? &ps->monitors : NULL, ps->o.wintype_option, &after_damage_us); if (!succeeded) { @@ -2289,8 +2278,6 @@ static session_t *session_init(int argc, char **argv, Display *dpy, sum_kernel_preprocess((conv *)ps->shadow_context); } - rebuild_shadow_exclude_reg(ps); - // Query X Shape ext_info = xcb_get_extension_data(ps->c.c, &xcb_shape_id); if (ext_info && ext_info->present) { diff --git a/src/render.c b/src/render.c index bff4672d..c54b8ccc 100644 --- a/src/render.c +++ b/src/render.c @@ -1100,11 +1100,6 @@ void paint_all(session_t *ps, struct managed_win *t) { // of the windows above. Because no one can see it pixman_region32_subtract(®_tmp, ®ion, w->reg_ignore); - // Mask out the region we don't want shadow on - if (pixman_region32_not_empty(&ps->shadow_exclude_reg)) { - pixman_region32_subtract(®_tmp, ®_tmp, - &ps->shadow_exclude_reg); - } if (pixman_region32_not_empty(®_shadow_clip)) { pixman_region32_subtract(®_tmp, ®_tmp, ®_shadow_clip); } diff --git a/src/renderer/command_builder.c b/src/renderer/command_builder.c index eed526bd..deff5e7f 100644 --- a/src/renderer/command_builder.c +++ b/src/renderer/command_builder.c @@ -90,7 +90,7 @@ commands_for_window_body(struct layer *layer, struct backend_command *cmd, /// @param[in] end the end of the commands generated for this `layer`. static inline unsigned command_for_shadow(struct layer *layer, struct backend_command *cmd, - const struct win_option *wintype_options, const region_t *shadow_exclude, + const struct win_option *wintype_options, const struct x_monitors *monitors, const struct backend_command *end) { auto w = layer->win; if (!w->shadow) { @@ -134,9 +134,6 @@ command_for_shadow(struct layer *layer, struct backend_command *cmd, // Move mask region to screen coordinates for shadow exclusion // calculation pixman_region32_translate(&cmd->mask.region, layer->origin.x, layer->origin.y); - if (shadow_exclude) { - pixman_region32_subtract(&cmd->mask.region, &cmd->mask.region, shadow_exclude); - } if (monitors && w->randr_monitor >= 0 && w->randr_monitor < monitors->count) { pixman_region32_intersect(&cmd->mask.region, &cmd->mask.region, &monitors->regions[w->randr_monitor]); @@ -362,10 +359,9 @@ void command_builder_free(struct command_builder *cb) { // TODO(yshui) reduce the number of parameters by storing the final effective parameter // value in `struct managed_win`. -void command_builder_build(struct command_builder *cb, struct layout *layout, - bool force_blend, bool blur_frame, bool inactive_dim_fixed, - double max_brightness, double inactive_dim, - const region_t *shadow_exclude, const struct x_monitors *monitors, +void command_builder_build(struct command_builder *cb, struct layout *layout, bool force_blend, + bool blur_frame, bool inactive_dim_fixed, double max_brightness, + double inactive_dim, const struct x_monitors *monitors, const struct win_option *wintype_options) { unsigned ncmds = 1; @@ -402,8 +398,7 @@ void command_builder_build(struct command_builder *cb, struct layout *layout, inactive_dim, max_brightness); // Add shadow - cmd -= command_for_shadow(layer, cmd, wintype_options, shadow_exclude, - monitors, last + 1); + cmd -= command_for_shadow(layer, cmd, wintype_options, monitors, last + 1); // Add blur cmd -= command_for_blur(layer, cmd, &frame_region, force_blend, blur_frame); diff --git a/src/renderer/command_builder.h b/src/renderer/command_builder.h index f94a5eef..4672f315 100644 --- a/src/renderer/command_builder.h +++ b/src/renderer/command_builder.h @@ -20,8 +20,7 @@ void command_builder_command_list_free(struct backend_command *cmds); /// It is guaranteed that each of the command's region of operation (e.g. the mask.region /// argument of blit), will be store in `struct backend_command::mask`. This might not /// stay true after further passes. -void command_builder_build(struct command_builder *cb, struct layout *layout, - bool force_blend, bool blur_frame, bool inactive_dim_fixed, - double max_brightness, double inactive_dim, - const region_t *shadow_exclude, const struct x_monitors *monitors, +void command_builder_build(struct command_builder *cb, struct layout *layout, bool force_blend, + bool blur_frame, bool inactive_dim_fixed, double max_brightness, + double inactive_dim, const struct x_monitors *monitors, const struct win_option *wintype_options); diff --git a/src/renderer/renderer.c b/src/renderer/renderer.c index 877cb9c6..4129f966 100644 --- a/src/renderer/renderer.c +++ b/src/renderer/renderer.c @@ -450,10 +450,10 @@ void renderer_ensure_monitor_repaint_ready(struct renderer *r, struct backend_ba bool renderer_render(struct renderer *r, struct backend_base *backend, image_handle root_image, struct layout_manager *lm, struct command_builder *cb, void *blur_context, - uint64_t render_start_us, xcb_sync_fence_t xsync_fence, bool use_damage, - bool monitor_repaint, bool force_blend, bool blur_frame, - bool inactive_dim_fixed, double max_brightness, double inactive_dim, - const region_t *shadow_exclude, const struct x_monitors *monitors, + uint64_t render_start_us, xcb_sync_fence_t xsync_fence, + bool use_damage, bool monitor_repaint, bool force_blend, + bool blur_frame, bool inactive_dim_fixed, double max_brightness, + double inactive_dim, const struct x_monitors *monitors, const struct win_option *wintype_options, uint64_t *after_damage_us) { if (xsync_fence != XCB_NONE) { // Trigger the fence but don't immediately wait on it. Let it run @@ -477,8 +477,7 @@ bool renderer_render(struct renderer *r, struct backend_base *backend, } command_builder_build(cb, layout, force_blend, blur_frame, inactive_dim_fixed, - max_brightness, inactive_dim, shadow_exclude, monitors, - wintype_options); + max_brightness, inactive_dim, monitors, wintype_options); if (log_get_level_tls() <= LOG_LEVEL_TRACE) { auto layer = layout->layers - 1; auto layer_end = &layout->commands[layout->first_layer_start]; diff --git a/src/renderer/renderer.h b/src/renderer/renderer.h index 961a2dff..7354b998 100644 --- a/src/renderer/renderer.h +++ b/src/renderer/renderer.h @@ -22,8 +22,8 @@ struct renderer *renderer_new(struct backend_base *backend, double shadow_radius bool renderer_render(struct renderer *r, struct backend_base *backend, image_handle root_image, struct layout_manager *lm, struct command_builder *cb, void *blur_context, - uint64_t render_start_us, xcb_sync_fence_t xsync_fence, bool use_damage, - bool monitor_repaint, bool force_blend, bool blur_frame, - bool inactive_dim_fixed, double max_brightness, double inactive_dim, - const region_t *shadow_exclude, const struct x_monitors *monitors, + uint64_t render_start_us, xcb_sync_fence_t xsync_fence, + bool use_damage, bool monitor_repaint, bool force_blend, + bool blur_frame, bool inactive_dim_fixed, double max_brightness, + double inactive_dim, const struct x_monitors *monitors, const struct win_option *wintype_options, uint64_t *after_damage_us); diff --git a/tests/configs/parsing_test.conf b/tests/configs/parsing_test.conf index 7b6acd31..a3088680 100644 --- a/tests/configs/parsing_test.conf +++ b/tests/configs/parsing_test.conf @@ -57,13 +57,6 @@ shadow-exclude = [ # Specify a list of conditions of windows that should have no shadow painted over, such as a dock window. # clip-shadow-above = [] -# Specify a X geometry that describes the region in which shadow should not -# be painted in, such as a dock window region. Use -# shadow-exclude-reg = "x10+0+0" -# for example, if the 10 pixels on the bottom of the screen should not have shadows painted on. -# -# shadow-exclude-reg = "" - # Crop shadow of a window fully on a particular monitor to that monitor. This is # currently implemented using the X RandR extension. # crop-shadow-to-monitor = false