Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

layer-shell: remove unused surface list #2309

Merged
merged 1 commit into from
Jul 7, 2020

Conversation

ifreund
Copy link
Member

@ifreund ifreund commented Jun 30, 2020

This was rendered useless in 5cde359.


Breaking change: wlr_layer_shell_v1.surfaces has been removed.

This was rendered useless in 5cde359.
@emersion emersion added the breaking Breaking change in public API label Jun 30, 2020
@emersion
Copy link
Member

This is a breaking change, e.g. Sway uses it:

sway/desktop/output.c
438:	wl_list_for_each(wlr_layer_surface_v1, &server.layer_shell->surfaces, link) {

@ifreund
Copy link
Member Author

ifreund commented Jun 30, 2020

Didn't realize that this is in use by sway, but sway also stores its own lists of layer surfaces per output so this is duplicated state. This loop should be written as

diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 2a2e332a..19b6df84 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -434,18 +434,9 @@ struct sway_workspace *output_get_active_workspace(struct sway_output *output) {
 }

 bool output_has_opaque_overlay_layer_surface(struct sway_output *output) {
-       struct wlr_layer_surface_v1 *wlr_layer_surface_v1;
-       wl_list_for_each(wlr_layer_surface_v1, &server.layer_shell->surfaces, link) {
-               if (wlr_layer_surface_v1->output != output->wlr_output ||
-                               wlr_layer_surface_v1->current.layer != ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY) {
-                       continue;
-               }
-               struct wlr_surface *wlr_surface = wlr_layer_surface_v1->surface;
-               struct sway_layer_surface *sway_layer_surface =
-                       layer_from_wlr_layer_surface_v1(wlr_layer_surface_v1);
-               if (sway_layer_surface == NULL) {
-                       continue;
-               }
+       struct sway_layer_surface *sway_layer_surface;
+       wl_list_for_each(sway_layer_surface, &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY], link) {
+               struct wlr_surface *wlr_surface = sway_layer_surface->layer_surface->surface;
                pixman_box32_t output_box = {
                        .x2 = output->width,
                        .y2 = output->height,

Would be happy to send this patch to sway if you like.

@emersion
Copy link
Member

Would be happy to send this patch to sway if you like.

Oh yeah you're right! Please do :)

Copy link
Member

@emersion emersion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this list isn't used by other wlroots compositors after a quick look.

LGTM, thanks!

@emersion emersion merged commit 92c8585 into swaywm:master Jul 7, 2020
@ifreund ifreund deleted the layer-shell-cleanup branch July 7, 2020 10:46
@emersion emersion added this to the 0.11.0 milestone Jul 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking Breaking change in public API
Development

Successfully merging this pull request may close these issues.

2 participants