diff options
author | William McKinnon <[email protected]> | 2023-09-06 00:32:08 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2023-09-06 00:32:08 -0400 |
commit | 6f6991a1b38b03e87fd3f73607ca2393ae62cfea (patch) | |
tree | fcb05d87a897f167f57142877aa7e2003d32bf82 /sway/tree/workspace.c | |
parent | 13eeea5ed5f569eb8a9af329af8a7f6b4b0b114e (diff) |
refactor: simplify blur (#219)
* refactor: removed surface_width + surface_height from render_blur()
* Fixed scaling issues
* Minor refactors
* removed scaled_dst box
* removed uneeded fb bind
* removed unneeded src_box
* removed unneeded wlr_fbox_from_box function
* removed src_box
* Don't scale the blur translucent region twice
* Renamed extended_damage to original_damage to reflect better what it actually is
* Removed unneeded clearing of the wlr fbo before rendering onto it
* Removed the need for our own main FBO, also fixes some damage bugs
* Simplified detection of blur on workspace
* cleaned up comments
---------
Co-authored-by: Erik Reider <[email protected]>
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r-- | sway/tree/workspace.c | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 8bc62f3f..7e7146dd 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c @@ -692,24 +692,39 @@ void workspace_detect_urgent(struct sway_workspace *workspace) { } } -static bool find_blurred_con_iterator(struct sway_container *con, void *data) { +struct blur_region_data { + struct sway_workspace *ws; + pixman_region32_t *blur_region; +}; + +static void find_blurred_region_iterator(struct sway_container *con, void *data) { struct sway_view *view = con->view; if (!view) { - return false; + return; + } + + struct blur_region_data *region_data = data; + struct sway_workspace *ws = region_data->ws; + pixman_region32_t *blur_region = region_data->blur_region; + + if (con->blur_enabled && !view->surface->opaque) { + pixman_region32_union_rect(blur_region, blur_region, + floor(con->current.x) - ws->output->lx, + floor(con->current.y) - ws->output->ly, + con->current.width, con->current.height); } - return con->blur_enabled && !view->surface->opaque; } -bool should_workspace_have_blur(struct sway_workspace *ws) { - if (!workspace_is_visible(ws)) { +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; } - if ((bool)workspace_find_container(ws, find_blurred_con_iterator, NULL)) { - return true; - } + // Each toplevel + struct blur_region_data data = { ws, blur_region }; + workspace_for_each_container(ws, find_blurred_region_iterator, &data); - // Check if any layer-shell surfaces will render effects + // Each Layer 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) { @@ -717,12 +732,14 @@ bool should_workspace_have_blur(struct sway_workspace *ws) { 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; + struct wlr_box *geo = &lsurface->geo; + pixman_region32_union_rect(blur_region, blur_region, + geo->x, geo->y, geo->width, geo->height); } } } - return false; + return pixman_region32_not_empty(blur_region); } void workspace_for_each_container(struct sway_workspace *ws, |