From 0a4932cf2952dbb7c587cfb6f528f3f6a6fcff1f Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Fri, 31 Mar 2023 22:35:04 -0700 Subject: [PATCH] tab bar: fixup placement of macos native titlebar buttons --- wezterm-gui/src/tabbar.rs | 20 +++++++++----------- wezterm-gui/src/termwindow/render.rs | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/wezterm-gui/src/tabbar.rs b/wezterm-gui/src/tabbar.rs index c945d6fb2..b7bd0dfc7 100644 --- a/wezterm-gui/src/tabbar.rs +++ b/wezterm-gui/src/tabbar.rs @@ -358,13 +358,6 @@ impl TabBarState { let mut x = 0; let mut items = vec![]; - if use_integrated_title_buttons - && config.integrated_title_button_style != IntegratedTitleButtonStyle::MacOsNative - && config.integrated_title_button_alignment == IntegratedTitleButtonAlignment::Left - { - Self::integrated_title_buttons(mouse_x, &mut x, config, &mut items, &mut line, &colors); - } - let black_cell = Cell::blank_with_attrs( CellAttributes::default() .set_background(ColorSpec::TrueColor(*colors.background())) @@ -376,11 +369,18 @@ impl TabBarState { && config.use_fancy_tab_bar == false { for _ in 0..10 as usize { - line.insert_cell(x, black_cell.clone(), title_width, SEQ_ZERO); + line.insert_cell(0, black_cell.clone(), title_width, SEQ_ZERO); x += 1; } } + if use_integrated_title_buttons + && config.integrated_title_button_style != IntegratedTitleButtonStyle::MacOsNative + && config.integrated_title_button_alignment == IntegratedTitleButtonAlignment::Left + { + Self::integrated_title_buttons(mouse_x, &mut x, config, &mut items, &mut line, &colors); + } + let left_status_line = parse_status_text(left_status, black_cell.attrs().clone()); if left_status_line.len() > 0 { items.push(TabEntry { @@ -549,17 +549,15 @@ impl TabBarState { pub fn compute_ui_items(&self, y: usize, cell_height: usize, cell_width: usize) -> Vec { let mut items = vec![]; - let mut last_x = 0; for entry in self.items.iter() { items.push(UIItem { - x: last_x * cell_width, + x: entry.x * cell_width, width: entry.width * cell_width, y, height: cell_height, item_type: UIItemType::TabBar(entry.item), }); - last_x += entry.width; } items diff --git a/wezterm-gui/src/termwindow/render.rs b/wezterm-gui/src/termwindow/render.rs index ea76d491f..8002fe275 100644 --- a/wezterm-gui/src/termwindow/render.rs +++ b/wezterm-gui/src/termwindow/render.rs @@ -1156,6 +1156,23 @@ impl super::TermWindow { - (1.5 * metrics.cell_size.width as f32)) .max(0.); + // Reserve space for the native titlebar buttons + if self + .config + .window_decorations + .contains(::window::WindowDecorations::INTEGRATED_BUTTONS) + && self.config.integrated_title_button_style == IntegratedTitleButtonStyle::MacOsNative + { + left_status.push( + Element::new(&font, ElementContent::Text("".to_string())).margin(BoxDimension { + left: Dimension::Cells(4.0), // FIXME: determine exact width of macos ... buttons + right: Dimension::Cells(0.), + top: Dimension::Cells(0.), + bottom: Dimension::Cells(0.), + }), + ); + } + for item in items { match item.item { TabBarItem::LeftStatus => left_status.push(item_to_elem(item)),