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(macos): add a frosted window backdrop and drop clear-over-blur

RoversX06c523aa606b
diff --git a/config/src/background.rs b/config/src/background.rs
index 6763d407..0e081a48 100644
--- a/config/src/background.rs
+++ b/config/src/background.rs
@@ -313,16 +313,15 @@ pub enum Win32BackdropTrial {
}
/// What a see-through window on macOS shows behind it: the blur of
-/// `macos_window_background_blur`, or Liquid Glass (macOS 26 and later) in
-/// its regular or clear style, the clear one alone or over a blur of its
-/// own.
+/// `macos_window_background_blur`, the system's frosted material, or Liquid
+/// Glass (macOS 26 and later) in its regular or clear style.
#[derive(Debug, Copy, Clone, FromDynamic, ToDynamic, PartialEq, Eq, Default)]
pub enum MacosWindowGlass {
#[default]
Blur,
+ Frosted,
Regular,
Clear,
- ClearOverBlur,
}
pub fn default_win32_acrylic_accent_color() -> RgbaColor {
diff --git a/thinkterm-i18n/i18n/de-DE.ftl b/thinkterm-i18n/i18n/de-DE.ftl
index b1090803..150635cd 100644
--- a/thinkterm-i18n/i18n/de-DE.ftl
+++ b/thinkterm-i18n/i18n/de-DE.ftl
@@ -127,9 +127,9 @@ settings-window-opacity-platforms = Unter Linux noch nicht verfügbar, unter Win
settings-mac-glass = Glaseffekt
settings-mac-glass-description = Was ein durchscheinendes Fenster hinter sich zeigt.
settings-mac-glass-blur = Unschärfe
+settings-mac-glass-frosted = Milchglas
settings-mac-glass-regular = Liquid Glass
settings-mac-glass-clear = Klares Glas
-settings-mac-glass-clear-over-blur = Klar + Unschärfe
settings-sidebar-shade = Farbe der Seitenleisten
settings-sidebar-shade-description = Wie dunkel beide Seitenleisten sind, in einem durchscheinenden Fenster.
settings-appearance-sidebar-heading = Symbole und Status
diff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftl
index fe124da2..94726ed7 100644
--- a/thinkterm-i18n/i18n/en-US.ftl
+++ b/thinkterm-i18n/i18n/en-US.ftl
@@ -127,9 +127,9 @@ settings-window-opacity-platforms = Not available on Linux yet, and not yet stab
settings-mac-glass = Glass effect
settings-mac-glass-description = What a see-through window shows behind it.
settings-mac-glass-blur = Blur
+settings-mac-glass-frosted = Frosted
settings-mac-glass-regular = Liquid Glass
settings-mac-glass-clear = Clear glass
-settings-mac-glass-clear-over-blur = Clear + blur
settings-sidebar-shade = Sidebar color
settings-sidebar-shade-description = How dark both sidebars are, in a see-through window.
settings-appearance-sidebar-heading = Icons and status
diff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftl
index 8d40aa56..dec5d607 100644
--- a/thinkterm-i18n/i18n/fr-FR.ftl
+++ b/thinkterm-i18n/i18n/fr-FR.ftl
@@ -127,9 +127,9 @@ settings-window-opacity-platforms = Pas encore disponible sous Linux, pas encore
settings-mac-glass = Effet de verre
settings-mac-glass-description = Ce qu'une fenêtre transparente montre derrière elle.
settings-mac-glass-blur = Flou
+settings-mac-glass-frosted = Dépoli
settings-mac-glass-regular = Liquid Glass
settings-mac-glass-clear = Verre clair
-settings-mac-glass-clear-over-blur = Clair + flou
settings-sidebar-shade = Couleur des barres latérales
settings-sidebar-shade-description = Le ton des deux barres latérales, dans une fenêtre transparente.
settings-appearance-sidebar-heading = Icônes et état
diff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftl
index 3c64b264..412e375d 100644
--- a/thinkterm-i18n/i18n/ja-JP.ftl
+++ b/thinkterm-i18n/i18n/ja-JP.ftl
@@ -124,9 +124,9 @@ settings-window-opacity-platforms = Linux では未対応、Windows ではまだ
settings-mac-glass = ガラス効果
settings-mac-glass-description = ウインドウが透けているとき、背後に何を表示するか。
settings-mac-glass-blur = ぼかし
+settings-mac-glass-frosted = すりガラス
settings-mac-glass-regular = Liquid Glass
settings-mac-glass-clear = クリアガラス
-settings-mac-glass-clear-over-blur = クリア+ぼかし
settings-sidebar-shade = サイドバーの色
settings-sidebar-shade-description = 左右のサイドバーの濃さ。ウインドウが透けているときに効きます。
settings-appearance-sidebar-heading = アイコンと状態
diff --git a/thinkterm-i18n/i18n/ru-RU.ftl b/thinkterm-i18n/i18n/ru-RU.ftl
index eefc0a6a..11f8f9e9 100644
--- a/thinkterm-i18n/i18n/ru-RU.ftl
+++ b/thinkterm-i18n/i18n/ru-RU.ftl
@@ -124,9 +124,9 @@ settings-window-opacity-platforms = Пока недоступно в Linux и н
settings-mac-glass = Эффект стекла
settings-mac-glass-description = Как выглядит фон за прозрачным окном.
settings-mac-glass-blur = Размытие
+settings-mac-glass-frosted = Матовое стекло
settings-mac-glass-regular = Liquid Glass
settings-mac-glass-clear = Прозрачное стекло
-settings-mac-glass-clear-over-blur = Стекло и размытие
settings-sidebar-shade = Цвет боковых панелей
settings-sidebar-shade-description = Насколько тёмными будут обе боковые панели в прозрачном окне.
settings-appearance-sidebar-heading = Значки и состояние
diff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftl
index 71a40953..dfa80e32 100644
--- a/thinkterm-i18n/i18n/zh-CN.ftl
+++ b/thinkterm-i18n/i18n/zh-CN.ftl
@@ -124,9 +124,9 @@ settings-window-opacity-platforms = Linux 暂时不支持,Windows 上还不够
settings-mac-glass = 玻璃效果
settings-mac-glass-description = 窗口透明时,背后显示什么。
settings-mac-glass-blur = 模糊
+settings-mac-glass-frosted = 磨砂
settings-mac-glass-regular = 液态玻璃
settings-mac-glass-clear = 通透玻璃
-settings-mac-glass-clear-over-blur = 通透+模糊
settings-sidebar-shade = 侧栏颜色
settings-sidebar-shade-description = 左右两个侧栏的深浅,窗口透明时生效。
settings-appearance-sidebar-heading = 图标与状态
diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rs
index be78e4d2..4924fcd1 100644
--- a/wezterm-gui/src/native_settings.rs
+++ b/wezterm-gui/src/native_settings.rs
@@ -606,28 +606,37 @@ impl NativeThreadStatus {
pub(crate) const ALL: [Self; 4] = [Self::Ring, Self::Pulse, Self::Pixels, Self::Dots];
}
-/// What a see-through window shows behind it on macOS: the plain blur, or
-/// Liquid Glass (see `config::MacosWindowGlass`).
+/// What a see-through window shows behind it on macOS: the plain blur, the
+/// system's frosted material, or Liquid Glass (see
+/// `config::MacosWindowGlass`).
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub(crate) enum NativeMacGlass {
#[default]
Blur,
+ /// Clear glass over the material was offered once; the material is
+ /// what is left of it.
+ #[serde(alias = "clear_over_blur")]
+ Frosted,
Regular,
Clear,
- ClearOverBlur,
}
impl NativeMacGlass {
/// Every look, in the order the settings window offers them.
- pub(crate) const ALL: [Self; 4] = [Self::Blur, Self::Regular, Self::Clear, Self::ClearOverBlur];
+ pub(crate) const ALL: [Self; 4] = [Self::Frosted, Self::Regular, Self::Clear, Self::Blur];
+
+ /// Whether it is Liquid Glass, which only macOS 26 and later have.
+ pub(crate) fn is_liquid_glass(self) -> bool {
+ matches!(self, Self::Regular | Self::Clear)
+ }
fn glass(self) -> config::MacosWindowGlass {
match self {
Self::Blur => config::MacosWindowGlass::Blur,
+ Self::Frosted => config::MacosWindowGlass::Frosted,
Self::Regular => config::MacosWindowGlass::Regular,
Self::Clear => config::MacosWindowGlass::Clear,
- Self::ClearOverBlur => config::MacosWindowGlass::ClearOverBlur,
}
}
}
@@ -3734,12 +3743,12 @@ mod tests {
fn the_mac_glass_is_asked_for_on_macos_and_read_whatever_was_written() {
use wezterm_dynamic::ToDynamic;
let mut settings = ThinkTermNativeSettings::default();
- settings.appearance.mac_glass = NativeMacGlass::ClearOverBlur;
+ settings.appearance.mac_glass = NativeMacGlass::Frosted;
let [.., glass] = window_opacity_overrides(&settings);
assert_eq!(
glass.1,
cfg!(target_os = "macos")
- .then(|| config::MacosWindowGlass::ClearOverBlur.to_dynamic())
+ .then(|| config::MacosWindowGlass::Frosted.to_dynamic())
);
let read = |written: &str| {
let text = format!(r#"{{"appearance":{{"mac_glass":{written}}}}}"#);
@@ -3748,7 +3757,9 @@ mod tests {
.appearance
.mac_glass
};
- assert_eq!(read(r#""clear_over_blur""#), NativeMacGlass::ClearOverBlur);
+ assert_eq!(read(r#""frosted""#), NativeMacGlass::Frosted);
+ // Clear glass over the blur became the blur on its own.
+ assert_eq!(read(r#""clear_over_blur""#), NativeMacGlass::Frosted);
// A look tried and dropped reads as the blur.
assert_eq!(read(r#""regular_over_blur""#), NativeMacGlass::Blur);
assert_eq!(read(r#""something_new""#), NativeMacGlass::Blur);
diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rs
index f26aef5f..8d90fd6c 100644
--- a/wezterm-gui/src/settings_window.rs
+++ b/wezterm-gui/src/settings_window.rs
@@ -1769,9 +1769,9 @@ fn localized_mac_glass_label(glass: crate::native_settings::NativeMacGlass) -> S
use crate::native_settings::NativeMacGlass;
crate::i18n::tr(match glass {
NativeMacGlass::Blur => "settings-mac-glass-blur",
+ NativeMacGlass::Frosted => "settings-mac-glass-frosted",
NativeMacGlass::Regular => "settings-mac-glass-regular",
NativeMacGlass::Clear => "settings-mac-glass-clear",
- NativeMacGlass::ClearOverBlur => "settings-mac-glass-clear-over-blur",
})
}
@@ -9474,7 +9474,7 @@ impl SettingsWindow {
TileColor::Blue,
)?;
rows.add(this.paint_window_opacity_row(layers, tx, rows.y, tw, rows.rule())?);
- if cfg!(target_os = "macos") && liquid_glass_available() {
+ if cfg!(target_os = "macos") {
let (tx, tw) = this.paint_row_tile(
layers,
row_x,
@@ -20332,6 +20332,7 @@ impl SettingsWindow {
let current = self.native_settings.appearance.mac_glass;
crate::native_settings::NativeMacGlass::ALL
.iter()
+ .filter(|glass| !glass.is_liquid_glass() || liquid_glass_available())
.map(|glass| {
(
localized_mac_glass_label(*glass),
diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs
index 0850b78a..61c80654 100644
--- a/window/src/os/macos/window.rs
+++ b/window/src/os/macos/window.rs
@@ -790,14 +790,11 @@ pub(crate) struct WindowInner {
window: StrongPtr,
config: ConfigHandle,
titlebar_sidebar_button_visible: bool,
- /// The Liquid Glass the view sits in while the window is see-through,
- /// in place of it as the window's content view, and the look it was
- /// made for: see `update_glass`.
- glass: Option<(StrongPtr, GlassLook)>,
- /// What the glass sits on when the look has a blur under it: an
- /// `NSVisualEffectView` blurring the desktop behind the window, as the
- /// window's content view in the glass's place.
- glass_backing: Option<StrongPtr>,
+ /// What the view sits in while the window is see-through -- Liquid
+ /// Glass or the frosted material -- in place of it as the window's
+ /// content view, and the backdrop it was made for: see
+ /// `update_backdrop`.
+ backdrop: Option<(StrongPtr, Backdrop)>,
/// What the window hangs on itself to be a card.
floating: Option<FloatingViews>,
}
@@ -872,24 +869,26 @@ unsafe fn opaque_mask_part(frame: NSRect) -> id {
part
}
-/// Liquid Glass as `NSGlassEffectView` draws it: its style, and whether it
-/// sits on a blur of its own.
+/// What a see-through window's view sits in: Liquid Glass as
+/// `NSGlassEffectView` draws it, in one of its styles, or the frosted
+/// material of an `NSVisualEffectView` blurring the desktop behind.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-struct GlassLook {
- style: isize,
- over_blur: bool,
+enum Backdrop {
+ Glass { style: isize },
+ Frosted,
}
-impl GlassLook {
- /// The look `glass` asks for, or `None` for the plain blur.
+impl Backdrop {
+ /// The backdrop `glass` asks for here, or `None` for the plain blur:
+ /// also where this macOS has no Liquid Glass.
fn of(glass: MacosWindowGlass) -> Option<Self> {
- let (style, over_blur) = match glass {
- MacosWindowGlass::Blur => return None,
- MacosWindowGlass::Regular => (0, false),
- MacosWindowGlass::Clear => (1, false),
- MacosWindowGlass::ClearOverBlur => (1, true),
- };
- Some(Self { style, over_blur })
+ let glass_style = |style| liquid_glass_available().then_some(Self::Glass { style });
+ match glass {
+ MacosWindowGlass::Blur => None,
+ MacosWindowGlass::Frosted => Some(Self::Frosted),
+ MacosWindowGlass::Regular => glass_style(0),
+ MacosWindowGlass::Clear => glass_style(1),
+ }
}
}
@@ -1186,8 +1185,7 @@ impl Window {
view,
config: config.clone(),
titlebar_sidebar_button_visible: false,
- glass: None,
- glass_backing: None,
+ backdrop: None,
floating: None,
}));
inner.borrow_mut().window.replace(weak_window);
@@ -1957,14 +1955,14 @@ impl WindowInner {
{
false
} else {
- // Glass is a surface of its own, and its shadow takes its
- // shape -- except clear glass alone, which lets the text's
- // alpha through as the plain window does (wezterm#310).
+ // Glass and the material are surfaces of their own, and the
+ // shadow takes their shape -- except clear glass, which lets
+ // the text's alpha through as the plain window does
+ // (wezterm#310).
is_opaque == YES
- || self
- .glass
- .as_ref()
- .is_some_and(|(_, look)| look.style == 0 || look.over_blur)
+ || self.backdrop.as_ref().is_some_and(|(_, made)| {
+ matches!(made, Backdrop::Glass { style: 0 } | Backdrop::Frosted)
+ })
};
self.window.setHasShadow_(if shadow { YES } else { NO });
}
@@ -1986,10 +1984,10 @@ impl WindowInner {
}
fn update_window_background_blur(&mut self) {
- // The glass blurs what is behind it itself, or sits on a blur of its
- // own: this one, the window server's, under it puts a dark band
- // along its rim.
- let radius = if self.glass.is_some() {
+ // The glass and the material blur what is behind them themselves:
+ // this one, the window server's, under them puts a dark band along
+ // the rim.
+ let radius = if self.backdrop.is_some() {
0
} else {
self.config.macos_window_background_blur
@@ -2003,56 +2001,70 @@ impl WindowInner {
}
}
- /// Put the view in Liquid Glass while the window is see-through and
- /// the configuration asks for it, and take it out again otherwise. The
- /// glass is the window's content view then -- or sits in the blur that
- /// is -- with ours as its content: what we draw see-through shows the
- /// glass behind it. A different look is made afresh.
- fn update_glass(&mut self) {
- let look = GlassLook::of(self.config.macos_window_glass)
- .filter(|_| self.config.window_background_opacity < 1.0)
- .filter(|_| liquid_glass_available());
- if self.glass.as_ref().map(|(_, made)| *made) == look {
+ /// Put the view in Liquid Glass or the frosted material while the
+ /// window is see-through and the configuration asks for one, and take
+ /// it out again otherwise. That is the window's content view then, with
+ /// ours in it: what we draw see-through shows it behind. A different
+ /// backdrop is made afresh.
+ fn update_backdrop(&mut self) {
+ let wanted = Backdrop::of(self.config.macos_window_glass)
+ .filter(|_| self.config.window_background_opacity < 1.0);
+ if self.backdrop.as_ref().map(|(_, made)| *made) == wanted {
return;
}
unsafe {
- if let Some((glass, _)) = self.glass.take() {
- let () = msg_send![*glass, setContentView: nil];
+ if let Some((holder, made)) = self.backdrop.take() {
+ match made {
+ Backdrop::Glass { .. } => {
+ let () = msg_send![*holder, setContentView: nil];
+ }
+ Backdrop::Frosted => {
+ let () = msg_send![*self.view, removeFromSuperview];
+ }
+ }
self.window.setContentView_(*self.view);
- self.glass_backing = None;
}
- if let Some(look) = look {
+ if let Some(backdrop) = wanted {
let frame = NSView::frame(*self.view);
- let glass: id = msg_send![class!(NSGlassEffectView), alloc];
- let glass = StrongPtr::new(msg_send![glass, initWithFrame: frame]);
- let () = msg_send![*glass, setStyle: look.style];
- let () = msg_send![*glass, setCornerRadius: window_corner_radius(*self.window)];
+ let holder = match backdrop {
+ Backdrop::Glass { style } => {
+ let glass: id = msg_send![class!(NSGlassEffectView), alloc];
+ let glass = StrongPtr::new(msg_send![glass, initWithFrame: frame]);
+ let () = msg_send![*glass, setStyle: style];
+ let () = msg_send![
+ *glass,
+ setCornerRadius: window_corner_radius(*self.window)
+ ];
+ self.window.setContentView_(*glass);
+ let () = msg_send![*glass, setContentView: *self.view];
+ glass
+ }
+ Backdrop::Frosted => {
+ let material: id = msg_send![class!(NSVisualEffectView), alloc];
+ let material = StrongPtr::new(msg_send![material, initWithFrame: frame]);
+ // Blending behind the window, always active, with the
+ // under-window material.
+ let () = msg_send![*material, setBlendingMode: 0isize];
+ let () = msg_send![*material, setState: 1isize];
+ let () = msg_send![*material, setMaterial: 21isize];
+ self.window.setContentView_(*material);
+ let bounds: NSRect = msg_send![*material, bounds];
+ let () = msg_send![*self.view, setFrame: bounds];
+ let () = msg_send![
+ *self.view,
+ setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable
+ ];
+ let () = msg_send![*material, addSubview: *self.view];
+ material
+ }
+ };
let () = msg_send![
- *glass,
+ *holder,
setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable
];
- if look.over_blur {
- let backing: id = msg_send![class!(NSVisualEffectView), alloc];
- let backing = StrongPtr::new(msg_send![backing, initWithFrame: frame]);
- // Blending behind the window, always active, with the
- // under-window material.
- let () = msg_send![*backing, setBlendingMode: 0isize];
- let () = msg_send![*backing, setState: 1isize];
- let () = msg_send![*backing, setMaterial: 21isize];
- let () = msg_send![
- *backing,
- setAutoresizingMask: NSViewHeightSizable | NSViewWidthSizable
- ];
- self.window.setContentView_(*backing);
- let () = msg_send![*backing, addSubview: *glass];
- self.glass_backing = Some(backing);
- } else {
- self.window.setContentView_(*glass);
- }
- let () = msg_send![*glass, setContentView: *self.view];
- self.glass = Some((glass, look));
+ self.backdrop = Some((holder, backdrop));
}
- log::info!("liquid glass: {look:?}");
+ log::info!("window backdrop: {wanted:?}");
let () = msg_send![*self.window, makeFirstResponder: *self.view];
}
}
@@ -2154,8 +2166,8 @@ impl WindowInner {
let () = msg_send![root_layer, addSublayer: *shadow];
self.window.setContentView_(*root);
- let content = match self.glass.as_ref() {
- Some((glass, _)) => **glass,
+ let content = match self.backdrop.as_ref() {
+ Some((holder, _)) => **holder,
None => *self.view,
};
let () = msg_send![content, setFrame: body];
@@ -2167,7 +2179,10 @@ impl WindowInner {
let picture_layer: id = msg_send![*self.view, layer];
let top_down: BOOL = msg_send![picture_layer, isGeometryFlipped];
- let picture_mask = self.glass.as_ref().map(|(glass, _)| {
+ let glass = self.backdrop.as_ref().and_then(|(holder, made)| {
+ matches!(made, Backdrop::Glass { .. }).then_some(holder)
+ });
+ let picture_mask = glass.map(|glass| {
// Borderless, the window has no corners for the glass to follow.
let () = msg_send![**glass, setCornerRadius: points(card.corner_radius)];
@@ -2696,7 +2711,7 @@ impl WindowInner {
inner.screen_changed = true;
}
}
- self.update_glass();
+ self.update_backdrop();
self.update_window_shadow();
self.update_window_background_blur();
self.update_titlebar_background();