A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
feat(gui): set the window's opacity in Settings and see through the chrome
RoversX6f5996f47b35
diff --git a/config/src/lib.rs b/config/src/lib.rsindex 7ea3c75d..418e33d7 100644--- a/config/src/lib.rs+++ b/config/src/lib.rs@@ -942,6 +942,18 @@ impl ConfigHandle {}}+ /// This configuration with `change` made to a copy of it, under the+ /// same generation: for what a window derives from its configuration+ /// without reloading it.+ pub fn adjusted(&self, change: impl FnOnce(&mut Config)) -> Self {+ let mut config = (*self.config).clone();+ change(&mut config);+ Self {+ config: Arc::new(config),+ generation: self.generation,+ }+ }+pub fn unicode_version(&self) -> UnicodeVersion {UnicodeVersion {version: self.config.unicode_version,@@ -977,6 +989,21 @@ fn default_true() -> bool {true}+#[cfg(test)]+mod config_handle_tests {+ use super::*;++ #[test]+ fn an_adjusted_handle_changes_only_its_own_copy() {+ let handle = ConfigHandle::default_config();+ let adjusted = handle.adjusted(|config| config.window_background_opacity = 0.5);+ assert_eq!(adjusted.window_background_opacity, 0.5);+ assert_eq!(handle.window_background_opacity, 1.0);+ // Nothing keyed on the generation is told to rebuild.+ assert_eq!(adjusted.generation(), handle.generation());+ }+}+#[cfg(test)]mod runtime_file_name_tests {use super::scoped_runtime_file_name;diff --git a/thinkterm-i18n/i18n/de-DE.ftl b/thinkterm-i18n/i18n/de-DE.ftlindex bd41338d..f4f52f83 100644--- a/thinkterm-i18n/i18n/de-DE.ftl+++ b/thinkterm-i18n/i18n/de-DE.ftl@@ -82,6 +82,13 @@ settings-appearance-theme-heading = Designsettings-app-icon = App-Symbolsettings-app-icon-description = Wechselt das laufende Symbol im Dock und im App-Umschalter.settings-app-icon-note = Funktioniert derzeit nur unter macOS.+settings-appearance-window-heading = Fenster+settings-window-opacity = Fensterdeckkraft+settings-window-opacity-description = Zum Einstellen ziehen, ganz rechts ist deckend. Seitenleisten und Tabs bleiben etwas deckender.+settings-window-opacity-default = Standard+settings-window-opacity-reset = Zurücksetzen+settings-window-opacity-linux = Unter Linux noch nicht verfügbar.+settings-badge-beta = Betasettings-app-icon-simple = Schlichtsettings-app-icon-classic = Klassischsettings-effective-color-scheme = Aktives Farbschemadiff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftlindex 136e598d..e92bdaa2 100644--- a/thinkterm-i18n/i18n/en-US.ftl+++ b/thinkterm-i18n/i18n/en-US.ftl@@ -82,6 +82,13 @@ settings-appearance-theme-heading = Themesettings-app-icon = App Iconsettings-app-icon-description = Switch the running Dock and app switcher icon.settings-app-icon-note = Currently only works on macOS.+settings-appearance-window-heading = Window+settings-window-opacity = Window Opacity+settings-window-opacity-description = Drag to adjust; all the way right is opaque. The sidebars and tab bar stay a little more solid.+settings-window-opacity-default = Default+settings-window-opacity-reset = Reset to Default+settings-window-opacity-linux = Not available on Linux yet.+settings-badge-beta = Betasettings-app-icon-simple = Simplesettings-app-icon-classic = Classicsettings-effective-color-scheme = Effective Color Schemediff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftlindex d6e9b9eb..7122363f 100644--- a/thinkterm-i18n/i18n/fr-FR.ftl+++ b/thinkterm-i18n/i18n/fr-FR.ftl@@ -82,6 +82,13 @@ settings-appearance-theme-heading = Thèmesettings-app-icon = Icône de l’applicationsettings-app-icon-description = Changer l’icône affichée dans le Dock et le sélecteur d’applications.settings-app-icon-note = Fonctionne actuellement uniquement sur macOS.+settings-appearance-window-heading = Fenêtre+settings-window-opacity = Opacité de la fenêtre+settings-window-opacity-description = Faites glisser ; tout à droite est opaque. Barres latérales et onglets restent un peu plus opaques.+settings-window-opacity-default = Par défaut+settings-window-opacity-reset = Rétablir+settings-window-opacity-linux = Pas encore disponible sous Linux.+settings-badge-beta = Bêtasettings-app-icon-simple = Simplesettings-app-icon-classic = Classiquesettings-effective-color-scheme = Jeu de couleurs actifdiff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftlindex 6b60a1d6..9d7bbcb0 100644--- a/thinkterm-i18n/i18n/ja-JP.ftl+++ b/thinkterm-i18n/i18n/ja-JP.ftl@@ -79,6 +79,13 @@ settings-appearance-theme-heading = テーマsettings-app-icon = アプリアイコンsettings-app-icon-description = 実行中の Dock とアプリスイッチャーのアイコンを変更します。settings-app-icon-note = 現在は macOS のみ対応しています。+settings-appearance-window-heading = ウィンドウ+settings-window-opacity = ウィンドウの不透明度+settings-window-opacity-description = ドラッグで調整、右端は不透明。サイドバーとタブバーは少し濃くなります。+settings-window-opacity-default = デフォルト+settings-window-opacity-reset = デフォルトに戻す+settings-window-opacity-linux = Linux では未対応です。+settings-badge-beta = ベータsettings-app-icon-simple = シンプルsettings-app-icon-classic = クラシックsettings-effective-color-scheme = 有効なカラースキームdiff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftlindex 1e0d624a..93c91fe7 100644--- a/thinkterm-i18n/i18n/zh-CN.ftl+++ b/thinkterm-i18n/i18n/zh-CN.ftl@@ -79,6 +79,13 @@ settings-appearance-theme-heading = 主题settings-app-icon = 应用图标settings-app-icon-description = 更改当前程序坞和应用切换器中的图标。settings-app-icon-note = 目前仅支持 macOS。+settings-appearance-window-heading = 窗口+settings-window-opacity = 窗口透明度+settings-window-opacity-description = 拖动调整,最右边是不透明;侧栏和标签条会更实一些。+settings-window-opacity-default = 默认+settings-window-opacity-reset = 恢复默认+settings-window-opacity-linux = Linux 暂时不支持。+settings-badge-beta = Betasettings-app-icon-simple = 简约settings-app-icon-classic = 经典settings-effective-color-scheme = 当前配色方案diff --git a/thinkterm-render/src/quad.rs b/thinkterm-render/src/quad.rsindex fe0f09c5..a23dc314 100644--- a/thinkterm-render/src/quad.rs+++ b/thinkterm-render/src/quad.rs@@ -887,21 +887,37 @@ impl HeapQuadAllocator {/// Remove covered pixels before a recorded surface is faded. Merely fading/// an opaque cover and the glyph beneath it separately reveals the glyph.+ /// Also what a see-through panel's scroll masks do instead of covering:+ /// a cover there would show as a darker band.////// The scratch rectangles are reused for all quads; unchanged quads move- /// without cloning. Axis-aligned mask edges partition a quad into at most+ /// without cloning, and those before the first one a mask touches do not+ /// move at all. Axis-aligned mask edges partition a quad into at most/// (2*n + 1)^2 cells, so overlapping masks cannot cause exponential growth.- /// Callers bound n (recording masks allow 64 per pane) and run this only- /// while rebuilding a cache or capturing a transition, never on replay.+ /// Callers bound n: recording masks allow 64 per pane, a panel's scroll+ /// masks are two or three.pub fn occlude(&mut self, masks: &[QuadClipRect]) {if masks.is_empty() {return;}+ let touches = |quad: &BoxedQuad| {+ let (left, top, right, bottom) = quad.position;+ masks.iter().any(|mask| {+ left.max(mask.left) < right.min(mask.right)+ && top.max(mask.top) < bottom.min(mask.bottom)+ })+ };let mut visible = Vec::new();let mut next = Vec::new();for layer in [&mut self.layer0, &mut self.layer1, &mut self.layer2] {- let mut output = Vec::with_capacity(layer.len());- for quad in layer.drain(..) {+ // Most of a surface lies clear of the masks: everything before+ // the first quad one touches stays where it is, unmoved.+ let Some(first) = layer.iter().position(|quad| touches(quad)) else {+ continue;+ };+ let rest: Vec<BoxedQuad> = layer.drain(first..).collect();+ let mut output = std::mem::take(layer);+ for quad in rest {let (left, top, right, bottom) = quad.position;let original = QuadClipRect {left,@@ -952,6 +968,27 @@ impl HeapQuadAllocator {}}+ /// Crop what was recorded from `mark` on to `clip`, in place; quads+ /// wholly outside it are dropped. For a stretch that scrolls under chrome+ /// it may not be covered by, as in a see-through window.+ pub fn clip_after(&mut self, mark: &HeapQuadMark, clip: QuadClipRect) {+ for (layer_num, layer) in [+ (0, &mut self.layer0),+ (1, &mut self.layer1),+ (2, &mut self.layer2),+ ] {+ let begin = Self::layer_bounds(mark, layer_num).min(layer.len());+ let mut kept = begin;+ for index in begin..layer.len() {+ if let Some(clipped) = layer[index].translated_clipped(0.0, 0.0, clip) {+ layer[kept] = clipped;+ kept += 1;+ }+ }+ layer.truncate(kept);+ }+ }+pub fn quad_count(&self) -> usize {self.layers().iter().map(|(_, quads)| quads.len()).sum()}@@ -1778,4 +1815,43 @@ mod recording_occlusion_tests {assert_eq!(area, 80.0 * 60.0);assert_eq!(heap.quad_count(), 4);}++ #[test]+ fn occlusion_keeps_the_recorded_order_around_what_it_cuts() {+ // Later quads draw over earlier ones in a layer: a cut piece moved+ // to the end would land on top of what came after it.+ let mut heap = HeapQuadAllocator::default();+ for x in [0.0, 100.0, 200.0] {+ heap.allocate(1)+ .unwrap()+ .set_position(x, 0.0, x + 50.0, 50.0);+ }+ heap.occlude(&[rect(100.0, 0.0, 150.0, 25.0)]);+ let lefts: Vec<f32> = heap.layer1.iter().map(|q| q.position.0).collect();+ assert_eq!(lefts, vec![0.0, 100.0, 200.0]);+ assert_eq!(heap.layer1[1].position, (100.0, 25.0, 150.0, 50.0));+ }++ #[test]+ fn clipping_after_a_mark_leaves_what_came_before_whole() {+ let mut heap = HeapQuadAllocator::default();+ heap.allocate(0)+ .unwrap()+ .set_position(0.0, 0.0, 100.0, 100.0);+ let mark = heap.mark();+ for top in [-20.0, 40.0, 120.0] {+ heap.allocate(0)+ .unwrap()+ .set_position(0.0, top, 100.0, top + 30.0);+ }+ heap.clip_after(&mark, rect(0.0, 0.0, 100.0, 100.0));+ let tops: Vec<(f32, f32)> = heap+ .layer0+ .iter()+ .map(|q| (q.position.1, q.position.3))+ .collect();+ // The ground is untouched, the row above is cut at the top, the row+ // below is gone.+ assert_eq!(tops, vec![(0.0, 100.0), (0.0, 10.0), (40.0, 70.0)]);+ }}diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rsindex 21e5ded2..594fcb03 100644--- a/wezterm-gui/src/native_settings.rs+++ b/wezterm-gui/src/native_settings.rs@@ -335,6 +335,183 @@ pub(crate) struct NativeAppearanceSettings {/// Color scheme picked in the command palette; overrides the config's/// `color_scheme` for every window. `None` follows the configuration.pub(crate) color_scheme: Option<String>,+ /// The window's opacity in percent, over the configuration's+ /// `window_background_opacity`. `None` follows the configuration.+ #[serde(deserialize_with = "window_opacity_or_default")]+ pub(crate) window_opacity: Option<u8>,+}++/// The window opacity, whatever shape a hand edit gave it. One field that+/// fails to parse loses the whole file to the defaults, and the next save+/// writes them over everything, so: a fraction such as 0.8 is read as 80, a+/// percentage out of range is brought into it, and anything else is no+/// setting at all.+fn window_opacity_or_default<'de, D>(deserializer: D) -> Result<Option<u8>, D::Error>+where+ D: serde::Deserializer<'de>,+{+ let raw = serde_json::Value::deserialize(deserializer)?;+ Ok(match raw.as_f64() {+ Some(number) if number.is_finite() => {+ let percent = if number > 0.0 && number <= 1.0 {+ number * 100.0+ } else {+ number+ };+ Some(+ percent+ .round()+ .clamp(f64::from(WINDOW_OPACITY_LEAST), 100.0) as u8,+ )+ }+ _ => {+ if !raw.is_null() {+ log::warn!(+ "unknown window_opacity {raw} in the settings; following the configuration"+ );+ }+ None+ }+ })+}++/// The least window opacity Settings offers, in percent, and the step of its+/// slider. Below the least the terminal's text is hard to read.+pub(crate) const WINDOW_OPACITY_LEAST: u8 = 30;+pub(crate) const WINDOW_OPACITY_STEP: u8 = 5;++/// Whether Settings can make the window see-through here, with what is+/// behind it blurred. Linux has no blur most desktops offer, so the slider+/// is not offered there; the configuration still is.+pub(crate) fn window_opacity_supported() -> bool {+ cfg!(any(target_os = "macos", windows))+}++/// The blur behind a window Settings made see-through, unless the+/// configuration names one: see-through alone shows the desktop sharp behind+/// the text, and what the setting is for is the frosted kind.+const WINDOW_BLUR_RADIUS: i64 = 20;++/// The configuration keys the window-opacity setting overrides, and with+/// what. `None` removes a key, so that the configuration decides again.+pub(crate) fn window_opacity_overrides(+ settings: &ThinkTermNativeSettings,+) -> [(&'static str, Option<wezterm_dynamic::Value>); 3] {+ use wezterm_dynamic::ToDynamic;+ let changes = window_opacity_changes(settings.appearance.window_opacity);+ let [opacity, blur, backdrop] = WINDOW_OPACITY_KEYS;+ [+ (opacity, changes.opacity.map(|opacity| opacity.to_dynamic())),+ (blur, changes.blur.map(|blur| blur.to_dynamic())),+ (+ backdrop,+ changes.backdrop.map(|backdrop| backdrop.to_dynamic()),+ ),+ ]+}++/// The configuration keys Settings' window opacity overrides in a window.+pub(crate) const WINDOW_OPACITY_KEYS: [&str; 3] = [+ "window_background_opacity",+ "macos_window_background_blur",+ "win32_system_backdrop",+];++/// What a window opacity of `percent` changes in a window's configuration:+/// the opacity, and while it is see-through the blur or backdrop the+/// configuration file does not ask for itself. `None` changes nothing.+struct WindowOpacityChanges {+ opacity: Option<f64>,+ blur: Option<i64>,+ backdrop: Option<config::SystemBackdrop>,+}++fn window_opacity_changes(percent: Option<u8>) -> WindowOpacityChanges {+ let opacity = percent+ .filter(|_| window_opacity_supported())+ .map(|percent| f64::from(percent.clamp(WINDOW_OPACITY_LEAST, 100)) / 100.0);+ let see_through = opacity.is_some_and(|opacity| opacity < 1.0);+ let config = config::configuration();+ WindowOpacityChanges {+ opacity,+ blur: (see_through+ && cfg!(target_os = "macos")+ && config.macos_window_background_blur == 0)+ .then_some(WINDOW_BLUR_RADIUS),+ // Acrylic is the backdrop Windows 10 and 11 both have.+ backdrop: (see_through+ && cfg!(windows)+ && config.win32_system_backdrop == config::SystemBackdrop::Auto)+ .then_some(config::SystemBackdrop::Acrylic),+ }+}++/// What `window_opacity_overrides` for a window opacity of `percent` leaves+/// in a window's configuration -- its opacity, blur and backdrop -- without+/// the reload applying them takes. What the slider previews while dragged.+pub(crate) fn window_opacity_preview(percent: u8) -> (f32, i64, config::SystemBackdrop) {+ let changes = window_opacity_changes(Some(percent));+ let file = config::configuration();+ (+ changes+ .opacity+ .map_or(file.window_background_opacity, |opacity| opacity as f32),+ changes.blur.unwrap_or(file.macos_window_background_blur),+ changes.backdrop.unwrap_or(file.win32_system_backdrop),+ )+}++/// Every configuration key Settings overrides in a window -- the colour+/// scheme, the window's opacity and what goes with it -- and with what.+/// `None` removes a key. New windows seed their overrides from this and open+/// ones are brought to it, so both always agree.+pub(crate) fn settings_config_overrides(+ settings: &ThinkTermNativeSettings,+ config: &ConfigHandle,+) -> Vec<(&'static str, Option<wezterm_dynamic::Value>)> {+ use wezterm_dynamic::ToDynamic;+ let scheme = effective_color_scheme(settings, config);+ let mut overrides = vec![("color_scheme", scheme.map(|scheme| scheme.to_dynamic()))];+ overrides.extend(window_opacity_overrides(settings));+ overrides+}++/// Bring every window to the window opacity `settings` asks for: all a+/// change of it needs of `apply_to_app`. A window still showing a preview+/// goes back to what it loaded, since applying reloads only a window whose+/// overrides changed.+pub(crate) fn apply_window_opacity_to_app(settings: &ThinkTermNativeSettings) {+ let overrides = window_opacity_overrides(settings).to_vec();+ if let Some(front_end) = crate::frontend::try_front_end() {+ for gui_window in front_end.gui_windows() {+ let overrides = overrides.clone();+ gui_window+ .window+ .notify(crate::termwindow::TermWindowNotif::Apply(Box::new(+ move |term_window| {+ term_window.apply_settings_overrides(&overrides);+ term_window.preview_window_opacity(None);+ },+ )));+ }+ }+}++/// Show a window opacity of `percent` in every window, without saving it:+/// the Settings slider calls this while it is dragged. `None` ends the+/// preview, each window going back to its configuration as loaded.+pub(crate) fn preview_window_opacity(percent: Option<u8>) {+ if let Some(front_end) = crate::frontend::try_front_end() {+ for gui_window in front_end.gui_windows() {+ gui_window+ .window+ .notify(crate::termwindow::TermWindowNotif::Apply(Box::new(+ move |term_window| {+ term_window.preview_window_opacity(percent);+ },+ )));+ }+ }}fn default_true() -> bool {@@ -1168,8 +1345,9 @@ fn apply_external_change(before: &ThinkTermNativeSettings, after: &ThinkTermNati|| before.appearance.theme_mode != after.appearance.theme_mode|| before.appearance.app_icon != after.appearance.app_icon|| before.appearance.color_scheme != after.appearance.color_scheme+ || before.appearance.window_opacity != after.appearance.window_opacity{- // Language, theme, colour scheme, chrome and app icon.+ // Language, theme, colour scheme, opacity, chrome and app icon.apply_to_app(after);}crate::settings_window::follow_open_settings_window(before, after);@@ -1582,15 +1760,16 @@ pub(crate) fn apply_to_app(settings: &ThinkTermNativeSettings) {// it, not just repainted. Applying a scheme the window already has is a// no-op, so the common case -- a mode change that does not move the// default -- costs nothing.- let scheme = effective_color_scheme(settings, &config::configuration());+ // All at once, so a window reloads its configuration once for them.+ let overrides = settings_config_overrides(settings, &config::configuration());if let Some(front_end) = crate::frontend::try_front_end() {for gui_window in front_end.gui_windows() {- let scheme = scheme.clone();+ let overrides = overrides.clone();gui_window.window.notify(crate::termwindow::TermWindowNotif::Apply(Box::new(move |term_window| {- term_window.apply_color_scheme_override(scheme);+ term_window.apply_settings_overrides(&overrides);term_window.refresh_chrome();},)));@@ -1924,6 +2103,58 @@ pub(crate) fn main_window_renderer(mod tests {use super::*;+ #[test]+ fn a_hand_edited_window_opacity_never_costs_the_file() {+ for (written, read) in [+ ("80", Some(80)),+ ("0.8", Some(80)),+ ("150", Some(100)),+ ("5", Some(WINDOW_OPACITY_LEAST)),+ ("\"half\"", None),+ ("null", None),+ ] {+ let json =+ format!(r#"{{"appearance":{{"theme_mode":"dark","window_opacity":{written}}}}}"#);+ let settings: ThinkTermNativeSettings = serde_json::from_str(&json).unwrap();+ assert_eq!(settings.appearance.window_opacity, read, "{written}");+ // The rest of the file still counts.+ assert_eq!(+ settings.appearance.theme_mode,+ NativeThemeMode::Dark,+ "{written}"+ );+ }+ }++ #[test]+ fn window_opacity_overrides_the_opacity_and_asks_for_a_blur() {+ use wezterm_dynamic::ToDynamic;+ let mut settings = ThinkTermNativeSettings::default();+ let [opacity, blur, backdrop] = window_opacity_overrides(&settings);+ assert_eq!(opacity, ("window_background_opacity", None));+ assert_eq!(blur, ("macos_window_background_blur", None));+ assert_eq!(backdrop, ("win32_system_backdrop", None));+ settings.appearance.window_opacity = Some(80);+ let [opacity, blur, backdrop] = window_opacity_overrides(&settings);+ if window_opacity_supported() {+ assert_eq!(opacity.1, Some(0.8f64.to_dynamic()));+ } else {+ assert_eq!(opacity.1, None);+ }+ assert_eq!(blur.1.is_some(), cfg!(target_os = "macos"));+ assert_eq!(backdrop.1.is_some(), cfg!(windows));+ // Below the least is the least; opaque needs no blur.+ settings.appearance.window_opacity = Some(5);+ let [opacity, ..] = window_opacity_overrides(&settings);+ if window_opacity_supported() {+ assert_eq!(opacity.1, Some(0.3f64.to_dynamic()));+ }+ settings.appearance.window_opacity = Some(100);+ let [_, blur, backdrop] = window_opacity_overrides(&settings);+ assert_eq!(blur.1, None);+ assert_eq!(backdrop.1, None);+ }+use config::UiColors;use std::convert::TryFrom;use window::Appearance;diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rsindex 1d04b139..a4a14197 100644--- a/wezterm-gui/src/settings_window.rs+++ b/wezterm-gui/src/settings_window.rs@@ -29,7 +29,7 @@ use std::rc::Rc;use std::time::{Duration, Instant, SystemTime, UNIX_EPOCH};use wezterm_bidi::Direction;use wezterm_dynamic::{ToDynamic, Value};-use wezterm_font::{FontConfiguration, LoadedFont};+use wezterm_font::{FontConfiguration, FontMetrics, LoadedFont};use window::bitmaps::atlas::OutOfTextureSpace;use window::color::LinearRgba;use window::{@@ -849,6 +849,9 @@ impl SettingsSection {"Theme Mode","Effective Color Scheme","App Icon",+ "Window Opacity",+ "Transparency",+ "Blur","Settings UI Font Size","Workspace Sidebar Font Size","Tab Bar Font Size",@@ -1030,6 +1033,10 @@ impl SettingsSection {&& crate::i18n::tr("settings-language").to_lowercase().contains(query))+ || (self == Self::Appearance+ && crate::i18n::tr("settings-window-opacity")+ .to_lowercase()+ .contains(query))}}@@ -1045,6 +1052,45 @@ mod settings_search_tests {}}+/// How often a drag of the window-opacity slider shows itself in the windows:+/// about once a frame.+const WINDOW_OPACITY_PREVIEW_INTERVAL: Duration = Duration::from_millis(16);++/// The opacity the slider's knob stands for at `x`, on a track from `left`+/// across `width`: the nearest step from the least to opaque.+fn window_opacity_at(x: f32, left: f32, width: f32) -> u8 {+ use crate::native_settings::{WINDOW_OPACITY_LEAST, WINDOW_OPACITY_STEP};+ let along = ((x - left) / width.max(1.0)).clamp(0.0, 1.0);+ let steps = f32::from((100 - WINDOW_OPACITY_LEAST) / WINDOW_OPACITY_STEP);+ WINDOW_OPACITY_LEAST + (along * steps).round() as u8 * WINDOW_OPACITY_STEP+}++#[cfg(test)]+mod window_opacity_slider_tests {+ use super::window_opacity_at;++ #[test]+ fn the_knob_lands_on_steps_from_the_least_to_opaque() {+ assert_eq!(window_opacity_at(100.0, 100.0, 140.0), 30);+ assert_eq!(window_opacity_at(240.0, 100.0, 140.0), 100);+ assert_eq!(window_opacity_at(170.0, 100.0, 140.0), 65);+ // Between steps it takes the nearer one; off the ends, the end.+ assert_eq!(window_opacity_at(104.0, 100.0, 140.0), 30);+ assert_eq!(window_opacity_at(106.0, 100.0, 140.0), 35);+ assert_eq!(window_opacity_at(-50.0, 100.0, 140.0), 30);+ assert_eq!(window_opacity_at(900.0, 100.0, 140.0), 100);+ }+}++/// How Settings names a window-opacity choice: the configuration's own, or a+/// percentage.+fn window_opacity_label(choice: Option<u8>) -> String {+ match choice {+ None => crate::i18n::tr("settings-window-opacity-default"),+ Some(percent) => format!("{percent}%"),+ }+}+/// What the expiry dropdown offers, shortest first.////// `None` last, because it is the one with no bound and reading the list in@@ -1385,6 +1431,8 @@ enum SettingsAction {ToggleLanguageMenu,SetLanguage(&'static str),SetAppIcon(NativeAppIcon),+ SetWindowOpacity(Option<u8>),+ WindowOpacitySlider,ToggleMainRendererMenu,SetMainRenderer(NativeRendererBackend),/// Swallows clicks that land in an open dropdown's padding or row@@ -1496,7 +1544,13 @@ struct TabIconEditorLayout {#[derive(Debug, Clone, Copy)]enum SettingsDrag {- SidebarResize { start_x: f32, start_width: f32 },+ SidebarResize {+ start_x: f32,+ start_width: f32,+ },+ /// The window-opacity slider's knob: previewed while it moves, saved+ /// when it is let go.+ WindowOpacity,}#[derive(Debug, Clone, Copy, PartialEq, Eq)]@@ -1964,6 +2018,11 @@ struct SettingsUiState {remote_drop_input_dirty: bool,interaction: InteractionState<SettingsAction>,drag: Option<SettingsDrag>,+ /// The window-opacity slider's track as last painted: its left edge and+ /// width, for turning the pointer's x into a value.+ window_opacity_track: Option<(f32, f32)>,+ /// When a drag of that slider last showed its value in the windows.+ window_opacity_previewed: Option<Instant>,open_dropdown: Option<SettingsDropdown>,/// The ⓘ under the pointer this frame: its i18n key and where the icon/// was painted, for the bubble the overlay pass draws.@@ -2086,6 +2145,8 @@ impl SettingsUiState {remote_drop_input_dirty: false,interaction: InteractionState::default(),drag: None,+ window_opacity_track: None,+ window_opacity_previewed: None,open_dropdown: None,hint: None,memory_monitoring: false,@@ -3196,6 +3257,11 @@ impl SettingsWindow {}self.cleaned_up = true;self.commit_focused_input();+ // Closed mid-drag: what the windows are previewing is what is kept.+ if matches!(self.ui.drag, Some(SettingsDrag::WindowOpacity)) {+ self.ui.drag = None;+ self.commit_window_opacity();+ }self.ui.memory_monitoring = false;self.ui.memory_monitor_generation = self.ui.memory_monitor_generation.wrapping_add(1);self.render_state.take();@@ -3274,6 +3340,9 @@ impl SettingsWindow {WindowEvent::MouseLeave => {self.ui.interaction.hovered = None;self.ui.interaction.pressed = None;+ if matches!(self.ui.drag, Some(SettingsDrag::WindowOpacity)) {+ self.commit_window_opacity();+ }self.ui.drag = None;window.set_cursor(Some(MouseCursor::Arrow));window.invalidate();@@ -3356,6 +3425,11 @@ impl SettingsWindow {window.invalidate();return;}+ if let Some(SettingsDrag::WindowOpacity) = self.ui.drag {+ self.drag_window_opacity(x);+ window.invalidate();+ return;+ }if self.ui.interaction.hovered != action {self.ui.interaction.hovered = action;@@ -3399,6 +3473,12 @@ impl SettingsWindow {});self.ui.open_dropdown = None;}+ Some(SettingsAction::WindowOpacitySlider) => {+ self.set_focused_input(None);+ self.ui.open_dropdown = None;+ self.ui.drag = Some(SettingsDrag::WindowOpacity);+ self.drag_window_opacity(x);+ }Some(SettingsAction::SetThemeMode(_)| SettingsAction::ToggleLanguageMenu@@ -3435,6 +3515,9 @@ impl SettingsWindow {}MouseEventKind::Release(MousePress::Left) => {let pressed = self.ui.interaction.pressed.take();+ if matches!(self.ui.drag, Some(SettingsDrag::WindowOpacity)) {+ self.commit_window_opacity();+ }self.ui.drag = None;self.ui.interaction.hovered = action;if pressed.is_some() && pressed == action {@@ -4488,6 +4571,72 @@ impl SettingsWindow {}}+ /// Move the window-opacity knob to `x` and show the result in every+ /// window, without saving it yet.+ fn drag_window_opacity(&mut self, x: f32) {+ let Some((left, width)) = self.ui.window_opacity_track else {+ return;+ };+ let percent = window_opacity_at(x, left, width);+ if self.native_settings.appearance.window_opacity == Some(percent) {+ return;+ }+ self.native_settings.appearance.window_opacity = Some(percent);+ // Each preview repaints every window, so a fast drag shows some of+ // the steps; letting go shows the last.+ let due = self+ .ui+ .window_opacity_previewed+ .is_none_or(|at| at.elapsed() >= WINDOW_OPACITY_PREVIEW_INTERVAL);+ if due {+ self.ui.window_opacity_previewed = Some(Instant::now());+ crate::native_settings::preview_window_opacity(Some(percent));+ }+ }++ fn commit_window_opacity(&mut self) {+ self.ui.window_opacity_previewed = None;+ let opacity = self.native_settings.appearance.window_opacity;+ // Let go where it started: nothing to save, only a preview to end.+ if crate::native_settings::load().appearance.window_opacity == opacity {+ crate::native_settings::preview_window_opacity(None);+ return;+ }+ self.apply_window_opacity(opacity);+ }++ fn apply_window_opacity(&mut self, opacity: Option<u8>) {+ self.ui.open_dropdown = None;+ // Merged into the freshest settings, as `apply_text_contrast` does:+ // this window's copy can be older than what other windows saved.+ let mut merged = crate::native_settings::load();+ merged.appearance.window_opacity = opacity;+ self.set_native_settings(merged);+ let setting = crate::i18n::tr("settings-window-opacity");+ match crate::native_settings::save(&self.native_settings) {+ Ok(()) => {+ crate::native_settings::apply_window_opacity_to_app(&self.native_settings);+ self.status = settings_tr(+ "settings-status-value-now",+ &[+ ("setting", setting),+ ("value", window_opacity_label(opacity)),+ ],+ );+ }+ Err(err) => {+ // Not kept: the slider and the windows go back to the+ // opacity that is.+ self.set_native_settings(crate::native_settings::load());+ crate::native_settings::preview_window_opacity(None);+ self.status = settings_tr(+ "settings-status-save-error",+ &[("setting", setting), ("error", format!("{err:#}"))],+ );+ }+ }+ }+fn apply_scroll_mode(&mut self, mode: crate::native_settings::NativeScrollMode) {self.ui.open_dropdown = None;self.native_settings.terminal.scroll_mode = mode;@@ -5340,6 +5489,9 @@ impl SettingsWindow {}}SettingsAction::SetScrollMode(mode) => self.apply_scroll_mode(mode),+ SettingsAction::SetWindowOpacity(opacity) => self.apply_window_opacity(opacity),+ // Handled as a drag, on press and release.+ SettingsAction::WindowOpacitySlider => {}SettingsAction::SetTextContrast(mode) => self.apply_text_contrast(mode),SettingsAction::SetRemotePaneResizeMode(mode) => {self.apply_remote_pane_resize_mode(mode)@@ -7628,6 +7780,27 @@ impl SettingsWindow {this.paint_typography_rows(layers, row_x, top, row_width)})?;+ let card_y = self.paint_card_heading(+ layers,+ x,+ bottom,+ max_width,+ &crate::i18n::tr("settings-appearance-window-heading"),+ )?;+ let bottom = self.paint_card(layers, x, card_y, max_width, |this, layers, top| {+ let mut rows = RowCursor::new(top, this);+ let (tx, tw) = this.paint_row_tile(+ layers,+ row_x,+ rows.y,+ row_width,+ SvgIcon::Contrast,+ TileColor::Blue,+ )?;+ rows.add(this.paint_window_opacity_row(layers, tx, rows.y, tw, rows.rule())?);+ Ok(rows.bottom)+ })?;+self.ui.content_scroll.set_extents(self.content_viewport_extent(),self.settings_content_extent(bottom + scroll),@@ -15301,6 +15474,228 @@ impl SettingsWindow {Ok(extra)}+ /// The window's opacity: a slider from `WINDOW_OPACITY_LEAST` to opaque+ /// and its value -- "Default" while the configuration decides, the knob+ /// then showing what that decided -- with a note that Linux has none.+ fn paint_window_opacity_row(+ &mut self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ y: f32,+ width: f32,+ draw_top_rule: bool,+ ) -> anyhow::Result<f32> {+ use crate::native_settings::WINDOW_OPACITY_LEAST;+ let palette = self.palette();+ let accent = self.chrome_palette.accent;+ let ui_font = Rc::clone(&self.ui_font);+ let body_font = Rc::clone(&self.body_font);+ if draw_top_rule {+ self.paint_separator(layers, x, y - self.ui_px(28.0), width)?;+ }+ let supported = crate::native_settings::window_opacity_supported();+ let chosen = self+ .native_settings+ .appearance+ .window_opacity+ .filter(|_| supported)+ .map(|percent| percent.clamp(WINDOW_OPACITY_LEAST, 100));+ let percent = chosen+ .unwrap_or_else(|| {+ (configuration().window_background_opacity.clamp(0.0, 1.0) * 100.0).round() as u8+ })+ .clamp(WINDOW_OPACITY_LEAST, 100);++ let column_width = self.settings_control_width(width);+ let control_x = x + width - column_width;+ let text_width = (control_x - x - self.ui_px(24.0)).max(width * 0.45);+ let title = crate::i18n::tr("settings-window-opacity");+ self.draw_text(layers, &ui_font, x, y, &title, palette.text, text_width)?;+ let title_width = self.measure_text_width(&ui_font, &title).min(text_width);+ self.paint_beta_badge(+ layers,+ x + title_width + self.ui_px(14.0),+ y,+ x + text_width,+ )?;+ let description_extra = self.draw_row_description(+ layers,+ x,+ y,+ &crate::i18n::tr("settings-window-opacity-description"),+ text_width,+ )?;++ // A groove, the part of it up to the knob, the knob, and the value.+ let control_y = y + self.ui_px(4.0);+ let control_height = self.ui_px(CONTROL_HEIGHT);+ let center_y = control_y + control_height / 2.0;+ let knob = self.ui_px(22.0);+ let groove = self.ui_px(4.0);+ let value_width = self.ui_px(72.0);+ let track_left = control_x + knob / 2.0;+ let track_width = (column_width - value_width - knob).max(self.ui_px(48.0));+ let along =+ f32::from(percent - WINDOW_OPACITY_LEAST) / f32::from(100 - WINDOW_OPACITY_LEAST);+ let knob_x = track_left + track_width * along;+ let set = chosen.is_some();+ self.draw_rounded_rect(+ layers,+ 0,+ track_left,+ center_y - groove / 2.0,+ track_width,+ groove,+ palette.track_off,+ groove / 2.0,+ )?;+ self.draw_rounded_rect(+ layers,+ 0,+ track_left,+ center_y - groove / 2.0,+ knob_x - track_left,+ groove,+ if set { accent } else { palette.muted_text },+ groove / 2.0,+ )?;+ let knob_fill = if supported {+ LinearRgba::with_components(1.0, 1.0, 1.0, 1.0)+ } else {+ palette.control_hover_bg+ };+ self.draw_rounded_frame(+ layers,+ 0,+ knob_x - knob / 2.0,+ center_y - knob / 2.0,+ knob,+ knob,+ knob_fill,+ palette.control_border,+ knob / 2.0,+ )?;+ let value = window_opacity_label(chosen);+ let value_text_width = self.measure_text_width(&ui_font, &value).min(value_width);+ self.draw_text(+ layers,+ &ui_font,+ x + width - value_text_width,+ self.control_text_y(control_y, control_height),+ &value,+ if set {+ palette.text+ } else {+ palette.secondary_text+ },+ value_width,+ )?;+ if supported {+ self.ui.window_opacity_track = Some((track_left, track_width));+ self.ui_context.push(+ rect(control_x, control_y, track_width + knob, control_height),+ WidgetKind::Button,+ SettingsAction::WindowOpacitySlider,+ );+ } else {+ self.ui.window_opacity_track = None;+ }+ let step = self.description_line_step();+ let mut control_bottom = control_y + control_height;+ // Back to the configuration's, once Settings has one of its own.+ if set {+ let reset = crate::i18n::tr("settings-window-opacity-reset");+ let reset_width = self.measure_text_width(&body_font, &reset);+ let reset_x = x + width - reset_width;+ let reset_y = control_bottom + self.ui_px(6.0);+ let action = SettingsAction::SetWindowOpacity(None);+ let hovered = self.ui.interaction.hovered == Some(action);+ self.draw_text(+ layers,+ &body_font,+ reset_x,+ reset_y,+ &reset,+ if hovered { palette.text } else { accent },+ reset_width,+ )?;+ self.ui_context.push(+ rect(reset_x, reset_y, reset_width, step),+ WidgetKind::Button,+ action,+ );+ control_bottom = reset_y + step;+ }++ // The one place the slider is not offered, said plainly, as the app+ // icon's row says where it works.+ let note_y = self.settings_row_description_y(y) + step + description_extra;+ self.draw_text(+ layers,+ &body_font,+ x,+ note_y,+ &crate::i18n::tr("settings-window-opacity-linux"),+ palette.muted_text,+ text_width,+ )?;+ let cell_height = self.metrics.cell_size.height as f32;+ let bottom = (note_y + cell_height).max(control_bottom) + self.ui_px(6.0);+ Ok((bottom - (y + self.settings_row_visual_height())).max(0.0))+ }++ /// A small "Beta" capsule starting at `x` after a title drawn at+ /// `title_y`, centred on the title's capitals. Left out when it would+ /// run past `right_edge`.+ fn paint_beta_badge(+ &self,+ layers: &mut TripleLayerQuadAllocator<'_>,+ x: f32,+ title_y: f32,+ right_edge: f32,+ ) -> anyhow::Result<()> {+ let font = Rc::clone(&self.logo_caption_font);+ let label = crate::i18n::tr("settings-badge-beta");+ let pad = self.ui_px(12.0);+ let width = (self.measure_text_width(&font, &label) + pad * 2.0).round();+ if x + width > right_edge {+ return Ok(());+ }+ let cap_height = |metrics: FontMetrics| {+ metrics+ .cap_height+ .map(|cap| cap.get() as f32)+ .unwrap_or(metrics.cell_height.get() as f32 * 0.58)+ };+ // `draw_text` puts the baseline this far below the y it is given,+ // whatever the font.+ let baseline_offset =+ self.metrics.cell_size.height as f32 + self.metrics.descender.get() as f32;+ let center_y = title_y + baseline_offset - cap_height(self.ui_font.metrics()) / 2.0;+ let label_cap = cap_height(font.metrics());+ let height = (label_cap + self.ui_px(16.0)).round();+ let accent = self.chrome_palette.accent;+ self.draw_rounded_rect(+ layers,+ 0,+ x,+ (center_y - height / 2.0).round(),+ width,+ height,+ accent.mul_alpha(0.16),+ height / 2.0,+ )?;+ self.draw_text(+ layers,+ &font,+ x + pad,+ (center_y + label_cap / 2.0 - baseline_offset).round(),+ &label,+ accent,+ width - pad,+ )+ }+/// The closed face of a dropdown: a pill wide enough for its current/// value plus the chevron, capped at the column and flush with the/// column's right edge (where the open menu also anchors).diff --git a/wezterm-gui/src/termwindow/content_view.rs b/wezterm-gui/src/termwindow/content_view.rsindex 3a673855..48c7ad9e 100644--- a/wezterm-gui/src/termwindow/content_view.rs+++ b/wezterm-gui/src/termwindow/content_view.rs@@ -157,6 +157,57 @@ mod flight_rect_tests {}}+#[cfg(test)]+mod frame_piece_tests {+ use super::*;++ fn window() -> RectF {+ euclid::rect(0.0, 0.0, 1000.0, 600.0)+ }++ // Sidebars 200 wide either side, a tab bar 80 tall over the terminal.+ fn terminal() -> RectF {+ euclid::rect(200.0, 80.0, 600.0, 520.0)+ }++ fn covered(rects: &[RectF], x: f32, y: f32) -> bool {+ rects.iter().any(|rect| rect.contains(euclid::point2(x, y)))+ }++ #[test]+ fn in_place_the_pieces_and_the_terminal_leave_no_gap() {+ // Nothing for the transition's ground to fill on its first frame, so+ // that frame looks exactly like the window it starts from.+ let mut rects = frame_pieces_at(window(), terminal(), 81.0, 0.0).to_vec();+ rects.push(terminal());+ for y in (0..600).step_by(5) {+ for x in (0..1000).step_by(5) {+ assert!(+ covered(&rects, x as f32 + 0.5, y as f32 + 0.5),+ "{},{}",+ x,+ y+ );+ }+ }+ }++ #[test]+ fn gone_the_pieces_are_off_the_window() {+ for piece in frame_pieces_at(window(), terminal(), 81.0, 1.0) {+ assert!(!piece.intersects(&window()), "{:?}", piece);+ }+ }++ #[test]+ fn halfway_each_piece_has_left_half_of_itself_behind() {+ let [left, right, top] = frame_pieces_at(window(), terminal(), 81.0, 0.5);+ assert_eq!(left.min_x(), -100.0);+ assert_eq!(right.min_x(), 900.0);+ assert_eq!(top.min_y(), -40.5);+ }+}+#[cfg(test)]mod transition_input_tests {use super::*;@@ -272,6 +323,41 @@ pub(crate) fn flight_rect_at(source: RectF, destination: RectF, travel: f32) ->)}+/// Where the three pieces of the window frame have slid to once they are+/// `gone` of the way off the edges they leave by: the left sidebar, the right+/// one, and the tab bar between them, `top_height` tall. In place, they and+/// `terminal` cover `window` whole.+pub(crate) fn frame_pieces_at(+ window: RectF,+ terminal: RectF,+ top_height: f32,+ gone: f32,+) -> [RectF; 3] {+ let gone = gone.clamp(0.0, 1.0);+ let left_width = terminal.min_x() - window.min_x();+ let right_width = window.max_x() - terminal.max_x();+ [+ euclid::rect(+ window.min_x() - left_width * gone,+ window.min_y(),+ left_width,+ window.height(),+ ),+ euclid::rect(+ terminal.max_x() + right_width * gone,+ window.min_y(),+ right_width,+ window.height(),+ ),+ euclid::rect(+ terminal.min_x(),+ window.min_y() - top_height * gone,+ terminal.width(),+ top_height,+ ),+ ]+}+#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]pub(crate) enum ContentViewPresentation {#[default]diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex bc0f087d..9a7a0d0d 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -2076,6 +2076,120 @@ fn frame_can_acknowledge_output(outcome: PaintOutcome, presented: bool) -> boolpresented && outcome.draw_submitted && outcome.frame_complete}+/// How solid the chrome is in a window whose terminal has `window_opacity`:+/// a quarter of the way from that to opaque. Enough to read as the frame+/// around the terminal and still let the window behind through; an opaque+/// window keeps opaque chrome.+/// What Settings' `changes` come to in a window whose overrides are+/// `current`. `owned` holds the window opacity overrides Settings put there+/// before, and is brought up to date: a window opacity key Settings no+/// longer sets is taken out only while it still holds Settings' value.+fn settings_override_changes(+ changes: &[(&'static str, Option<wezterm_dynamic::Value>)],+ owned: &mut HashMap<&'static str, wezterm_dynamic::Value>,+ current: &wezterm_dynamic::Value,+) -> Vec<(&'static str, Option<wezterm_dynamic::Value>)> {+ use wezterm_dynamic::{ToDynamic, Value};+ let mut applied = Vec::with_capacity(changes.len());+ for (key, value) in changes {+ if !crate::native_settings::WINDOW_OPACITY_KEYS.contains(key) {+ applied.push((*key, value.clone()));+ continue;+ }+ match value {+ Some(value) => {+ owned.insert(key, value.clone());+ applied.push((*key, Some(value.clone())));+ }+ None => {+ let Some(ours) = owned.remove(key) else {+ continue;+ };+ let still_ours = match current {+ Value::Object(map) => map.get(&key.to_dynamic()) == Some(&ours),+ _ => false,+ };+ if still_ours {+ applied.push((*key, None));+ }+ }+ }+ }+ applied+}++fn chrome_opacity(window_opacity: f32) -> f32 {+ let window = window_opacity.clamp(0.0, 1.0);+ window + (1.0 - window) / 4.0+}++#[cfg(test)]+mod chrome_opacity_tests {+ use super::chrome_opacity;++ #[test]+ fn chrome_is_a_step_more_solid_than_the_terminal() {+ assert_eq!(chrome_opacity(1.0), 1.0);+ assert!((chrome_opacity(0.8) - 0.85).abs() < 1e-6);+ assert_eq!(chrome_opacity(0.0), 0.25);+ // Out of range configurations do not make it more than opaque.+ assert_eq!(chrome_opacity(1.5), 1.0);+ }+}++#[cfg(test)]+mod settings_override_tests {+ use super::settings_override_changes;+ use std::collections::HashMap;+ use wezterm_dynamic::{ToDynamic, Value};++ const OPACITY: &str = "window_background_opacity";++ fn overrides(entries: &[(&str, f64)]) -> Value {+ let mut map = wezterm_dynamic::Object::default();+ for (key, value) in entries {+ map.insert(key.to_dynamic(), value.to_dynamic());+ }+ Value::Object(map)+ }++ #[test]+ fn a_scripts_opacity_survives_settings_that_set_none() {+ let mut owned = HashMap::new();+ let current = overrides(&[(OPACITY, 0.6)]);+ let changes = settings_override_changes(&[(OPACITY, None)], &mut owned, ¤t);+ assert!(changes.is_empty());+ }++ #[test]+ fn settings_take_out_only_what_they_put_in() {+ let mut owned = HashMap::new();+ let set = settings_override_changes(+ &[(OPACITY, Some(0.8.to_dynamic()))],+ &mut owned,+ &Value::Null,+ );+ assert_eq!(set, vec![(OPACITY, Some(0.8.to_dynamic()))]);+ // Still Settings' value: back to the configuration, it comes out.+ let current = overrides(&[(OPACITY, 0.8)]);+ let reset = settings_override_changes(&[(OPACITY, None)], &mut owned.clone(), ¤t);+ assert_eq!(reset, vec![(OPACITY, None)]);+ // A script has set its own since: that one stays.+ let current = overrides(&[(OPACITY, 0.6)]);+ let reset = settings_override_changes(&[(OPACITY, None)], &mut owned, ¤t);+ assert!(reset.is_empty());+ assert!(owned.is_empty());+ }++ #[test]+ fn other_keys_pass_through_as_given() {+ let mut owned = HashMap::new();+ let changes =+ settings_override_changes(&[("color_scheme", None)], &mut owned, &Value::Null);+ assert_eq!(changes, vec![("color_scheme", None)]);+ }+}+#[cfg(test)]mod stale_viewport_tests {use super::TermWindow;@@ -2457,7 +2571,13 @@ const RESTORED_FRAME_SETTLE_TIME: Duration = Duration::from_secs(3);pub struct TermWindow {pub window: Option<Window>,pub config: ConfigHandle,+ /// `config` as loaded, before the window's state has its say: full+ /// screen is opaque. See `config_for_window_state`.+ configured_config: ConfigHandle,pub config_overrides: wezterm_dynamic::Value,+ /// The window opacity overrides Settings has put in `config_overrides`,+ /// so that it takes out only those. See `apply_settings_overrides`.+ settings_opacity_overrides: HashMap<&'static str, wezterm_dynamic::Value>,os_parameters: Option<parameters::Parameters>,/// When we most recently received keyboard focuspub focused: Option<Instant>,@@ -2860,6 +2980,10 @@ pub struct TermWindow {/// entry and sets it around the row loop, so it describes that paint and/// no other; a paint that bailed out before the list leaves it `None`.workspace_sidebar_list_quads: Option<(HeapQuadMark, HeapQuadMark)>,+ /// The see-through left sidebar's recording buffer, kept from frame to+ /// frame: no larger than `WORKSPACE_SIDEBAR_SCRATCH_KEEP_BYTES`, let go+ /// when the sidebar collapses.+ workspace_sidebar_scratch: HeapQuadAllocator,workspace_sidebar_scrollbar_visible_until: Option<Instant>,/// Presentation-only hover reveal of the collapsed sidebar. This never/// touches `workspace_sidebar_collapsed` or `workspace_sidebar_width`:@@ -2946,6 +3070,17 @@ pub struct TermWindow {/// reading `load_error`, which a later transient would overwrite.right_sidebar_note_vault_failure: Option<ui::right_sidebar::NoteVaultFailure>,right_sidebar_note_tree_scroll_offset: f32,+ /// A right sidebar panel's contents are being recorded on their own,+ /// see-through: its scroll masks cut out what they cover rather than+ /// paint over it. See `paint_right_sidebar_contents`.+ right_sidebar_recording_contents: bool,+ /// A sidebar revealed by hovering is being painted: it floats over the+ /// terminal and is solid. See `chrome_window_opacity`.+ painting_floating_chrome: bool,+ /// Those recordings' buffers, kept from frame to frame: one per level of+ /// nesting, none larger than `RIGHT_SIDEBAR_SCRATCH_KEEP_BYTES`, all let+ /// go when the sidebar closes.+ right_sidebar_contents_scratch: Vec<HeapQuadAllocator>,right_sidebar_note_tree_expanded: HashSet<String>,right_sidebar_note_vault_tree_collapsed: bool,right_sidebar_note_wide_layout: bool,@@ -4037,35 +4172,47 @@ impl TermWindow {) -> anyhow::Result<()> {let config = configuration();let native_settings = crate::native_settings::load();- // A palette-picked color scheme applies from the first frame; seeding+ // What Settings overrides -- a palette-picked color scheme, the+ // window's opacity -- applies from the first frame; seeding// config_overrides here is what makes it stick for new windows.- let (config, config_overrides) = match crate::native_settings::effective_color_scheme(- &native_settings,- &config,- ) {- Some(scheme) => {- use wezterm_dynamic::ToDynamic;+ let mut seeded = wezterm_dynamic::Object::default();+ let settings_overrides =+ crate::native_settings::settings_config_overrides(&native_settings, &config);+ let settings_opacity_overrides: HashMap<&'static str, wezterm_dynamic::Value> =+ settings_overrides+ .iter()+ .filter(|(key, _)| crate::native_settings::WINDOW_OPACITY_KEYS.contains(key))+ .filter_map(|(key, value)| Some((*key, value.clone()?)))+ .collect();+ for (key, value) in settings_overrides {+ use wezterm_dynamic::ToDynamic;+ let Some(value) = value else {+ continue;+ };+ if key == "color_scheme" {// Deliberately louder than trace: this silently overrides// `color_scheme` from the config file, and "why doesn't my// config change do anything" needs a breadcrumb.log::info!(- "color scheme overridden to {scheme:?} -- either picked in the command \+ "color scheme overridden to {value:?} -- either picked in the command \palette or in Settings, or the light default that goes with a light \interface; pick \"Use configured default\" in the palette to follow the \config file again");- let mut obj = wezterm_dynamic::Object::default();- obj.insert("color_scheme".to_dynamic(), scheme.to_dynamic());- let overrides = wezterm_dynamic::Value::Object(obj);- match config::overridden_config(&overrides) {- Ok(config) => (config, overrides),- Err(err) => {- log::warn!("failed to apply saved color scheme: {err:#}");- (config, wezterm_dynamic::Value::default())- }+ }+ seeded.insert(key.to_dynamic(), value);+ }+ let (config, config_overrides) = if seeded.is_empty() {+ (config, wezterm_dynamic::Value::default())+ } else {+ let overrides = wezterm_dynamic::Value::Object(seeded);+ match config::overridden_config(&overrides) {+ Ok(config) => (config, overrides),+ Err(err) => {+ log::warn!("failed to apply the overrides from Settings: {err:#}");+ (config, wezterm_dynamic::Value::default())}}- None => (config, wezterm_dynamic::Value::default()),};let main_renderer =crate::native_settings::main_window_renderer(&native_settings, config.front_end);@@ -4225,7 +4372,9 @@ impl TermWindow {window: None,window_background,config: config.clone(),+ configured_config: config.clone(),config_overrides,+ settings_opacity_overrides,palette: None,focused: None,occluded: None,@@ -4420,6 +4569,7 @@ impl TermWindow {workspace_space_swipe_target_frame: None,workspace_space_swipe_tracked: false,workspace_sidebar_list_quads: None,+ workspace_sidebar_scratch: HeapQuadAllocator::default(),workspace_space_swipe_push_active: false,workspace_space_swipe_direction: 0.0,workspace_space_swipe_pending_commit: None,@@ -4462,6 +4612,9 @@ impl TermWindow {right_sidebar_note_open_failure: None,right_sidebar_note_vault_failure: None,right_sidebar_note_tree_scroll_offset: 0.0,+ right_sidebar_recording_contents: false,+ painting_floating_chrome: false,+ right_sidebar_contents_scratch: Vec::new(),right_sidebar_note_tree_expanded: HashSet::new(),right_sidebar_note_vault_tree_collapsed: false,right_sidebar_note_wide_layout: false,@@ -5387,14 +5540,16 @@ impl TermWindow {.context("send GetTerminalSize response")?;}TermWindowNotif::GetEffectiveConfig(tx) => {+ // As loaded: what full screen makes of it is the window's+ // business, and a script deciding from it would be misled.let tab_bar = self- .config+ .configured_config.resolved_palette.tab_bar.is_none().then(|| self.theme_aligned_tab_bar_colors());tx.try_send(crate::tabbar::config_for_lua(- &self.config,+ &self.configured_config,tab_bar.as_ref(),)).map_err(chan_err)@@ -6952,18 +7107,47 @@ impl TermWindow {/// already run. Callers about to reload anyway can use that to not do it/// twice -- a reload re-runs the Lua configuration from disk.pub(crate) fn apply_color_scheme_override(&mut self, name: Option<String>) -> bool {+ use wezterm_dynamic::ToDynamic;+ self.apply_config_overrides(&[("color_scheme", name.map(|scheme| scheme.to_dynamic()))])+ }++ /// Set (`Some`) or clear (`None`) keys in this window's configuration+ /// overrides, as `apply_color_scheme_override` does for the scheme, and+ /// reload once if anything moved. True when it did.+ /// Settings' overrides, as `apply_config_overrides` takes them -- but a+ /// window opacity key Settings has stopped setting comes out only while+ /// it still holds what Settings put in: one a script set with+ /// `window:set_config_overrides` is the script's.+ pub(crate) fn apply_settings_overrides(+ &mut self,+ changes: &[(&'static str, Option<wezterm_dynamic::Value>)],+ ) -> bool {+ let applied = settings_override_changes(+ changes,+ &mut self.settings_opacity_overrides,+ &self.config_overrides,+ );+ self.apply_config_overrides(&applied)+ }++ pub(crate) fn apply_config_overrides(+ &mut self,+ changes: &[(&str, Option<wezterm_dynamic::Value>)],+ ) -> bool {use wezterm_dynamic::{ToDynamic, Value};let mut map = match &self.config_overrides {Value::Object(obj) => obj.clone(),_ => Default::default(),};- let key = "color_scheme".to_dynamic();- match &name {- Some(scheme) => {- map.insert(key, scheme.to_dynamic());- }- None => {- map.remove(&key);+ for (key, value) in changes {+ let key = key.to_dynamic();+ match value {+ Some(value) => {+ map.insert(key, value.clone());+ }+ None => {+ map.remove(&key);+ }}}let next = Value::Object(map);@@ -7112,6 +7296,8 @@ impl TermWindow {configuration()}};+ self.configured_config = config.clone();+ let config = self.config_for_window_state(config);self.config = config.clone();self.palette.take();// One place for all three ways the chrome's colours can move: a@@ -8167,6 +8353,112 @@ impl TermWindow {.then(|| self.chrome().sidebar_bg)}+ /// `color` as a surface of the chrome paints it. In a see-through window+ /// the sidebars, the tab strip and the pane bars let the window behind+ /// through as well, but less than the terminal does, so that they still+ /// read as the frame around it.+ pub(crate) fn chrome_surface(&self, color: LinearRgba) -> LinearRgba {+ color.mul_alpha(chrome_opacity(self.chrome_window_opacity()))+ }++ /// Whether the window is see-through, and its chrome with it. Covering+ /// one thing by painting the ground over it shows there, as a darker+ /// band and as what it was meant to hide, so such covers are left out.+ pub(crate) fn chrome_see_through(&self) -> bool {+ self.chrome_window_opacity() < 1.0+ }++ /// The window opacity the chrome is painted for: the window's, but a+ /// panel floating over the terminal -- a hover-revealed sidebar -- is+ /// solid.+ fn chrome_window_opacity(&self) -> f32 {+ if self.painting_floating_chrome {+ 1.0+ } else {+ self.config.window_background_opacity+ }+ }++ /// What `config` is for this window in its present state. Full screen+ /// on macOS is opaque and unblurred: native full screen has nothing of+ /// the user's behind it to see through to, and simple full screen makes+ /// the window opaque outright, under which see-through comes out wrong.+ /// Elsewhere full screen keeps the configured opacity, as it always has.+ fn config_for_window_state(&self, config: ConfigHandle) -> ConfigHandle {+ if !cfg!(target_os = "macos")+ || !self.window_state.contains(WindowState::FULL_SCREEN)+ || config.window_background_opacity >= 1.0+ {+ return config;+ }+ config.adjusted(|config| {+ config.window_background_opacity = 1.0;+ config.macos_window_background_blur = 0;+ })+ }++ /// Full screen came or went: derive the window's configuration from the+ /// loaded one again, without reloading it.+ pub(crate) fn window_state_changed_config(&mut self) {+ self.use_derived_config(self.configured_config.clone());+ }++ /// Show a window opacity of `percent` -- the Settings slider's, while it+ /// is dragged -- without the reload applying it as an override takes.+ /// `None` goes back to the configuration as loaded.+ pub(crate) fn preview_window_opacity(&mut self, percent: Option<u8>) {+ let config = match percent {+ Some(percent) => {+ let (opacity, blur, backdrop) =+ crate::native_settings::window_opacity_preview(percent);+ // A step that shows what is shown already copies nothing.+ if self.config.window_background_opacity == opacity+ && self.config.macos_window_background_blur == blur+ && self.config.win32_system_backdrop == backdrop+ {+ return;+ }+ self.configured_config.adjusted(|config| {+ config.window_background_opacity = opacity;+ config.macos_window_background_blur = blur;+ config.win32_system_backdrop = backdrop;+ })+ }+ None => self.configured_config.clone(),+ };+ self.use_derived_config(config);+ }++ /// Make `config` -- the loaded configuration, changed only in how+ /// see-through the window is -- this window's. The platform window hears+ /// of it only when what it does changes: whether the window is opaque,+ /// and its blur or backdrop.+ fn use_derived_config(&mut self, config: ConfigHandle) {+ let config = self.config_for_window_state(config);+ let before = &self.config;+ let platform_changed = (config.window_background_opacity >= 1.0)+ != (before.window_background_opacity >= 1.0)+ || config.macos_window_background_blur != before.macos_window_background_blur+ || config.win32_system_backdrop != before.win32_system_backdrop;+ if !platform_changed && config.window_background_opacity == before.window_background_opacity+ {+ return;+ }+ // Cached line quads carry the cells' background alpha, which is+ // whether the window is see-through.+ if (config.window_background_opacity != 1.0) != (before.window_background_opacity != 1.0) {+ self.quad_generation += 1;+ }+ self.config = config;+ self.invalidate_fancy_tab_bar();+ if let Some(window) = self.window.as_ref() {+ if platform_changed {+ window.config_did_change(&self.config);+ }+ window.invalidate();+ }+ }+/// The terminal's default background as painted.pub(crate) fn terminal_default_background(&mut self) -> LinearRgba {match self.dark_terminal_ground() {diff --git a/wezterm-gui/src/termwindow/render/borders.rs b/wezterm-gui/src/termwindow/render/borders.rsindex 7a57a1c9..d77ce9ca 100644--- a/wezterm-gui/src/termwindow/render/borders.rs+++ b/wezterm-gui/src/termwindow/render/borders.rs@@ -19,9 +19,18 @@ impl crate::TermWindow {let width = self.dimensions.pixel_width as f32;// The window frame is ThinkTerm's chrome, whatever `window_frame`// asks for: Lua configures the terminal area only.- let chrome_border_color = self.chrome().sidebar_bg;+ let chrome_border_color = self.chrome_surface(self.chrome().sidebar_bg);let border_top = border_dimensions.top.get() as f32;+ let border_bottom = border_dimensions.bottom.get() as f32;+ // Opaque, the sides overlap the top and bottom at the corners+ // unseen. See-through, the overlap would show darker, so the+ // sides stop where those begin.+ let (side_top, side_height) = if self.chrome_see_through() {+ (border_top, (height - border_top - border_bottom).max(0.0))+ } else {+ (0.0, height)+ };if border_top > 0.0 {self.filled_rectangle(layers,@@ -36,12 +45,11 @@ impl crate::TermWindow {self.filled_rectangle(layers,1,- euclid::rect(0.0, 0.0, border_left, height),+ euclid::rect(0.0, side_top, border_left, side_height),chrome_border_color,)?;}- let border_bottom = border_dimensions.bottom.get() as f32;if border_bottom > 0.0 {self.filled_rectangle(layers,@@ -56,7 +64,7 @@ impl crate::TermWindow {self.filled_rectangle(layers,1,- euclid::rect(width - border_right, 0.0, border_right, height),+ euclid::rect(width - border_right, side_top, border_right, side_height),chrome_border_color,)?;}diff --git a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rsindex dd7a02e0..a7601615 100644--- a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs+++ b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs@@ -55,7 +55,7 @@ impl crate::TermWindow {let metrics = RenderMetrics::with_font_metrics(&font.metrics());let tab_width = self.window_tab_width_pixels().ceil() as usize;- let background = chrome.header_bg;+ let background = self.chrome_surface(chrome.header_bg);let foreground = chrome.text;let muted_fg = chrome.secondary_text;@@ -259,7 +259,7 @@ impl crate::TermWindow {// Establish a hard paint boundary before the trailing actions. Tab// surfaces and glyphs are already geometrically clipped, but this mask// also protects the action area from shader and texture overhang.- if viewport_right < row_right {+ if viewport_right < row_right && !self.chrome_see_through() {self.filled_rectangle(layers,2,@@ -778,6 +778,9 @@ impl crate::TermWindow {chrome.active_tab_surface()} else if is_hovered && !is_renaming {chrome.control_hover_bg+ } else if self.chrome_see_through() {+ // The bar's own ground: a second coat would show as a darker pill.+ LinearRgba::TRANSPARENT} else {background};@@ -811,13 +814,17 @@ impl crate::TermWindow {let mut content_layers = TripleLayerQuadAllocator::Heap(&mut content);let layers = &mut content_layers;- self.filled_rectangle(- layers,- 1,- euclid::rect(0.0, row_y as f32, tab_width as f32, row_height as f32),- background,- )- .context("window tab background")?;+ // The bar's own ground under the tab. Over a see-through bar a second+ // coat of it would show as a darker block.+ if !self.chrome_see_through() {+ self.filled_rectangle(+ layers,+ 1,+ euclid::rect(0.0, row_y as f32, tab_width as f32, row_height as f32),+ background,+ )+ .context("window tab background")?;+ }self.paint_tab_capsule(layers,@@ -1022,6 +1029,9 @@ impl crate::TermWindow {chrome.active_tab_surface()} else if is_hovered {chrome.control_hover_bg+ } else if self.chrome_see_through() {+ // As the window tabs: no second coat of the bar's ground.+ LinearRgba::TRANSPARENT} else {background};@@ -1042,13 +1052,16 @@ impl crate::TermWindow {let mut content_layers = TripleLayerQuadAllocator::Heap(&mut content);let layers = &mut content_layers;- self.filled_rectangle(- layers,- 1,- euclid::rect(0.0, row_y as f32, tab_width as f32, row_height as f32),- background,- )- .context("content view tab background")?;+ // As for a window tab: no second coat of a see-through bar.+ if !self.chrome_see_through() {+ self.filled_rectangle(+ layers,+ 1,+ euclid::rect(0.0, row_y as f32, tab_width as f32, row_height as f32),+ background,+ )+ .context("content view tab background")?;+ }self.paint_tab_capsule(layers,1,diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rsindex 5b3cfc8a..6522b138 100644--- a/wezterm-gui/src/termwindow/render/paint.rs+++ b/wezterm-gui/src/termwindow/render/paint.rs@@ -11,7 +11,7 @@ use ::window::RectF;use ::window::WindowOps;use anyhow::Context;use mux::renderable::{RenderableDimensions, StableCursorPosition};-use mux::tab::{SplitDirection, TabId};+use mux::tab::{PositionedPane, SplitDirection, TabId};use smol::Timer;use std::collections::hash_map::DefaultHasher;use std::collections::HashSet;@@ -47,6 +47,9 @@ const MAX_PREVIEW_FILL: f32 = 1.5;/// Height of the pane layer divider the tab bar draws below itself, in the same/// device pixels the divider quad uses. Kept in step with `fancy_tab_bar`.const TAB_BAR_SEAM_HEIGHT: f32 = 1.0;+/// The largest recording buffer the see-through left sidebar keeps for the+/// next frame.+const WORKSPACE_SIDEBAR_SCRATCH_KEEP_BYTES: usize = 8 << 20;/// How many cards may rebuild their recorded quads in one frame.///@@ -1502,39 +1505,16 @@ impl crate::TermWindow {/// last stretch is spent fading, because what it lands on is the card's/// own thumbnail of the same terminal drawn from the same snapshot -- near/// enough to blend into, not near enough to cut to.- fn paint_content_view_flight(&self) -> anyhow::Result<()> {- let now = Instant::now();+ fn paint_content_view_flight(&self, now: Instant) -> anyhow::Result<()> {let Some(fade) = self.content_view_fade.as_ref() else {return Ok(());};let Some(flight) = fade.flight.as_ref() else {return Ok(());};- if flight.recording_revision- != crate::termwindow::ui::recording_overlay::recording_mask_revision()- {+ let Some((source, target)) = self.content_view_flight_rects(now) else {return Ok(());- }- // The terminal grid is what travels, and the card's own thumbnail is- // what it lands on, so both ends of the journey are the same picture.- //- // The source is the one recorded with the surface, not the terminal's- // rectangle now: these quads hold the positions they were authored at.- let source = flight.source;- // The destination, on the other hand, is re-asked every frame. An- // arriving overview keeps laying itself out while the terminal crosses- // the window -- closing a card reflows the grid underneath it -- and a- // rectangle sampled once meant landing on where the card used to be- // and then jumping to where it is.- let destination = flight- .tab_id- .and_then(|tab_id| {- self.active_content_view()- .and_then(|view| view.terminal_landing_rect(tab_id))- })- .unwrap_or(flight.destination);- let travel = fade.travel.value(now);- let target = crate::termwindow::content_view::flight_rect_at(source, destination, travel);+ };// Opaque for all of the journey but the landing.//// An earlier version faded over the last tenth of the *distance*, and@@ -1565,6 +1545,102 @@ impl crate::TermWindow {)}+ /// Where the recorded terminal was recorded, and where its travel has+ /// taken it now; `None` while there is no flight to paint.+ fn content_view_flight_rects(&self, now: Instant) -> Option<(RectF, RectF)> {+ let fade = self.content_view_fade.as_ref()?;+ let flight = fade.flight.as_ref()?;+ if flight.recording_revision+ != crate::termwindow::ui::recording_overlay::recording_mask_revision()+ {+ return None;+ }+ // The terminal grid is what travels, and the card's own thumbnail is+ // what it lands on, so both ends of the journey are the same picture.+ //+ // The source is the one recorded with the surface, not the terminal's+ // rectangle now: these quads hold the positions they were authored at.+ let source = flight.source;+ // The destination, on the other hand, is re-asked every frame. An+ // arriving overview keeps laying itself out while the terminal crosses+ // the window -- closing a card reflows the grid underneath it -- and a+ // rectangle sampled once meant landing on where the card used to be+ // and then jumping to where it is.+ let destination = flight+ .tab_id+ .and_then(|tab_id| {+ self.active_content_view()+ .and_then(|view| view.terminal_landing_rect(tab_id))+ })+ .unwrap_or(flight.destination);+ let travel = fade.travel.value(now);+ let target = crate::termwindow::content_view::flight_rect_at(source, destination, travel);+ Some((source, target))+ }++ /// The terminal's ground under a transition, wherever neither the+ /// travelling terminal nor the departing window frame is.+ ///+ /// Opaque, the window's background is painted across the whole window+ /// every frame, so a view fades in and out against it. See-through, that+ /// is left to the panes -- and while a transition runs, the panes are a+ /// recording on its way into a card: the gaps it and the sliding frame+ /// leave would show the desktop through the half-faded view.+ fn paint_content_view_transition_ground(+ &self,+ now: Instant,+ ground: LinearRgba,+ ) -> anyhow::Result<()> {+ if !self.window_background.is_empty() || self.config.window_background_opacity >= 1.0 {+ return Ok(());+ }+ let Some(fade) = self.content_view_fade.as_ref() else {+ return Ok(());+ };+ let window = self.window_rect();+ let mut covered = Vec::with_capacity(4);+ if let Some((_, target)) = self.content_view_flight_rects(now) {+ covered.push(self.clip_of(target));+ }+ if fade.chrome.is_some() {+ // Where `paint_content_view_chrome` slides each piece to.+ for piece in self.content_view_frame_pieces(fade.chrome_travel.value(now)) {+ covered.push(self.clip_of(piece));+ }+ }+ let mut gaps = HeapQuadAllocator::default();+ self.filled_rectangle(+ &mut TripleLayerQuadAllocator::Heap(&mut gaps),+ 0,+ window,+ ground,+ )+ .context("content view transition ground")?;+ gaps.occlude(&covered);++ let gl_state = self.render_state.as_ref().unwrap();+ let layer = gl_state+ .layer_for_zindex(0)+ .context("content view transition ground layer")?;+ let mut layers = layer.quad_allocator();+ gaps.apply_to(&mut layers)+ }++ /// The terminal's ground across the window, as see-through as the window+ /// is: the dark interface's, a lone pane's own, or the palette's.+ fn window_terminal_ground(&mut self, panes: &[PositionedPane]) -> LinearRgba {+ let ground = if let Some(ground) = self.dark_terminal_ground() {+ ground+ } else if panes.len() == 1 {+ // If we're the only pane, use the pane's palette+ // to draw the padding background+ panes[0].pane.palette().background.to_linear()+ } else {+ self.palette().background.to_linear()+ };+ ground.mul_alpha(self.config.window_background_opacity)+ }+/// Record the window frame in three pieces, one per edge it can leave by.fn record_content_view_chrome(&mut self) -> anyhow::Result<()> {let mut chrome = crate::termwindow::content_view::ContentViewChrome::default();@@ -1593,27 +1669,16 @@ impl crate::TermWindow {/// Anchored motion rather than a fade: a panel that lives against the left/// edge reads as leaving when it goes left, and as merely disappearing/// when it dissolves in place.- fn paint_content_view_chrome(&self) -> anyhow::Result<()> {- let now = Instant::now();+ fn paint_content_view_chrome(&self, now: Instant) -> anyhow::Result<()> {let Some(fade) = self.content_view_fade.as_ref() else {return Ok(());};let Some(chrome) = fade.chrome.as_ref() else {return Ok(());};- let gone = fade.chrome_travel.value(now).clamp(0.0, 1.0);let window = self.window_rect();- let terminal = self.terminal_content_rect();- let left_width = terminal.min_x() - window.min_x();- let right_width = window.max_x() - terminal.max_x();- // The tab bar paints one row past its own band. The pane layer divider- // in `fancy_tab_bar` sits at the seam -- `row_y + row_height`, which is- // the terminal's first row, not the tab bar's last -- so sliding by the- // terminal's top inset alone parks exactly that row against the top of- // the window and leaves it there. Windowed, the rounded corner mask- // hides most of it; fullscreen has no corners and it reads as a- // hairline that never leaves.- let top_height = terminal.min_y() - window.min_y() + TAB_BAR_SEAM_HEIGHT;+ let home = self.content_view_frame_pieces(0.0);+ let pieces = self.content_view_frame_pieces(fade.chrome_travel.value(now));let gl_state = self.render_state.as_ref().unwrap();let layer = gl_state@@ -1621,17 +1686,30 @@ impl crate::TermWindow {.context("content view chrome layer")?;let mut layers = layer.quad_allocator();let full = self.clip_of(window);- for (surface, dx, dy) in [- (&chrome.left, -left_width * gone, 0.0),- (&chrome.right, right_width * gone, 0.0),- (&chrome.top, 0.0, -top_height * gone),- ] {- let shifted = window.translate(euclid::vec2(dx, dy));+ let surfaces = [&chrome.left, &chrome.right, &chrome.top];+ for ((surface, piece), home) in surfaces.iter().zip(pieces).zip(home) {+ let shifted = window.translate(piece.origin - home.origin);surface.apply_to_scaled(&mut layers, full, self.clip_of(shifted), full, 1.0)?;}Ok(())}+ /// Where the window frame's three pieces are once `gone` of the way off+ /// their edges; see `content_view::frame_pieces_at`.+ fn content_view_frame_pieces(&self, gone: f32) -> [RectF; 3] {+ let window = self.window_rect();+ let terminal = self.terminal_content_rect();+ // The tab bar paints one row past its own band. The pane layer divider+ // in `fancy_tab_bar` sits at the seam -- `row_y + row_height`, which is+ // the terminal's first row, not the tab bar's last -- so sliding by the+ // terminal's top inset alone parks exactly that row against the top of+ // the window and leaves it there. Windowed, the rounded corner mask+ // hides most of it; fullscreen has no corners and it reads as a+ // hairline that never leaves.+ let top_height = terminal.min_y() - window.min_y() + TAB_BAR_SEAM_HEIGHT;+ crate::termwindow::content_view::frame_pieces_at(window, terminal, top_height, gone)+ }+/// Work out where the terminal is heading and hand it the recorded frame.////// Called after the view has painted, because the destination comes from@@ -3555,11 +3633,14 @@ impl crate::TermWindow {};let ui_items_before = self.ui_items.len();let mut panel_frame = HeapQuadAllocator::default();+ // Solid while it floats, as the left one is.+ let floating = std::mem::replace(&mut self.painting_floating_chrome, true);let result = {let mut panel_layers = TripleLayerQuadAllocator::Heap(&mut panel_frame);self.paint_right_sidebar(&mut panel_layers).and_then(|_| self.paint_right_sidebar_hover_shadow(&mut panel_layers))};+ self.painting_floating_chrome = floating;result.context("record hover-revealed right sidebar")?;let mut items: Vec<UIItem> = self.ui_items.drain(ui_items_before..).collect();if !self.right_sidebar_hover.is_fully_presented(now) {@@ -3670,11 +3751,15 @@ impl crate::TermWindow {};let ui_items_before = self.ui_items.len();let mut sidebar_frame = HeapQuadAllocator::default();+ // Floating over the terminal, the panel is solid; only docked is it+ // as see-through as the window.+ let floating = std::mem::replace(&mut self.painting_floating_chrome, true);let result = {let mut sidebar_layers = TripleLayerQuadAllocator::Heap(&mut sidebar_frame);self.paint_workspace_sidebar(&mut sidebar_layers).and_then(|_| self.paint_workspace_sidebar_hover_shadow(&mut sidebar_layers))};+ self.painting_floating_chrome = floating;// The marks describe `sidebar_frame`, which the swipe composite below// may still split; nobody downstream of this fn may.let live_list = self.workspace_sidebar_list_quads;@@ -4012,9 +4097,14 @@ impl crate::TermWindow {&mut self.workspace_sidebar_scroll_offset,preview_scroll_offset,);+ // Collapsed, the panel is on screen only as a hover reveal, which is+ // solid: so is the neighbour sliding into it.+ let floating = self.painting_floating_chrome;+ self.painting_floating_chrome |= self.workspace_sidebar_collapsed;let mut layers = TripleLayerQuadAllocator::Heap(&mut quads);let painted = self.paint_workspace_sidebar(&mut layers);drop(layers);+ self.painting_floating_chrome = floating;self.workspace_sidebar_scroll_offset = live_scroll_offset;self.workspace_sidebar_preview_space_id = None;// This paint laid out hit targets for a Space the window has not@@ -4124,23 +4214,7 @@ impl crate::TermWindow {if paint_terminal_background {// Regular window background color- let background = if let Some(ground) = self.dark_terminal_ground() {- ground.mul_alpha(self.config.window_background_opacity)- } else if panes.len() == 1 {- // If we're the only pane, use the pane's palette- // to draw the padding background- panes[0]- .pane- .palette()- .background- .to_linear()- .mul_alpha(self.config.window_background_opacity)- } else {- self.palette()- .background- .to_linear()- .mul_alpha(self.config.window_background_opacity)- };+ let background = self.window_terminal_ground(&panes);self.filled_rectangle(&mut layers,@@ -4158,13 +4232,15 @@ impl crate::TermWindow {let border = self.get_os_border();let header_height = border.top.get() as f32;- if header_height > 0.0 {+ // `paint_window_borders` paints this band as well; in a see-through+ // window the second coat would show.+ if header_height > 0.0 && !self.chrome_see_through() {let chrome = self.chrome();self.filled_rectangle(&mut layers,0,euclid::rect(0.0, 0.0, self.dimensions.pixel_width as f32, header_height),- chrome.sidebar_bg,+ self.chrome_surface(chrome.sidebar_bg),).context("filled_rectangle for chrome header background")?;}@@ -4179,6 +4255,9 @@ impl crate::TermWindow {// closing view is already gone by now, so its side of the transition// is a recorded frame rather than a live paint.let fading_content_view = self.content_view_fade.is_some();+ // What `paint_content_view_transition_ground` fills the gaps with,+ // taken while the panes are still to hand.+ let transition_ground = fading_content_view.then(|| self.window_terminal_ground(&panes));// While a transition runs the terminal is a recording: drawn once into// `flight_capture` on the opening frame, replayed thereafter.//@@ -4483,10 +4562,20 @@ impl crate::TermWindow {}}} else if capture_space_source {- let mut sidebar_layers = layer.tee_quad_allocator(&mut sidebar_frame);- self.paint_workspace_sidebar(&mut sidebar_layers)- .context("capture source workspace sidebar")?;- drop(sidebar_layers);+ // See-through, the sidebar's list is cut to its viewport, which+ // takes a recording: record, then draw what was recorded.+ if self.chrome_see_through() {+ let mut sidebar_layers = TripleLayerQuadAllocator::Heap(&mut sidebar_frame);+ self.paint_workspace_sidebar(&mut sidebar_layers)+ .context("capture source workspace sidebar")?;+ drop(sidebar_layers);+ sidebar_frame.apply_to(&mut layer.quad_allocator())?;+ } else {+ let mut sidebar_layers = layer.tee_quad_allocator(&mut sidebar_frame);+ self.paint_workspace_sidebar(&mut sidebar_layers)+ .context("capture source workspace sidebar")?;+ drop(sidebar_layers);+ }self.workspace_space_swipe_source_frame =Some(crate::termwindow::CapturedSidebar {@@ -4504,6 +4593,23 @@ impl crate::TermWindow {)));}}+ } else if self.chrome_see_through() {+ // As above: the list is cut in a recording, one whose buffer+ // is kept from frame to frame.+ let mut recorded = std::mem::take(&mut self.workspace_sidebar_scratch);+ recorded.recycle();+ let mut sidebar_layers = TripleLayerQuadAllocator::Heap(&mut recorded);+ let painted = self.paint_workspace_sidebar(&mut sidebar_layers);+ drop(sidebar_layers);+ // The marks describe a buffer about to be reused.+ self.workspace_sidebar_list_quads = None;+ let applied = painted+ .context("paint_workspace_sidebar")+ .and_then(|()| recorded.apply_to(&mut layer.quad_allocator()));+ if recorded.resident_bytes() <= WORKSPACE_SIDEBAR_SCRATCH_KEEP_BYTES {+ self.workspace_sidebar_scratch = recorded;+ }+ applied?;} else {let mut sidebar_layers = layer.quad_allocator();self.paint_workspace_sidebar(&mut sidebar_layers)@@ -4612,9 +4718,15 @@ impl crate::TermWindow {self.resolve_content_view_flight(flight_capture);}if fading_content_view {- self.paint_content_view_chrome()+ // One moment for all three, or the gaps cut for the frame and+ // the terminal would trail where they are painted.+ let now = Instant::now();+ if let Some(ground) = transition_ground {+ self.paint_content_view_transition_ground(now, ground)?;+ }+ self.paint_content_view_chrome(now).context("paint content view chrome")?;- self.paint_content_view_flight()+ self.paint_content_view_flight(now).context("paint content view flight")?;}diff --git a/wezterm-gui/src/termwindow/render/pane.rs b/wezterm-gui/src/termwindow/render/pane.rsindex 330f0623..e48bd886 100644--- a/wezterm-gui/src/termwindow/render/pane.rs+++ b/wezterm-gui/src/termwindow/render/pane.rs@@ -304,6 +304,114 @@ impl crate::TermWindow {))}+ /// The pane's own background: out to half way across the splits beside+ /// it, and to the edges of the terminal area along them.+ pub(crate) fn pane_background_rect(&self, pos: &PositionedPane) -> RectF {+ let (padding_left, padding_top) = self.padding_left_top();+ let (top_bar_height, _) = self.pane_area_insets();+ let border = self.get_os_border();+ let top_pixel_y = top_bar_height + padding_top + border.top.get() as f32;+ let cell_width = self.render_metrics.cell_size.width as f32;+ let cell_height = self.render_metrics.cell_size.height as f32;+ // We want to fill out to the edges of the splits+ let (x, width_delta) = if pos.left == 0 {+ // See-through, the sidebar shows its own ground only: this+ // one under it as well would darken it below the tab bar.+ let left = if self.chrome_see_through() {+ self.tab_bar_left_edge() as f32+ } else {+ 0.+ };+ (+ left,+ padding_left + border.left.get() as f32 + (cell_width / 2.0) - left,+ )+ } else {+ (+ padding_left + border.left.get() as f32 - (cell_width / 2.0)+ + (pos.left as f32 * cell_width),+ cell_width,+ )+ };++ let (y, height_delta) = if pos.top == 0 {+ (+ (top_pixel_y - padding_top),+ padding_top + (cell_height / 2.0),+ )+ } else {+ (+ top_pixel_y + (pos.top as f32 * cell_height) - (cell_height / 2.0),+ cell_height,+ )+ };+ let candidate_right = if pos.left + pos.width >= self.terminal_size.cols as usize {+ self.terminal_viewport_right()+ } else {+ x + (pos.width as f32 * cell_width) + width_delta+ };+ let (x, width) =+ clamp_pane_horizontal_span(x, candidate_right, self.terminal_viewport_right());+ euclid::rect(+ x,+ y,+ width,+ // Go all the way to the bottom if we're bottom-most+ if pos.top + pos.height >= self.terminal_size.rows as usize {+ self.pane_area_bottom() - y+ } else {+ (pos.height as f32 * cell_height) + height_delta as f32+ },+ )+ }++ /// Where the pane's own background goes: all of `pane_background_rect`,+ /// but, see-through, not the band its nav bar takes -- collapsed, its+ /// whole frame. Chrome there is painted over nothing, as see-through as+ /// the tab strip beside it; over the pane's ground it would come out+ /// tinted by it.+ fn pane_ground_rects(&self, pos: &PositionedPane) -> anyhow::Result<Vec<RectF>> {+ let ground = self.pane_background_rect(pos);+ if !self.chrome_see_through() {+ return Ok(vec![ground]);+ }+ let chrome = if self.collapsed_pane_layouts.contains_key(&pos.pane_stack_id) {+ self.pane_frame_rect(pos)?+ } else {+ let nav_height = self.pane_nav_bar_height_for_pane(pos) as f32;+ if nav_height <= 0.0 {+ return Ok(vec![ground]);+ }+ let (_, pane_y) = self.pane_content_origin(pos)?;+ euclid::rect(+ ground.min_x(),+ pane_y - self.pane_nav_lift(pos),+ ground.width(),+ nav_height,+ )+ };+ let mut rects = Vec::with_capacity(2);+ let above = chrome.min_y().min(ground.max_y());+ if above > ground.min_y() {+ rects.push(euclid::rect(+ ground.min_x(),+ ground.min_y(),+ ground.width(),+ above - ground.min_y(),+ ));+ }+ let below = chrome.max_y().max(ground.min_y());+ if ground.max_y() > below {+ rects.push(euclid::rect(+ ground.min_x(),+ below,+ ground.width(),+ ground.max_y() - below,+ ));+ }+ Ok(rects)+ }+/// The pane's rectangle without that lift. Recording masks are kept as/// fractions of it, so it has to move with the pane's rows when a/// terminal bar comes or goes, as the whole frame did before the lift.@@ -329,7 +437,7 @@ impl crate::TermWindow {let foreground = chrome.text;let muted_fg = chrome.secondary_text;- self.filled_rectangle(layers, 0, pane_rect, chrome.sidebar_bg)+ self.filled_rectangle(layers, 0, pane_rect, self.chrome_surface(chrome.sidebar_bg)).context("collapsed pane background")?;self.ui_items.push(UIItem {@@ -715,7 +823,7 @@ impl crate::TermWindow {// sliced in half.self.paint_tab_row_fades(layers,- chrome.sidebar_bg,+ self.chrome_surface(chrome.sidebar_bg),tab_y,tab_height,tab_start,@@ -776,7 +884,8 @@ impl crate::TermWindow {// terminal's header rather than to the sidebar -- same reasoning as// the tab strip itself. `header_bg` is the chrome's own colour in a// dark interface, so nothing moves there.- let background = chrome.header_bg;+ // Over nothing see-through: the pane's ground stops below it.+ let background = self.chrome_surface(chrome.header_bg);let foreground = chrome.text;let muted_fg = chrome.secondary_text;let tab_fg = if pos.is_active { foreground } else { muted_fg };@@ -1575,72 +1684,27 @@ impl crate::TermWindow {config.text_background_opacity});- let cell_width = self.render_metrics.cell_size.width as f32;- let cell_height = self.render_metrics.cell_size.height as f32;- let background_rect = {- // We want to fill out to the edges of the splits- let (x, width_delta) = if pos.left == 0 {- (- 0.,- padding_left + border.left.get() as f32 + (cell_width / 2.0),- )- } else {- (- padding_left + border.left.get() as f32 - (cell_width / 2.0)- + (pos.left as f32 * cell_width),- cell_width,- )- };-- let (y, height_delta) = if pos.top == 0 {- (- (top_pixel_y - padding_top),- padding_top + (cell_height / 2.0),- )- } else {- (- top_pixel_y + (pos.top as f32 * cell_height) - (cell_height / 2.0),- cell_height,- )- };- let candidate_right = if pos.left + pos.width >= self.terminal_size.cols as usize {- self.terminal_viewport_right()- } else {- x + (pos.width as f32 * cell_width) + width_delta- };- let (x, width) =- clamp_pane_horizontal_span(x, candidate_right, self.terminal_viewport_right());- euclid::rect(- x,- y,- width,- // Go all the way to the bottom if we're bottom-most- if pos.top + pos.height >= self.terminal_size.rows as usize {- self.pane_area_bottom() - y- } else {- (pos.height as f32 * cell_height) + height_delta as f32- },- )- };+ let ground_rects = self.pane_ground_rects(pos)?;if self.window_background.is_empty() {// Per-pane, palette-specified background-- let mut quad = self- .filled_rectangle(- layers,- 0,- background_rect,- dark_chrome_background- .unwrap_or_else(|| palette.background.to_linear())- .mul_alpha(config.window_background_opacity),- )- .context("filled_rectangle")?;- quad.set_hsv(if pos.is_active {- None- } else {- Some(config.inactive_pane_hsb_for_background(palette.background))- });+ for background_rect in &ground_rects {+ let mut quad = self+ .filled_rectangle(+ layers,+ 0,+ *background_rect,+ dark_chrome_background+ .unwrap_or_else(|| palette.background.to_linear())+ .mul_alpha(config.window_background_opacity),+ )+ .context("filled_rectangle")?;+ quad.set_hsv(if pos.is_active {+ None+ } else {+ Some(config.inactive_pane_hsb_for_background(palette.background))+ });+ }}{@@ -1680,15 +1744,17 @@ impl crate::TermWindow {};log::trace!("bell color is {:?}", background);- let mut quad = self- .filled_rectangle(layers, 0, background_rect, background)- .context("filled_rectangle")?;+ for background_rect in &ground_rects {+ let mut quad = self+ .filled_rectangle(layers, 0, *background_rect, background)+ .context("filled_rectangle")?;- quad.set_hsv(if pos.is_active {- None- } else {- Some(config.inactive_pane_hsb_for_background(palette.background))- });+ quad.set_hsv(if pos.is_active {+ None+ } else {+ Some(config.inactive_pane_hsb_for_background(palette.background))+ });+ }}}diff --git a/wezterm-gui/src/termwindow/resize.rs b/wezterm-gui/src/termwindow/resize.rsindex bd973dae..ace60691 100644--- a/wezterm-gui/src/termwindow/resize.rs+++ b/wezterm-gui/src/termwindow/resize.rs@@ -2740,6 +2740,11 @@ impl super::TermWindow {self.quad_generation += 1;if last_state != self.window_state {self.load_os_parameters();+ if last_state.contains(WindowState::FULL_SCREEN)+ != window_state.contains(WindowState::FULL_SCREEN)+ {+ self.window_state_changed_config();+ }}if let Some(webgpu) = self.webgpu.as_mut() {diff --git a/wezterm-gui/src/termwindow/ui/mod.rs b/wezterm-gui/src/termwindow/ui/mod.rsindex e1fc30ea..1cfccc52 100644--- a/wezterm-gui/src/termwindow/ui/mod.rs+++ b/wezterm-gui/src/termwindow/ui/mod.rs@@ -137,6 +137,11 @@ impl crate::TermWindow {) -> anyhow::Result<()> {use crate::ui::anim::Easing;use anyhow::Context;+ // The tabs are clipped at the viewport already; over a see-through+ // bar this fade would only darken a band of it.+ if self.chrome_see_through() {+ return Ok(());+ }if row_height == 0 || viewport_right <= viewport_left {return Ok(());diff --git a/wezterm-gui/src/termwindow/ui/plugin_panel.rs b/wezterm-gui/src/termwindow/ui/plugin_panel.rsindex fb5c7899..e97cec69 100644--- a/wezterm-gui/src/termwindow/ui/plugin_panel.rs+++ b/wezterm-gui/src/termwindow/ui/plugin_panel.rs@@ -73,6 +73,10 @@ const ENV_EVERY: Duration = Duration::from_millis(100);/// The most quads a painting is recorded with: a glyph each, a column for/// each pixel a line or an area crosses. What is beyond it is left out.const QUAD_LIMIT: usize = 100_000;+/// The most rectangles of the panel's ground a see-through painting cuts out+/// of what was drawn before them, each a pass over all of that. Any after+/// these are painted, as an opaque painting paints them.+const GROUND_CUT_LIMIT: usize = 64;/// The most a plugin's ask brings back from another machine: with the/// answer carried as base64, it fits in a frame to the plugin.const ASK_BYTES: usize = 8 * 1024 * 1024;@@ -212,6 +216,8 @@ struct PaintKey {/// Bumped when the glyphs the quads point into may have moved.shapes: usize,chrome: UiPalette,+ /// See-through, grounds are cut out rather than painted.+ see_through: bool,sizes: [f64; 3],mono_size: f64,}@@ -1213,6 +1219,7 @@ impl TermWindow {window: (self.dimensions.pixel_width, self.dimensions.pixel_height),shapes: self.shape_generation,chrome: *chrome,+ see_through: self.chrome_see_through(),sizes: fonts.sizes,mono_size: fonts.mono_size,};@@ -1241,17 +1248,81 @@ impl TermWindow {) -> anyhow::Result<Vec<(Bounds, HeapQuadAllocator)>> {let mut regions: Vec<(Bounds, HeapQuadAllocator)> = Vec::new();let mut budget = QUAD_LIMIT;+ let mut cuts = GROUND_CUT_LIMIT;for draw in &shown.player.draw() {+ // A rectangle of the panel's own ground covers what was drawn+ // before it. See-through it is not painted, since a second coat+ // would show, so what it covers is cut out instead.+ let mut ground_cut = false;+ if cuts > 0 {+ let cover = self.plugin_ground_cover(shown, draw);+ if !cover.is_empty() {+ for (_, heap) in regions.iter_mut() {+ heap.occlude(&cover);+ }+ cuts -= 1;+ ground_cut = true;+ }+ }if regions.last().is_none_or(|(clip, _)| *clip != draw.clip) {regions.push((draw.clip, HeapQuadAllocator::default()));}let (_, heap) = regions.last_mut().expect("pushed above");let mut recorded = TripleLayerQuadAllocator::Heap(heap);- self.paint_plugin_panel_draw(&mut recorded, shown, draw, fonts, chrome, &mut budget)?;+ self.paint_plugin_panel_draw(+ &mut recorded,+ shown,+ draw,+ fonts,+ chrome,+ &mut budget,+ ground_cut,+ )?;}Ok(regions)}+ /// Where, see-through, `draw` is a rectangle of the panel's own ground,+ /// the part of the window it covers. Rounded, that is less its corners:+ /// a band across and a band down, the corners' content left standing.+ fn plugin_ground_cover(&self, shown: &Shown, draw: &Draw<'_>) -> Vec<QuadClipRect> {+ let Drawn::Rect(rect) = draw.what else {+ return Vec::new();+ };+ if rect.fill != Some(Color::Token(Token::Bg)) || !self.chrome_see_through() {+ return Vec::new();+ }+ let (x, y, scale) = (shown.origin.0, shown.origin.1, shown.scale);+ let left = x + (rect.x + draw.dx) * scale;+ let top = y + (rect.y + draw.dy) * scale;+ let right = left + rect.w.max(0.0) * scale;+ let bottom = top + rect.h.max(0.0) * scale;+ let radius = (rect.radius * scale)+ .max(0.0)+ .min((right - left) / 2.0)+ .min((bottom - top) / 2.0);+ let bands = if radius > 0.0 {+ vec![+ (left, top + radius, right, bottom - radius),+ (left + radius, top, right - radius, bottom),+ ]+ } else {+ vec![(left, top, right, bottom)]+ };+ bands+ .into_iter()+ .filter_map(|(left, top, right, bottom)| {+ let left = left.max(x + draw.clip.left * scale);+ let top = top.max(y + draw.clip.top * scale);+ let right = right.min(x + draw.clip.right * scale);+ let bottom = bottom.min(y + draw.clip.bottom * scale);+ (right > left && bottom > top).then(|| {+ QuadClipRect::from_top_left_pixels(left, top, right, bottom, &self.dimensions)+ })+ })+ .collect()+ }+fn lay_plugin_panel_heap(&self,layers: &mut TripleLayerQuadAllocator,@@ -1270,6 +1341,7 @@ impl TermWindow {heap.apply_to_clipped(layers, clip, 1.0)}+ #[allow(clippy::too_many_arguments)]fn paint_plugin_panel_draw(&self,layers: &mut TripleLayerQuadAllocator,@@ -1278,6 +1350,7 @@ impl TermWindow {fonts: &PanelFonts,chrome: &UiPalette,budget: &mut usize,+ ground_cut: bool,) -> anyhow::Result<()> {let scale = shown.scale;// What of the window the draw shows in, across.@@ -1311,7 +1384,10 @@ impl TermWindow {radius,border,}) => {- let fill = fill.map(|fill| color(chrome, fill));+ // A ground cut out of what came before it in+ // `record_plugin_panel` is not painted: see-through, a second+ // coat of the panel's ground would show as a darker block.+ let fill = fill.filter(|_| !ground_cut).map(|fill| color(chrome, fill));let border = border.map(|border| color(chrome, border));self.paint_panel_rect(layers, place(*x, *y, *w, *h), fill, border, radius * scale)}diff --git a/wezterm-gui/src/termwindow/ui/right_sidebar.rs b/wezterm-gui/src/termwindow/ui/right_sidebar.rsindex ee87c331..87df995d 100644--- a/wezterm-gui/src/termwindow/ui/right_sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/right_sidebar.rs@@ -6,7 +6,9 @@ use crate::markdown_editor::{NoteSpellingIssue, ProjectedCodeBlock, ProjectedObject, SaveState, SourceSelection,TableAlignment, VisualDocument, VisualLineKind,};-use crate::quad::{QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTrait};+use crate::quad::{+ QuadClipRect, QuadTrait, TripleLayerQuadAllocator, TripleLayerQuadAllocatorTrait,+};use crate::termwindow::remote_files::{download_name_candidates, invalidate_remote_connection, invalidate_remote_connection_if_dead,local_path_is_occupied, remote_connection_key, remote_connection_manager,@@ -81,6 +83,9 @@ const RIGHT_SIDEBAR_WIDTH_CELLS: usize = 40;const RIGHT_SIDEBAR_MIN_WIDTH: usize = 340;const RIGHT_SIDEBAR_MAX_WIDTH: usize = 900;const RIGHT_SIDEBAR_TOP_BAR_HEIGHT: usize = 82;+/// The largest recording buffer `paint_right_sidebar_contents` keeps for the+/// next frame: a long note or preview at a small font.+const RIGHT_SIDEBAR_SCRATCH_KEEP_BYTES: usize = 8 << 20;const RIGHT_SIDEBAR_CLOSE_BUTTON_SIZE: usize = 58;const RIGHT_SIDEBAR_CLOSE_ICON_SIZE: usize = 27;const RIGHT_SIDEBAR_CLOSE_BUTTON_X_ADJUST: usize = 8;@@ -1798,6 +1803,7 @@ impl crate::TermWindow {self.right_sidebar_hover_was_presented = false;self.right_sidebar_collapsed = !self.right_sidebar_collapsed;if self.right_sidebar_collapsed {+ self.right_sidebar_contents_scratch.clear();if self.right_sidebar_mode == RightSidebarMode::Tasks {self.clear_right_sidebar_text_focus();}@@ -7229,7 +7235,8 @@ impl crate::TermWindow {let chrome = self.chrome();let foreground = chrome.text;let muted_fg = chrome.secondary_text;- let sidebar_bg = chrome.workspace_sidebar_bg;+ let sidebar_bg = self.chrome_surface(chrome.workspace_sidebar_bg);+ let see_through = self.chrome_see_through();let settings = crate::native_settings::load();let base_font_size = crate::native_settings::right_sidebar_font_size(&settings);let ui_font = self@@ -7266,8 +7273,9 @@ impl crate::TermWindow {if let Some(pane_rect) = self.right_sidebar_note_pane_rect() {// Chrome only; paint_note_sidebar paints the editor into this- // rect later in the frame.- if pane_rect.y > 0 {+ // rect later in the frame. The band above it is the window+ // border's, which see-through must not get a second coat.+ if pane_rect.y > 0 && !see_through {self.filled_rectangle(layers,0,@@ -7317,14 +7325,19 @@ impl crate::TermWindow {// A plugin's extended view: its ground and edge here, what the// plugin draws in it with the panel's, below.if let Some(extended_rect) = self.right_sidebar_plugin_extended_rect() {+ // From the window's top, but for the border's band see-through.+ let ground_top = if see_through { extended_rect.y } else { 0 };self.filled_rectangle(layers,0,euclid::rect(extended_rect.x as f32,- 0.0,+ ground_top as f32,extended_rect.width as f32,- extended_rect.y.saturating_add(extended_rect.height) as f32,+ extended_rect+ .y+ .saturating_add(extended_rect.height)+ .saturating_sub(ground_top) as f32,),sidebar_bg,)@@ -7350,7 +7363,7 @@ impl crate::TermWindow {.context("right sidebar plugin extended view left separator")?;}- if rect.y > 0 {+ if rect.y > 0 && !see_through {self.filled_rectangle(layers,0,@@ -7719,6 +7732,44 @@ impl crate::TermWindow {if !matches!(self.right_sidebar_mode, RightSidebarMode::Plugin(_)) {self.close_plugin_panel();}+ let panel_bottom = rect.y.saturating_add(rect.height);+ self.paint_right_sidebar_contents(layers, |this, layers| {+ this.paint_right_sidebar_panel(+ layers,+ &ui_font,+ ui_metrics,+ chrome,+ foreground,+ muted_fg,+ rect,+ content_x,+ content_top,+ content_width,+ panel_bottom,+ base_font_size,+ icon_size,+ )+ })+ }++ /// The open mode's panel, under the mode selector.+ #[allow(clippy::too_many_arguments)]+ fn paint_right_sidebar_panel(+ &mut self,+ layers: &mut TripleLayerQuadAllocator,+ ui_font: &Rc<LoadedFont>,+ ui_metrics: RenderMetrics,+ chrome: UiPalette,+ foreground: LinearRgba,+ muted_fg: LinearRgba,+ rect: RightSidebarRect,+ content_x: usize,+ content_top: usize,+ content_width: usize,+ panel_bottom: usize,+ base_font_size: f64,+ icon_size: usize,+ ) -> anyhow::Result<()> {match self.right_sidebar_mode {RightSidebarMode::Chat => {let file_font_size = self.right_sidebar_file_preview_font_size();@@ -7739,7 +7790,7 @@ impl crate::TermWindow {content_x,content_top,content_width,- rect.y.saturating_add(rect.height),+ panel_bottom,file_icon_size,)?;return Ok(());@@ -7748,7 +7799,7 @@ impl crate::TermWindow {let stage = crate::input_diagnostics::StageTimer::begin("snippet_paint");let result = self.paint_snippets_sidebar(layers,- &ui_font,+ ui_font,ui_metrics,chrome,foreground,@@ -7756,7 +7807,7 @@ impl crate::TermWindow {content_x,content_top,content_width,- rect.y.saturating_add(rect.height),+ panel_bottom,icon_size,);stage.finish(result.is_ok());@@ -7767,7 +7818,7 @@ impl crate::TermWindow {let stage = crate::input_diagnostics::StageTimer::begin("note_paint");let result = self.paint_note_sidebar(layers,- &ui_font,+ ui_font,ui_metrics,chrome,foreground,@@ -7775,7 +7826,7 @@ impl crate::TermWindow {content_x,content_top,content_width,- rect.y.saturating_add(rect.height),+ panel_bottom,base_font_size,);stage.finish(result.is_ok());@@ -7789,7 +7840,7 @@ impl crate::TermWindow {}self.paint_agents_sidebar(layers,- &ui_font,+ ui_font,ui_metrics,chrome,foreground,@@ -7797,7 +7848,7 @@ impl crate::TermWindow {content_x,content_top,content_width,- rect.y.saturating_add(rect.height),+ panel_bottom,)?;return Ok(());}@@ -7813,13 +7864,13 @@ impl crate::TermWindow {layers,&panel.id,&paint,- &ui_font,+ ui_font,ui_metrics,chrome,rect.x + self.ui_px(SIDEBAR_INSET),content_top,rect.width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 2),- rect.y.saturating_add(rect.height),+ panel_bottom,)?;// Its extended view from the top, as the file preview// is, with the preview's close button where the preview@@ -7839,7 +7890,7 @@ impl crate::TermWindow {self.paint_plugin_panel_extended(layers,&paint,- &ui_font,+ ui_font,ui_metrics,chrome,extended_rect.x + self.ui_px(SIDEBAR_INSET),@@ -8105,103 +8156,127 @@ impl crate::TermWindow {visible_height,row_metrics.row_height,);- let selected = self- .right_sidebar_note- .document- .as_ref()- .map(|document| document.relative_path.as_str());- for index in range {- let row = &rows[index];- let y = tree_top as f32 + (index * row_metrics.row_height) as f32- - self.right_sidebar_note_tree_scroll_offset;- let y = y.floor().max(tree_top as f32) as usize;- let height = row_metrics.row_height.min(tree_bottom.saturating_sub(y));- if height == 0 {- continue;- }- let active = !row.is_dir && selected == Some(row.relative_path.as_str());- let hovered = self.is_pointer_over_ui_rect(content_x, y, content_width, height);- if active || hovered {- self.fill_rounded_rectangle(- layers,- 1,- euclid::rect(- content_x as f32,- y as f32,- content_width as f32,- height as f32,- ),- if active {- chrome.selected_bg.mul_alpha(0.46)- } else {- chrome.sidebar_button_hover_bg- },- self.ui_f32(SIDEBAR_ROW_RADIUS),- )?;- }- self.ui_items.push(UIItem {- x: content_x,- y,- width: content_width,- height,- item_type: UIItemType::RightSidebarNoteTreeRow(row.relative_path.clone()),- });- let indent = row- .depth- .saturating_mul(row_metrics.indent_step)- .min(content_width.saturating_sub(24));- let icon_x = content_x + self.ui_px(SIDEBAR_INSET) + indent;- let icon_y = y + height.saturating_sub(row_metrics.icon_size) / 2;- if row.is_dir {- self.paint_sidebar_icon(- layers,- if self- .right_sidebar_note_tree_expanded- .contains(&row.relative_path)- {- SvgIcon::FolderOpen- } else {- SvgIcon::Folder- },- icon_x,- icon_y,- row_metrics.icon_size,- muted_fg,- )?;- } else {- if let Some(icon) = material_file_icon_for_name(&row.name) {- self.paint_sidebar_material_icon(+ let see_through = self.chrome_see_through();+ self.paint_right_sidebar_contents(layers, |this, layers| {+ let selected = this+ .right_sidebar_note+ .document+ .as_ref()+ .map(|document| document.relative_path.as_str());+ for index in range {+ let row = &rows[index];+ let y = tree_top as f32 + (index * row_metrics.row_height) as f32+ - this.right_sidebar_note_tree_scroll_offset;+ // Opaque, a row scrolled part-way out stays whole at the top,+ // under the fade. See-through has no fade, so the row keeps its+ // place and what is above the list is cut away after the loop.+ let y = y+ .floor()+ .max(if see_through { 0.0 } else { tree_top as f32 })+ as usize;+ let height = row_metrics.row_height.min(tree_bottom.saturating_sub(y));+ // What is hovered and clicked: the part inside the list.+ let hit_y = y.max(tree_top);+ let hit_height = (y + height).saturating_sub(hit_y);+ if hit_height == 0 {+ continue;+ }+ let active = !row.is_dir && selected == Some(row.relative_path.as_str());+ let hovered =+ this.is_pointer_over_ui_rect(content_x, hit_y, content_width, hit_height);+ if active || hovered {+ this.fill_rounded_rectangle(layers,- icon,- icon_x,- icon_y,- row_metrics.icon_size,+ 1,+ euclid::rect(+ content_x as f32,+ y as f32,+ content_width as f32,+ height as f32,+ ),+ if active {+ chrome.selected_bg.mul_alpha(0.46)+ } else {+ chrome.sidebar_button_hover_bg+ },+ this.ui_f32(SIDEBAR_ROW_RADIUS),)?;- } else {- self.paint_sidebar_icon(+ }+ this.ui_items.push(UIItem {+ x: content_x,+ y: hit_y,+ width: content_width,+ height: hit_height,+ item_type: UIItemType::RightSidebarNoteTreeRow(row.relative_path.clone()),+ });+ let indent = row+ .depth+ .saturating_mul(row_metrics.indent_step)+ .min(content_width.saturating_sub(24));+ let icon_x = content_x + this.ui_px(SIDEBAR_INSET) + indent;+ let icon_y = y + height.saturating_sub(row_metrics.icon_size) / 2;+ if row.is_dir {+ this.paint_sidebar_icon(layers,- SvgIcon::FileText,+ if this+ .right_sidebar_note_tree_expanded+ .contains(&row.relative_path)+ {+ SvgIcon::FolderOpen+ } else {+ SvgIcon::Folder+ },icon_x,icon_y,row_metrics.icon_size,- if active { foreground } else { muted_fg },+ muted_fg,)?;+ } else {+ if let Some(icon) = material_file_icon_for_name(&row.name) {+ this.paint_sidebar_material_icon(+ layers,+ icon,+ icon_x,+ icon_y,+ row_metrics.icon_size,+ )?;+ } else {+ this.paint_sidebar_icon(+ layers,+ SvgIcon::FileText,+ icon_x,+ icon_y,+ row_metrics.icon_size,+ if active { foreground } else { muted_fg },+ )?;+ }}+ let text_x = icon_x + row_metrics.icon_size + row_metrics.icon_gap;+ this.paint_sidebar_text(+ layers,+ ui_font,+ ui_metrics,+ &row.name,+ text_x,+ y + height.saturating_sub(ui_metrics.cell_size.height as usize) / 2,+ content_x+ .saturating_add(content_width)+ .saturating_sub(text_x + this.ui_px(SIDEBAR_INSET)),+ if active { foreground } else { muted_fg },+ )?;}- let text_x = icon_x + row_metrics.icon_size + row_metrics.icon_gap;- self.paint_sidebar_text(- layers,- ui_font,- ui_metrics,- &row.name,- text_x,- y + height.saturating_sub(ui_metrics.cell_size.height as usize) / 2,- content_x- .saturating_add(content_width)- .saturating_sub(text_x + self.ui_px(SIDEBAR_INSET)),- if active { foreground } else { muted_fg },- )?;- }+ if see_through {+ this.paint_right_sidebar_file_mask(+ layers,+ chrome,+ content_x,+ content_top,+ content_width,+ tree_top.saturating_sub(content_top),+ )?;+ }+ Ok(())+ })?;if self.right_sidebar_note_tree_scroll_offset > 0.0 {self.paint_right_sidebar_file_top_fade(@@ -10943,8 +11018,9 @@ impl crate::TermWindow {muted_fg: LinearRgba,rect: RightSidebarRect,) -> anyhow::Result<()> {- let sidebar_bg = chrome.workspace_sidebar_bg;- if rect.y > 0 {+ let sidebar_bg = self.chrome_surface(chrome.workspace_sidebar_bg);+ // See-through, the band above is the window border's alone.+ if rect.y > 0 && !self.chrome_see_through() {self.filled_rectangle(layers,0,@@ -10997,18 +11073,20 @@ impl crate::TermWindow {let content_width = rect.width.saturating_sub(self.ui_px(SIDEBAR_INSET) * 4);let content_top = rect.y + self.ui_px(SIDEBAR_INSET) * 2;let content_bottom = rect.y.saturating_add(rect.height);- self.paint_files_preview(- layers,- ui_font,- ui_metrics,- chrome,- foreground,- muted_fg,- content_x,- content_top,- content_width,- content_bottom,- )+ self.paint_right_sidebar_contents(layers, |this, layers| {+ this.paint_files_preview(+ layers,+ ui_font,+ ui_metrics,+ chrome,+ foreground,+ muted_fg,+ content_x,+ content_top,+ content_width,+ content_bottom,+ )+ })}#[allow(clippy::too_many_arguments)]@@ -16164,7 +16242,7 @@ impl crate::TermWindow {width: usize,height: usize,) -> anyhow::Result<()> {- if width == 0 || height == 0 {+ if width == 0 || height == 0 || self.chrome_see_through() {return Ok(());}let opaque_height = self.ui_px(12).min(height);@@ -16191,17 +16269,59 @@ impl crate::TermWindow {if width == 0 || height == 0 {return Ok(());}+ if self.right_sidebar_recording_contents {+ if let TripleLayerQuadAllocator::Heap(contents) = layers {+ contents.occlude(&[QuadClipRect::from_top_left_pixels(+ x as f32,+ y as f32,+ (x + width) as f32,+ (y + height) as f32,+ &self.dimensions,+ )]);+ return Ok(());+ }+ }self.filled_rectangle(layers,2,euclid::rect(x as f32, y as f32, width as f32, height as f32),- chrome.workspace_sidebar_bg,+ self.chrome_surface(chrome.workspace_sidebar_bg),).context("right sidebar file scroll mask")?;Ok(())}+ /// Paints `contents` -- what a panel holds, over the ground it has+ /// already painted -- into `layers`. See-through, they are recorded on+ /// their own first, so that the scroll masks painted among them cut what+ /// they cover out of what `contents` painted before them: painting the+ /// ground over it again, as an opaque window does, would show as a darker+ /// band. Nested, the inner block's masks cut only the inner block.+ pub(crate) fn paint_right_sidebar_contents(+ &mut self,+ layers: &mut TripleLayerQuadAllocator,+ contents: impl FnOnce(&mut Self, &mut TripleLayerQuadAllocator) -> anyhow::Result<()>,+ ) -> anyhow::Result<()> {+ if !self.chrome_see_through() {+ return contents(self, layers);+ }+ let mut recorded = self+ .right_sidebar_contents_scratch+ .pop()+ .unwrap_or_default();+ recorded.recycle();+ let outer = std::mem::replace(&mut self.right_sidebar_recording_contents, true);+ let result = contents(self, &mut TripleLayerQuadAllocator::Heap(&mut recorded));+ self.right_sidebar_recording_contents = outer;+ let applied = result.and_then(|()| recorded.apply_to(layers));+ // Kept for the next frame, unless a long note made it large.+ if recorded.resident_bytes() <= RIGHT_SIDEBAR_SCRATCH_KEEP_BYTES {+ self.right_sidebar_contents_scratch.push(recorded);+ }+ applied+ }+pub(crate) fn paint_right_sidebar_file_top_fade(&mut self,layers: &mut TripleLayerQuadAllocator,@@ -16211,7 +16331,9 @@ impl crate::TermWindow {width: usize,height: usize,) -> anyhow::Result<()> {- if width == 0 || height == 0 {+ // See-through, the list is cut where the mask begins instead: a fade+ // of the ground over it would darken the ground.+ if width == 0 || height == 0 || self.chrome_see_through() {return Ok(());}@@ -16222,7 +16344,8 @@ impl crate::TermWindow {layers,2,euclid::rect(x as f32, (y + step) as f32, width as f32, 1.0),- chrome.workspace_sidebar_bg.mul_alpha(alpha),+ self.chrome_surface(chrome.workspace_sidebar_bg)+ .mul_alpha(alpha),).context("right sidebar file top fade")?;}diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rsindex 8b848527..20961d4a 100644--- a/wezterm-gui/src/termwindow/ui/sidebar.rs+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs@@ -267,6 +267,9 @@ impl crate::TermWindow {self.workspace_sidebar_collapsed = collapsed;crate::native_settings::save_workspace_sidebar_shown(shown);}+ if collapsed {+ self.workspace_sidebar_scratch = Default::default();+ }// Either way the hover machine must not act on the pointer still// sitting where it was: collapsing must not instantly re-reveal, and// docking makes the reveal moot. The native titlebar button also@@ -1087,7 +1090,8 @@ impl crate::TermWindow {let chrome = self.chrome();let foreground = chrome.text;- let sidebar_bg = chrome.workspace_sidebar_bg;+ let sidebar_bg = self.chrome_surface(chrome.workspace_sidebar_bg);+ let see_through = self.chrome_see_through();let sidebar_separator = chrome.separator;let selected_bg = chrome.sidebar_row_active_bg;let selected_border = chrome.sidebar_row_active_border;@@ -1110,13 +1114,17 @@ impl crate::TermWindow {let settings_footer_height = layout.settings_footer_height;if rect.y > 0 {- self.filled_rectangle(- layers,- 0,- euclid::rect(rect.x as f32, 0.0, rect.width as f32, rect.y as f32),- sidebar_bg,- )- .context("sidebar header background")?;+ // See-through, `paint_window_borders` paints this band, and a+ // second coat would show.+ if !see_through {+ self.filled_rectangle(+ layers,+ 0,+ euclid::rect(rect.x as f32, 0.0, rect.width as f32, rect.y as f32),+ sidebar_bg,+ )+ .context("sidebar header background")?;+ }self.ui_items.push(UIItem {x: rect.x,y: 0,@@ -2634,10 +2642,33 @@ impl crate::TermWindow {}}+ // See-through, a row scrolled under the header or the footer is cut+ // off there: the covers painted over it opaque would show as darker+ // bands. Only a recording can be cut, so the see-through callers+ // record; anything else keeps the covers.+ let list_cut = match (see_through, list_quads_start, &mut *layers) {+ (true, Some(start), TripleLayerQuadAllocator::Heap(heap)) => {+ heap.clip_after(+ &start,+ crate::quad::QuadClipRect::from_top_left_pixels(+ panel_x as f32,+ list_top_f,+ (panel_x + panel_width) as f32,+ content_bottom_f,+ &self.dimensions,+ ),+ );+ true+ }+ _ => false,+ };self.workspace_sidebar_list_quads = list_quads_start.zip(layers.heap_mark());let header_mask_height = list_top.saturating_sub(panel_y);- if header_mask_height > 0 {+ // Covers what the list left under the header, then paints the header+ // again over that. Not once the list is cut: the header painted first+ // is then the one in view, and a second coat of it would show.+ if header_mask_height > 0 && !list_cut {self.filled_rectangle(layers,2,@@ -2856,7 +2887,7 @@ impl crate::TermWindow {}}- if max_scroll > 0.0 && scroll_offset > 0.0 {+ if max_scroll > 0.0 && scroll_offset > 0.0 && !list_cut {let fade_height = self.ui_px(SIDEBAR_TOP_FADE_HEIGHT).min(content_bottom.saturating_sub(list_top));@@ -2881,7 +2912,7 @@ impl crate::TermWindow {let bottom_mask_height = panel_y.saturating_add(panel_height).saturating_sub(content_bottom);- if bottom_mask_height > 0 {+ if bottom_mask_height > 0 && !list_cut {self.filled_rectangle(layers,2,@@ -2901,7 +2932,7 @@ impl crate::TermWindow {.ui_px(SIDEBAR_SETTINGS_FADE_HEIGHT).min(settings_footer_y.saturating_sub(panel_y)).min(content_bottom.saturating_sub(panel_y));- if max_scroll > 0.0 && fade_height > 0 {+ if max_scroll > 0.0 && fade_height > 0 && !list_cut {for step in 0..fade_height {let progress = (step + 1) as f32 / fade_height as f32;self.filled_rectangle(@@ -2919,18 +2950,20 @@ impl crate::TermWindow {}}- self.filled_rectangle(- layers,- 2,- euclid::rect(- panel_x as f32,- settings_footer_y as f32,- panel_width as f32,- settings_footer_height as f32,- ),- sidebar_bg,- )- .context("sidebar settings footer background")?;+ if !list_cut {+ self.filled_rectangle(+ layers,+ 2,+ euclid::rect(+ panel_x as f32,+ settings_footer_y as f32,+ panel_width as f32,+ settings_footer_height as f32,+ ),+ sidebar_bg,+ )+ .context("sidebar settings footer background")?;+ }let settings_row_x = item_x + self.ui_px(SIDEBAR_SETTINGS_ROW_SIDE_PADDING);let settings_row_y = (settings_footer_y + self.ui_px(SIDEBAR_SETTINGS_ROW_TOP_PADDING))@@ -3214,7 +3247,7 @@ impl crate::TermWindow {ring,ring,),- chrome.workspace_sidebar_bg,+ self.chrome_surface(chrome.workspace_sidebar_bg),ring / 2.0,).context("sidebar update dot ring")?;