From 00694dd05957df85eae9fc4b8b208b535d6793a0 Mon Sep 17 00:00:00 2001 From: William McKinnon Date: Sun, 7 May 2023 00:51:03 -0400 Subject: [PATCH] moved workspace optimized check function to workspace.c --- include/sway/tree/workspace.h | 2 ++ sway/desktop/render.c | 27 ++------------------------- sway/tree/workspace.c | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index b3d93a81..89113f32 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h @@ -92,6 +92,8 @@ struct sway_output *workspace_output_get_highest_available( void workspace_detect_urgent(struct sway_workspace *workspace); +bool should_workspace_need_optimized_blur(struct sway_workspace *ws); + void workspace_for_each_container(struct sway_workspace *ws, void (*f)(struct sway_container *con, void *data), void *data); diff --git a/sway/desktop/render.c b/sway/desktop/render.c index 96f68680..9892c78a 100644 --- a/sway/desktop/render.c +++ b/sway/desktop/render.c @@ -1757,27 +1757,6 @@ static void render_seatops(struct sway_output *output, } } -static bool find_con_needing_optimized_blur(struct sway_container *con, void *data) { - struct sway_view *view = con->view; - if (!view) { - return false; - } - if (con->blur_enabled && !view->surface->opaque && (!container_is_floating(con) || config->blur_xray)) { - return true; - } - return false; -} - -// TODO: move to workspace.c? -static bool should_workspace_have_optimized_blur(struct sway_output *sway_output) { - struct sway_workspace *workspace = sway_output->current.active_workspace; - if (!workspace_is_visible(workspace) || !sway_output->renderer->blur_buffer_dirty) { - return false; - } - // Iterate through the workspace containers and check if any require optimized blur - return (bool)workspace_find_container(workspace, find_con_needing_optimized_blur, NULL); -} - void output_render(struct sway_output *output, struct timespec *when, pixman_region32_t *damage) { struct wlr_output *wlr_output = output->wlr_output; @@ -1905,11 +1884,9 @@ void output_render(struct sway_output *output, struct timespec *when, render_layer_toplevel(output, damage, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM]); - - // Check if there are any windows to blur + // check if the background needs to be blurred if (should_parameters_blur() && renderer->blur_buffer_dirty) { - if (should_workspace_have_optimized_blur(output)) { - // Damage the whole output + if (should_workspace_need_optimized_blur(workspace)) { pixman_region32_union_rect(damage, damage, 0, 0, width, height); render_monitor_blur(output, damage); } diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index ee940466..5a3a9255 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -690,6 +690,24 @@ void workspace_detect_urgent(struct sway_workspace *workspace) { } } +static bool find_con_needing_optimized_blur(struct sway_container *con, void *data) { + struct sway_view *view = con->view; + if (!view) { + return false; + } + if (con->blur_enabled && !view->surface->opaque && (!container_is_floating(con) || config->blur_xray)) { + return true; + } + return false; +} + +bool should_workspace_need_optimized_blur(struct sway_workspace *ws) { + if (!workspace_is_visible(ws)) { + return false; + } + return (bool)workspace_find_container(ws, find_con_needing_optimized_blur, NULL); +} + void workspace_for_each_container(struct sway_workspace *ws, void (*f)(struct sway_container *con, void *data), void *data) { // Tiling