From 9e2ac25fd93188bef9087e9110b5244d2910aeb0 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Fri, 19 Mar 2021 10:47:29 +0100 Subject: [PATCH] layer-shell: don't arrange layers on each surface commit Only arrange layer surfaces if a surface has updated its layer-shell configuration. References: https://github.com/swaywm/wlroots/pull/2794 --- sway/desktop/layer_shell.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sway/desktop/layer_shell.c b/sway/desktop/layer_shell.c index c5b6d19ca..6f2f4b9ad 100644 --- a/sway/desktop/layer_shell.c +++ b/sway/desktop/layer_shell.c @@ -289,13 +289,16 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) { return; } - struct sway_output *output = wlr_output->data; - struct wlr_box old_geo = layer->geo; - arrange_layers(output); + bool geo_changed = false, layer_changed = false; + if (layer_surface->current.committed != 0) { + struct sway_output *output = wlr_output->data; + struct wlr_box old_geo = layer->geo; + arrange_layers(output); + + geo_changed = memcmp(&old_geo, &layer->geo, sizeof(struct wlr_box)) != 0; + layer_changed = layer->layer != layer_surface->current.layer; + } - bool geo_changed = - memcmp(&old_geo, &layer->geo, sizeof(struct wlr_box)) != 0; - bool layer_changed = layer->layer != layer_surface->current.layer; if (layer_changed) { wl_list_remove(&layer->link); wl_list_insert(&output->layers[layer_surface->current.layer],