From 9b406d8d33ad1d4635bd489e0b83728aab11a2f5 Mon Sep 17 00:00:00 2001 From: Raphael Robatsch Date: Sat, 6 Nov 2021 19:51:17 +0100 Subject: [PATCH] Layer shell: Prevent infinte configure/commit loop Check the wlr_layer_surface_v1_state.committed bitmask to see if we need to rearrange. This is also what sway does. Without this check, every commit request (even if only the attached buffer changed) will lead to another configure event, which will lead to another commit, etc. This loop results in swaybg consuming 100% CPU. --- dwl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dwl.c b/dwl.c index 6303c25..b4b3cea 100644 --- a/dwl.c +++ b/dwl.c @@ -150,6 +150,7 @@ typedef struct { struct wlr_box geo; enum zwlr_layer_shell_v1_layer layer; + bool mapped; } LayerSurface; typedef struct { @@ -755,6 +756,12 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data) struct wlr_output *wlr_output = wlr_layer_surface->output; Monitor *m; + if (wlr_layer_surface->current.committed == 0 && + layersurface->mapped == wlr_layer_surface->mapped) + return; + + layersurface->mapped = wlr_layer_surface->mapped; + if (!wlr_output) return;