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): show, auto-hide or hide the window tab row
RoversX73266b2a19ad
diff --git a/thinkterm-i18n/i18n/de-DE.ftl b/thinkterm-i18n/i18n/de-DE.ftlindex 1cb76af4..1c3d83a5 100644--- a/thinkterm-i18n/i18n/de-DE.ftl+++ b/thinkterm-i18n/i18n/de-DE.ftl@@ -149,6 +149,11 @@ settings-agents-status = Agents-Statussettings-agents-status-description = Wie Agents zeigen, dass sie arbeiten oder auf Sie warten, im Status-Panel und in den Hover-Karten.settings-tab-bar-shade = Farbe der Tableistensettings-tab-bar-shade-description = Wie dunkel beide Tableisten sind, in einem durchscheinenden Fenster.+settings-window-tabs = Obere Tab-Leiste+settings-window-tabs-description = Automatisch ausblenden: Sie erscheint, wenn der Zeiger am oberen Rand ruht, und schiebt das Terminal nach unten, ohne seine Größe zu ändern; die Stecknadel hält sie fest. Ausgeblendet bleiben die Tabs erhalten: Wechseln Sie per Tastatur oder Befehlspalette.+settings-window-tabs-show = Anzeigen+settings-window-tabs-auto-hide = Automatisch+settings-window-tabs-hide = Ausblendensettings-terminal-shade = Farbe des Terminalssettings-terminal-shade-description = Wie dunkel der Hintergrund des Terminals ist, in einem durchscheinenden Fenster.settings-area-shade-dark = Dunkeldiff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftlindex 40ba5fda..d61bdbe9 100644--- a/thinkterm-i18n/i18n/en-US.ftl+++ b/thinkterm-i18n/i18n/en-US.ftl@@ -149,6 +149,11 @@ settings-agents-status = Agent statussettings-agents-status-description = How agents show they are working or waiting for you, in Status and the hover cards.settings-tab-bar-shade = Tab bar colorsettings-tab-bar-shade-description = How dark both tab bars are, in a see-through window.+settings-window-tabs = Top tab bar+settings-window-tabs-description = Auto-hide brings it down while the pointer rests at the top edge, pushing the terminal down without resizing it; its pin keeps it out. Hidden, the tabs are still there: switch with the keyboard or the command palette.+settings-window-tabs-show = Show+settings-window-tabs-auto-hide = Auto-hide+settings-window-tabs-hide = Hidesettings-terminal-shade = Terminal colorsettings-terminal-shade-description = How dark the terminal's background is, in a see-through window.settings-area-shade-dark = Darkdiff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftlindex 7d6e5662..0f950417 100644--- a/thinkterm-i18n/i18n/fr-FR.ftl+++ b/thinkterm-i18n/i18n/fr-FR.ftl@@ -149,6 +149,11 @@ settings-agents-status = État des agentssettings-agents-status-description = Comment les agents montrent qu'ils travaillent ou vous attendent, dans le panneau État et les cartes au survol.settings-tab-bar-shade = Couleur des barres d'ongletssettings-tab-bar-shade-description = Le ton des deux barres d'onglets, dans une fenêtre transparente.+settings-window-tabs = Barre d’onglets du haut+settings-window-tabs-description = Masquage automatique : elle descend quand le pointeur s’arrête en haut de la fenêtre et pousse le terminal vers le bas sans le redimensionner ; l’épingle la garde affichée. Masqués, les onglets restent là : passez de l’un à l’autre au clavier ou par la palette de commandes.+settings-window-tabs-show = Afficher+settings-window-tabs-auto-hide = Automatique+settings-window-tabs-hide = Masquersettings-terminal-shade = Couleur du terminalsettings-terminal-shade-description = Le ton du fond du terminal, dans une fenêtre transparente.settings-area-shade-dark = Sombrediff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftlindex ed7acc73..b743e447 100644--- a/thinkterm-i18n/i18n/ja-JP.ftl+++ b/thinkterm-i18n/i18n/ja-JP.ftl@@ -146,6 +146,11 @@ settings-agents-status = Agents の状態表示settings-agents-status-description = エージェントが作業中・返事待ちのときの表示。ステータスパネルとホバーカードで使います。settings-tab-bar-shade = タブバーの色settings-tab-bar-shade-description = 2 段のタブバーの濃さ。ウインドウが透けているときに効きます。+settings-window-tabs = 上段のタブバー+settings-window-tabs-description = 自動的に隠す:ポインターをウインドウの上端に置くと現れ、ターミナルをサイズを変えずに下へ押し下げます。右端のピンで固定できます。隠してもタブは残っており、キーボードやコマンドパレットで切り替えられます。+settings-window-tabs-show = 表示+settings-window-tabs-auto-hide = 自動的に隠す+settings-window-tabs-hide = 隠すsettings-terminal-shade = ターミナルの色settings-terminal-shade-description = ターミナルの背景の濃さ。ウインドウが透けているときに効きます。settings-area-shade-dark = 濃いdiff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftlindex 391e9b81..db701423 100644--- a/thinkterm-i18n/i18n/zh-CN.ftl+++ b/thinkterm-i18n/i18n/zh-CN.ftl@@ -146,6 +146,11 @@ settings-agents-status = Agents 状态样式settings-agents-status-description = agent 在干活、等你回复时怎么显示。状态面板和悬停卡片都用它。settings-tab-bar-shade = 标签栏颜色settings-tab-bar-shade-description = 两行标签栏的深浅,窗口透明时生效。+settings-window-tabs = 一级标签栏+settings-window-tabs-description = 自动隐藏:鼠标停在窗口顶部边缘时滑出来,把终端整体往下推、不改变大小;点右边的图钉可以固定住。隐藏后标签都还在,用快捷键或命令面板切换。+settings-window-tabs-show = 显示+settings-window-tabs-auto-hide = 自动隐藏+settings-window-tabs-hide = 隐藏settings-terminal-shade = 终端颜色settings-terminal-shade-description = 终端底色的深浅,窗口透明时生效。settings-area-shade-dark = 深diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rsindex f9dd1d2f..a60ea31c 100644--- a/wezterm-gui/src/native_settings.rs+++ b/wezterm-gui/src/native_settings.rs@@ -459,6 +459,33 @@ impl NativeBottomQuoteMode {pub(crate) const ALL: [Self; 2] = [Self::Timed, Self::PseudoRandom];}+/// The window tab row: the first of the two tab bars.+///+/// `Show` is the default and the row it has always been. `AutoHide` gives+/// its height back to the terminal and brings it down over the top of the+/// window while the pointer rests at the top edge, pushing the terminal+/// area down rather than resizing it; its pin keeps it out+/// (`window_tabs_pinned`). `Hide` leaves it out altogether, the tabs still+/// there behind the keyboard and the command palette.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Deserialize, Serialize)]+#[serde(rename_all = "snake_case")]+pub(crate) enum NativeWindowTabs {+ Show,+ AutoHide,+ Hide,+}++impl Default for NativeWindowTabs {+ fn default() -> Self {+ Self::Show+ }+}++impl NativeWindowTabs {+ /// Every choice, in the order the settings window offers them.+ pub(crate) const ALL: [Self; 3] = [Self::Show, Self::AutoHide, Self::Hide];+}+#[derive(Debug, Clone, Default, Deserialize, Serialize)]#[serde(default)]pub(crate) struct NativeAppearanceSettings {@@ -497,6 +524,12 @@ pub(crate) struct NativeAppearanceSettings {/// hover cards.#[serde(deserialize_with = "choice_or_default")]pub(crate) agents_status: NativeThreadStatus,+ /// See [`NativeWindowTabs`].+ #[serde(deserialize_with = "choice_or_default")]+ pub(crate) window_tabs: NativeWindowTabs,+ /// Under `AutoHide`, the row's pin is in: it stays out and takes its+ /// height in the layout, as under `Show`.+ pub(crate) window_tabs_pinned: bool,}/// How a sidebar thread row draws the programs its panes run. All but@@ -1058,6 +1091,24 @@ pub(crate) fn cursor_shape_choice() -> NativeCursorShape {load_shared().terminal.cursor_shape}+/// The window tab row's mode and, under `AutoHide`, whether it is pinned.+/// Read when a window builds or refreshes its state, not per frame.+pub(crate) fn window_tabs_choice() -> (NativeWindowTabs, bool) {+ let settings = load_shared();+ (+ settings.appearance.window_tabs,+ settings.appearance.window_tabs_pinned,+ )+}++/// Pin or unpin the auto-hiding window tab row, from its pin button. Every+/// window is told directly, so no reload is owed.+pub(crate) fn save_window_tabs_pinned(pinned: bool) -> anyhow::Result<()> {+ update_ui_state_and_settings_window(|settings| {+ settings.appearance.window_tabs_pinned = pinned+ })+}+/// Read once per painted pane, through the shared handle.pub(crate) fn overlay_scrollbar() -> bool {load_shared().terminal.overlay_scrollbar@@ -2319,6 +2370,8 @@ fn apply_external_change(before: &ThinkTermNativeSettings, after: &ThinkTermNatilet contrast = before.terminal.text_contrast != after.terminal.text_contrast;let cursor_style = before.terminal.cursor_blink != after.terminal.cursor_blink|| before.terminal.cursor_shape != after.terminal.cursor_shape;+ let window_tabs = before.appearance.window_tabs != after.appearance.window_tabs+ || before.appearance.window_tabs_pinned != after.appearance.window_tabs_pinned;let before_chrome = &before.chrome;let after_chrome = &after.chrome;let panels = before_chrome.right_sidebar_files_enabled != after_chrome.right_sidebar_files_enabled@@ -2355,6 +2408,9 @@ fn apply_external_change(before: &ThinkTermNativeSettings, after: &ThinkTermNatiif cursor_style {term_window.refresh_cursor_style();}+ if window_tabs {+ term_window.refresh_window_tabs();+ }if panels {term_window.right_sidebar_panels_changed();}@@ -3509,6 +3565,38 @@ mod tests {assert_eq!(settings.terminal.cursor_shape, NativeCursorShape::Block);}+ /// A file from before the window tab row could hide keeps it shown.+ #[test]+ fn a_settings_file_without_a_window_tabs_choice_shows_the_row() {+ let json = r#"{ "version": 1, "appearance": { "theme_mode": "system" } }"#;+ let settings: ThinkTermNativeSettings =+ serde_json::from_str(json).expect("the file has to survive");+ assert_eq!(settings.appearance.window_tabs, NativeWindowTabs::Show);+ assert!(!settings.appearance.window_tabs_pinned);+ }++ #[test]+ fn a_window_tabs_choice_round_trips_through_the_file() {+ for (written, expected) in [+ ("show", NativeWindowTabs::Show),+ ("auto_hide", NativeWindowTabs::AutoHide),+ ("hide", NativeWindowTabs::Hide),+ ] {+ let json = format!(r#"{{"appearance": {{"window_tabs": "{written}"}}}}"#);+ let settings: ThinkTermNativeSettings =+ serde_json::from_str(&json).expect("the file has to survive");+ assert_eq!(settings.appearance.window_tabs, expected, "{written}");++ let out = serde_json::to_string(&settings).expect("serialises");+ assert!(+ out.contains(&format!("\"window_tabs\":\"{written}\"")),+ "{} has to survive a save: {}",+ written,+ out+ );+ }+ }+#[test]fn a_cursor_shape_choice_round_trips_through_the_file() {for (written, expected) in [diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rsindex 6c9bafe9..b37eff63 100644--- a/wezterm-gui/src/settings_window.rs+++ b/wezterm-gui/src/settings_window.rs@@ -1161,6 +1161,10 @@ impl SettingsSection {],Self::Appearance => &["Theme Mode",+ "Tab Bar",+ "Top Tab Bar",+ "Auto-hide",+ "Hide Tabs","Effective Color Scheme","App Icon","Window Opacity",@@ -1380,6 +1384,7 @@ impl SettingsSection {|| (self == Self::Appearance&& ["settings-window-opacity",+ "settings-window-tabs","settings-thread-icons","settings-thread-status","settings-agents-status",@@ -1786,6 +1791,15 @@ fn localized_text_contrast_label(mode: crate::native_settings::NativeTextContras})}+fn localized_window_tabs_label(mode: crate::native_settings::NativeWindowTabs) -> String {+ use crate::native_settings::NativeWindowTabs;+ crate::i18n::tr(match mode {+ NativeWindowTabs::Show => "settings-window-tabs-show",+ NativeWindowTabs::AutoHide => "settings-window-tabs-auto-hide",+ NativeWindowTabs::Hide => "settings-window-tabs-hide",+ })+}+fn localized_cursor_shape_label(shape: crate::native_settings::NativeCursorShape) -> String {use crate::native_settings::NativeCursorShape;crate::i18n::tr(match shape {@@ -2069,6 +2083,7 @@ enum SettingsAction {SetMacGlass(crate::native_settings::NativeMacGlass),SetSidebarShade(crate::native_settings::NativeShade),SetTabBarShade(crate::native_settings::NativeShade),+ SetWindowTabs(crate::native_settings::NativeWindowTabs),SetTerminalShade(crate::native_settings::NativeShade),SetThreadIcons(crate::native_settings::NativeThreadIcons),SetThreadStatus(crate::native_settings::NativeThreadStatus),@@ -6419,6 +6434,7 @@ impl SettingsWindow {localized_shade_label(shade),|appearance| appearance.tab_bar_shade = shade,),+ SettingsAction::SetWindowTabs(mode) => self.apply_window_tabs(mode),SettingsAction::SetTerminalShade(shade) => self.apply_window_areas("settings-terminal-shade",localized_shade_label(shade),@@ -9108,6 +9124,41 @@ impl SettingsWindow {)?);}}+ {+ use crate::native_settings::NativeWindowTabs;+ let options: Vec<(String, SettingsAction)> = NativeWindowTabs::ALL+ .iter()+ .map(|mode| {+ (+ localized_window_tabs_label(*mode),+ SettingsAction::SetWindowTabs(*mode),+ )+ })+ .collect();+ let selected = NativeWindowTabs::ALL+ .iter()+ .position(|mode| *mode == this.native_settings.appearance.window_tabs)+ .unwrap_or(0);+ let (tx, tw) = this.paint_row_tile(+ layers,+ row_x,+ rows.y,+ row_width,+ SvgIcon::AppWindow,+ TileColor::Blue,+ )?;+ rows.add(this.paint_segmented_setting_row(+ layers,+ tx,+ rows.y,+ tw,+ &crate::i18n::tr("settings-window-tabs"),+ &crate::i18n::tr("settings-window-tabs-description"),+ &options,+ selected,+ rows.rule(),+ )?);+ }Ok(rows.bottom)})?;@@ -19168,6 +19219,45 @@ impl SettingsWindow {}}+ /// Show, auto-hide or hide the window tab row, in every window. Choosing+ /// auto-hide here starts with the pin out: it is what was asked for.+ fn apply_window_tabs(&mut self, mode: crate::native_settings::NativeWindowTabs) {+ self.ui.open_dropdown = None;+ // The chosen segment pressed again: nothing changes, the pin included.+ if crate::native_settings::load_shared().appearance.window_tabs == mode {+ return;+ }+ let mut merged = crate::native_settings::load();+ merged.appearance.window_tabs = mode;+ merged.appearance.window_tabs_pinned = false;+ self.set_native_settings(merged);+ let setting = crate::i18n::tr("settings-window-tabs");+ match crate::native_settings::save(&self.native_settings) {+ Ok(()) => {+ 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(|term_window| {+ term_window.refresh_window_tabs();+ })),+ );+ }+ }+ self.status = settings_tr(+ "settings-status-value-now",+ &[("setting", setting), ("value", localized_window_tabs_label(mode))],+ );+ }+ Err(err) => {+ self.set_native_settings(crate::native_settings::load());+ self.status = settings_tr(+ "settings-status-save-error",+ &[("setting", setting), ("error", format!("{err:#}"))],+ );+ }+ }+ }+/// What a see-through window shows behind it on macOS, in every window/// at once, as the window opacity is.fn apply_mac_glass(&mut self, glass: crate::native_settings::NativeMacGlass) {diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex 0c887881..930fd3d5 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -167,6 +167,7 @@ pub mod resize;mod selection;mod sidebar_hover;mod space_swipe;+mod window_tab_reveal;pub mod spawn;pub mod ssh_hosts_view;pub(crate) mod transfer_walk;@@ -814,6 +815,10 @@ pub enum UIItemType {UpdateCapsule,UpdateCapsuleDismiss,RightSidebarToggle,+ /// The pin of an auto-hiding window tab row.+ WindowTabsPin,+ /// A window tab row on its way down or back up: takes no click.+ WindowTabsTravelling,RightSidebarMode(RightSidebarMode),RightSidebarBackground,RightSidebarResize,@@ -3236,6 +3241,9 @@ pub struct TermWindow {/// touches `workspace_sidebar_collapsed` or `workspace_sidebar_width`:/// the terminal must not reflow for a hover.workspace_sidebar_hover: sidebar_hover::SidebarHoverReveal,+ /// The window tab row hidden or brought down from the top edge, as+ /// Settings asks; see `window_tab_reveal`.+ window_tab_reveal: window_tab_reveal::WindowTabReveal,/// Hover-reveal of the collapsed right sidebar: the same machine as the/// left one's, mirrored onto the right edge.right_sidebar_hover: sidebar_hover::SidebarHoverReveal,@@ -4221,6 +4229,7 @@ impl TermWindow {|| self.active_content_view_index().is_some()|| self.workspace_sidebar_hover.needs_frames()|| self.right_sidebar_hover.needs_frames()+ || self.window_tab_reveal.needs_frames()|| self.overlay_scrollbar_owes_frames()// A light still running, or a paste still to show up for one:// copying and then switching to the app to paste it in is the@@ -4556,6 +4565,7 @@ impl TermWindow {self.workspace_sidebar_swipe.cancel_immediately();self.workspace_sidebar_hover.cancel_immediately();self.right_sidebar_hover.cancel_immediately();+ self.window_tab_reveal.cancel();self.clear_workspace_space_swipe_frame_transition();self.right_sidebar_note.native_text_input_snapshot_key = None;window.set_native_text_input_snapshot(None);@@ -4748,7 +4758,16 @@ impl TermWindow {// Initially we have only a single tab, and no status text yet.let terminal_bar_kind = crate::tabbar::terminal_bar_kind(&config, 1, false);- let tab_bar_height = Self::tab_bar_pixel_height_impl(&fontconfig)? as usize+ // A window tab row that hides gives its height to the terminal: the+ // window opens without it, and the shell starts at the size it asked+ // for rather than being resized as the window appears.+ let window_tab_reveal = window_tab_reveal::WindowTabReveal::new();+ let window_tab_row_height = if window_tab_reveal.in_layout() {+ Self::tab_bar_pixel_height_impl(&fontconfig)? as usize+ } else {+ 0+ };+ let tab_bar_height = window_tab_row_height+ crate::termwindow::render::tab_bar::terminal_bar_height(terminal_bar_kind,&render_metrics,@@ -5114,6 +5133,7 @@ impl TermWindow {workspace_space_swipe_needs_settle_start: false,workspace_sidebar_scrollbar_visible_until: None,workspace_sidebar_hover: sidebar_hover::SidebarHoverReveal::default(),+ window_tab_reveal,right_sidebar_hover: sidebar_hover::SidebarHoverReveal::default(),right_sidebar_hover_was_presented: false,titlebar_sidebar_button_hovered: false,@@ -8256,7 +8276,9 @@ impl TermWindow {// The terminal bar is part of the terminal, and the top panes' nav// bars rise into its band: only the window tab row is outside.let left = self.workspace_sidebar_width() as f32 + border.left.get() as f32;- let top = border.top.get() as f32 + self.tab_bar_pixel_height().unwrap_or(0.0);+ let top = border.top.get() as f32+ + self.window_tab_row_layout_height()+ + self.window_tab_reveal_offset();let right = self.terminal_viewport_right();let bottom = (self.dimensions.pixel_height as f32 - border.bottom.get() as f32).max(top);euclid::rect(left, top, (right - left).max(0.0), (bottom - top).max(0.0))@@ -9955,6 +9977,7 @@ impl TermWindow {InlineTabRenameTarget::WindowTab(tab_id),initial_title,));+ self.reveal_window_tab_row_for_rename();self.update_title_impl();}diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rsindex 2fadffe1..1a34d217 100644--- a/wezterm-gui/src/termwindow/mouseevent.rs+++ b/wezterm-gui/src/termwindow/mouseevent.rs@@ -6,9 +6,10 @@ use crate::termwindow::space_swipe::{SidebarSpaceSwipeFinish, SidebarSpaceSwipeUuse crate::termwindow::ui::platform_chrome::WindowTabChromeParams;use crate::termwindow::ui::sidebar::SpaceConnectionState;use crate::termwindow::ui::tokens::{- PANE_NAV_INSET, PANE_NAV_TAB_GAP, TAB_MIN_WIDTH, TAB_ROW_START_PADDING, TAB_TARGET_WIDTH,- TAB_VERTICAL_PADDING, WINDOW_TAB_ACTION_RESERVED_WIDTH, WINDOW_TAB_GAP,- WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE, WINDOW_TAB_LEADING_ACTION_GAP, WINDOW_TAB_TOP_SPACER,+ MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH, PANE_NAV_INSET, PANE_NAV_TAB_GAP, TAB_MIN_WIDTH,+ TAB_ROW_START_PADDING, TAB_TARGET_WIDTH, TAB_VERTICAL_PADDING,+ WINDOW_TAB_ACTION_RESERVED_WIDTH, WINDOW_TAB_GAP, WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE,+ WINDOW_TAB_LEADING_ACTION_GAP, WINDOW_TAB_TOP_SPACER,};use crate::termwindow::{pane_drop_action, pane_drop_zone, zone_split_request, GuiWin, MouseCapture, PaneDropKind,@@ -569,7 +570,7 @@ impl super::TermWindow {1} else {2- };+ } + usize::from(self.window_tab_reveal.shows_pin());let window_button_count = if self.right_sidebar_width() == 0&& self.window_tab_chrome_params()@@ -593,7 +594,20 @@ impl super::TermWindow {)}- pub(super) fn pane_nav_tab_left_inset(&self, pane_left: usize) -> usize {+ pub(super) fn pane_nav_tab_left_inset(&self, pane_left: usize, pane_top: usize) -> usize {+ // A window tab row out of the layout leaves the traffic lights over+ // the top-left pane's bar, which then starts clear of them. Nothing+ // else of the row's stays behind to make room for.+ if pane_left == 0+ && pane_top == 0+ && cfg!(target_os = "macos")+ && !self.window_state.contains(WindowState::FULL_SCREEN)+ && self.workspace_sidebar_width() == 0+ && !self.window_tab_reveal.in_layout()+ {+ return self.ui_px(MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH)+ + self.ui_px(TAB_ROW_START_PADDING);+ }if pane_left == 0 && self.workspace_sidebar_width() > 0 {self.ui_px(TAB_ROW_START_PADDING)} else {@@ -879,7 +893,11 @@ impl super::TermWindow {}}- let tab_bar_height = self.tab_bar_pixel_height().unwrap_or(0.);+ let tab_bar_height = if self.window_tab_row_in_place() {+ self.tab_bar_pixel_height().unwrap_or(0.)+ } else {+ 0.+ };let tab_bar_y = border.top.get() as f32;if event.coords.x >= self.tab_bar_left_edge() as isize&& (event.coords.x as f32) < self.terminal_viewport_right()@@ -1651,6 +1669,8 @@ impl super::TermWindow {| UIItemType::WorkspaceSidebarLiveOverview| UIItemType::WorkspaceSidebarNotifications| UIItemType::RightSidebarToggle+ | UIItemType::WindowTabsPin+ | UIItemType::WindowTabsTravelling| UIItemType::RightSidebarMode(_)| UIItemType::RightSidebarBackground| UIItemType::RightSidebarResize@@ -1825,6 +1845,8 @@ impl super::TermWindow {| UIItemType::WorkspaceSidebarLiveOverview| UIItemType::WorkspaceSidebarNotifications| UIItemType::RightSidebarToggle+ | UIItemType::WindowTabsPin+ | UIItemType::WindowTabsTravelling| UIItemType::RightSidebarMode(_)| UIItemType::RightSidebarBackground| UIItemType::RightSidebarResize@@ -2109,6 +2131,15 @@ impl super::TermWindow {self.cancel_remote_divider_resizes_except(None);context.invalidate();}+ // Chrome stays usable over a terminal held up here: the top edge+ // still brings the window tab row down -- the way to another tab+ // -- as the side edges do their sidebars where they may.+ if self.command_palette.is_none() {+ self.current_mouse_event.replace(event.clone());+ self.update_workspace_sidebar_hover(context);+ self.update_right_sidebar_hover(context);+ self.update_window_tab_reveal(context);+ }return;}if terminal_surface && takeover_gesture {@@ -2124,6 +2155,7 @@ impl super::TermWindow {if self.command_palette.is_none() {self.update_workspace_sidebar_hover(context);self.update_right_sidebar_hover(context);+ self.update_window_tab_reveal(context);}if self.consume_context_menu_suppressed_release(&event) {@@ -2645,6 +2677,7 @@ impl super::TermWindow {// The machine reads `Away` now: cancels an Arming, starts a grace.self.update_workspace_sidebar_hover(context);self.update_right_sidebar_hover(context);+ self.update_window_tab_reveal(context);self.update_title();if !preserve_cursor {context.set_cursor(Some(MouseCursor::Arrow));@@ -4036,6 +4069,15 @@ impl super::TermWindow {UIItemType::RightSidebarToggle => {self.mouse_event_right_sidebar_toggle(event, context);}+ UIItemType::WindowTabsPin => {+ context.set_cursor(Some(MouseCursor::Hand));+ if event.kind == WMEK::Press(MousePress::Left) {+ self.toggle_window_tabs_pinned();+ }+ }+ UIItemType::WindowTabsTravelling => {+ context.set_cursor(Some(MouseCursor::Arrow));+ }UIItemType::RightSidebarMode(mode) => {self.mouse_event_right_sidebar_mode(mode, event, context);}@@ -4648,6 +4690,15 @@ impl super::TermWindow {UIItemType::RightSidebarToggle => {self.mouse_event_right_sidebar_toggle(event, context);}+ UIItemType::WindowTabsPin => {+ context.set_cursor(Some(MouseCursor::Hand));+ if event.kind == WMEK::Press(MousePress::Left) {+ self.toggle_window_tabs_pinned();+ }+ }+ UIItemType::WindowTabsTravelling => {+ context.set_cursor(Some(MouseCursor::Arrow));+ }UIItemType::RightSidebarMode(mode) => {self.mouse_event_right_sidebar_mode(mode, event, context);}diff --git a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rsindex 7a5d0ab7..06926d6d 100644--- a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs+++ b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs@@ -45,7 +45,7 @@ impl crate::TermWindow {) -> anyhow::Result<Vec<UIItem>> {let chrome = self.chrome();let row_height = self.tab_bar_pixel_height()?.ceil() as usize;- if row_height == 0 {+ if row_height == 0 || !self.window_tab_row_drawn() {return Ok(vec![]);}@@ -286,7 +286,7 @@ impl crate::TermWindow {layers: &mut TripleLayerQuadAllocator,) -> anyhow::Result<Vec<UIItem>> {let row_height = self.tab_bar_pixel_height()?.ceil() as usize;- if row_height == 0 {+ if row_height == 0 || !self.window_tab_row_drawn() {return Ok(Vec::new());}let border = self.get_os_border();@@ -310,19 +310,13 @@ impl crate::TermWindow {let muted_fg = chrome.secondary_text;let mut ui_items = Vec::new();let mut action_right = row_right.saturating_sub(self.ui_px(WINDOW_TAB_INSET) + 2);- if self.fancy_tab_bar_shows_window_buttons() {- let window_button_right = if self.right_sidebar_width() > 0 {- self.dimensions- .pixel_width- .saturating_sub(border.right.get() as usize)- .saturating_sub(self.ui_px(WINDOW_TAB_INSET) + 2)- } else {- action_right- };- let window_button_left = self.paint_window_tab_window_buttons(+ // Over an open right sidebar the window's buttons are the sidebar's:+ // see `paint_right_sidebar_window_buttons`.+ if self.fancy_tab_bar_shows_window_buttons() && self.right_sidebar_width() == 0 {+ action_right = self.paint_window_tab_window_buttons(layers,&mut ui_items,- window_button_right,+ action_right,content_row_y,content_row_height,button_size,@@ -330,30 +324,48 @@ impl crate::TermWindow {foreground,muted_fg,)?;- if self.right_sidebar_width() == 0 {- action_right = window_button_left;- }}+ // An auto-hiding row's pin takes the new-tab button's slot, just+ // right of it, and moves the button one slot left.+ let pin_then_new_tab = |slot: usize| {+ if self.window_tab_reveal.shows_pin() {+ (+ Some(slot),+ slot.saturating_sub(self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP) + button_size),+ )+ } else {+ (None, slot)+ }+ };+ let pin_x;if self.right_sidebar_width() > 0 {let action_button_x = action_right.saturating_sub(button_size);if cfg!(target_os = "macos") {- self.paint_window_tab_new_button(+ let (pin, new_button_x) = pin_then_new_tab(action_button_x);+ pin_x = pin;+ self.paint_window_tab_icon_button(layers,&mut ui_items,- action_button_x,+ new_button_x,content_row_y,content_row_height,button_size,icon_size,foreground,muted_fg,+ SvgIcon::Plus,+ UIItemType::TabBar(TabBarItem::NewTabButton),+ false,)?;} else {let right_sidebar_toggle_x = action_button_x;- let new_button_x = right_sidebar_toggle_x- .saturating_sub(self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP) + button_size);- self.paint_window_tab_new_button(+ let (pin, new_button_x) = pin_then_new_tab(+ right_sidebar_toggle_x+ .saturating_sub(self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP) + button_size),+ );+ pin_x = pin;+ self.paint_window_tab_icon_button(layers,&mut ui_items,new_button_x,@@ -363,6 +375,9 @@ impl crate::TermWindow {icon_size,foreground,muted_fg,+ SvgIcon::Plus,+ UIItemType::TabBar(TabBarItem::NewTabButton),+ false,)?;self.paint_window_tab_right_sidebar_toggle_button(layers,@@ -383,13 +398,14 @@ impl crate::TermWindow {// slot to match. The new button has to take that slot, or it// lands one button to the left -- inside the width the tab strip// was just given -- and overlaps the last tab.- let new_button_x = if self.right_sidebar_has_panels() {+ let (pin, new_button_x) = pin_then_new_tab(if self.right_sidebar_has_panels() {right_sidebar_toggle_x.saturating_sub(self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP) + button_size)} else {right_sidebar_toggle_x- };- self.paint_window_tab_new_button(+ });+ pin_x = pin;+ self.paint_window_tab_icon_button(layers,&mut ui_items,new_button_x,@@ -399,6 +415,9 @@ impl crate::TermWindow {icon_size,foreground,muted_fg,+ SvgIcon::Plus,+ UIItemType::TabBar(TabBarItem::NewTabButton),+ false,)?;self.paint_window_tab_right_sidebar_toggle_button(layers,@@ -413,6 +432,70 @@ impl crate::TermWindow {)?;}+ if let Some(pin_x) = pin_x {+ // In, the row stays out and keeps its place, and the pin is drawn+ // in the text's colour; out, the row comes and goes with the+ // pointer.+ self.paint_window_tab_icon_button(+ layers,+ &mut ui_items,+ pin_x,+ content_row_y,+ content_row_height,+ button_size,+ icon_size,+ foreground,+ muted_fg,+ SvgIcon::Pin,+ UIItemType::WindowTabsPin,+ self.window_tab_reveal.pinned(),+ )?;+ }++ Ok(ui_items)+ }++ /// The window's own buttons while an open right sidebar holds them at its+ /// top rather than the row at its end. They stay there whether the row+ /// is shown, hidden or on its way: hidden with the row, a window that+ /// draws its own frame could not be closed.+ pub(crate) fn paint_right_sidebar_window_buttons(+ &self,+ layers: &mut TripleLayerQuadAllocator,+ ) -> anyhow::Result<Vec<UIItem>> {+ let row_height = self.tab_bar_pixel_height()?.ceil() as usize;+ if row_height == 0+ || self.right_sidebar_width() == 0+ || !self.fancy_tab_bar_shows_window_buttons()+ {+ return Ok(Vec::new());+ }+ let border = self.get_os_border();+ let content_top_spacer = self.ui_px(WINDOW_TAB_TOP_SPACER).min(row_height);+ let content_row_y = border.top.get() as usize + content_top_spacer;+ let content_row_height = row_height.saturating_sub(content_top_spacer);+ let icon_size = self.ui_px(TAB_ICON_SIZE).min(content_row_height);+ let button_size = content_row_height+ .saturating_sub(self.ui_px(TAB_VERTICAL_PADDING) * 2)+ .max(icon_size);+ let right = self+ .dimensions+ .pixel_width+ .saturating_sub(border.right.get() as usize)+ .saturating_sub(self.ui_px(WINDOW_TAB_INSET) + 2);+ let chrome = self.chrome();+ let mut ui_items = Vec::new();+ self.paint_window_tab_window_buttons(+ layers,+ &mut ui_items,+ right,+ content_row_y,+ content_row_height,+ button_size,+ icon_size,+ chrome.text,+ chrome.secondary_text,+ )?;Ok(ui_items)}@@ -475,7 +558,7 @@ impl crate::TermWindow {Ok(ui_items)}- fn fancy_tab_bar_shows_window_buttons(&self) -> bool {+ pub(crate) fn fancy_tab_bar_shows_window_buttons(&self) -> bool {uses_integrated_window_buttons(self.config.window_decorations, self.window_state)&& self.config.integrated_title_button_style != IntegratedTitleButtonStyle::MacOsNative&& !self.config.integrated_title_buttons.is_empty()@@ -1148,8 +1231,10 @@ impl crate::TermWindow {Ok(())}+ /// A square icon button at the row's end: the new-tab button, the pin.+ /// `lit` draws the icon in the text's colour without the pointer on it.#[allow(clippy::too_many_arguments)]- fn paint_window_tab_new_button(+ fn paint_window_tab_icon_button(&self,layers: &mut TripleLayerQuadAllocator,ui_items: &mut Vec<UIItem>,@@ -1160,6 +1245,9 @@ impl crate::TermWindow {icon_size: usize,foreground: LinearRgba,muted_fg: LinearRgba,+ icon: SvgIcon,+ item_type: UIItemType,+ lit: bool,) -> anyhow::Result<()> {let button_y = row_y + (row_height.saturating_sub(button_size) / 2);let hovered = self.is_pointer_over_ui_rect(button_x, button_y, button_size, button_size);@@ -1190,7 +1278,7 @@ impl crate::TermWindow {WINDOW_TAB_ADD_BUTTON_RADIUS,ICON_BUTTON_BORDER_WIDTH,)- .context("window tab new button hover")?;+ .context("window tab button hover")?;}ui_items.push(UIItem {@@ -1198,7 +1286,7 @@ impl crate::TermWindow {y: button_y,width: button_size,height: button_size,- item_type: UIItemType::TabBar(TabBarItem::NewTabButton),+ item_type,});let icon_size = if pressed {@@ -1208,11 +1296,11 @@ impl crate::TermWindow {};self.paint_fancy_tab_icon(layers,- SvgIcon::Plus,+ icon,button_x + press_inset + (visual_size.saturating_sub(icon_size) / 2),button_y + press_inset + (visual_size.saturating_sub(icon_size) / 2),icon_size,- if hovered { foreground } else { muted_fg },+ if hovered || lit { foreground } else { muted_fg },)}diff --git a/wezterm-gui/src/termwindow/render/mod.rs b/wezterm-gui/src/termwindow/render/mod.rsindex d9bf175b..5f81af20 100644--- a/wezterm-gui/src/termwindow/render/mod.rs+++ b/wezterm-gui/src/termwindow/render/mod.rs@@ -522,7 +522,7 @@ impl crate::TermWindow {- padding_top- padding_bottom- {- let (top, bottom) = self.pane_area_insets();+ let (top, bottom) = self.pane_area_layout_insets();top + bottom};let left_gap = match self.config.window_content_alignment.horizontal {diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rsindex 2a32f565..b39e74da 100644--- a/wezterm-gui/src/termwindow/render/paint.rs+++ b/wezterm-gui/src/termwindow/render/paint.rs@@ -4449,6 +4449,7 @@ impl crate::TermWindow {self.advance_workspace_space_swipe_push(frame_now);self.advance_workspace_sidebar_hover(frame_now);self.advance_right_sidebar_hover(frame_now);+ self.advance_window_tab_reveal(frame_now);self.advance_content_view_fade(frame_now);// Card texture work is queued per pass; a retried pass re-queues it.self.pending_card_renders.borrow_mut().clear();@@ -5126,10 +5127,21 @@ impl crate::TermWindow {}let defer_trailing_actions = !cfg!(target_os = "macos") && right_hover_overlay.is_some();- let tab_items = self- .paint_fancy_tab_bar(&mut chrome_layers, defer_trailing_actions)- .context("paint_tab_bar")?;+ let tab_items = if let Some(shift) = self.window_tab_row_travel_shift() {+ // On its way down from the top edge or back up: nothing on+ // it takes a click until it lands.+ self.paint_window_tab_row_travelling(&mut chrome_layers, shift)+ .context("paint travelling tab bar")?+ } else {+ self.paint_fancy_tab_bar(&mut chrome_layers, defer_trailing_actions)+ .context("paint_tab_bar")?+ };self.ui_items.extend(tab_items);+ // Over an open right sidebar, whatever the row is doing.+ let window_buttons = self+ .paint_right_sidebar_window_buttons(&mut chrome_layers)+ .context("paint window buttons over the right sidebar")?;+ self.ui_items.extend(window_buttons);drop(chrome_layers);if let Some((overlay, hidden, items)) = hover_overlay {@@ -5167,7 +5179,7 @@ impl crate::TermWindow {self.paint_right_sidebar_hover_overlay(&overlay, hidden).context("paint hover-revealed right sidebar")?;self.ui_items.extend(items);- if !cfg!(target_os = "macos") {+ if !cfg!(target_os = "macos") && self.window_tab_row_in_place() {// Keep the full-height hover background, with the window// and sidebar buttons above it. Flatten their sub-layers// just like the panel so button fills remain visible too.diff --git a/wezterm-gui/src/termwindow/render/pane.rs b/wezterm-gui/src/termwindow/render/pane.rsindex d8cf3b94..ed6563ae 100644--- a/wezterm-gui/src/termwindow/render/pane.rs+++ b/wezterm-gui/src/termwindow/render/pane.rs@@ -266,7 +266,8 @@ impl crate::TermWindow {let Ok((pane_x, pane_width)) = self.pane_chrome_span(pos) else {return 0.0;};- let tab_start = pane_x.max(0.0) as usize + self.pane_nav_tab_left_inset(pos.left);+ let tab_start =+ pane_x.max(0.0) as usize + self.pane_nav_tab_left_inset(pos.left, pos.top);let max_tab_right = ((pane_x + pane_width).max(0.0) as usize).saturating_sub(self.pane_nav_action_reserved_width(pos, nav_height));max_tab_right.saturating_sub(tab_start) as f32@@ -1117,7 +1118,7 @@ impl crate::TermWindow {}let tabs = self.pane_nav_tabs(pos);- let tab_start = pane_x as usize + self.pane_nav_tab_left_inset(pos.left);+ let tab_start = pane_x as usize + self.pane_nav_tab_left_inset(pos.left, pos.top);let tab_gap = self.ui_px(PANE_NAV_TAB_GAP);let viewport_width = self.pane_nav_tab_viewport_width(pos) as usize;let max_tab_right = tab_start.saturating_add(viewport_width);diff --git a/wezterm-gui/src/termwindow/render/split.rs b/wezterm-gui/src/termwindow/render/split.rsindex ebf4c7b5..6a7e95c8 100644--- a/wezterm-gui/src/termwindow/render/split.rs+++ b/wezterm-gui/src/termwindow/render/split.rs@@ -41,7 +41,9 @@ impl crate::TermWindow {// Never above the terminal area: with no top padding (tabline.wez// zeroes it) the half-cell overhang reached into the window tab// row.- let area_top = border.top.get() as f32 + self.tab_bar_pixel_height().unwrap_or(0.);+ let area_top = border.top.get() as f32+ + self.window_tab_row_layout_height()+ + self.window_tab_reveal_offset();top = (top - lift).max(area_top);self.filled_rectangle(layers,diff --git a/wezterm-gui/src/termwindow/render/tab_bar.rs b/wezterm-gui/src/termwindow/render/tab_bar.rsindex a5f19bbd..0a4b5a3e 100644--- a/wezterm-gui/src/termwindow/render/tab_bar.rs+++ b/wezterm-gui/src/termwindow/render/tab_bar.rs@@ -70,9 +70,17 @@ impl crate::TermWindow {}/// Pixels the window tab row and the terminal bar take above and below- /// the pane tree.+ /// the pane tree, as painted and pointed at: a window tab row brought+ /// down from the top edge pushes the panes down with it.pub(crate) fn pane_area_insets(&self) -> (f32, f32) {- let window_tabs = self.tab_bar_pixel_height().unwrap_or(0.);+ let (top, bottom) = self.pane_area_layout_insets();+ (top + self.window_tab_reveal_offset(), bottom)+ }++ /// As `pane_area_insets`, for sizing the terminal: a brought-down row+ /// moves the panes without taking any rows from them.+ pub(crate) fn pane_area_layout_insets(&self) -> (f32, f32) {+ let window_tabs = self.window_tab_row_layout_height();match self.terminal_bar_placement() {Some(bar) if bar.at_bottom => (window_tabs, bar.height),Some(bar) => (window_tabs + bar.height, 0.),diff --git a/wezterm-gui/src/termwindow/resize.rs b/wezterm-gui/src/termwindow/resize.rsindex 66eb83cc..a8f75925 100644--- a/wezterm-gui/src/termwindow/resize.rs+++ b/wezterm-gui/src/termwindow/resize.rs@@ -2289,7 +2289,7 @@ impl super::TermWindow {// Everything above and below the pane tree: the window tab row and// the terminal bar.let tab_bar_height = {- let (top, bottom) = self.pane_area_insets();+ let (top, bottom) = self.pane_area_layout_insets();top + bottom};@@ -3164,7 +3164,7 @@ impl super::TermWindow {dpi: size.dpi,};- let tab_bar_height = self.tab_bar_pixel_height()? as usize+ let tab_bar_height = self.window_tab_row_layout_height() as usize+ crate::termwindow::render::tab_bar::terminal_bar_height(self.terminal_bar_kind,&render_metrics,diff --git a/wezterm-gui/src/termwindow/ui/tokens.rs b/wezterm-gui/src/termwindow/ui/tokens.rsindex 31b2584e..62888c98 100644--- a/wezterm-gui/src/termwindow/ui/tokens.rs+++ b/wezterm-gui/src/termwindow/ui/tokens.rs@@ -34,6 +34,17 @@ pub const SIDEBAR_HOVER_DWELL_MS: u64 = 180;/// Generous on purpose: it is the only defence against a native macOS menu,/// which sets no flag while open (see `ui/context_menu.rs`).pub const SIDEBAR_HOVER_GRACE_MS: u64 = 400;+/// The window tab row's strip along the top, its counterpart of+/// `SIDEBAR_HOVER_HOT_ZONE_WIDTH`. Deeper than that strip is wide: a window+/// under the menu bar has nothing above it to stop the pointer, and an+/// overshoot leaves the window.+pub const WINDOW_TAB_REVEAL_HOT_ZONE_HEIGHT: usize = 16;+/// The top strip's counterpart of `SIDEBAR_HOVER_STICKY_ZONE_WIDTH`.+pub const WINDOW_TAB_REVEAL_STICKY_ZONE_HEIGHT: usize = 32;+/// Off macOS, the top edge a window drawing its own frame leaves to the+/// system for resizing, where the pointer never reaches the window: six+/// logical pixels on X11 and Wayland, a little less on Windows.+pub const WINDOW_RESIZE_EDGE_HEIGHT: usize = 12;pub const MACOS_TITLEBAR_CONTENT_TOP_INSET: usize = 52;pub const MACOS_TRAFFIC_LIGHT_CLEARANCE_WIDTH: usize = 164;pub const MACOS_WINDOW_TAB_RESERVED_ACTION_SLOTS: usize = 1;diff --git a/wezterm-gui/src/termwindow/window_tab_reveal.rs b/wezterm-gui/src/termwindow/window_tab_reveal.rsnew file mode 100644index 00000000..77a7daee--- /dev/null+++ b/wezterm-gui/src/termwindow/window_tab_reveal.rs@@ -0,0 +1,357 @@+//! The window tab row when it does not keep its place: hidden outright, or+//! brought down from the top edge while the pointer rests there.+//!+//! Hidden, the row gives its height back to the terminal. Brought down, it+//! comes in over the window's top and pushes the terminal area down by the+//! same amount -- painted lower, never resized, so nothing reflows and the+//! last line or two drop out of view until it goes again. The hover is the+//! workspace sidebar's machine (`SidebarHoverReveal`): the same dwell, grace+//! and travel, fed a strip along the top instead of the left edge.++use crate::native_settings::NativeWindowTabs;+use crate::quad::{HeapQuadAllocator, QuadClipRect, TripleLayerQuadAllocator};+use crate::termwindow::sidebar_hover::{HoverFrame, HoverInput, PointerZone, SidebarHoverReveal};+use crate::termwindow::ui::tokens::{+ WINDOW_RESIZE_EDGE_HEIGHT, WINDOW_TAB_REVEAL_HOT_ZONE_HEIGHT,+ WINDOW_TAB_REVEAL_STICKY_ZONE_HEIGHT,+};+use crate::termwindow::{+ InlineTabRenameTarget, TermWindow, TermWindowNotif, UIItem, UIItemType,+};+use std::time::Instant;+use window::{WindowDecorations, WindowOps};++#[derive(Debug, Clone, Default)]+pub(crate) struct WindowTabReveal {+ mode: NativeWindowTabs,+ pinned: bool,+ hover: SidebarHoverReveal,+ /// How far out the row is, 0 to 1, as of the last step: what geometry+ /// reads between steps, so a frame and the clicks on it agree.+ shown: f32,+}++impl WindowTabReveal {+ pub(crate) fn new() -> Self {+ let (mode, pinned) = crate::native_settings::window_tabs_choice();+ Self {+ mode,+ pinned,+ ..Default::default()+ }+ }++ /// The row keeps its place in the layout.+ pub(crate) fn in_layout(&self) -> bool {+ row_in_layout(self.mode, self.pinned)+ }++ /// The row carries its pin: it auto-hides, pinned or not.+ pub(crate) fn shows_pin(&self) -> bool {+ self.mode == NativeWindowTabs::AutoHide+ }++ pub(crate) fn pinned(&self) -> bool {+ self.pinned+ }++ /// A dwell, a grace or a travel is under way.+ pub(crate) fn needs_frames(&self) -> bool {+ self.hover.needs_frames()+ }++ /// Focus loss: put the row away without a travel.+ pub(crate) fn cancel(&mut self) {+ self.hover.cancel_immediately();+ self.shown = 0.0;+ }+}++/// Whether the row takes its height in the layout: shown, or auto-hiding+/// with its pin in.+fn row_in_layout(mode: NativeWindowTabs, pinned: bool) -> bool {+ match mode {+ NativeWindowTabs::Show => true,+ NativeWindowTabs::AutoHide => pinned,+ NativeWindowTabs::Hide => false,+ }+}++/// Whether the top edge may bring the row down. A hidden row comes down+/// only while it holds the window's own buttons: they have nowhere else to+/// be, and a window that cannot be closed is worse than a row that shows.+fn row_may_reveal(mode: NativeWindowTabs, pinned: bool, carries_window_buttons: bool) -> bool {+ match mode {+ NativeWindowTabs::Show => false,+ NativeWindowTabs::AutoHide => !pinned,+ NativeWindowTabs::Hide => carries_window_buttons,+ }+}++impl TermWindow {+ /// The height the window tab row takes in the layout: all of it while it+ /// keeps its place, none while it hides. A revealed row takes none+ /// either -- see `window_tab_reveal_offset`.+ pub(crate) fn window_tab_row_layout_height(&self) -> f32 {+ if self.window_tab_reveal.in_layout() {+ self.tab_bar_pixel_height().unwrap_or(0.0)+ } else {+ 0.0+ }+ }++ /// How far a row brought down from the top edge has pushed the terminal+ /// area down. Painting and pointer mapping add it; the terminal's size+ /// never does.+ pub(crate) fn window_tab_reveal_offset(&self) -> f32 {+ if self.window_tab_reveal.in_layout() {+ return 0.0;+ }+ self.window_tab_reveal.shown * self.tab_bar_pixel_height().unwrap_or(0.0)+ }++ /// How much of the window's top the row covers as it stands: all of its+ /// height while it keeps its place, as far as it has come down otherwise.+ pub(crate) fn window_tab_row_drawn_height(&self) -> f32 {+ self.window_tab_row_layout_height() + self.window_tab_reveal_offset()+ }++ /// The row is drawn where it always is, with live buttons: it keeps its+ /// place, or it has come all the way down.+ pub(crate) fn window_tab_row_in_place(&self) -> bool {+ self.window_tab_reveal.in_layout() || self.window_tab_reveal.shown >= 1.0+ }++ /// The row is drawn at all this frame: in place, or travelling.+ pub(crate) fn window_tab_row_drawn(&self) -> bool {+ self.window_tab_row_in_place() || self.window_tab_reveal.shown > 0.0+ }++ /// While the row travels: how far above its place it is drawn, as a+ /// negative shift. `None` when it is in place or away.+ pub(crate) fn window_tab_row_travel_shift(&self) -> Option<f32> {+ let shown = self.window_tab_reveal.shown;+ if self.window_tab_row_in_place() || shown <= 0.0 {+ return None;+ }+ Some((shown - 1.0) * self.tab_bar_pixel_height().unwrap_or(0.0))+ }++ /// Paint the row `shift` pixels above its place, cropped to the window:+ /// recorded where it sits, since the painters take unsigned coordinates,+ /// and moved on replay. Nothing on it takes a click until it lands, and+ /// the one target returned keeps a click there from falling through to+ /// the terminal's first row instead.+ pub(crate) fn paint_window_tab_row_travelling(+ &mut self,+ layers: &mut TripleLayerQuadAllocator,+ shift: f32,+ ) -> anyhow::Result<Vec<UIItem>> {+ let mut recorded = HeapQuadAllocator::default();+ let mut row_layers = TripleLayerQuadAllocator::Heap(&mut recorded);+ self.paint_fancy_tab_bar(&mut row_layers, false)?;+ drop(row_layers);+ let clip = QuadClipRect::from_top_left_pixels(+ 0.0,+ 0.0,+ self.dimensions.pixel_width as f32,+ self.dimensions.pixel_height as f32,+ &self.dimensions,+ );+ recorded.apply_to_clipped_at(layers, 0.0, shift, clip, 1.0)?;+ let left = self.tab_bar_left_edge();+ Ok(vec![UIItem {+ x: left,+ y: self.get_os_border().top.get() as usize,+ width: (self.terminal_viewport_right() as usize).saturating_sub(left),+ height: self.window_tab_reveal_offset().ceil() as usize,+ item_type: UIItemType::WindowTabsTravelling,+ }])+ }++ /// The window's own minimise, maximise and close buttons are on the row,+ /// as they are with integrated buttons and the right sidebar closed.+ fn window_tab_row_carries_window_buttons(&self) -> bool {+ self.fancy_tab_bar_shows_window_buttons() && self.right_sidebar_width() == 0+ }++ /// A tab of the row is being renamed in place, which needs the row out.+ fn renaming_window_tab(&self) -> bool {+ self.inline_tab_rename+ .as_ref()+ .is_some_and(|rename| matches!(rename.target, InlineTabRenameTarget::WindowTab(_)))+ }++ /// Off macOS, the top edge the system keeps for resizing a window that+ /// draws its own frame. The pointer there never reaches the window, so+ /// the strip that brings the row down reaches past it.+ fn window_tab_resize_edge(&self) -> usize {+ if cfg!(target_os = "macos")+ || self.config.window_decorations.contains(WindowDecorations::TITLE)+ || !self.window_state.can_resize()+ {+ return 0;+ }+ self.ui_px(WINDOW_RESIZE_EDGE_HEIGHT)+ }++ fn window_tab_hover_input(&self) -> HoverInput {+ let overlay_open = self.menu_or_overlay_open();+ let presented = self.window_tab_reveal.hover.is_presented();+ // A row out for a rename goes back the usual way once it is done,+ // whatever the mode. Unlike the sidebars, a terminal that is+ // connecting or offline does not hold the row back: it is the way+ // to another tab.+ let eligible = (row_may_reveal(+ self.window_tab_reveal.mode,+ self.window_tab_reveal.pinned,+ self.window_tab_row_carries_window_buttons(),+ ) || self.renaming_window_tab()+ || presented)+ && self.tab_bar_pixel_height().unwrap_or(0.0) > 0.0+ && !self.content_view_is_full_window()+ && (!overlay_open || presented);+ let pointer = match &self.current_mouse_event {+ None => PointerZone::Away,+ Some(event) => {+ let x = event.coords.x;+ let y = event.coords.y;+ let top = self.get_os_border().top.get() as isize;+ let left = self.tab_bar_left_edge() as isize;+ let right = self.terminal_viewport_right() as isize;+ let row_bottom = top + self.window_tab_reveal_offset().ceil() as isize;+ let edge = top + self.window_tab_resize_edge() as isize;+ if x < left || x >= right {+ PointerZone::Away+ } else if presented && y < row_bottom {+ PointerZone::Panel+ } else if y < edge + self.ui_px(WINDOW_TAB_REVEAL_HOT_ZONE_HEIGHT) as isize {+ PointerZone::HotZone+ } else if y < edge + self.ui_px(WINDOW_TAB_REVEAL_STICKY_ZONE_HEIGHT) as isize {+ PointerZone::NearHotZone+ } else {+ PointerZone::Away+ }+ }+ };+ let pinned = !self.current_mouse_buttons.is_empty()+ || self.current_mouse_capture.is_some()+ || self.dragging.is_some()+ || self.pane_tab_drag.is_some()+ || overlay_open;+ HoverInput {+ eligible,+ pointer,+ pinned,+ }+ }++ /// Step the row's hover machine and keep its position for the frame.+ /// From the frame loop, so a resting pointer still brings it down at+ /// dwell expiry and a departed one still sends it back at grace expiry.+ pub(crate) fn advance_window_tab_reveal(&mut self, now: Instant) {+ let input = self.window_tab_hover_input();+ let frame = self.window_tab_reveal.hover.step(input, now);+ self.window_tab_reveal.shown = self.window_tab_reveal.hover.progress(now).unwrap_or(0.0);+ match frame {+ HoverFrame::None => {}+ HoverFrame::Now => {+ if let Some(window) = self.window.as_ref() {+ window.invalidate();+ }+ }+ HoverFrame::At(due) => self.update_next_frame_time(Some(due)),+ }+ }++ /// Feed a pointer event to the row's hover machine. Never consumes it.+ pub(crate) fn update_window_tab_reveal(&mut self, context: &dyn WindowOps) {+ let input = self.window_tab_hover_input();+ if self.window_tab_reveal.hover.step(input, Instant::now()) != HoverFrame::None {+ // As with the sidebar: the frame's advance registers deadlines.+ context.invalidate();+ }+ }++ /// Take a new mode or pin from Settings: the terminal gets the row's+ /// height back, or gives it up, once.+ pub(crate) fn refresh_window_tabs(&mut self) {+ let before = self.window_tab_reveal.in_layout();+ let (mode, pinned) = crate::native_settings::window_tabs_choice();+ self.window_tab_reveal.mode = mode;+ self.window_tab_reveal.pinned = pinned;+ if !row_may_reveal(mode, pinned, self.window_tab_row_carries_window_buttons()) {+ self.window_tab_reveal.cancel();+ }+ if before != self.window_tab_reveal.in_layout() {+ self.invalidate_fancy_tab_bar();+ if let Some(window) = self.window.as_ref().cloned() {+ let dimensions = self.dimensions;+ self.apply_dimensions(&dimensions, None, &window);+ }+ }+ if let Some(window) = self.window.as_ref() {+ window.invalidate();+ }+ }++ /// A row tab renamed from the keyboard or the palette while the row is+ /// away: bring the row down for the edit, which holds it out until done.+ pub(crate) fn reveal_window_tab_row_for_rename(&mut self) {+ if self.window_tab_reveal.in_layout() || !self.renaming_window_tab() {+ return;+ }+ self.window_tab_reveal.hover.reveal_now(Instant::now());+ if let Some(window) = self.window.as_ref() {+ window.invalidate();+ }+ }++ /// The pin: keep an auto-hiding row out, or let it go again. Saved, so+ /// every window follows and the next launch remembers.+ pub(crate) fn toggle_window_tabs_pinned(&mut self) {+ let pinned = !self.window_tab_reveal.pinned;+ if let Err(err) = crate::native_settings::save_window_tabs_pinned(pinned) {+ log::warn!("failed to save the window tab row's pin: {err:#}");+ return;+ }+ // This window at once: a frame painted before the notice below+ // reaches it would still go by the old pin.+ self.refresh_window_tabs();+ if !pinned {+ // Unpinned under the pointer: it stays out until the pointer+ // leaves, as a row brought down by hover would.+ self.window_tab_reveal.hover.present_immediately();+ self.window_tab_reveal.shown = 1.0;+ }+ if let Some(front_end) = crate::frontend::try_front_end() {+ for gui_window in front_end.gui_windows() {+ gui_window.window.notify(TermWindowNotif::Apply(Box::new(|term_window| {+ term_window.refresh_window_tabs();+ })));+ }+ }+ }+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn only_a_shown_or_pinned_row_keeps_its_place() {+ assert!(row_in_layout(NativeWindowTabs::Show, false));+ assert!(row_in_layout(NativeWindowTabs::AutoHide, true));+ assert!(!row_in_layout(NativeWindowTabs::AutoHide, false));+ assert!(!row_in_layout(NativeWindowTabs::Hide, false));+ }++ #[test]+ fn a_hidden_row_comes_down_only_for_the_window_buttons() {+ assert!(row_may_reveal(NativeWindowTabs::AutoHide, false, false));+ assert!(!row_may_reveal(NativeWindowTabs::AutoHide, true, false));+ assert!(!row_may_reveal(NativeWindowTabs::Show, false, true));+ assert!(!row_may_reveal(NativeWindowTabs::Hide, false, false));+ assert!(row_may_reveal(NativeWindowTabs::Hide, false, true));+ }+}