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(windows): give a see-through window the acrylic by itself

RoversX7ab1542033a6
diff --git a/thinkterm-i18n/i18n/de-DE.ftl b/thinkterm-i18n/i18n/de-DE.ftl
index 5492a8a1..2447ea0a 100644
--- a/thinkterm-i18n/i18n/de-DE.ftl
+++ b/thinkterm-i18n/i18n/de-DE.ftl
@@ -123,8 +123,6 @@ settings-window-opacity-description = Zum Einstellen ziehen, ganz rechts ist dec
settings-window-opacity-default = Standard
settings-window-opacity-reset = Zurücksetzen
settings-window-opacity-platforms = Unter Linux noch nicht verfügbar, unter Windows noch nicht stabil.
-settings-windows-backdrop = Milchglas
-settings-windows-backdrop-description = Nutzt das Acryl von Windows 11 hinter dem Fenster. Braucht den OpenGL-Renderer und eine Deckkraft unter 100 %; wirkt nach einem Neustart von ThinkTerm.
settings-badge-beta = Beta
settings-app-icon-simple = Blaue Pille
settings-app-icon-red = Rote Pille
@@ -762,7 +760,7 @@ settings-status-stop-session-server-error = Der Sitzungsserver konnte nicht gest
settings-status-window-restore-off = Wiederherstellen des Fensterrahmens für neue macOS-Fenster deaktiviert.
settings-status-window-restore-error = Einstellung zum Wiederherstellen des Fensters konnte nicht gespeichert werden: { $error }
settings-status-renderer = Renderer auf { $renderer } gesetzt; starten Sie ThinkTerm neu, um ihn anzuwenden.
-settings-status-value-after-restart = { $setting } auf { $value } gesetzt; starten Sie ThinkTerm neu, um es anzuwenden.
+settings-status-window-acrylic-after-restart = { $setting } ist jetzt { $value }; das Milchglas erscheint nach einem Neustart von ThinkTerm (mit dem OpenGL-Renderer).
settings-status-renderer-error = Renderer-Einstellung konnte nicht gespeichert werden: { $error }
settings-status-restarting = ThinkTerm wird neu gestartet…
settings-status-restart-error = ThinkTerm konnte nicht neu gestartet werden: { $error }
diff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftl
index 149b955d..606d1121 100644
--- a/thinkterm-i18n/i18n/en-US.ftl
+++ b/thinkterm-i18n/i18n/en-US.ftl
@@ -123,8 +123,6 @@ settings-window-opacity-description = Drag to adjust; all the way right is opaqu
settings-window-opacity-default = Default
settings-window-opacity-reset = Reset to Default
settings-window-opacity-platforms = Not available on Linux yet, and not yet stable on Windows.
-settings-windows-backdrop = Frosted glass
-settings-windows-backdrop-description = Uses Windows 11's own acrylic behind the window. Needs the OpenGL renderer and an opacity below 100%; takes effect after ThinkTerm restarts.
settings-badge-beta = Beta
settings-app-icon-simple = Blue Pill
settings-app-icon-red = Red Pill
@@ -762,7 +760,7 @@ settings-status-stop-session-server-error = Could not stop the session server: {
settings-status-window-restore-off = Main window frame restore disabled for new macOS windows.
settings-status-window-restore-error = Unable to save window restore setting: { $error }
settings-status-renderer = Renderer set to { $renderer }; restart ThinkTerm to apply it.
-settings-status-value-after-restart = { $setting } set to { $value }; restart ThinkTerm to apply it.
+settings-status-window-acrylic-after-restart = { $setting } is now { $value }; the frosted glass shows after ThinkTerm restarts (with the OpenGL renderer).
settings-status-renderer-error = Unable to save renderer setting: { $error }
settings-status-restarting = Restarting ThinkTerm…
settings-status-restart-error = Unable to restart ThinkTerm: { $error }
diff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftl
index 1e232f92..81b711d1 100644
--- a/thinkterm-i18n/i18n/fr-FR.ftl
+++ b/thinkterm-i18n/i18n/fr-FR.ftl
@@ -123,8 +123,6 @@ settings-window-opacity-description = Faites glisser ; tout à droite est opaque
settings-window-opacity-default = Par défaut
settings-window-opacity-reset = Rétablir
settings-window-opacity-platforms = Pas encore disponible sous Linux, pas encore stable sous Windows.
-settings-windows-backdrop = Verre dépoli
-settings-windows-backdrop-description = Utilise l'acrylique de Windows 11 derrière la fenêtre. Demande le rendu OpenGL et une opacité sous 100 % ; s'applique après le redémarrage de ThinkTerm.
settings-badge-beta = Bêta
settings-app-icon-simple = Pilule bleue
settings-app-icon-red = Pilule rouge
@@ -762,7 +760,7 @@ settings-status-stop-session-server-error = Impossible d’arrêter le serveur d
settings-status-window-restore-off = Restauration de la taille et position désactivée pour les nouvelles fenêtres macOS.
settings-status-window-restore-error = Impossible d’enregistrer la restauration de fenêtre : { $error }
settings-status-renderer = Moteur de rendu défini sur { $renderer } ; redémarrez ThinkTerm pour l’appliquer.
-settings-status-value-after-restart = { $setting } défini sur { $value } ; redémarrez ThinkTerm pour l’appliquer.
+settings-status-window-acrylic-after-restart = { $setting } est maintenant { $value } ; le verre dépoli apparaît après le redémarrage de ThinkTerm (avec le rendu OpenGL).
settings-status-renderer-error = Impossible d’enregistrer le moteur de rendu : { $error }
settings-status-restarting = Redémarrage de ThinkTerm…
settings-status-restart-error = Impossible de redémarrer ThinkTerm : { $error }
diff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftl
index 3a69f447..fae6cbcb 100644
--- a/thinkterm-i18n/i18n/ja-JP.ftl
+++ b/thinkterm-i18n/i18n/ja-JP.ftl
@@ -120,8 +120,6 @@ settings-window-opacity-description = ドラッグで調整、右端は不透明
settings-window-opacity-default = デフォルト
settings-window-opacity-reset = デフォルトに戻す
settings-window-opacity-platforms = Linux では未対応、Windows ではまだ安定していません。
-settings-windows-backdrop = すりガラス
-settings-windows-backdrop-description = Windows 11 標準のアクリルをウインドウの背景にします。レンダラーを OpenGL にし、不透明度を 100% 未満にしてください。ThinkTerm の再起動後に適用されます。
settings-badge-beta = ベータ
settings-app-icon-simple = 青いピル
settings-app-icon-red = 赤いピル
@@ -753,7 +751,7 @@ settings-status-stop-session-server-error = セッションサーバーを停止
settings-status-window-restore-off = 新しい macOS ウィンドウで位置とサイズの復元を無効にしました。
settings-status-window-restore-error = ウィンドウ復元設定を保存できません:{ $error }
settings-status-renderer = レンダラーを { $renderer } に設定しました。ThinkTerm の再起動後に適用されます。
-settings-status-value-after-restart = { $setting }を { $value } に設定しました。ThinkTerm の再起動後に適用されます。
+settings-status-window-acrylic-after-restart = { $setting }を{ $value }に変更しました。すりガラスは ThinkTerm の再起動後に表示されます(OpenGL レンダラーが必要)。
settings-status-renderer-error = レンダラー設定を保存できません:{ $error }
settings-status-restarting = ThinkTerm を再起動しています…
settings-status-restart-error = ThinkTerm を再起動できません:{ $error }
diff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftl
index 8d34a269..cd5160a3 100644
--- a/thinkterm-i18n/i18n/zh-CN.ftl
+++ b/thinkterm-i18n/i18n/zh-CN.ftl
@@ -120,8 +120,6 @@ settings-window-opacity-description = 拖动调整,最右边是不透明;侧
settings-window-opacity-default = 默认
settings-window-opacity-reset = 恢复默认
settings-window-opacity-platforms = Linux 暂时不支持,Windows 上还不够稳定。
-settings-windows-backdrop = 毛玻璃
-settings-windows-backdrop-description = 用 Windows 11 自带的亚克力做窗口背景。要把渲染器换成 OpenGL、透明度调到 100% 以下;开关后重启 ThinkTerm 生效。
settings-badge-beta = Beta
settings-app-icon-simple = 蓝色药丸
settings-app-icon-red = 红色药丸
@@ -753,7 +751,7 @@ settings-status-stop-session-server-error = 无法停止会话服务器:{ $error
settings-status-window-restore-off = 已为新的 macOS 窗口关闭主窗口位置与大小恢复。
settings-status-window-restore-error = 无法保存窗口恢复设置:{ $error }
settings-status-renderer = 渲染器已设为 { $renderer };重启 ThinkTerm 后生效。
-settings-status-value-after-restart = { $setting }已设为 { $value };重启 ThinkTerm 后生效。
+settings-status-window-acrylic-after-restart = { $setting }现为{ $value };毛玻璃要重启 ThinkTerm 后出现(需要 OpenGL 渲染器)。
settings-status-renderer-error = 无法保存渲染器设置:{ $error }
settings-status-restarting = 正在重启 ThinkTerm…
settings-status-restart-error = 无法重启 ThinkTerm:{ $error }
diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rs
index c01cbf29..e4e125a0 100644
--- a/wezterm-gui/src/native_settings.rs
+++ b/wezterm-gui/src/native_settings.rs
@@ -421,28 +421,6 @@ pub(crate) struct NativeAppearanceSettings {
/// `window_background_opacity`. `None` follows the configuration.
#[serde(deserialize_with = "window_opacity_or_default")]
pub(crate) window_opacity: Option<u8>,
- /// On Windows, the system acrylic behind a see-through window (see
- /// `config::Win32BackdropTrial`).
- #[serde(deserialize_with = "choice_or_default")]
- pub(crate) windows_backdrop: NativeWindowsBackdrop,
-}
-
-/// Whether Settings asks Windows for its acrylic, `Composition` being on.
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Deserialize, Serialize)]
-#[serde(rename_all = "snake_case")]
-pub(crate) enum NativeWindowsBackdrop {
- #[default]
- Off,
- Composition,
-}
-
-impl NativeWindowsBackdrop {
- fn trial(self) -> config::Win32BackdropTrial {
- match self {
- Self::Off => config::Win32BackdropTrial::Off,
- Self::Composition => config::Win32BackdropTrial::Composition,
- }
- }
}
/// The window opacity, whatever shape a hand edit gave it. One field that
@@ -506,15 +484,10 @@ pub(crate) fn window_opacity_overrides(
use wezterm_dynamic::ToDynamic;
let changes = window_opacity_changes(settings.appearance.window_opacity);
let [opacity, blur, backdrop] = WINDOW_OPACITY_KEYS;
- let trial = settings.appearance.windows_backdrop;
[
(opacity, changes.opacity.map(|opacity| opacity.to_dynamic())),
(blur, changes.blur.map(|blur| blur.to_dynamic())),
- (
- backdrop,
- (cfg!(windows) && trial != NativeWindowsBackdrop::Off)
- .then(|| trial.trial().to_dynamic()),
- ),
+ (backdrop, changes.acrylic.map(|acrylic| acrylic.to_dynamic())),
]
}
@@ -526,15 +499,17 @@ pub(crate) const WINDOW_OPACITY_KEYS: [&str; 3] = [
];
/// What a window opacity of `percent` changes in a window's configuration:
-/// the opacity, and while it is see-through on macOS the blur the
-/// configuration file does not ask for itself. `None` changes nothing.
+/// the opacity, and while it is see-through the frosted glass that goes
+/// with it -- on macOS the blur the configuration file does not ask for
+/// itself, on Windows the acrylic drawn through DirectComposition, which a
+/// window takes as it is made. `None` changes nothing.
///
-/// Windows is given no backdrop: with this window frame any
-/// `win32_system_backdrop` turns a see-through window opaque (see
-/// wezterm#6265), so that stays the configuration's to choose.
+/// `win32_system_backdrop` stays the configuration's to choose: with this
+/// window frame it turns a see-through window opaque (wezterm#6265).
struct WindowOpacityChanges {
opacity: Option<f64>,
blur: Option<i64>,
+ acrylic: Option<config::Win32BackdropTrial>,
}
fn window_opacity_changes(percent: Option<u8>) -> WindowOpacityChanges {
@@ -549,6 +524,8 @@ fn window_opacity_changes(percent: Option<u8>) -> WindowOpacityChanges {
&& cfg!(target_os = "macos")
&& config.macos_window_background_blur == 0)
.then_some(WINDOW_BLUR_RADIUS),
+ acrylic: (see_through && cfg!(windows))
+ .then_some(config::Win32BackdropTrial::Composition),
}
}
@@ -1962,7 +1939,6 @@ fn apply_external_change(before: &ThinkTermNativeSettings, after: &ThinkTermNati
|| before.appearance.app_icon != after.appearance.app_icon
|| before.appearance.color_scheme != after.appearance.color_scheme
|| before.appearance.window_opacity != after.appearance.window_opacity
- || before.appearance.windows_backdrop != after.appearance.windows_backdrop
{
// Language, theme, colour scheme, opacity, chrome and app icon.
apply_to_app(after);
@@ -2936,31 +2912,26 @@ mod tests {
settings.appearance.window_opacity = Some(100);
let [_, blur, _] = window_opacity_overrides(&settings);
assert_eq!(blur.1, None);
- // The Windows backdrop is never Settings' to set; the acrylic drawn
- // through DirectComposition is, on Windows.
+ // Opaque, Windows is asked for no acrylic either. The Windows
+ // backdrop itself is never Settings' to set.
+ let [.., backdrop] = window_opacity_overrides(&settings);
+ assert_eq!(backdrop.1, None);
assert!(!WINDOW_OPACITY_KEYS.contains(&"win32_system_backdrop"));
- settings.appearance.windows_backdrop = NativeWindowsBackdrop::Composition;
+ // See-through, it is, on Windows.
+ settings.appearance.window_opacity = Some(80);
let [.., backdrop] = window_opacity_overrides(&settings);
assert_eq!(
backdrop.1,
- cfg!(windows).then(|| config::Win32BackdropTrial::Composition.to_dynamic())
+ (cfg!(windows) && window_opacity_supported())
+ .then(|| config::Win32BackdropTrial::Composition.to_dynamic())
);
}
#[test]
- fn a_windows_backdrop_this_build_does_not_know_is_off() {
- let read = |written: &str| {
- let text = format!(r#"{{"appearance":{{"windows_backdrop":{written}}}}}"#);
- serde_json::from_str::<ThinkTermNativeSettings>(&text)
- .unwrap()
- .appearance
- .windows_backdrop
- };
- assert_eq!(read(r#""composition""#), NativeWindowsBackdrop::Composition);
- // Ways tried and dropped read as off, as one not known yet does.
- assert_eq!(read(r#""accent""#), NativeWindowsBackdrop::Off);
- assert_eq!(read(r#""system_blur""#), NativeWindowsBackdrop::Off);
- assert_eq!(read(r#""something_new""#), NativeWindowsBackdrop::Off);
+ fn a_frosted_glass_choice_left_by_a_trial_build_is_ignored() {
+ let text = r#"{"appearance":{"window_opacity":80,"windows_backdrop":"composition"}}"#;
+ let settings: ThinkTermNativeSettings = serde_json::from_str(text).unwrap();
+ assert_eq!(settings.appearance.window_opacity, Some(80));
}
use config::UiColors;
diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rs
index 9daa7eef..c83b4166 100644
--- a/wezterm-gui/src/settings_window.rs
+++ b/wezterm-gui/src/settings_window.rs
@@ -43,7 +43,7 @@ use window::{
use crate::native_settings::{
NativeAppIcon, NativeBottomQuoteMode, NativeRemotePaneResizeMode, NativeRendererBackend,
- NativeThemeMode, NativeWindowsBackdrop, ThinkTermNativeSettings, DEFAULT_HOME_FONT_SIZE,
+ NativeThemeMode, ThinkTermNativeSettings, DEFAULT_HOME_FONT_SIZE,
DEFAULT_PANE_HEADER_FONT_SIZE, DEFAULT_SETTINGS_FONT_SIZE, DEFAULT_SIDEBAR_FONT_SIZE,
DEFAULT_TAB_FONT_SIZE,
};
@@ -1845,7 +1845,6 @@ enum SettingsAction {
QuitApplication,
ToggleBottomQuote,
SetRemotePaneResizeMode(NativeRemotePaneResizeMode),
- ToggleWindowsBackdrop,
SetScrollMode(crate::native_settings::NativeScrollMode),
SetSelectionStyle(crate::native_settings::NativeSelectionStyle),
ToggleCopyOnSelect,
@@ -5186,6 +5185,11 @@ impl SettingsWindow {
// Merged into the freshest settings, as `apply_text_contrast` does:
// this window's copy can be older than what other windows saved.
let mut merged = crate::native_settings::load();
+ // On Windows the acrylic behind a see-through window is drawn the way
+ // a window was made: windows made opaque show it after a restart.
+ let see_through = |opacity: Option<u8>| opacity.is_some_and(|percent| percent < 100);
+ let acrylic_after_restart =
+ cfg!(windows) && !see_through(merged.appearance.window_opacity) && see_through(opacity);
merged.appearance.window_opacity = opacity;
self.set_native_settings(merged);
let setting = crate::i18n::tr("settings-window-opacity");
@@ -5193,7 +5197,11 @@ impl SettingsWindow {
Ok(()) => {
crate::native_settings::apply_window_opacity_to_app(&self.native_settings);
self.status = settings_tr(
- "settings-status-value-now",
+ if acrylic_after_restart {
+ "settings-status-window-acrylic-after-restart"
+ } else {
+ "settings-status-value-now"
+ },
&[
("setting", setting),
("value", window_opacity_label(opacity)),
@@ -5320,41 +5328,6 @@ impl SettingsWindow {
}
}
- /// Turn the Windows acrylic on or off. A window takes it, or leaves
- /// it, as it is made: it shows once ThinkTerm has restarted.
- fn toggle_windows_backdrop(&mut self) {
- self.ui.open_dropdown = None;
- // Merged into the freshest settings, as `apply_window_opacity` is.
- let mut merged = crate::native_settings::load();
- let on = merged.appearance.windows_backdrop == NativeWindowsBackdrop::Off;
- merged.appearance.windows_backdrop = if on {
- NativeWindowsBackdrop::Composition
- } else {
- NativeWindowsBackdrop::Off
- };
- self.set_native_settings(merged);
- let setting = crate::i18n::tr("settings-windows-backdrop");
- match crate::native_settings::save(&self.native_settings) {
- Ok(()) => {
- crate::native_settings::apply_window_opacity_to_app(&self.native_settings);
- self.status = settings_tr(
- "settings-status-value-after-restart",
- &[
- ("setting", setting),
- ("value", crate::i18n::tr(if on { "common-on" } else { "common-off" })),
- ],
- );
- }
- Err(err) => {
- self.set_native_settings(crate::native_settings::load());
- self.status = settings_tr(
- "settings-status-save-error",
- &[("setting", setting), ("error", format!("{err:#}"))],
- );
- }
- }
- }
-
fn apply_remote_pane_resize_mode(&mut self, mode: NativeRemotePaneResizeMode) {
self.ui.open_dropdown = None;
self.native_settings.terminal.remote_pane_resize_mode = mode;
@@ -6297,7 +6270,6 @@ impl SettingsWindow {
SettingsAction::SetRemotePaneResizeMode(mode) => {
self.apply_remote_pane_resize_mode(mode)
}
- SettingsAction::ToggleWindowsBackdrop => self.toggle_windows_backdrop(),
SettingsAction::SetBottomQuoteMode(mode) => self.apply_bottom_quote_mode(mode),
SettingsAction::DecreaseBottomQuoteFontSize => self.step_bottom_quote_font_size(-1.0),
SettingsAction::IncreaseBottomQuoteFontSize => self.step_bottom_quote_font_size(1.0),
@@ -8540,28 +8512,6 @@ impl SettingsWindow {
TileColor::Blue,
)?;
rows.add(this.paint_window_opacity_row(layers, tx, rows.y, tw, rows.rule())?);
- if cfg!(windows) {
- let (tx, tw) = this.paint_row_tile(
- layers,
- row_x,
- rows.y,
- row_width,
- SvgIcon::Contrast,
- TileColor::Indigo,
- )?;
- rows.add(this.paint_toggle_setting_row(
- layers,
- tx,
- rows.y,
- tw,
- &crate::i18n::tr("settings-windows-backdrop"),
- &crate::i18n::tr("settings-windows-backdrop-description"),
- this.native_settings.appearance.windows_backdrop
- != NativeWindowsBackdrop::Off,
- SettingsAction::ToggleWindowsBackdrop,
- rows.rule(),
- )?);
- }
Ok(rows.bottom)
})?;