From 7d79933d28fd9d49c1383f5da683157870f5930c Mon Sep 17 00:00:00 2001 From: YuraIz <7516890@gmail.com> Date: Sun, 13 Nov 2022 19:55:07 +0300 Subject: [PATCH] integrated-title-bar: Ignore style config on macos and windows --- config/src/config.rs | 3 +++ wezterm-gui/src/tabbar.rs | 19 +++++++++++++++---- wezterm-gui/src/termwindow/render.rs | 10 ++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/config/src/config.rs b/config/src/config.rs index a0cfe0a25..6a6803b68 100644 --- a/config/src/config.rs +++ b/config/src/config.rs @@ -79,6 +79,9 @@ pub struct Config { #[dynamic(default)] pub window_decorations: WindowDecorations, + /// Controls window buttons position and style + /// for fancy window decorations. + /// Has no effect on macOS or Windows. #[dynamic(default)] pub log_unknown_escape_sequences: bool, diff --git a/wezterm-gui/src/tabbar.rs b/wezterm-gui/src/tabbar.rs index 0106b7db9..1769da53e 100644 --- a/wezterm-gui/src/tabbar.rs +++ b/wezterm-gui/src/tabbar.rs @@ -246,7 +246,12 @@ impl TabBarState { remove_hide_button, remove_maximize_button, .. - } = config.fancy_window_decorations; + } = if cfg!(any(windows, target_os = "macos")) { + // Ignore changes to config on windows and macos + window::FancyWindowDecorations::default() + } else { + config.fancy_window_decorations.clone() + }; let button_order = if is_left { ['X', '.', '-'] @@ -401,7 +406,7 @@ impl TabBarState { let mut x = 0; let mut items = vec![]; - if fancy_window_decorations && config.fancy_window_decorations.is_left { + if fancy_window_decorations && config.fancy_window_decorations.is_left && !cfg!(widnows) { Self::fancy_window_decorations(mouse_x, &mut x, config, &mut items, &mut line, &colors); } @@ -499,7 +504,10 @@ impl TabBarState { } // Reserve place for buttons - let title_width = if fancy_window_decorations && !config.fancy_window_decorations.is_left { + let title_width = if fancy_window_decorations + && !config.fancy_window_decorations.is_left + && !cfg!(target_os = "macos") + { let window_hide = parse_status_text(&config.tab_bar_style.window_hide, CellAttributes::default()); let window_hide_hover = parse_status_text( @@ -552,7 +560,10 @@ impl TabBarState { line.insert_cell(x, black_cell.clone(), title_width, SEQ_ZERO); } - if fancy_window_decorations && !config.fancy_window_decorations.is_left { + if fancy_window_decorations + && !config.fancy_window_decorations.is_left + && !cfg!(target_os = "macos") + { x = title_width; Self::fancy_window_decorations(mouse_x, &mut x, config, &mut items, &mut line, &colors); } diff --git a/wezterm-gui/src/termwindow/render.rs b/wezterm-gui/src/termwindow/render.rs index 2737594fc..fdf1774fa 100644 --- a/wezterm-gui/src/termwindow/render.rs +++ b/wezterm-gui/src/termwindow/render.rs @@ -308,6 +308,9 @@ fn window_button_element( ) -> Element { use window::FancyWindowDecorationsStyle as Style; + #[cfg(any(windows, targer_os = "macos"))] + let style = Style::default(); + let poly = match style { Style::Windows => { use window_buttons::windows::{CLOSE, HIDE, MAXIMIZE, RESTORE}; @@ -1180,7 +1183,9 @@ impl super::TermWindow { TabBarItem::WindowHideButton | TabBarItem::WindowMaximizeButton | TabBarItem::WindowCloseButton => { - if self.config.fancy_window_decorations.is_left { + if (self.config.fancy_window_decorations.is_left || cfg!(target_os = "macos")) + && cfg!(not(windows)) + { left_eles.push(item_to_elem(item)) } else { right_eles.push(item_to_elem(item)) @@ -1270,7 +1275,8 @@ impl super::TermWindow { let window_buttons_at_left = self.config.window_decorations == window::WindowDecorations::FANCY - && self.config.fancy_window_decorations.is_left; + && (self.config.fancy_window_decorations.is_left + || cfg!(target_os = "macos") && cfg!(not(windows))); let left_padding = if window_buttons_at_left { 0.0 } else { 0.5 };