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): try other ways of asking for the acrylic backdrop

RoversXe10c6ce5792e
diff --git a/config/src/background.rs b/config/src/background.rs
index 0712d2e2..3dc21369 100644
--- a/config/src/background.rs
+++ b/config/src/background.rs
@@ -301,6 +301,22 @@ 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.
+/// `System` and `SystemBlur` ask for the system backdrop over the whole
+/// window, without and with the blur behind that lets the window's own
+/// alpha through; `Accent` asks with the undocumented accent policy, as on
+/// Windows 10, even where the system backdrop exists.
+#[derive(Debug, Copy, Clone, FromDynamic, ToDynamic, PartialEq, Eq, Default)]
+pub enum Win32BackdropTrial {
+ #[default]
+ Off,
+ System,
+ SystemBlur,
+ Accent,
+}
+
pub fn default_win32_acrylic_accent_color() -> RgbaColor {
SrgbaTuple(0.156863, 0.156863, 0.156863, 0.003922).into()
}
diff --git a/config/src/config.rs b/config/src/config.rs
index 396a7c91..fd0abdc7 100644
--- a/config/src/config.rs
+++ b/config/src/config.rs
@@ -25,8 +25,8 @@ use crate::{
default_config_with_overrides_applied, default_one_point_oh, default_one_point_oh_f64,
default_true, default_win32_acrylic_accent_color, CellWidth, GpuInfo,
IntegratedTitleButtonColor, KeyMapPreference, LoadedConfig, MouseEventTriggerMods, RgbaColor,
- SerialDomain, SystemBackdrop, WebGpuPowerPreference, CONFIG_DIRS, CONFIG_FILE_OVERRIDE,
- CONFIG_OVERRIDES, CONFIG_SKIP, HOME_DIR,
+ SerialDomain, SystemBackdrop, WebGpuPowerPreference, Win32BackdropTrial, CONFIG_DIRS,
+ CONFIG_FILE_OVERRIDE, CONFIG_OVERRIDES, CONFIG_SKIP, HOME_DIR,
};
use anyhow::Context;
use luahelper::impl_lua_conversion_dynamic;
@@ -629,6 +629,11 @@ pub struct Config {
#[dynamic(default = "default_win32_acrylic_accent_color")]
pub win32_acrylic_accent_color: RgbaColor,
+ /// Only works on Windows: tries another way of asking for the acrylic
+ /// backdrop, which it then asks for (see `Win32BackdropTrial`).
+ #[dynamic(default)]
+ pub win32_backdrop_trial: Win32BackdropTrial,
+
/// Specifies the alpha value to use when rendering the background
/// of the window. The background is taken either from the
/// window_background_image, or if there is none, the background
diff --git a/thinkterm-i18n/i18n/de-DE.ftl b/thinkterm-i18n/i18n/de-DE.ftl
index f0f93e8c..3e85dd74 100644
--- a/thinkterm-i18n/i18n/de-DE.ftl
+++ b/thinkterm-i18n/i18n/de-DE.ftl
@@ -123,6 +123,12 @@ 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.
+settings-windows-backdrop-off = Aus
+settings-windows-backdrop-accent = Methode 1
+settings-windows-backdrop-system = Methode 2
+settings-windows-backdrop-system-blur = Methode 3
settings-badge-beta = Beta
settings-app-icon-simple = Schlicht
settings-app-icon-classic = Klassisch
diff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftl
index 957c0085..c4cb1a7b 100644
--- a/thinkterm-i18n/i18n/en-US.ftl
+++ b/thinkterm-i18n/i18n/en-US.ftl
@@ -123,6 +123,12 @@ 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%.
+settings-windows-backdrop-off = Off
+settings-windows-backdrop-accent = Way 1
+settings-windows-backdrop-system = Way 2
+settings-windows-backdrop-system-blur = Way 3
settings-badge-beta = Beta
settings-app-icon-simple = Simple
settings-app-icon-classic = Classic
diff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftl
index 7ac004ba..dd1a5aff 100644
--- a/thinkterm-i18n/i18n/fr-FR.ftl
+++ b/thinkterm-i18n/i18n/fr-FR.ftl
@@ -123,6 +123,12 @@ 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 %.
+settings-windows-backdrop-off = Désactivé
+settings-windows-backdrop-accent = Méthode 1
+settings-windows-backdrop-system = Méthode 2
+settings-windows-backdrop-system-blur = Méthode 3
settings-badge-beta = Bêta
settings-app-icon-simple = Simple
settings-app-icon-classic = Classique
diff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftl
index 67bf6426..42fc924a 100644
--- a/thinkterm-i18n/i18n/ja-JP.ftl
+++ b/thinkterm-i18n/i18n/ja-JP.ftl
@@ -120,6 +120,12 @@ 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% 未満にしてください。
+settings-windows-backdrop-off = オフ
+settings-windows-backdrop-accent = 方法 1
+settings-windows-backdrop-system = 方法 2
+settings-windows-backdrop-system-blur = 方法 3
settings-badge-beta = ベータ
settings-app-icon-simple = シンプル
settings-app-icon-classic = クラシック
diff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftl
index c2519a3e..ffb6b3be 100644
--- a/thinkterm-i18n/i18n/zh-CN.ftl
+++ b/thinkterm-i18n/i18n/zh-CN.ftl
@@ -120,6 +120,12 @@ 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% 以下。
+settings-windows-backdrop-off = 关
+settings-windows-backdrop-accent = 方式一
+settings-windows-backdrop-system = 方式二
+settings-windows-backdrop-system-blur = 方式三
settings-badge-beta = Beta
settings-app-icon-simple = 简约
settings-app-icon-classic = 经典
diff --git a/wezterm-gui/src/native_settings.rs b/wezterm-gui/src/native_settings.rs
index 5d180d13..561e9339 100644
--- a/wezterm-gui/src/native_settings.rs
+++ b/wezterm-gui/src/native_settings.rs
@@ -413,6 +413,36 @@ 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`).
+ #[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.
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, Deserialize, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub(crate) enum NativeWindowsBackdrop {
+ #[default]
+ Off,
+ Accent,
+ System,
+ SystemBlur,
+}
+
+impl NativeWindowsBackdrop {
+ /// Every way, in the order the settings window offers them.
+ pub(crate) const ALL: [Self; 4] = [Self::Off, Self::Accent, Self::System, Self::SystemBlur];
+
+ fn trial(self) -> config::Win32BackdropTrial {
+ match self {
+ Self::Off => config::Win32BackdropTrial::Off,
+ Self::Accent => config::Win32BackdropTrial::Accent,
+ Self::System => config::Win32BackdropTrial::System,
+ Self::SystemBlur => config::Win32BackdropTrial::SystemBlur,
+ }
+ }
}
/// The window opacity, whatever shape a hand edit gave it. One field that
@@ -467,22 +497,33 @@ pub(crate) fn window_opacity_supported() -> bool {
const WINDOW_BLUR_RADIUS: i64 = 20;
/// The configuration keys the window-opacity setting overrides, and with
-/// what. `None` removes a key, so that the configuration decides again.
+/// what -- with them, on Windows, the way of asking for the frosted
+/// backdrop being tried. `None` removes a key, so that the configuration
+/// decides again.
pub(crate) fn window_opacity_overrides(
settings: &ThinkTermNativeSettings,
-) -> [(&'static str, Option<wezterm_dynamic::Value>); 2] {
+) -> [(&'static str, Option<wezterm_dynamic::Value>); 3] {
use wezterm_dynamic::ToDynamic;
let changes = window_opacity_changes(settings.appearance.window_opacity);
- let [opacity, blur] = WINDOW_OPACITY_KEYS;
+ 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()),
+ ),
]
}
/// The configuration keys Settings' window opacity overrides in a window.
-pub(crate) const WINDOW_OPACITY_KEYS: [&str; 2] =
- ["window_background_opacity", "macos_window_background_blur"];
+pub(crate) const WINDOW_OPACITY_KEYS: [&str; 3] = [
+ "window_background_opacity",
+ "macos_window_background_blur",
+ "win32_backdrop_trial",
+];
/// 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
@@ -1912,6 +1953,7 @@ 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);
@@ -2864,11 +2906,12 @@ mod tests {
fn window_opacity_overrides_the_opacity_and_asks_for_a_blur() {
use wezterm_dynamic::ToDynamic;
let mut settings = ThinkTermNativeSettings::default();
- let [opacity, blur] = window_opacity_overrides(&settings);
+ let [opacity, blur, backdrop] = window_opacity_overrides(&settings);
assert_eq!(opacity, ("window_background_opacity", None));
assert_eq!(blur, ("macos_window_background_blur", None));
+ assert_eq!(backdrop, ("win32_backdrop_trial", None));
settings.appearance.window_opacity = Some(80);
- let [opacity, blur] = window_opacity_overrides(&settings);
+ let [opacity, blur, _] = window_opacity_overrides(&settings);
if window_opacity_supported() {
assert_eq!(opacity.1, Some(0.8f64.to_dynamic()));
} else {
@@ -2882,10 +2925,30 @@ mod tests {
assert_eq!(opacity.1, Some(0.3f64.to_dynamic()));
}
settings.appearance.window_opacity = Some(100);
- let [_, blur] = window_opacity_overrides(&settings);
+ let [_, blur, _] = window_opacity_overrides(&settings);
assert_eq!(blur.1, None);
- // The Windows backdrop is never Settings' to set.
+ // The Windows backdrop is never Settings' to set; a way of asking
+ // for it being tried is, on Windows.
assert!(!WINDOW_OPACITY_KEYS.contains(&"win32_system_backdrop"));
+ settings.appearance.windows_backdrop = NativeWindowsBackdrop::Accent;
+ let [.., backdrop] = window_opacity_overrides(&settings);
+ assert_eq!(
+ backdrop.1,
+ cfg!(windows).then(|| config::Win32BackdropTrial::Accent.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#""system_blur""#), NativeWindowsBackdrop::SystemBlur);
+ assert_eq!(read(r#""something_new""#), NativeWindowsBackdrop::Off);
}
use config::UiColors;
diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rs
index 602cd1fa..619a6f04 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, ThinkTermNativeSettings, DEFAULT_HOME_FONT_SIZE,
+ NativeThemeMode, NativeWindowsBackdrop, ThinkTermNativeSettings, DEFAULT_HOME_FONT_SIZE,
DEFAULT_PANE_HEADER_FONT_SIZE, DEFAULT_SETTINGS_FONT_SIZE, DEFAULT_SIDEBAR_FONT_SIZE,
DEFAULT_TAB_FONT_SIZE,
};
@@ -1487,6 +1487,15 @@ 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::System => "settings-windows-backdrop-system",
+ NativeWindowsBackdrop::SystemBlur => "settings-windows-backdrop-system-blur",
+ })
+}
+
fn localized_remote_pane_resize_mode_label(mode: NativeRemotePaneResizeMode) -> String {
crate::i18n::tr(match mode {
NativeRemotePaneResizeMode::Auto => "settings-remote-pane-resize-mode-auto",
@@ -1824,6 +1833,7 @@ enum SettingsAction {
QuitApplication,
ToggleBottomQuote,
SetRemotePaneResizeMode(NativeRemotePaneResizeMode),
+ SetWindowsBackdrop(NativeWindowsBackdrop),
SetScrollMode(crate::native_settings::NativeScrollMode),
SetSelectionStyle(crate::native_settings::NativeSelectionStyle),
ToggleCopyOnSelect,
@@ -5297,6 +5307,36 @@ 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) {
+ self.ui.open_dropdown = None;
+ // Merged into the freshest settings, as `apply_window_opacity` is.
+ let mut merged = crate::native_settings::load();
+ merged.appearance.windows_backdrop = backdrop;
+ 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-now",
+ &[
+ ("setting", setting),
+ ("value", localized_windows_backdrop_label(backdrop)),
+ ],
+ );
+ }
+ 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;
@@ -6226,6 +6266,7 @@ impl SettingsWindow {
SettingsAction::SetRemotePaneResizeMode(mode) => {
self.apply_remote_pane_resize_mode(mode)
}
+ SettingsAction::SetWindowsBackdrop(backdrop) => self.apply_windows_backdrop(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),
@@ -8468,6 +8509,42 @@ impl SettingsWindow {
TileColor::Blue,
)?;
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,
+ rows.y,
+ row_width,
+ SvgIcon::Contrast,
+ TileColor::Indigo,
+ )?;
+ rows.add(this.paint_segmented_setting_row(
+ layers,
+ tx,
+ rows.y,
+ tw,
+ &crate::i18n::tr("settings-windows-backdrop"),
+ &crate::i18n::tr("settings-windows-backdrop-description"),
+ &options,
+ selected,
+ rows.rule(),
+ )?);
+ }
Ok(rows.bottom)
})?;
diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rs
index ab927a83..bd50b3de 100644
--- a/wezterm-gui/src/termwindow/mod.rs
+++ b/wezterm-gui/src/termwindow/mod.rs
@@ -8957,7 +8957,8 @@ impl TermWindow {
let platform_changed = (config.window_background_opacity >= 1.0)
!= (before.window_background_opacity >= 1.0)
|| config.macos_window_background_blur != before.macos_window_background_blur
- || config.win32_system_backdrop != before.win32_system_backdrop;
+ || config.win32_system_backdrop != before.win32_system_backdrop
+ || config.win32_backdrop_trial != before.win32_backdrop_trial;
if !platform_changed && config.window_background_opacity == before.window_background_opacity
{
return;
diff --git a/window/src/os/windows/window.rs b/window/src/os/windows/window.rs
index ef64cd8e..35e5f743 100644
--- a/window/src/os/windows/window.rs
+++ b/window/src/os/windows/window.rs
@@ -10,7 +10,7 @@ use crate::{
};
use anyhow::{anyhow, bail};
use async_trait::async_trait;
-use config::{ConfigHandle, ImePreeditRendering, SystemBackdrop};
+use config::{ConfigHandle, ImePreeditRendering, SystemBackdrop, Win32BackdropTrial};
use lazy_static::lazy_static;
use promise::Future;
use raw_window_handle::{
@@ -143,6 +143,9 @@ 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,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
@@ -939,6 +942,7 @@ impl Window {
invalidated: true,
occlusion_visible: None,
last_frame_event: None,
+ backdrop_trial: Win32BackdropTrial::Off,
}));
// Careful: `raw` owns a ref to inner, but there is no Drop impl
@@ -997,7 +1001,10 @@ impl Window {
}
apply_theme(hwnd.0);
- enable_blur_behind(hwnd.0);
+ blur_behind(
+ hwnd.0,
+ config.win32_backdrop_trial != Win32BackdropTrial::System,
+ );
// Make window capable of accepting drag and drop
unsafe {
@@ -1840,8 +1847,9 @@ fn get_window_state(hwnd: HWND) -> WindowState {
/// effect that the DWM could enable. Subsequent windows
/// versions have removed the blurring. We use this call
/// to tell DWM that we set proper alpha channel info as
-/// a result of rendering our window content.
-fn enable_blur_behind(hwnd: HWND) {
+/// a result of rendering our window content; `enable`
+/// false takes that back.
+fn blur_behind(hwnd: HWND, enable: bool) {
use winapi::shared::minwindef::*;
use winapi::um::dwmapi::*;
use winapi::um::wingdi::*;
@@ -1851,7 +1859,7 @@ fn enable_blur_behind(hwnd: HWND) {
let bb = DWM_BLURBEHIND {
dwFlags: DWM_BB_ENABLE | DWM_BB_BLURREGION,
- fEnable: TRUE,
+ fEnable: if enable { TRUE } else { FALSE },
hRgnBlur: region,
fTransitionOnMaximized: FALSE,
};
@@ -1955,8 +1963,17 @@ 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
+ // Set Acrylic or Mica system Backdrop; a trial is of acrylic,
+ // asked for its own way.
+ let trial = inner.config.win32_backdrop_trial;
+ let system_trial =
+ matches!(trial, Win32BackdropTrial::System | Win32BackdropTrial::SystemBlur);
+ let accent = !*IS_WIN11_22H2 || trial == Win32BackdropTrial::Accent;
+ let acrylic = trial != Win32BackdropTrial::Off
+ || 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 system_trial => DWM_SYSTEMBACKDROP_TYPE::DWMSBT_TRANSIENTWINDOW,
SystemBackdrop::Auto => DWM_SYSTEMBACKDROP_TYPE::DWMSBT_AUTO,
SystemBackdrop::Disable => DWM_SYSTEMBACKDROP_TYPE::DWMSBT_NONE,
SystemBackdrop::Acrylic => DWM_SYSTEMBACKDROP_TYPE::DWMSBT_TRANSIENTWINDOW,
@@ -1965,6 +1982,7 @@ fn apply_theme(hwnd: HWND) -> Option<LRESULT> {
};
let margins = match inner.config.window_decorations {
+ _ if system_trial => -1,
WindowDecorations::TITLE => -1,
_ => 0,
};
@@ -1979,6 +1997,13 @@ fn apply_theme(hwnd: HWND) -> Option<LRESULT> {
},
);
+ // 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, trial != Win32BackdropTrial::System);
+ }
+
// Apply Acrylic or Mica Backdrop
if *IS_WIN11_22H2 {
DwmSetWindowAttribute(
@@ -1987,28 +2012,30 @@ fn apply_theme(hwnd: HWND) -> Option<LRESULT> {
&pv_attribute as *const _ as _,
std::mem::size_of_val(&pv_attribute) as u32,
);
- } else {
- 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 mut policy = ACCENT_POLICY {
- AccentState: if inner.config.win32_system_backdrop == SystemBackdrop::Acrylic {
- ACCENT_STATE::ACCENT_ENABLE_ACRYLICBLURBEHIND as _
- } else {
- ACCENT_STATE::ACCENT_DISABLED as _
- },
- AccentFlags: if inner.config.win32_system_backdrop == SystemBackdrop::Acrylic {
- 2
- } else {
- 0
- },
- GradientColour: (colour.0 as u32)
- | (colour.1 as u32) << 8
- | (colour.2 as u32) << 16
- | (colour.3 as u32) << 24,
- AnimationId: 0,
- };
+ // 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;
+ 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;
+ let mut policy = ACCENT_POLICY {
+ AccentState: if on {
+ ACCENT_STATE::ACCENT_ENABLE_ACRYLICBLURBEHIND as _
+ } else {
+ ACCENT_STATE::ACCENT_DISABLED as _
+ },
+ AccentFlags: if on { 2 } else { 0 },
+ GradientColour: (colour.0 as u32)
+ | (colour.1 as u32) << 8
+ | (colour.2 as u32) << 16
+ | (colour.3 as u32) << 24,
+ AnimationId: 0,
+ };
+
+ if send {
if let Ok(user) = User32::open(std::path::Path::new("user32.dll")) {
(user.SetWindowCompositionAttribute)(
hwnd,
@@ -2019,22 +2046,22 @@ fn apply_theme(hwnd: HWND) -> Option<LRESULT> {
},
);
}
+ }
- if !*IS_WIN10 && !*IS_WIN11_22H2 {
- // For build versions less than 22h2 but are still win11
- let mica_enabled: u32 =
- if inner.config.win32_system_backdrop == SystemBackdrop::Mica {
- 1
- } else {
- 0
- };
- DwmSetWindowAttribute(
- hwnd,
- DWMWA_MICA_EFFECT,
- &mica_enabled as *const _ as _,
- std::mem::size_of_val(&mica_enabled) as u32,
- );
- }
+ if !*IS_WIN10 && !*IS_WIN11_22H2 {
+ // For build versions less than 22h2 but are still win11
+ let mica_enabled: u32 =
+ if inner.config.win32_system_backdrop == SystemBackdrop::Mica {
+ 1
+ } else {
+ 0
+ };
+ DwmSetWindowAttribute(
+ hwnd,
+ DWMWA_MICA_EFFECT,
+ &mica_enabled as *const _ as _,
+ std::mem::size_of_val(&mica_enabled) as u32,
+ );
}
if appearance != inner.appearance {