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): make the acrylic one switch

RoversX68984716ce41
diff --git a/config/src/background.rs b/config/src/background.rs
index 4e018b19..dd70ed58 100644
--- a/config/src/background.rs
+++ b/config/src/background.rs
@@ -301,18 +301,14 @@ pub enum SystemBackdrop {
Tabbed,
}
-/// Another way of asking Windows for its acrylic backdrop, to find one that
-/// shows it behind a window drawn with OpenGL: asked for the usual way, it
-/// comes out opaque there (wezterm#6265). `Off` asks the usual way.
-/// `Accent` asks with the undocumented accent policy, as on Windows 10,
-/// even where the system backdrop exists. `Composition` draws through
-/// ANGLE onto a DirectComposition surface, whose alpha the system backdrop
-/// shows through; a window takes it, or leaves it, when opened.
+/// Acrylic behind a see-through window drawn with OpenGL, which the usual
+/// way of asking for it leaves opaque (wezterm#6265). `Composition` draws
+/// through ANGLE onto a DirectComposition surface, whose alpha the system
+/// acrylic shows through; a window takes it, or leaves it, when opened.
#[derive(Debug, Copy, Clone, FromDynamic, ToDynamic, PartialEq, Eq, Default)]
pub enum Win32BackdropTrial {
#[default]
Off,
- Accent,
Composition,
}
diff --git a/thinkterm-i18n/i18n/de-DE.ftl b/thinkterm-i18n/i18n/de-DE.ftl
index 1e3ac587..5492a8a1 100644
--- a/thinkterm-i18n/i18n/de-DE.ftl
+++ b/thinkterm-i18n/i18n/de-DE.ftl
@@ -123,11 +123,8 @@ 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 (Test)
-settings-windows-backdrop-description = Probiert aus, welche Methode unter Windows 11 Milchglas zeigt: zuerst den Renderer auf OpenGL stellen und die Deckkraft unter 100 % setzen. Methode 4 zu wählen oder zu verlassen wirkt nach einem Neustart von ThinkTerm.
-settings-windows-backdrop-off = Aus
-settings-windows-backdrop-accent = Methode 1
-settings-windows-backdrop-composition = Methode 4
+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
diff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftl
index e5f1c209..149b955d 100644
--- a/thinkterm-i18n/i18n/en-US.ftl
+++ b/thinkterm-i18n/i18n/en-US.ftl
@@ -123,11 +123,8 @@ 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 (trial)
-settings-windows-backdrop-description = Tries which way shows frosted glass on Windows 11: first switch the renderer to OpenGL and set the opacity below 100%. Choosing Way 4, or leaving it, takes effect after ThinkTerm restarts.
-settings-windows-backdrop-off = Off
-settings-windows-backdrop-accent = Way 1
-settings-windows-backdrop-composition = Way 4
+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
diff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftl
index fe1e07df..1e232f92 100644
--- a/thinkterm-i18n/i18n/fr-FR.ftl
+++ b/thinkterm-i18n/i18n/fr-FR.ftl
@@ -123,11 +123,8 @@ 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 (essai)
-settings-windows-backdrop-description = Essaie quelle méthode donne du verre dépoli sous Windows 11 : passez d'abord le rendu en OpenGL et l'opacité sous 100 %. Choisir la méthode 4, ou la quitter, s'applique après le redémarrage de ThinkTerm.
-settings-windows-backdrop-off = Désactivé
-settings-windows-backdrop-accent = Méthode 1
-settings-windows-backdrop-composition = Méthode 4
+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
diff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftl
index 622264b0..3a69f447 100644
--- a/thinkterm-i18n/i18n/ja-JP.ftl
+++ b/thinkterm-i18n/i18n/ja-JP.ftl
@@ -120,11 +120,8 @@ 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% 未満にしてください。方法 4 への切り替えと解除は、ThinkTerm の再起動後に適用されます。
-settings-windows-backdrop-off = オフ
-settings-windows-backdrop-accent = 方法 1
-settings-windows-backdrop-composition = 方法 4
+settings-windows-backdrop = すりガラス
+settings-windows-backdrop-description = Windows 11 標準のアクリルをウインドウの背景にします。レンダラーを OpenGL にし、不透明度を 100% 未満にしてください。ThinkTerm の再起動後に適用されます。
settings-badge-beta = ベータ
settings-app-icon-simple = 青いピル
settings-app-icon-red = 赤いピル
diff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftl
index f2218bdc..8d34a269 100644
--- a/thinkterm-i18n/i18n/zh-CN.ftl
+++ b/thinkterm-i18n/i18n/zh-CN.ftl
@@ -120,11 +120,8 @@ 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-windows-backdrop-off = 关
-settings-windows-backdrop-accent = 方式一
-settings-windows-backdrop-composition = 方式四
+settings-windows-backdrop = 毛玻璃
+settings-windows-backdrop-description = 用 Windows 11 自带的亚克力做窗口背景。要把渲染器换成 OpenGL、透明度调到 100% 以下;开关后重启 ThinkTerm 生效。
settings-badge-beta = Beta
settings-app-icon-simple = 蓝色药丸
settings-app-icon-red = 红色药丸
diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rs
index d1b6a4c7..c01cbf29 100644
--- a/wezterm-gui/src/native_settings.rs
+++ b/wezterm-gui/src/native_settings.rs
@@ -421,31 +421,25 @@ 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, another way of asking for the frosted backdrop behind a
- /// see-through window, being tried (see `config::Win32BackdropTrial`).
+ /// On Windows, the system acrylic behind a see-through window (see
+ /// `config::Win32BackdropTrial`).
#[serde(deserialize_with = "choice_or_default")]
pub(crate) windows_backdrop: NativeWindowsBackdrop,
}
-/// The ways Settings offers to try of asking Windows for the frosted
-/// backdrop, `Off` the usual one.
+/// 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,
- Accent,
Composition,
}
impl NativeWindowsBackdrop {
- /// Every way, in the order the settings window offers them.
- pub(crate) const ALL: [Self; 3] = [Self::Off, Self::Accent, Self::Composition];
-
fn trial(self) -> config::Win32BackdropTrial {
match self {
Self::Off => config::Win32BackdropTrial::Off,
- Self::Accent => config::Win32BackdropTrial::Accent,
Self::Composition => config::Win32BackdropTrial::Composition,
}
}
@@ -2942,14 +2936,14 @@ 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; a way of asking
- // for it being tried is, on Windows.
+ // The Windows backdrop is never Settings' to set; the acrylic drawn
+ // through DirectComposition is, on Windows.
assert!(!WINDOW_OPACITY_KEYS.contains(&"win32_system_backdrop"));
- settings.appearance.windows_backdrop = NativeWindowsBackdrop::Accent;
+ settings.appearance.windows_backdrop = NativeWindowsBackdrop::Composition;
let [.., backdrop] = window_opacity_overrides(&settings);
assert_eq!(
backdrop.1,
- cfg!(windows).then(|| config::Win32BackdropTrial::Accent.to_dynamic())
+ cfg!(windows).then(|| config::Win32BackdropTrial::Composition.to_dynamic())
);
}
@@ -2964,6 +2958,7 @@ mod tests {
};
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);
}
diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rs
index bb864ae4..9daa7eef 100644
--- a/wezterm-gui/src/settings_window.rs
+++ b/wezterm-gui/src/settings_window.rs
@@ -1508,14 +1508,6 @@ fn shell_catalog_including(
catalog
}
-fn localized_windows_backdrop_label(backdrop: NativeWindowsBackdrop) -> String {
- crate::i18n::tr(match backdrop {
- NativeWindowsBackdrop::Off => "settings-windows-backdrop-off",
- NativeWindowsBackdrop::Accent => "settings-windows-backdrop-accent",
- NativeWindowsBackdrop::Composition => "settings-windows-backdrop-composition",
- })
-}
-
fn localized_remote_pane_resize_mode_label(mode: NativeRemotePaneResizeMode) -> String {
crate::i18n::tr(match mode {
NativeRemotePaneResizeMode::Auto => "settings-remote-pane-resize-mode-auto",
@@ -1853,7 +1845,7 @@ enum SettingsAction {
QuitApplication,
ToggleBottomQuote,
SetRemotePaneResizeMode(NativeRemotePaneResizeMode),
- SetWindowsBackdrop(NativeWindowsBackdrop),
+ ToggleWindowsBackdrop,
SetScrollMode(crate::native_settings::NativeScrollMode),
SetSelectionStyle(crate::native_settings::NativeSelectionStyle),
ToggleCopyOnSelect,
@@ -5328,31 +5320,28 @@ impl SettingsWindow {
}
}
- /// Try another way of asking Windows for the frosted backdrop, in every
- /// window at once, as the window opacity is.
- fn apply_windows_backdrop(&mut self, backdrop: NativeWindowsBackdrop) {
+ /// 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();
- // Way 4 is settled as a window is made: choosing it, or leaving it,
- // shows once ThinkTerm has restarted.
- let after_restart = [merged.appearance.windows_backdrop, backdrop]
- .contains(&NativeWindowsBackdrop::Composition);
- merged.appearance.windows_backdrop = backdrop;
+ 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(
- if after_restart {
- "settings-status-value-after-restart"
- } else {
- "settings-status-value-now"
- },
+ "settings-status-value-after-restart",
&[
("setting", setting),
- ("value", localized_windows_backdrop_label(backdrop)),
+ ("value", crate::i18n::tr(if on { "common-on" } else { "common-off" })),
],
);
}
@@ -6308,7 +6297,7 @@ impl SettingsWindow {
SettingsAction::SetRemotePaneResizeMode(mode) => {
self.apply_remote_pane_resize_mode(mode)
}
- SettingsAction::SetWindowsBackdrop(backdrop) => self.apply_windows_backdrop(backdrop),
+ 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),
@@ -8552,21 +8541,6 @@ impl SettingsWindow {
)?;
rows.add(this.paint_window_opacity_row(layers, tx, rows.y, tw, rows.rule())?);
if cfg!(windows) {
- let options: Vec<(String, SettingsAction)> = NativeWindowsBackdrop::ALL
- .iter()
- .map(|backdrop| {
- (
- localized_windows_backdrop_label(*backdrop),
- SettingsAction::SetWindowsBackdrop(*backdrop),
- )
- })
- .collect();
- let selected = NativeWindowsBackdrop::ALL
- .iter()
- .position(|backdrop| {
- *backdrop == this.native_settings.appearance.windows_backdrop
- })
- .unwrap_or(0);
let (tx, tw) = this.paint_row_tile(
layers,
row_x,
@@ -8575,15 +8549,16 @@ impl SettingsWindow {
SvgIcon::Contrast,
TileColor::Indigo,
)?;
- rows.add(this.paint_segmented_setting_row(
+ 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"),
- &options,
- selected,
+ this.native_settings.appearance.windows_backdrop
+ != NativeWindowsBackdrop::Off,
+ SettingsAction::ToggleWindowsBackdrop,
rows.rule(),
)?);
}
diff --git a/window/src/os/windows/window.rs b/window/src/os/windows/window.rs
index a0336410..3f874ca7 100644
--- a/window/src/os/windows/window.rs
+++ b/window/src/os/windows/window.rs
@@ -144,9 +144,6 @@ pub(crate) struct WindowInner {
/// reason as `occlusion_visible`: the owner wants the edges, not a message
/// per pixel of a drag.
last_frame_event: Option<(ScreenRect, bool)>,
- /// The way of asking for the backdrop last applied: one switched off is
- /// undone, and a window that never tried one is left as it always was.
- backdrop_trial: Win32BackdropTrial,
/// The EGL this window draws through onto DirectComposition, when it was
/// made for `Win32BackdropTrial::Composition`: without a redirection
/// bitmap, nothing it draws any other way would show.
@@ -966,7 +963,6 @@ impl Window {
invalidated: true,
occlusion_visible: None,
last_frame_event: None,
- backdrop_trial: Win32BackdropTrial::Off,
composition: None,
}));
@@ -1039,8 +1035,9 @@ impl Window {
}
apply_theme(hwnd.0);
- let trial = window_backdrop_trial(inner.borrow().composition.is_some(), &config);
- blur_behind(hwnd.0, blurs_behind(trial));
+ // DirectComposition carries the window's alpha itself; the rest
+ // need the old blur behind for it.
+ blur_behind(hwnd.0, inner.borrow().composition.is_none());
// Make window capable of accepting drag and drop
unsafe {
@@ -1909,23 +1906,6 @@ fn composition_connection(conn: &Connection) -> Option<Rc<crate::egl::GlConnecti
}
}
-/// The way of asking for the backdrop a window can take: whether it draws
-/// onto DirectComposition was settled when it was made, so a window made
-/// for it keeps it and one made without it waits for the next window.
-fn window_backdrop_trial(composition: bool, config: &ConfigHandle) -> Win32BackdropTrial {
- match config.win32_backdrop_trial {
- _ if composition => Win32BackdropTrial::Composition,
- Win32BackdropTrial::Composition => Win32BackdropTrial::Off,
- trial => trial,
- }
-}
-
-/// Whether the old blur behind the window stays on: it is what lets the
-/// window's alpha through, except onto DirectComposition, which carries it.
-fn blurs_behind(trial: Win32BackdropTrial) -> bool {
- trial != Win32BackdropTrial::Composition
-}
-
/// "Blur behind" is the old vista term for a cool blurring
/// effect that the DWM could enable. Subsequent windows
/// versions have removed the blurring. We use this call
@@ -2046,15 +2026,13 @@ fn apply_theme(hwnd: HWND) -> Option<LRESULT> {
if let Some(inner) = rc_from_hwnd(hwnd) {
let mut inner = inner.borrow_mut();
- // Set Acrylic or Mica system Backdrop; a trial is of acrylic,
- // asked for its own way.
- let trial = window_backdrop_trial(inner.composition.is_some(), &inner.config);
- let composition = trial == Win32BackdropTrial::Composition;
- let accent = !*IS_WIN11_22H2 || trial == Win32BackdropTrial::Accent;
- let acrylic = trial != Win32BackdropTrial::Off
- || inner.config.win32_system_backdrop == SystemBackdrop::Acrylic;
+ // Set Acrylic or Mica system Backdrop; a window drawn onto
+ // DirectComposition was made for acrylic, and keeps it.
+ let composition = inner.composition.is_some();
+ let accent = !*IS_WIN11_22H2;
+ let acrylic =
+ composition || inner.config.win32_system_backdrop == SystemBackdrop::Acrylic;
let pv_attribute = match inner.config.win32_system_backdrop {
- _ if trial == Win32BackdropTrial::Accent => DWM_SYSTEMBACKDROP_TYPE::DWMSBT_NONE,
_ if composition => DWM_SYSTEMBACKDROP_TYPE::DWMSBT_TRANSIENTWINDOW,
SystemBackdrop::Auto => DWM_SYSTEMBACKDROP_TYPE::DWMSBT_AUTO,
SystemBackdrop::Disable => DWM_SYSTEMBACKDROP_TYPE::DWMSBT_NONE,
@@ -2090,13 +2068,6 @@ fn apply_theme(hwnd: HWND) -> Option<LRESULT> {
DwmExtendFrameIntoClientArea(hwnd, &margins);
- // A trial may be switched while the window is open: what lets
- // the window's alpha through goes with it.
- let tried = std::mem::replace(&mut inner.backdrop_trial, trial);
- if trial != Win32BackdropTrial::Off || tried != Win32BackdropTrial::Off {
- blur_behind(hwnd, blurs_behind(trial));
- }
-
// Apply Acrylic or Mica Backdrop
if *IS_WIN11_22H2 {
DwmSetWindowAttribute(
@@ -2107,9 +2078,7 @@ fn apply_theme(hwnd: HWND) -> Option<LRESULT> {
);
}
- // The accent policy: acrylic before 22H2, or by the trial of it;
- // turned off again once that trial is.
- let send = accent || tried == Win32BackdropTrial::Accent;
+ // The accent policy: acrylic before 22H2.
let mut colour = inner.config.win32_acrylic_accent_color.to_srgb_u8();
colour.3 = if colour.3 == 0 { 1 } else { colour.3 }; // acrylic doesn't like to have 0 alpha
let on = accent && acrylic;
@@ -2128,7 +2097,7 @@ fn apply_theme(hwnd: HWND) -> Option<LRESULT> {
AnimationId: 0,
};
- if send {
+ if accent {
if let Ok(user) = User32::open(std::path::Path::new("user32.dll")) {
(user.SetWindowCompositionAttribute)(
hwnd,