Disable blur xray for BOTTOM layered surfaces

This commit is contained in:
Erik Reider 2023-05-02 20:19:54 +02:00
parent 8a7bb48e75
commit 13d4b7b187
4 changed files with 17 additions and 6 deletions

View file

@ -18,6 +18,7 @@
.saturation = 1.0f, \ .saturation = 1.0f, \
.has_titlebar = false, \ .has_titlebar = false, \
.blur = false, \ .blur = false, \
.can_blur_xray = false, \
.shadow = false, \ .shadow = false, \
} }
@ -45,6 +46,7 @@ struct decoration_data {
float *dim_color; float *dim_color;
bool has_titlebar; bool has_titlebar;
bool blur; bool blur;
bool can_blur_xray;
bool shadow; bool shadow;
}; };

View file

@ -692,6 +692,8 @@ void handle_layer_shell_surface(struct wl_listener *listener, void *data) {
struct layer_effects *effect = config->layer_effects->items[i]; struct layer_effects *effect = config->layer_effects->items[i];
if (strcmp(effect->namespace, layer_surface->namespace) == 0) { if (strcmp(effect->namespace, layer_surface->namespace) == 0) {
sway_layer->effects = effect; sway_layer->effects = effect;
// Blur optimization won't work for BOTTOM layered surfaces
sway_layer->effects->deco_data.can_blur_xray = layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM;
break; break;
} }
} }

View file

@ -333,7 +333,7 @@ void render_blur(bool optimized, struct sway_output *output,
wlr_region_scale(&inverse_opaque, &inverse_opaque, wlr_output->scale); wlr_region_scale(&inverse_opaque, &inverse_opaque, wlr_output->scale);
struct fx_framebuffer *buffer = &renderer->blur_buffer; struct fx_framebuffer *buffer = &renderer->blur_buffer;
if (!buffer->texture.id || (!optimized && !config->blur_xray)) { if (!buffer->texture.id || !optimized) {
pixman_region32_translate(&inverse_opaque, dst_box->x, dst_box->y); pixman_region32_translate(&inverse_opaque, dst_box->x, dst_box->y);
pixman_region32_intersect(&inverse_opaque, &inverse_opaque, &damage); pixman_region32_intersect(&inverse_opaque, &inverse_opaque, &damage);
@ -451,10 +451,10 @@ static void render_surface_iterator(struct sway_output *output,
// render blur (view->surface == surface excludes blurring subsurfaces) // render blur (view->surface == surface excludes blurring subsurfaces)
bool is_subsurface = false; // TODO: discussion here, would all cases where view is null be a non subsurface? bool is_subsurface = false; // TODO: discussion here, would all cases where view is null be a non subsurface?
bool should_optimize_blur = config->blur_xray; // TODO: for layershell bottom layer should be optimized bool should_optimize_blur = deco_data.can_blur_xray && config->blur_xray;
if (view) { if (view) {
is_subsurface = view->surface != surface; is_subsurface = view->surface != surface;
should_optimize_blur = !container_is_floating(view->container); should_optimize_blur = !container_is_floating(view->container) || config->blur_xray;
} }
if (deco_data.blur && should_parameters_blur() && !is_subsurface) { if (deco_data.blur && should_parameters_blur() && !is_subsurface) {
pixman_region32_t opaque_region; pixman_region32_t opaque_region;
@ -1446,6 +1446,7 @@ static void render_containers_linear(struct sway_output *output,
.saturation = child->saturation, .saturation = child->saturation,
.has_titlebar = has_titlebar, .has_titlebar = has_titlebar,
.blur = child->blur_enabled, .blur = child->blur_enabled,
.can_blur_xray = true,
.shadow = child->shadow_enabled, .shadow = child->shadow_enabled,
}; };
render_view(output, damage, child, colors, deco_data); render_view(output, damage, child, colors, deco_data);
@ -1496,6 +1497,7 @@ static void render_containers_tabbed(struct sway_output *output,
.saturation = current->saturation, .saturation = current->saturation,
.has_titlebar = true, .has_titlebar = true,
.blur = current->blur_enabled, .blur = current->blur_enabled,
.can_blur_xray = true,
}; };
// Render tabs // Render tabs
@ -1591,6 +1593,7 @@ static void render_containers_stacked(struct sway_output *output,
? 0 : current->corner_radius, ? 0 : current->corner_radius,
.has_titlebar = true, .has_titlebar = true,
.blur = current->blur_enabled, .blur = current->blur_enabled,
.can_blur_xray = true,
}; };
// Render titles // Render titles
@ -1738,6 +1741,7 @@ static void render_floating_container(struct sway_output *soutput,
.corner_radius = con->corner_radius, .corner_radius = con->corner_radius,
.has_titlebar = has_titlebar, .has_titlebar = has_titlebar,
.blur = con->blur_enabled, .blur = con->blur_enabled,
.can_blur_xray = true,
.shadow = con->shadow_enabled, .shadow = con->shadow_enabled,
}; };
render_view(soutput, damage, con, colors, deco_data); render_view(soutput, damage, con, colors, deco_data);
@ -1855,7 +1859,9 @@ static struct workspace_effect_info get_workspace_effect_info(struct sway_output
if (layer_effects->deco_data.blur && !lsurface->layer_surface->surface->opaque) { if (layer_effects->deco_data.blur && !lsurface->layer_surface->surface->opaque) {
effect_info.container_wants_blur = true; effect_info.container_wants_blur = true;
// Check if we should render optimized blur // Check if we should render optimized blur
if (renderer->blur_buffer_dirty && config->blur_xray) { if (renderer->blur_buffer_dirty && config->blur_xray
&& lsurface->layer != ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND
&& lsurface->layer != ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM) {
effect_info.should_render_optimized_blur = true; effect_info.should_render_optimized_blur = true;
} }
} }
@ -2079,6 +2085,7 @@ void output_render(struct sway_output *output, struct timespec *when,
.saturation = focus->saturation, .saturation = focus->saturation,
.has_titlebar = false, .has_titlebar = false,
.blur = false, .blur = false,
.can_blur_xray = false,
.shadow = false, .shadow = false,
}; };
render_view_popups(focus->view, output, damage, deco_data); render_view_popups(focus->view, output, damage, deco_data);

View file

@ -74,8 +74,8 @@ The following commands may only be used in the configuration file.
*layer_effects* <layer-namespace> <effects> *layer_effects* <layer-namespace> <effects>
Apply effects on specific layer shell surfaces, eg waybar or rofi. Apply effects on specific layer shell surfaces, eg waybar or rofi.
At least one effect needs to be provided. The <layer-namespace> can be At least one effect needs to be provided. The <layer-namespace> can be
gotten through *sway-ipc*. Note: only surfaces in the _top_ and _overlay_ gotten through *sway-ipc*. Note: Surfaces in the _bottom_ layer cannot
layers can use these effects. use these effects.
Effects: Effects:
- *blur* <enable|disable> - *blur* <enable|disable>