diff --git a/src/config.h b/src/config.h index 8d0ac180cf..987d33a577 100644 --- a/src/config.h +++ b/src/config.h @@ -142,6 +142,9 @@ struct window_maybe_options { /// Window opacity, NaN means not set. double opacity; + /// Window dim level, NaN means not set. + double dim; + /// Name of the custom fragment shader for this window. NULL means not set. const struct shader_info *shader; @@ -153,8 +156,6 @@ struct window_maybe_options { enum tristate invert_color; /// Whether to blur window background. enum tristate blur_background; - /// Whether the window is to be dimmed. - enum tristate dim; /// Whether this window should fade. enum tristate fade; /// Do not paint shadow over this window. @@ -168,13 +169,13 @@ struct window_maybe_options { /// Like `window_maybe_options`, but all fields are guaranteed to be set. struct window_options { double opacity; + double dim; const struct shader_info *shader; unsigned int corner_radius; bool transparent_clipping; bool shadow; bool invert_color; bool blur_background; - bool dim; bool fade; bool clip_shadow_above; bool paint; @@ -188,7 +189,7 @@ win_options_eq(const struct window_options *a, const struct window_options *b) { return memcmp(a, b, offsetof(struct window_options, padding)) == 0; } -static_assert(offsetof(struct window_options, padding) == 29, "window_options has " +static_assert(offsetof(struct window_options, padding) == 36, "window_options has " "implicit padding"); extern struct shader_info null_shader; diff --git a/src/picom.c b/src/picom.c index fdd2c70481..65c25c9a86 100644 --- a/src/picom.c +++ b/src/picom.c @@ -1824,12 +1824,11 @@ static void draw_callback_impl(EV_P_ session_t *ps, int revents attr_unused) { ps->layout_manager, ps->wm, ps->root_image_generation, (ivec2){.width = ps->root_width, .height = ps->root_height}); bool succeeded = renderer_render( - ps->renderer, ps->backend_data, ps->root_image, - ps->layout_manager, ps->command_builder, - 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->renderer, ps->backend_data, ps->root_image, ps->layout_manager, + ps->command_builder, 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.crop_shadow_to_monitor ? &ps->monitors : NULL, ps->o.wintype_option, &after_damage_us); if (!succeeded) { diff --git a/src/render.c b/src/render.c index 2b3c87a60c..843b3bfd5b 100644 --- a/src/render.c +++ b/src/render.c @@ -561,8 +561,8 @@ void paint_one(session_t *ps, struct win *w, const struct window_options *w_opts } // Dimming the window if needed - if (w_opts->dim) { - double dim_opacity = ps->o.inactive_dim; + if (w_opts->dim > 0) { + double dim_opacity = w_opts->dim; if (!ps->o.inactive_dim_fixed) { dim_opacity *= window_opacity; } diff --git a/src/renderer/command_builder.c b/src/renderer/command_builder.c index c12df7b40b..257e9454df 100644 --- a/src/renderer/command_builder.c +++ b/src/renderer/command_builder.c @@ -17,17 +17,14 @@ static inline unsigned commands_for_window_body(struct layer *layer, struct backend_command *cmd, const region_t *frame_region, bool inactive_dim_fixed, - double inactive_dim, double max_brightness) { + double max_brightness) { auto w = layer->win; scoped_region_t crop = region_from_box(layer->crop); auto mode = win_calc_mode_raw(layer->win); int border_width = w->g.border_width; - double dim = 0; - if (layer->options.dim) { - dim = inactive_dim; - if (!inactive_dim_fixed) { - dim *= layer->opacity; - } + double dim = layer->options.dim; + if (!inactive_dim_fixed) { + dim *= layer->opacity; } if (border_width == 0) { // Some WM has borders implemented as WM frames @@ -363,9 +360,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 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, const struct x_monitors *monitors, const struct win_option *wintype_options) { unsigned ncmds = 1; @@ -398,8 +395,8 @@ void command_builder_build(struct command_builder *cb, struct layout *layout, bo layer->window.origin.y); // Add window body - cmd -= commands_for_window_body(layer, cmd, &frame_region, inactive_dim_fixed, - inactive_dim, max_brightness); + cmd -= commands_for_window_body(layer, cmd, &frame_region, + inactive_dim_fixed, max_brightness); // Add shadow cmd -= command_for_shadow(layer, cmd, wintype_options, monitors, last + 1); diff --git a/src/renderer/command_builder.h b/src/renderer/command_builder.h index a8c9c24e1e..f003d60e04 100644 --- a/src/renderer/command_builder.h +++ b/src/renderer/command_builder.h @@ -23,7 +23,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 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, const struct x_monitors *monitors, const struct win_option *wintype_options); diff --git a/src/renderer/renderer.c b/src/renderer/renderer.c index ca38f93a8c..dacd14923c 100644 --- a/src/renderer/renderer.c +++ b/src/renderer/renderer.c @@ -486,11 +486,10 @@ void renderer_ensure_images_ready(struct renderer *r, struct backend_base *backe /// @return true if a frame is rendered, false if this frame is skipped. 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 struct x_monitors *monitors, + 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, 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 @@ -512,7 +511,7 @@ bool renderer_render(struct renderer *r, struct backend_base *backend, renderer_ensure_images_ready(r, backend, monitor_repaint); command_builder_build(cb, layout, force_blend, blur_frame, inactive_dim_fixed, - max_brightness, inactive_dim, monitors, wintype_options); + max_brightness, 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 3a4b655675..19a1ad6c2e 100644 --- a/src/renderer/renderer.h +++ b/src/renderer/renderer.h @@ -22,9 +22,8 @@ struct renderer *renderer_new(struct backend_base *backend, double shadow_radius struct color shadow_color, bool dithered_present); 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 struct x_monitors *monitors, + 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, const struct x_monitors *monitors, const struct win_option *wintype_options, uint64_t *after_damage_us); diff --git a/src/wm/win.c b/src/wm/win.c index 36f37f7424..93bebf9874 100644 --- a/src/wm/win.c +++ b/src/wm/win.c @@ -875,9 +875,9 @@ static void win_update_dim(session_t *ps, struct win *w, bool focused) { } if (ps->o.inactive_dim > 0 && !focused) { - w->options.dim = TRI_TRUE; + w->options.dim = ps->o.inactive_dim; } else { - w->options.dim = TRI_FALSE; + w->options.dim = 0; } } @@ -1017,7 +1017,7 @@ static void win_determine_rounded_corners(session_t *ps, struct win *w) { // Don't round full screen windows & excluded windows, // unless we find a corner override in corner_radius_rules - if (!matched && w && w->is_fullscreen) { + if (!matched && w->is_fullscreen) { w->options.corner_radius = 0; log_debug("Not rounding corners for window %#010x", win_id(w)); } else { diff --git a/src/wm/win.h b/src/wm/win.h index e48afbd4c9..c5b234d240 100644 --- a/src/wm/win.h +++ b/src/wm/win.h @@ -305,7 +305,7 @@ static const struct window_maybe_options WIN_MAYBE_OPTIONS_DEFAULT = { .fade = TRI_UNKNOWN, .invert_color = TRI_UNKNOWN, .paint = TRI_UNKNOWN, - .dim = TRI_UNKNOWN, + .dim = NAN, .opacity = NAN, .shader = NULL, .corner_radius = -1, @@ -320,11 +320,11 @@ win_maybe_options_fold(struct window_maybe_options upper, struct window_maybe_op .blur_background = tri_or(upper.blur_background, lower.blur_background), .clip_shadow_above = tri_or(upper.clip_shadow_above, lower.clip_shadow_above), .shadow = tri_or(upper.shadow, lower.shadow), - .dim = tri_or(upper.dim, lower.dim), .fade = tri_or(upper.fade, lower.fade), .invert_color = tri_or(upper.invert_color, lower.invert_color), .paint = tri_or(upper.paint, lower.paint), .opacity = !safe_isnan(upper.opacity) ? upper.opacity : lower.opacity, + .dim = !safe_isnan(upper.dim) ? upper.dim : lower.dim, .shader = upper.shader ? upper.shader : lower.shader, .corner_radius = upper.corner_radius >= 0 ? upper.corner_radius : lower.corner_radius, }; @@ -340,11 +340,11 @@ win_maybe_options_or(struct window_maybe_options maybe, struct window_options de .shadow = tri_or_bool(maybe.shadow, def.shadow), .corner_radius = maybe.corner_radius >= 0 ? (unsigned int)maybe.corner_radius : def.corner_radius, - .dim = tri_or_bool(maybe.dim, def.dim), .fade = tri_or_bool(maybe.fade, def.fade), .invert_color = tri_or_bool(maybe.invert_color, def.invert_color), .paint = tri_or_bool(maybe.paint, def.paint), .opacity = !safe_isnan(maybe.opacity) ? maybe.opacity : def.opacity, + .dim = !safe_isnan(maybe.dim) ? maybe.dim : def.dim, .shader = maybe.shader ? maybe.shader : def.shader, }; }