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.

fix(gui): move a thread window by its top bar on macOS

RoversX7d93b8332a35
diff --git a/wezterm-gui/src/termwindow/window_tab_reveal.rs b/wezterm-gui/src/termwindow/window_tab_reveal.rs
index 3475b441..5d5ec053 100644
--- a/wezterm-gui/src/termwindow/window_tab_reveal.rs
+++ b/wezterm-gui/src/termwindow/window_tab_reveal.rs
@@ -25,7 +25,7 @@ use crate::termwindow::{
use mux::tab::PositionedPane;
use mux::Mux;
use std::time::Instant;
-use window::{MouseEvent, WindowDecorations, WindowOps, WindowState};
+use window::{IntegratedTitleButtonStyle, MouseEvent, WindowDecorations, WindowOps, WindowState};
#[derive(Debug, Clone, Default)]
pub(crate) struct WindowTabReveal {
@@ -172,6 +172,25 @@ fn row_in_layout(mode: NativeWindowTabs, pinned: bool) -> bool {
}
}
+/// Whether the window has a title bar of the system's above what it draws.
+/// macOS mostly keeps its bar over the content, `TITLE` or not, and what
+/// lies under it there is for the window to say.
+#[cfg(target_os = "macos")]
+fn title_bar_above_content(
+ decorations: WindowDecorations,
+ button_style: IntegratedTitleButtonStyle,
+) -> bool {
+ !::window::os::macos::content_under_title_bar(decorations, button_style)
+}
+
+#[cfg(not(target_os = "macos"))]
+fn title_bar_above_content(
+ decorations: WindowDecorations,
+ _button_style: IntegratedTitleButtonStyle,
+) -> bool {
+ decorations.contains(WindowDecorations::TITLE)
+}
+
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
@@ -347,7 +366,10 @@ impl TermWindow {
return false;
};
(self.pane_bars_stand_in() || self.window_tab_reveal.always_hiding)
- && !self.config.window_decorations.contains(WindowDecorations::TITLE)
+ && !title_bar_above_content(
+ self.config.window_decorations,
+ self.config.integrated_title_button_style,
+ )
&& !self
.window_state
.intersects(WindowState::FULL_SCREEN | WindowState::SERVER_DECORATED)
@@ -573,6 +595,24 @@ mod tests {
assert!(!PaneBarsHeld::default().covers(700, 10));
}
+ #[test]
+ fn a_window_left_to_its_defaults_has_no_title_bar_above_its_pane_bars() {
+ assert!(!title_bar_above_content(
+ WindowDecorations::default(),
+ IntegratedTitleButtonStyle::default()
+ ));
+ }
+
+ #[test]
+ fn a_title_bar_is_above_the_pane_bars_only_where_the_window_keeps_it_there() {
+ let style = IntegratedTitleButtonStyle::default();
+ assert!(title_bar_above_content(WindowDecorations::TITLE, style));
+ assert_eq!(
+ title_bar_above_content(WindowDecorations::TITLE | WindowDecorations::RESIZE, style),
+ !cfg!(target_os = "macos")
+ );
+ }
+
#[test]
fn only_a_shown_or_pinned_row_keeps_its_place() {
assert!(row_in_layout(NativeWindowTabs::Show, false));
diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs
index e89b99d5..0850b78a 100644
--- a/window/src/os/macos/window.rs
+++ b/window/src/os/macos/window.rs
@@ -2938,6 +2938,16 @@ fn thinkterm_titlebar_sidebar_button(titlebar_view_container: &StrongPtr) -> Opt
}
}
+/// Whether a window with these decorations has its content run on under the
+/// title bar, rather than starting below it.
+pub fn content_under_title_bar(
+ decorations: WindowDecorations,
+ integrated_title_button_style: IntegratedTitleButtonStyle,
+) -> bool {
+ decoration_to_mask(decorations, integrated_title_button_style)
+ .contains(NSWindowStyleMask::NSFullSizeContentViewWindowMask)
+}
+
fn decoration_to_mask(
decorations: WindowDecorations,
integrated_title_button_style: IntegratedTitleButtonStyle,