From c4a0bb268a7a518c88939a8897e9e5a3290b9934 Mon Sep 17 00:00:00 2001 From: Erik Reider <35975961+ErikReider@users.noreply.github.com> Date: Sat, 20 May 2023 23:21:02 +0200 Subject: [PATCH] Fix layer surface damage not being extended if using effects (#160) --- sway/desktop/layer_shell.c | 7 +++++++ sway/desktop/output.c | 27 ++++++++++++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index bbc2e6f3..3bbc855d 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -334,6 +334,13 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { bool extent_changed = memcmp(&old_extent, &layer->extent, sizeof(struct wlr_box)) != 0; if (extent_changed || layer_changed) { + int blur_size = layer->has_blur? config_get_blur_size(): 0; + int shadow_sigma = layer->has_shadow? config->shadow_blur_sigma: 0; + int effect_size = MAX(blur_size, shadow_sigma); + old_extent.x -= effect_size; + old_extent.y -= effect_size; + old_extent.width += effect_size * 2; + old_extent.height += effect_size * 2; output_damage_box(output, &old_extent); output_damage_surface(output, layer->geo.x, layer->geo.y, layer_surface->surface, true); diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 7ea6a6e7..5d61186f 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -697,9 +697,19 @@ static void damage_surface_iterator(struct sway_output *output, } pixman_region32_translate(&damage, box.x, box.y); - if (view) { - int blur_size = view->container->blur_enabled ? config_get_blur_size() : 0; - + // Extend view/layer damage size + int effect_size = 0; + if (view && view->container->blur_enabled) { + // Don't check for shadow, gets extended in `output_damage_whole_container` + effect_size = config_get_blur_size(); + } else if (wlr_surface_is_layer_surface(surface)) { + struct wlr_layer_surface_v1 *layer = wlr_layer_surface_v1_from_wlr_surface(surface); + struct sway_layer_surface *sway_layer = layer_from_wlr_layer_surface_v1(layer); + int blur_size = sway_layer->has_blur? config_get_blur_size(): 0; + int shadow_sigma = sway_layer->has_shadow? config->shadow_blur_sigma: 0; + effect_size = MAX(blur_size, shadow_sigma); + } + if (effect_size > 0) { if (pixman_region32_not_empty(&damage)) { int output_width, output_height; wlr_output_transformed_resolution(output->wlr_output, &output_width, &output_height); @@ -708,14 +718,13 @@ static void damage_surface_iterator(struct sway_output *output, if (damage_width > output_width || damage_height > output_height) { pixman_region32_intersect_rect(&damage, &damage, 0, 0, output_width, output_height); } else { - wlr_region_expand(&damage, &damage, blur_size); + wlr_region_expand(&damage, &damage, effect_size); } } - - box.x -= blur_size; - box.y -= blur_size; - box.width += blur_size * 2; - box.height += blur_size * 2; + box.x -= effect_size; + box.y -= effect_size; + box.width += effect_size * 2; + box.height += effect_size * 2; } if (wlr_damage_ring_add(&output->damage_ring, &damage)) {