diff --git a/wezterm-gui/src/termwindow/render.rs b/wezterm-gui/src/termwindow/render.rs index 52b5cc2ce..c22b01c92 100644 --- a/wezterm-gui/src/termwindow/render.rs +++ b/wezterm-gui/src/termwindow/render.rs @@ -338,7 +338,6 @@ fn window_button_element( is_maximized: bool, font: &Rc, metrics: &RenderMetrics, - colors: &TabBarColors, config: &ConfigHandle, ) -> Element { use window::IntegratedTitleButtonStyle as Style; @@ -346,8 +345,12 @@ fn window_button_element( let style = config.integrated_title_button_style; + if style == Style::Native { + return Element::new(font, ElementContent::Text(String::new())); + } + let poly = { - let (CLOSE, HIDE, MAXIMIZE, RESTORE) = match style { + let (close, hide, maximize, restore) = match style { Style::Windows => { use window_buttons::windows::{CLOSE, HIDE, MAXIMIZE, RESTORE}; (CLOSE, HIDE, MAXIMIZE, RESTORE) @@ -356,22 +359,24 @@ fn window_button_element( use window_buttons::gnome::{CLOSE, HIDE, MAXIMIZE, RESTORE}; (CLOSE, HIDE, MAXIMIZE, RESTORE) } + Style::Native => unreachable!(), }; let poly = match window_button { - Button::Hide => HIDE, + Button::Hide => hide, Button::Maximize => { if is_maximized { - RESTORE + restore } else { - MAXIMIZE + maximize } } - Button::Close => CLOSE, + Button::Close => close, }; match style { Style::Windows => window_buttons::windows::sized_poly(poly), Style::Gnome => window_buttons::gnome::sized_poly(poly), + Style::Native => unreachable!(), } }; @@ -442,6 +447,7 @@ fn window_button_element( bottom: Dimension::Pixels(7.), }) } + Style::Native => unreachable!(), }; let foreground = config.integrated_title_button_color.clone(); @@ -461,6 +467,7 @@ fn window_button_element( let window_button_colors_fn = match style { Style::Windows => window_buttons::windows::window_button_colors, Style::Gnome => window_buttons::gnome::window_button_colors, + Style::Native => unreachable!(), }; let colors = window_button_colors_fn(background_lightness, foreground, window_button); @@ -1140,7 +1147,6 @@ impl super::TermWindow { self.window_state.contains(window::WindowState::MAXIMIZED), &font, &metrics, - &colors, &self.config, ), } diff --git a/wezterm-input-types/src/lib.rs b/wezterm-input-types/src/lib.rs index a820c1724..80a64f75a 100644 --- a/wezterm-input-types/src/lib.rs +++ b/wezterm-input-types/src/lib.rs @@ -1465,11 +1465,52 @@ pub enum IntegratedTitleButtonAlignment { Left, } -#[derive(Debug, Default, FromDynamic, ToDynamic, PartialEq, Eq, Clone, Copy)] +#[derive(Debug, Default, ToDynamic, PartialEq, Eq, Clone, Copy)] pub enum IntegratedTitleButtonStyle { #[default] Windows, Gnome, + // macos only + Native, +} + +impl FromDynamic for IntegratedTitleButtonStyle { + fn from_dynamic( + value: &wezterm_dynamic::Value, + _options: wezterm_dynamic::FromDynamicOptions, + ) -> Result + where + Self: Sized, + { + let type_name = "integrated_title_button_style"; + + if let wezterm_dynamic::Value::String(string) = value { + let style = match string.as_str() { + "Windows" => Self::Windows, + "Gnome" => Self::Gnome, + "Native" if cfg!(target_os = "macos") => Self::Native, + _ => { + let possible: &[&str] = if cfg!(target_os = "macos") { + &["Windows", "Gnome", "Native"] + } else { + &["Windows", "Gnome"] + }; + return Err(wezterm_dynamic::Error::InvalidVariantForType { + variant_name: string.to_string(), + type_name, + possible, + }); + } + }; + Ok(style) + } else { + Err(wezterm_dynamic::Error::InvalidVariantForType { + variant_name: value.variant_name().to_string(), + type_name, + possible: &["String"], + }) + } + } } /// Map c to its Ctrl equivalent.