diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index 0de93d8b..d25afbb2 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h @@ -92,9 +92,7 @@ struct sway_output *workspace_output_get_highest_available( void workspace_detect_urgent(struct sway_workspace *workspace); -bool should_workspace_have_blur(struct sway_workspace *ws); - -void workspace_get_blur_region(struct sway_workspace *ws, +bool workspace_get_blur_info(struct sway_workspace *ws, pixman_region32_t *blur_region); void workspace_for_each_container(struct sway_workspace *ws, diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 4e530116..109c1ad1 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -1791,8 +1791,13 @@ void output_render(struct sway_output *output, struct timespec *when, render_unmanaged(output, damage, &root->xwayland_unmanaged); #endif } else { - bool workspace_has_blur = should_workspace_have_blur(workspace); - if (workspace_has_blur && config_should_parameters_blur()) { + // Gather the whole region where blur is drawn (all surfaces on + // the focused workspace) + pixman_region32_t blur_region; + pixman_region32_init(&blur_region); + bool workspace_has_blur = workspace_get_blur_info(workspace, &blur_region); + // Expend the damage to compensate for blur + if (workspace_has_blur) { // Skip all of the blur artifact prevention if we're damaging the // whole viewport if (renderer->blur_buffer_dirty) { @@ -1818,15 +1823,8 @@ void output_render(struct sway_output *output, struct timespec *when, wlr_region_expand(damage, damage, config_get_blur_size()); } - pixman_region32_t blur_region; - pixman_region32_init(&blur_region); pixman_region32_t extended_damage; pixman_region32_init(&extended_damage); - - // Gather the whole region where blur is drawn (all surfaces on - // the focused workspace) - workspace_get_blur_region(workspace, &blur_region); - pixman_region32_intersect(&extended_damage, damage, &blur_region); // Expand the region to compensate for blur artifacts wlr_region_expand(&extended_damage, &extended_damage, config_get_blur_size()); @@ -1842,6 +1840,7 @@ void output_render(struct sway_output *output, struct timespec *when, // Combine into the surface damage (we need to redraw the padding // area as well) pixman_region32_union(damage, damage, &extended_damage); + pixman_region32_fini(&extended_damage); // Capture the padding pixels before blur for later use fx_framebuffer_bind(&renderer->blur_saved_pixels_buffer); @@ -1849,11 +1848,9 @@ void output_render(struct sway_output *output, struct timespec *when, render_whole_output(renderer, wlr_output, &renderer->blur_padding_region, &renderer->wlr_buffer.texture); fx_framebuffer_bind(&renderer->wlr_buffer); - - pixman_region32_fini(&blur_region); - pixman_region32_fini(&extended_damage); } } + pixman_region32_fini(&blur_region); float clear_color[] = {0.25f, 0.25f, 0.25f, 1.0f}; @@ -1870,7 +1867,7 @@ void output_render(struct sway_output *output, struct timespec *when, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); // check if the background needs to be blurred - if (config_should_parameters_blur() && renderer->blur_buffer_dirty && workspace_has_blur) { + if (workspace_has_blur && renderer->blur_buffer_dirty) { render_output_blur(output, damage); } diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index eadc2eb5..7e7146dd 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -692,39 +692,6 @@ void workspace_detect_urgent(struct sway_workspace *workspace) { } } -static bool find_blurred_con_iterator(struct sway_container *con, void *data) { - struct sway_view *view = con->view; - if (!view) { - return false; - } - return con->blur_enabled && !view->surface->opaque; -} - -bool should_workspace_have_blur(struct sway_workspace *ws) { - if (!workspace_is_visible(ws)) { - return false; - } - - if ((bool)workspace_find_container(ws, find_blurred_con_iterator, NULL)) { - return true; - } - - // Check if any layer-shell surfaces will render effects - struct sway_output *sway_output = ws->output; - size_t len = sizeof(sway_output->layers) / sizeof(sway_output->layers[0]); - for (size_t i = 0; i < len; ++i) { - struct sway_layer_surface *lsurface; - wl_list_for_each(lsurface, &sway_output->layers[i], link) { - if (lsurface->has_blur && !lsurface->layer_surface->surface->opaque - && lsurface->layer != ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND) { - return true; - } - } - } - - return false; -} - struct blur_region_data { struct sway_workspace *ws; pixman_region32_t *blur_region; @@ -748,9 +715,9 @@ static void find_blurred_region_iterator(struct sway_container *con, void *data) } } -void workspace_get_blur_region(struct sway_workspace *ws, pixman_region32_t *blur_region) { - if (!workspace_is_visible(ws)) { - return; +bool workspace_get_blur_info(struct sway_workspace *ws, pixman_region32_t *blur_region) { + if (!workspace_is_visible(ws) || !config_should_parameters_blur()) { + return false; } // Each toplevel @@ -771,6 +738,8 @@ void workspace_get_blur_region(struct sway_workspace *ws, pixman_region32_t *blu } } } + + return pixman_region32_not_empty(blur_region); } void workspace_for_each_container(struct sway_workspace *ws,