Skip to content

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.

feat(gui): keep window buttons in the top pane bars while tabs hide

RoversX70aff0ee7ded
diff --git a/wezterm-gui/src/termwindow/mouseevent.rs b/wezterm-gui/src/termwindow/mouseevent.rs
index 3fe47d6a..eac38bcb 100644
--- a/wezterm-gui/src/termwindow/mouseevent.rs
+++ b/wezterm-gui/src/termwindow/mouseevent.rs
@@ -594,32 +594,48 @@ impl super::TermWindow {
)
}
- pub(super) fn pane_nav_tab_left_inset(&self, pane_left: usize, pane_top: usize) -> usize {
+ pub(super) fn pane_nav_tab_left_inset(&self, pos: &PositionedPane) -> usize {
// A window tab row out of the layout leaves the traffic lights and
// the sidebar button beside them over the top-left pane's bar, whose
// tabs then start where the row's do. Brought down, the row takes
// them back and pushes the bar below them: its tabs go back to the
- // edge as the row comes.
- if pane_left == 0
- && pane_top == 0
+ // edge as the row comes. Off macOS the bar holds the sidebar button
+ // itself (see `pane_bar_sidebar_toggle_share`), and makes way for it
+ // the same way.
+ let edge = self.ui_px(PANE_NAV_INSET) as f32;
+ if pos.left == 0
+ && pos.top == 0
&& cfg!(target_os = "macos")
&& !self.window_state.contains(WindowState::FULL_SCREEN)
&& self.workspace_sidebar_width() == 0
&& !self.window_tab_reveal.in_layout()
{
- let edge = self.ui_px(PANE_NAV_INSET) as f32;
let clear = self.window_tab_left_padding_pixels().ceil()
+ self.ui_px(TAB_ROW_START_PADDING) as f32;
let away = 1.0 - self.window_tab_reveal.shown();
return (edge + (clear - edge).max(0.0) * away).round() as usize;
}
- if pane_left == 0 && self.workspace_sidebar_width() > 0 {
+ let share = self.pane_bar_sidebar_toggle_share(pos);
+ if share > 0.0 {
+ let clear = self.pane_bar_sidebar_toggle_clear(pos);
+ return (edge + (clear - edge).max(0.0) * share).round() as usize;
+ }
+ if pos.left == 0 && self.workspace_sidebar_width() > 0 {
self.ui_px(TAB_ROW_START_PADDING)
} else {
self.ui_px(PANE_NAV_INSET)
}
}
+ /// Where `pos`'s tabs start past the sidebar's toggle, once the row is
+ /// all the way away and its bar holds that.
+ pub(super) fn pane_bar_sidebar_toggle_clear(&self, pos: &PositionedPane) -> f32 {
+ let (_, _, button_size) =
+ self.pane_nav_button_metrics(self.pane_nav_bar_height_for_pane(pos));
+ self.window_tab_leading_action_start_pixels().ceil()
+ + (button_size + self.ui_px(TAB_ROW_START_PADDING)) as f32
+ }
+
pub(super) fn window_tab_viewport_width(&self) -> f32 {
let border = self.get_os_border();
let left_padding = self.window_tab_left_padding_pixels();
@@ -2070,7 +2086,8 @@ impl super::TermWindow {
}
// Hit-test first. Tab bar, sidebars, menus and OS chrome stay usable
- // without silently taking a terminal away from another device.
+ // without silently taking a terminal away from another device, a
+ // pane bar's blank standing in for the title bar among them.
let area = self.content_view_area();
let point_is_in_terminal_area = !self.content_view_foreground()
&& (event.coords.x as f32) >= area.min_x()
@@ -2085,7 +2102,7 @@ impl super::TermWindow {
| UIItemType::ScrollThumb(_)
| UIItemType::BelowScrollThumb(_)
| UIItemType::Split(_)
- )
+ ) && !self.pane_bar_blank_is_title_bar(&item)
});
let terminal_surface = point_is_in_terminal_area
&& (self.resolve_ui_item(&event).is_none() || terminal_ui_item);
@@ -8279,6 +8296,19 @@ impl super::TermWindow {
_ => {}
}
+ // A title bar's blank offers the system its drag ahead of a press.
+ // Windows then takes the press for its own and never passes it on,
+ // so only the active pane's does: a press on another's has to reach
+ // us to pick that pane.
+ if event.kind == WMEK::Move
+ && self.pane_bar_blank_is_title_bar(&item)
+ && Mux::get()
+ .get_active_tab_for_window(self.mux_window_id)
+ .is_some_and(|tab| tab.get_active_idx() == pane_index)
+ {
+ context.set_window_drag_position(event.screen_coords);
+ }
+
if event.kind == WMEK::Press(MousePress::Right) {
if let PaneNavAction::Activate(target_pane_id) = action {
self.show_term_context_menu(
@@ -8308,7 +8338,12 @@ impl super::TermWindow {
}
tab.set_active_idx(pane_index);
}
- if self.last_mouse_click.as_ref().map(|c| c.streak) == Some(2) {
+ // Along the top of a window whose tab row is away, the blank
+ // is the title bar's: it moves the window, and a double click
+ // zooms it rather than opening a tab.
+ if self.pane_bar_blank_is_title_bar(&item) {
+ self.mouse_event_window_header_blank(event, context);
+ } else if self.last_mouse_click.as_ref().map(|c| c.streak) == Some(2) {
self.spawn_pane_nav_tab(pane_id, pane_index);
}
}
diff --git a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs
index 06926d6d..2229ea2d 100644
--- a/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs
+++ b/wezterm-gui/src/termwindow/render/fancy_tab_bar.rs
@@ -14,6 +14,7 @@ use crate::termwindow::ui::tokens::{
WINDOW_TAB_LEADING_ACTION_BUTTON_SIZE, WINDOW_TAB_LEADING_ACTION_GAP,
WINDOW_TAB_LEADING_ACTION_ICON_SIZE, WINDOW_TAB_RADIUS, WINDOW_TAB_TOP_SPACER,
};
+use crate::termwindow::window_tab_reveal::PaneBarWindowChrome;
use crate::termwindow::{TermWindowNotif, UIItem, UIItemType, UiShapeCacheLookup};
use crate::ui::UiPalette;
use crate::utilsprites::RenderMetrics;
@@ -499,6 +500,93 @@ impl crate::TermWindow {
Ok(ui_items)
}
+ /// The window's own buttons at the end of the top-right pane bar, the
+ /// right sidebar's toggle before them and a rule between them and the
+ /// pane's buttons, while the pane bars stand in for a row that is away
+ /// (see `pane_bar_window_chrome`). Returns where the pane's buttons go on
+ /// from; `pane_bar_window_chrome_width` is the width this takes.
+ #[allow(clippy::too_many_arguments)]
+ pub(crate) fn paint_pane_bar_window_chrome(
+ &self,
+ layers: &mut TripleLayerQuadAllocator,
+ ui_items: &mut Vec<UIItem>,
+ parts: PaneBarWindowChrome,
+ bar_right: usize,
+ bar_y: usize,
+ bar_height: usize,
+ button_size: usize,
+ icon_size: usize,
+ ) -> anyhow::Result<usize> {
+ let chrome = self.chrome();
+ let mut x = bar_right.saturating_sub(self.ui_px(WINDOW_TAB_INSET) + 2);
+ if parts.window_buttons {
+ x = self.paint_window_tab_window_buttons(
+ layers,
+ ui_items,
+ x,
+ bar_y,
+ bar_height,
+ button_size,
+ icon_size,
+ chrome.text,
+ chrome.secondary_text,
+ )?;
+ }
+ if parts.right_sidebar_toggle {
+ x = x.saturating_sub(button_size);
+ self.paint_window_tab_right_sidebar_toggle_button(
+ layers,
+ ui_items,
+ x,
+ bar_y,
+ bar_height,
+ button_size,
+ icon_size,
+ chrome.text,
+ chrome.secondary_text,
+ )?;
+ }
+ x = x.saturating_sub(self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP));
+ let rule_height = button_size * 3 / 5;
+ self.filled_rectangle(
+ layers,
+ 1,
+ euclid::rect(
+ x as f32,
+ (bar_y + bar_height.saturating_sub(rule_height) / 2) as f32,
+ 1.0,
+ rule_height as f32,
+ ),
+ chrome.separator,
+ )
+ .context("pane bar window button rule")?;
+ debug_assert_eq!(
+ bar_right.saturating_sub(x),
+ self.pane_bar_window_chrome_width(parts, button_size)
+ );
+ Ok(x)
+ }
+
+ /// What `paint_pane_bar_window_chrome` takes from the bar's right end.
+ pub(crate) fn pane_bar_window_chrome_width(
+ &self,
+ parts: PaneBarWindowChrome,
+ button_size: usize,
+ ) -> usize {
+ let gap = self.ui_px(WINDOW_TAB_LEADING_ACTION_GAP);
+ let window_buttons = if parts.window_buttons {
+ self.config.integrated_title_buttons.len() * (button_size + gap / 2) + gap / 2
+ } else {
+ 0
+ };
+ let sidebar_toggle = if parts.right_sidebar_toggle {
+ button_size
+ } else {
+ 0
+ };
+ self.ui_px(WINDOW_TAB_INSET) + 2 + window_buttons + sidebar_toggle + gap
+ }
+
/// Paint only the essential native/client window chrome over a full-window
/// ContentView. The normal tabs and sidebar actions stay suppressed, while
/// the blank row retains window dragging and integrated buttons retain the
@@ -639,7 +727,7 @@ impl crate::TermWindow {
}
#[allow(clippy::too_many_arguments)]
- fn paint_window_sidebar_toggle_button(
+ pub(crate) fn paint_window_sidebar_toggle_button(
&self,
layers: &mut TripleLayerQuadAllocator,
ui_items: &mut Vec<UIItem>,
diff --git a/wezterm-gui/src/termwindow/render/paint.rs b/wezterm-gui/src/termwindow/render/paint.rs
index 6e8e9558..4afe1208 100644
--- a/wezterm-gui/src/termwindow/render/paint.rs
+++ b/wezterm-gui/src/termwindow/render/paint.rs
@@ -1215,7 +1215,11 @@ impl crate::TermWindow {
passes_used = pass + 1;
self.frame_pane_output_generations.clear();
self.track_pane_output_generations_for_frame = false;
- match self.paint_pass() {
+ let painted = self.paint_pass();
+ if painted.is_ok() {
+ self.window_tab_reveal.finish_paint();
+ }
+ match painted {
Ok(_) => match self.render_state.as_mut().unwrap().allocated_more_quads() {
Ok(allocated) => {
if !allocated {
@@ -4659,6 +4663,7 @@ impl crate::TermWindow {
// Clear out UI item positions; we'll rebuild these as we render
self.ui_items.clear();
+ self.window_tab_reveal.begin_paint();
// The Agents panel's arranged list lives while the panel is painted.
if !std::mem::take(&mut self.right_sidebar_agents_painted) {
self.right_sidebar_agents_list = None;
@@ -5410,6 +5415,29 @@ impl crate::TermWindow {
.context("paint right sidebar hover arming hint")?;
}
}
+
+ // The tab row's own, along the top edge, where the pointer goes
+ // by on its way to the pane bars far more often: it fades up as
+ // the dwell counts rather than flashing at every pass.
+ if let Some(arming) = self.window_tab_reveal.arming() {
+ let left = self.tab_bar_left_edge() as f32;
+ let hint_height =
+ self.ui_px(crate::termwindow::ui::tokens::SIDEBAR_HOVER_HINT_WIDTH) as f32;
+ let palette = self.chrome();
+ let mut hint_layers = layer.quad_allocator();
+ self.filled_rectangle(
+ &mut hint_layers,
+ 2,
+ euclid::rect(
+ left,
+ self.get_os_border().top.get() as f32,
+ self.terminal_viewport_right() - left,
+ hint_height,
+ ),
+ palette.sidebar_row_active_border.mul_alpha(0.7 * arming * arming),
+ )
+ .context("paint window tab row hover arming hint")?;
+ }
}
if fading_content_view {
diff --git a/wezterm-gui/src/termwindow/render/pane.rs b/wezterm-gui/src/termwindow/render/pane.rs
index 76e34279..5b5deb9e 100644
--- a/wezterm-gui/src/termwindow/render/pane.rs
+++ b/wezterm-gui/src/termwindow/render/pane.rs
@@ -20,7 +20,7 @@ use crate::termwindow::ui::tokens::{
PANE_NAV_ACTION_ICON_SIZE, PANE_NAV_BUTTON_GAP, PANE_NAV_ICON_GAP, PANE_NAV_INSET,
PANE_NAV_TAB_GAP, PANE_NAV_TAB_RADIUS, TAB_CLOSE_HOVER_INSET, TAB_CLOSE_HOVER_RADIUS,
TAB_CONTENT_INSET, TAB_ICON_CIRCLE_INSET, TAB_ICON_GLYPH_RATIO, TAB_ICON_SIZE,
- TAB_VERTICAL_PADDING,
+ TAB_MIN_WIDTH, TAB_VERTICAL_PADDING,
};
use crate::termwindow::{PaneNavAction, ScrollHit, ScrollTrack, UIItem, UIItemType};
use crate::ui::draw::DrawContext;
@@ -32,6 +32,7 @@ use config::VisualBellTarget;
use mux::pane::{PaneId, WithPaneLines};
use mux::renderable::{RenderableDimensions, StableCursorPosition};
use crate::termwindow::render::split_slide::TabPlace;
+use crate::termwindow::window_tab_reveal::PaneBarWindowChrome;
use mux::tab::{CollapsedPaneLayout, PaneStackTab, PositionedPane, SplitDirection};
use mux::Mux;
use ordered_float::NotNan;
@@ -169,7 +170,7 @@ impl crate::TermWindow {
/// Icon, action-icon and button sizes for a nav bar of `nav_height`.
/// The painter and the scroll clamp both size their geometry from these, so
/// they are derived once.
- fn pane_nav_button_metrics(&self, nav_height: usize) -> (usize, usize, usize) {
+ pub(crate) fn pane_nav_button_metrics(&self, nav_height: usize) -> (usize, usize, usize) {
// Fixed chrome sizes, clamped only so a nav bar squeezed by a short
// pane cannot overflow its own row. The tab icon deliberately matches
// the window tab row's; it used to be capped at 24 here and computed
@@ -188,15 +189,54 @@ impl crate::TermWindow {
/// Width the trailing action buttons claim from the nav bar's right edge:
/// new tab, split down, split right and zoom, plus collapse wherever the
- /// split shape allows it.
+ /// split shape allows it, and the room kept for the window's buttons.
fn pane_nav_action_reserved_width(&self, pos: &PositionedPane, nav_height: usize) -> usize {
let (_, _, button_size) = self.pane_nav_button_metrics(nav_height);
+ self.pane_nav_actions_width(pos, button_size)
+ .saturating_add(self.pane_bar_window_chrome_room(pos, button_size))
+ }
+
+ /// The trailing action buttons alone.
+ fn pane_nav_actions_width(&self, pos: &PositionedPane, button_size: usize) -> usize {
let action_count = 4 + usize::from(self.can_collapse_pane_stack(pos));
action_count
.saturating_mul(button_size + self.ui_px(PANE_NAV_BUTTON_GAP))
.saturating_add(self.ui_px(PANE_NAV_INSET))
}
+ /// `pos`'s bar, `width` wide, has room for the window's `parts` beside
+ /// all of its own: the sidebar's toggle when it holds that too, half a
+ /// tab at the least -- its icon, the start of its title and its close
+ /// button -- and its action buttons.
+ pub(crate) fn pane_bar_fits_window_chrome(
+ &self,
+ pos: &PositionedPane,
+ parts: PaneBarWindowChrome,
+ width: f32,
+ ) -> bool {
+ let (_, _, button_size) =
+ self.pane_nav_button_metrics(self.pane_nav_bar_height_for_pane(pos));
+ let tab_start = if self.pane_bar_sidebar_toggle_share(pos) > 0.0 {
+ self.pane_bar_sidebar_toggle_clear(pos)
+ } else {
+ self.pane_nav_tab_left_inset(pos) as f32
+ };
+ let buttons = self.pane_nav_actions_width(pos, button_size)
+ + self.pane_bar_window_chrome_width(parts, button_size);
+ tab_start + self.ui_f32(TAB_MIN_WIDTH / 2.0) + buttons as f32 <= width
+ }
+
+ /// The room `pos`'s bar keeps at its end for the window's buttons
+ /// (see `pane_bar_window_chrome`), shrinking as the row comes down.
+ fn pane_bar_window_chrome_room(&self, pos: &PositionedPane, button_size: usize) -> usize {
+ let parts = self.pane_bar_window_chrome(pos);
+ if !parts.any() {
+ return 0;
+ }
+ let width = self.pane_bar_window_chrome_width(parts, button_size);
+ (width as f32 * self.pane_bars_stand_in_share()).round() as usize
+ }
+
/// The band `pos`'s nav bar runs along, and where along it the buttons
/// at its end start; `None` without one, or for a stack collapsed to a
/// strip, which is all nav bar.
@@ -266,8 +306,7 @@ 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, pos.top);
+ let tab_start = pane_x.max(0.0) as usize + self.pane_nav_tab_left_inset(pos);
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
@@ -1080,6 +1119,73 @@ impl crate::TermWindow {
// capsule and 4 under it — the row read as sagging.
let button_y = pane_y as usize + nav_height.saturating_sub(button_size) / 2;
let mut button_x = (pane_x + pane_width) as usize;
+ // Standing in for a window tab row that is away, the bars along the
+ // top take what it held: the window's buttons end the top-right one,
+ // the sidebar's toggle starts the top-left one. They slide in from
+ // the bar's ends and fade up as the row goes, and back out as it
+ // comes, which carries its own; only all the way in do they work.
+ let mut window_items = Vec::new();
+ let bar_clip = QuadClipRect::from_top_left_pixels(
+ pane_x,
+ pane_y,
+ pane_x + pane_width,
+ pane_y + nav_height as f32,
+ &self.dimensions,
+ );
+ let window_chrome = self.pane_bar_window_chrome(pos);
+ let room = self.pane_bar_window_chrome_room(pos, button_size);
+ if window_chrome.any() {
+ let mut held = HeapQuadAllocator::default();
+ let mut held_layers = TripleLayerQuadAllocator::Heap(&mut held);
+ let left = self.paint_pane_bar_window_chrome(
+ &mut held_layers,
+ &mut window_items,
+ window_chrome,
+ button_x,
+ pane_y as usize,
+ nav_height,
+ button_size,
+ icon_size,
+ )?;
+ drop(held_layers);
+ let out = button_x.saturating_sub(left).saturating_sub(room) as f32;
+ held.apply_to_clipped_at(layers, out, 0.0, bar_clip, self.pane_bars_stand_in_share())
+ .context("pane bar window buttons")?;
+ if self.pane_bars_stand_in() {
+ self.window_tab_reveal
+ .note_window_chrome(left, pane_y as usize + nav_height);
+ }
+ }
+ button_x = button_x.saturating_sub(room);
+ let toggle_share = self.pane_bar_sidebar_toggle_share(pos);
+ if toggle_share > 0.0 {
+ let toggle_x =
+ pane_x as usize + self.window_tab_leading_action_start_pixels().ceil() as usize;
+ let mut held = HeapQuadAllocator::default();
+ let mut held_layers = TripleLayerQuadAllocator::Heap(&mut held);
+ self.paint_window_sidebar_toggle_button(
+ &mut held_layers,
+ &mut window_items,
+ toggle_x,
+ button_y,
+ button_size,
+ self.window_tab_sidebar_toggle_icon_size(),
+ foreground,
+ muted_fg,
+ )?;
+ drop(held_layers);
+ // Out past the bar's start, just clear of its tabs on their way.
+ let out = ((toggle_x + button_size) as f32 - pane_x) * (1.0 - toggle_share);
+ held.apply_to_clipped_at(layers, -out, 0.0, bar_clip, toggle_share)
+ .context("pane bar sidebar toggle")?;
+ if toggle_share >= 1.0 {
+ self.window_tab_reveal
+ .note_sidebar_toggle(toggle_x + button_size, pane_y as usize + nav_height);
+ }
+ }
+ if self.pane_bars_stand_in() {
+ self.ui_items.extend(window_items);
+ }
let mut actions = vec![
(SvgIcon::Plus, PaneNavAction::NewTab),
(SvgIcon::SplitVertical, PaneNavAction::SplitDown),
@@ -1118,7 +1224,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, pos.top);
+ let tab_start = pane_x as usize + self.pane_nav_tab_left_inset(pos);
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/sidebar_hover.rs b/wezterm-gui/src/termwindow/sidebar_hover.rs
index 86832d63..b6163c75 100644
--- a/wezterm-gui/src/termwindow/sidebar_hover.rs
+++ b/wezterm-gui/src/termwindow/sidebar_hover.rs
@@ -267,6 +267,17 @@ impl SidebarHoverReveal {
matches!(self.phase, Phase::Arming { .. })
}
+ /// How far a dwell that is counting down has got, 0 to 1.
+ pub(crate) fn arming_progress(&self, now: Instant) -> Option<f32> {
+ match self.phase {
+ Phase::Arming { since } => Some(
+ (now.saturating_duration_since(since).as_secs_f32() / DWELL.as_secs_f32())
+ .min(1.0),
+ ),
+ _ => None,
+ }
+ }
+
/// Whether the machine still owes frames — a travel in flight or a dwell
/// or grace counting down. Feeds the unfocused-window frame gate.
pub(crate) fn needs_frames(&self) -> bool {
@@ -383,6 +394,19 @@ mod tests {
panic!("panel never settled");
}
+ #[test]
+ fn a_dwell_counts_up_while_it_runs_and_only_then() {
+ let start = Instant::now();
+ let mut machine = SidebarHoverReveal::default();
+ assert_eq!(machine.arming_progress(start), None);
+ machine.step(input(PointerZone::HotZone), start);
+ assert_eq!(machine.arming_progress(start), Some(0.0));
+ let half = at(start, SIDEBAR_HOVER_DWELL_MS / 2);
+ assert!((machine.arming_progress(half).unwrap() - 0.5).abs() < 0.01);
+ machine.step(input(PointerZone::HotZone), at(start, SIDEBAR_HOVER_DWELL_MS));
+ assert_eq!(machine.arming_progress(at(start, SIDEBAR_HOVER_DWELL_MS)), None);
+ }
+
#[test]
fn a_pointer_passing_through_the_edge_never_reveals() {
let start = Instant::now();
diff --git a/wezterm-gui/src/termwindow/ui/right_sidebar.rs b/wezterm-gui/src/termwindow/ui/right_sidebar.rs
index acf96e95..f26a6138 100644
--- a/wezterm-gui/src/termwindow/ui/right_sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/right_sidebar.rs
@@ -2508,10 +2508,11 @@ impl crate::TermWindow {
/// window pixels. Computed against the docked rect so it exists while the
/// panel does not; like the left one it leaves out the tab bar row, where
/// the pointer is on its way to the tabs or the sidebar button -- as much
- /// of the row as is out, when it hides.
+ /// of the row as is out, when it hides, or the pane bar holding its
+ /// buttons.
pub(crate) fn right_sidebar_hover_hot_zone(&self) -> Option<(usize, usize, usize, usize)> {
let rect = self.right_sidebar_rect_for_width(self.right_sidebar_docked_width())?;
- let top_tab_bar_height = self.window_tab_row_drawn_height().ceil() as usize;
+ let top_tab_bar_height = self.window_top_right_chrome_height().ceil() as usize;
let width = self.ui_px(crate::termwindow::ui::tokens::SIDEBAR_HOVER_HOT_ZONE_WIDTH);
let right_edge = rect.x.saturating_add(rect.width);
crate::termwindow::sidebar_hover::hot_zone(
@@ -8417,9 +8418,9 @@ impl crate::TermWindow {
// Off macOS the panel has no toggle of its own and the tab bar keeps
// the window buttons at its right end; a hover-revealed panel stays
// below the tab bar so both remain reachable -- below as much of it
- // as is out, when it hides.
+ // as is out, when it hides, or below the pane bar holding them.
if !cfg!(target_os = "macos") && self.right_sidebar_collapsed {
- let tab_bar = self.window_tab_row_drawn_height().ceil() as usize;
+ let tab_bar = self.window_top_right_chrome_height().ceil() as usize;
let top = rect.y.saturating_add(tab_bar);
rect.height = rect.height.saturating_sub(top - rect.y);
rect.y = top;
diff --git a/wezterm-gui/src/termwindow/ui/sidebar.rs b/wezterm-gui/src/termwindow/ui/sidebar.rs
index b9ec8ec3..93362cd8 100644
--- a/wezterm-gui/src/termwindow/ui/sidebar.rs
+++ b/wezterm-gui/src/termwindow/ui/sidebar.rs
@@ -393,11 +393,11 @@ impl crate::TermWindow {
pub(crate) fn workspace_sidebar_hover_hot_zone(&self) -> Option<(usize, usize, usize, usize)> {
let rect = self.workspace_sidebar_rect_for_width(self.workspace_sidebar_docked_width())?;
// The traffic lights stay at the top-left when the window tab row
- // hides; off macOS nothing of the row's does.
+ // hides; off macOS the sidebar button does, in the pane bar there.
let top_tab_bar_height = if cfg!(target_os = "macos") {
self.tab_bar_pixel_height().unwrap_or(0.0)
} else {
- self.window_tab_row_drawn_height()
+ self.window_top_left_chrome_height()
}
.ceil() as usize;
crate::termwindow::sidebar_hover::hot_zone(
diff --git a/wezterm-gui/src/termwindow/ui/tokens.rs b/wezterm-gui/src/termwindow/ui/tokens.rs
index 82133107..e219219f 100644
--- a/wezterm-gui/src/termwindow/ui/tokens.rs
+++ b/wezterm-gui/src/termwindow/ui/tokens.rs
@@ -41,6 +41,12 @@ pub const SIDEBAR_HOVER_GRACE_MS: u64 = 400;
pub const WINDOW_TAB_REVEAL_HOT_ZONE_HEIGHT: usize = 20;
/// The top strip's counterpart of `SIDEBAR_HOVER_STICKY_ZONE_WIDTH`.
pub const WINDOW_TAB_REVEAL_STICKY_ZONE_HEIGHT: usize = 36;
+/// Over a pane bar's tabs and buttons, which the row's going leaves along
+/// the window's top, only this much of the strip counts: a pointer resting
+/// on one to click it is not asking for the row, one pushed on past it to
+/// the edge still is. So too over a blank standing in for the title bar,
+/// where the pointer comes to move the window.
+pub const WINDOW_TAB_REVEAL_EDGE_OVER_CONTROLS_HEIGHT: usize = 8;
/// 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.
diff --git a/wezterm-gui/src/termwindow/window_tab_reveal.rs b/wezterm-gui/src/termwindow/window_tab_reveal.rs
index 14c201a3..5fa830dd 100644
--- a/wezterm-gui/src/termwindow/window_tab_reveal.rs
+++ b/wezterm-gui/src/termwindow/window_tab_reveal.rs
@@ -7,19 +7,25 @@
//! 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.
+//!
+//! macOS keeps its traffic lights while the row is away. Elsewhere the row
+//! holds the window's own buttons and the sidebars' toggles, so the pane
+//! bars along the top hold them instead, and their blank moves the window.
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,
+ WINDOW_RESIZE_EDGE_HEIGHT, WINDOW_TAB_REVEAL_EDGE_OVER_CONTROLS_HEIGHT,
+ WINDOW_TAB_REVEAL_HOT_ZONE_HEIGHT, WINDOW_TAB_REVEAL_STICKY_ZONE_HEIGHT,
};
use crate::termwindow::{
- InlineTabRenameTarget, TermWindow, TermWindowNotif, UIItem, UIItemType,
+ InlineTabRenameTarget, PaneNavAction, TermWindow, TermWindowNotif, UIItem, UIItemType,
};
+use mux::tab::PositionedPane;
+use mux::Mux;
use std::time::Instant;
-use window::{WindowDecorations, WindowOps};
+use window::{MouseEvent, WindowDecorations, WindowOps, WindowState};
#[derive(Debug, Clone, Default)]
pub(crate) struct WindowTabReveal {
@@ -29,6 +35,12 @@ pub(crate) struct WindowTabReveal {
/// 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,
+ /// How far the dwell has counted, likewise.
+ arming: Option<f32>,
+ /// Where the pane bars along the top held what the row would, in the
+ /// last frame, and so far in this one.
+ held: PaneBarsHeld,
+ holding: PaneBarsHeld,
}
impl WindowTabReveal {
@@ -65,10 +77,77 @@ impl WindowTabReveal {
self.hover.needs_frames()
}
+ /// How far the dwell has counted while the pointer rests in the strip,
+ /// 0 to 1, as of the last step.
+ pub(crate) fn arming(&self) -> Option<f32> {
+ self.arming
+ }
+
/// Focus loss: put the row away without a travel.
pub(crate) fn cancel(&mut self) {
self.hover.cancel_immediately();
self.shown = 0.0;
+ self.arming = None;
+ }
+
+ /// A paint pass begins: what its pane bars hold is gathered afresh, and
+ /// the pointer goes by the last one's until it is done.
+ pub(crate) fn begin_paint(&mut self) {
+ self.holding = PaneBarsHeld::default();
+ }
+
+ /// A paint pass is done: the pointer goes by what its pane bars held.
+ pub(crate) fn finish_paint(&mut self) {
+ self.held = self.holding;
+ }
+
+ /// The top-right pane bar holds the row's buttons from `left` to its
+ /// end, down to `bottom`.
+ pub(crate) fn note_window_chrome(&mut self, left: usize, bottom: usize) {
+ self.holding.window_chrome = Some((left, bottom));
+ }
+
+ /// The top-left pane bar holds the sidebar's toggle up to `right`, down
+ /// to `bottom`.
+ pub(crate) fn note_sidebar_toggle(&mut self, right: usize, bottom: usize) {
+ self.holding.sidebar_toggle = Some((right, bottom));
+ }
+}
+
+/// Where the pane bars along the window's top hold what the row would, in
+/// window pixels.
+#[derive(Debug, Clone, Copy, Default)]
+struct PaneBarsHeld {
+ window_chrome: Option<(usize, usize)>,
+ sidebar_toggle: Option<(usize, usize)>,
+}
+
+impl PaneBarsHeld {
+ /// The pointer at `x`, `y` is over what they hold: on its way to a
+ /// button, not to the row.
+ fn covers(self, x: isize, y: isize) -> bool {
+ if x < 0 || y < 0 {
+ return false;
+ }
+ let (x, y) = (x as usize, y as usize);
+ self.window_chrome
+ .is_some_and(|(left, bottom)| x >= left && y < bottom)
+ || self
+ .sidebar_toggle
+ .is_some_and(|(right, bottom)| x < right && y < bottom)
+ }
+}
+
+/// What the top-right pane bar takes over from a row that is away.
+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
+pub(crate) struct PaneBarWindowChrome {
+ pub(crate) right_sidebar_toggle: bool,
+ pub(crate) window_buttons: bool,
+}
+
+impl PaneBarWindowChrome {
+ pub(crate) fn any(self) -> bool {
+ self.right_sidebar_toggle || self.window_buttons
}
}
@@ -162,6 +241,111 @@ impl TermWindow {
}])
}
+ /// Off macOS, while the row auto-hides, the pane bars along the window's
+ /// top keep room for what it holds that has nowhere else to be -- the
+ /// window's buttons and the sidebars' toggles -- as macOS keeps its
+ /// traffic lights: all of it while the row is away, none once it is
+ /// down, in step as it comes. 0 where they keep none.
+ pub(crate) fn pane_bars_stand_in_share(&self) -> f32 {
+ if cfg!(target_os = "macos")
+ || self.window_tab_reveal.in_layout()
+ || self.tab_bar_pixel_height().unwrap_or(0.0) <= 0.0
+ {
+ return 0.0;
+ }
+ 1.0 - self.window_tab_reveal.shown
+ }
+
+ /// The row is away and the pane bars along the top draw what they keep
+ /// room for. Once it starts down, it carries its own.
+ pub(crate) fn pane_bars_stand_in(&self) -> bool {
+ self.pane_bars_stand_in_share() >= 1.0
+ }
+
+ /// As `pane_bars_stand_in_share`, for `pos`'s bar starting with the
+ /// workspace sidebar's toggle: the one at the top left, wherever the row
+ /// would draw one.
+ pub(crate) fn pane_bar_sidebar_toggle_share(&self, pos: &PositionedPane) -> f32 {
+ let share = self.pane_bars_stand_in_share();
+ if share > 0.0
+ && pos.left == 0
+ && pos.top == 0
+ && self.window_tab_shows_sidebar_toggle_action()
+ {
+ share
+ } else {
+ 0.0
+ }
+ }
+
+ /// What `pos`'s bar ends with, as the bar at the top right standing in
+ /// for the row: the right sidebar's toggle, and the window's own
+ /// buttons unless an open sidebar holds them. A bar too narrow for them
+ /// all holds none, and the row has to come down for them.
+ pub(crate) fn pane_bar_window_chrome(&self, pos: &PositionedPane) -> PaneBarWindowChrome {
+ let top_right = pos.top == 0 && pos.left + pos.width >= self.terminal_size.cols;
+ if !top_right || self.pane_bars_stand_in_share() <= 0.0 {
+ return PaneBarWindowChrome::default();
+ }
+ let parts = PaneBarWindowChrome {
+ right_sidebar_toggle: self.right_sidebar_has_panels(),
+ window_buttons: self.fancy_tab_bar_shows_window_buttons()
+ && self.right_sidebar_width() == 0,
+ };
+ let fits = self
+ .pane_chrome_span(pos)
+ .is_ok_and(|(_, width)| self.pane_bar_fits_window_chrome(pos, parts, width));
+ if parts.any() && fits {
+ parts
+ } else {
+ PaneBarWindowChrome::default()
+ }
+ }
+
+ /// How far down from the window's top its chrome reaches at the right:
+ /// the row as it stands, or the pane bar holding what the row would.
+ pub(crate) fn window_top_right_chrome_height(&self) -> f32 {
+ let bar = self.window_tab_reveal.held.window_chrome;
+ self.window_tab_row_drawn_height().max(self.below_window_top(bar))
+ }
+
+ /// As `window_top_right_chrome_height`, at the left.
+ pub(crate) fn window_top_left_chrome_height(&self) -> f32 {
+ let bar = self.window_tab_reveal.held.sidebar_toggle;
+ self.window_tab_row_drawn_height().max(self.below_window_top(bar))
+ }
+
+ fn below_window_top(&self, held: Option<(usize, usize)>) -> f32 {
+ held.map_or(0.0, |(_, bottom)| {
+ bottom.saturating_sub(self.get_os_border().top.get() as usize) as f32
+ })
+ }
+
+ /// `item` is the blank of a pane bar along the window's top, and stands
+ /// in for the row's as the title bar: not where the system draws one,
+ /// nor in full screen, where there is no window to move, nor on the
+ /// strip of a collapsed stack, which runs the window's height.
+ pub(crate) fn pane_bar_blank_is_title_bar(&self, item: &UIItem) -> bool {
+ let UIItemType::PaneNav {
+ pane_id,
+ action: PaneNavAction::Background,
+ ..
+ } = item.item_type
+ else {
+ return false;
+ };
+ self.pane_bars_stand_in()
+ && !self.config.window_decorations.contains(WindowDecorations::TITLE)
+ && !self
+ .window_state
+ .intersects(WindowState::FULL_SCREEN | WindowState::SERVER_DECORATED)
+ && item.y <= self.get_os_border().top.get() as usize
+ && !Mux::get()
+ .get_active_tab_for_window(self.mux_window_id)
+ .and_then(|tab| tab.pane_stack_id(pane_id))
+ .is_some_and(|stack_id| self.collapsed_pane_layouts.contains_key(&stack_id))
+ }
+
/// 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
@@ -205,16 +389,25 @@ impl TermWindow {
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;
+ let below = |height: usize| y < edge + self.ui_px(height) 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 {
+ } else if self.window_tab_reveal.held.covers(x, y)
+ || !below(WINDOW_TAB_REVEAL_STICKY_ZONE_HEIGHT)
+ {
+ PointerZone::Away
+ } else if self.pointer_on_pane_bar_control(event) {
+ if below(WINDOW_TAB_REVEAL_EDGE_OVER_CONTROLS_HEIGHT) {
+ PointerZone::HotZone
+ } else {
+ PointerZone::Away
+ }
+ } else if below(WINDOW_TAB_REVEAL_HOT_ZONE_HEIGHT) {
PointerZone::HotZone
- } else if y < edge + self.ui_px(WINDOW_TAB_REVEAL_STICKY_ZONE_HEIGHT) as isize {
- PointerZone::NearHotZone
} else {
- PointerZone::Away
+ PointerZone::NearHotZone
}
}
};
@@ -230,6 +423,20 @@ impl TermWindow {
}
}
+ /// The pointer is over something of a pane bar's it may well be there
+ /// for rather than for the row, as the last frame laid them out: a tab,
+ /// a button, or a blank standing in for the title bar.
+ fn pointer_on_pane_bar_control(&self, event: &MouseEvent) -> bool {
+ self.resolve_ui_item(event).is_some_and(|item| match item.item_type {
+ UIItemType::PaneNav {
+ action: PaneNavAction::Background,
+ ..
+ } => self.pane_bar_blank_is_title_bar(&item),
+ UIItemType::PaneNav { .. } => true,
+ _ => false,
+ })
+ }
+
/// 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.
@@ -237,6 +444,7 @@ impl TermWindow {
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);
+ self.window_tab_reveal.arming = self.window_tab_reveal.hover.arming_progress(now);
match frame {
HoverFrame::None => {}
HoverFrame::Now => {
@@ -246,6 +454,13 @@ impl TermWindow {
}
HoverFrame::At(due) => self.update_next_frame_time(Some(due)),
}
+ // The hint along the top fades up as the dwell counts, which takes
+ // every frame of it: a pointer only passing through barely shows it.
+ if self.window_tab_reveal.arming.is_some() {
+ if let Some(window) = self.window.as_ref() {
+ window.invalidate();
+ }
+ }
}
/// Feed a pointer event to the row's hover machine. Never consumes it.
@@ -322,6 +537,20 @@ impl TermWindow {
mod tests {
use super::*;
+ #[test]
+ fn the_buttons_a_pane_bar_holds_do_not_bring_the_row_down() {
+ let held = PaneBarsHeld {
+ window_chrome: Some((600, 30)),
+ sidebar_toggle: Some((40, 30)),
+ };
+ assert!(held.covers(700, 10));
+ assert!(held.covers(20, 10));
+ assert!(!held.covers(300, 10));
+ assert!(!held.covers(700, 30));
+ assert!(!held.covers(-1, 10));
+ assert!(!PaneBarsHeld::default().covers(700, 10));
+ }
+
#[test]
fn only_a_shown_or_pinned_row_keeps_its_place() {
assert!(row_in_layout(NativeWindowTabs::Show, false));