From 55cedc24fa6763be9f0c1d3e332c870cdb43c828 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 16 Feb 2026 08:45:38 +0000 Subject: [PATCH] Format layout change string once per window in control notify, from Conor Taylor in GitHub issue 4848. --- control-notify.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/control-notify.c b/control-notify.c index 30f94194..ba6a8355 100644 --- a/control-notify.c +++ b/control-notify.c @@ -51,29 +51,24 @@ control_notify_window_layout_changed(struct window *w) template = "%layout-change #{window_id} #{window_layout} " "#{window_visible_layout} #{window_raw_flags}"; + /* + * When the last pane in a window is closed it won't have a layout root + * and we don't need to inform the client about the layout change + * because the whole window will go away soon. + */ + wl = TAILQ_FIRST(&w->winlinks); + if (wl == NULL || w->layout_root == NULL) + return; + cp = format_single(NULL, template, NULL, NULL, wl, NULL); + TAILQ_FOREACH(c, &clients, entry) { if (!CONTROL_SHOULD_NOTIFY_CLIENT(c) || c->session == NULL) continue; s = c->session; - - if (winlink_find_by_window_id(&s->windows, w->id) == NULL) - continue; - - /* - * When the last pane in a window is closed it won't have a - * layout root and we don't need to inform the client about the - * layout change because the whole window will go away soon. - */ - if (w->layout_root == NULL) - continue; - - wl = winlink_find_by_window(&s->windows, w); - if (wl != NULL) { - cp = format_single(NULL, template, c, NULL, wl, NULL); + if (winlink_find_by_window_id(&s->windows, w->id) != NULL) control_write(c, "%s", cp); - free(cp); - } } + free(cp); } void