From 3ae38eb5bfc277bd13e91d2d8ff332d0c3ebc367 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 10 Jan 2022 18:13:42 -0700 Subject: [PATCH] mux: synthesize PaletteChanged event when config is reloaded This is slightly misusing or misattributing things, but in the context of the problem at hand, it is OK. The issue is that palette changes are normally signalled by the terminal instance in response to escape sequences. Those changes are propagated to the mux client through the existing alerting channel. If the palette is changed implicitly via a config change, then the terminal doesn't trigger that alert and the mux client(s) don't know that they need to refresh the palette. This commit tracks the last config generation per pane and synthesizes a palette alert when it changes. It might be better to have another variant of alert to indicate config changes. refs: #1526 --- wezterm-mux-server-impl/src/sessionhandler.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/wezterm-mux-server-impl/src/sessionhandler.rs b/wezterm-mux-server-impl/src/sessionhandler.rs index 88080c382..c4385576b 100644 --- a/wezterm-mux-server-impl/src/sessionhandler.rs +++ b/wezterm-mux-server-impl/src/sessionhandler.rs @@ -45,6 +45,7 @@ pub(crate) struct PerPane { mouse_grabbed: bool, sent_initial_palette: bool, seqno: SequenceNo, + config_generation: usize, pub(crate) notifications: Vec, } @@ -151,6 +152,18 @@ fn maybe_push_pane_changes( serial: 0, })?; } + + let config = config::configuration(); + if per_pane.config_generation != config.generation() { + per_pane.config_generation = config.generation(); + // If the config changed, it may have changed colors + // in the palette that we need to push down, so we + // synthesize a palette change notification to let + // the client know + per_pane.notifications.push(Alert::PaletteChanged); + per_pane.sent_initial_palette = true; + } + if !per_pane.sent_initial_palette { per_pane.notifications.push(Alert::PaletteChanged); per_pane.sent_initial_palette = true;