From f3d01c4d1918032fbbb935fd44ae05327901ed28 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 21 Mar 2021 00:54:37 -0700 Subject: [PATCH] windows: fix window_background_opacity I'm not sure what exactly changed (perhaps it was a Windows updated?) but window_background_opacity was only taking effect for windows with no title bar. I found that explicitly configuring a region makes transparency work again. refs: #553 --- docs/changelog.md | 1 + window/src/os/windows/window.rs | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/changelog.md b/docs/changelog.md index cca25f54d..6b031e31a 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -15,6 +15,7 @@ brief notes about them may accumulate here. * Fixed: detection and handling of fonts such as terminus-bold.otb that contain only bitmap strikes. [#560](https://github.com/wez/wezterm/issues/560) * Fixed: the pixel size reported by the pty to the kernel wasn't adjusted for font metrics/dpi until the config was reloaded or window resized. [#563](https://github.com/wez/wezterm/issues/563) * Fixed: greatly reduce memory consumption when system fallback fonts are loaded [#559](https://github.com/wez/wezterm/issues/559) +* Fixed: Windows: `window_background_opacity` was only taking effect when `window_decorations="NONE"` [#553](https://github.com/wez/wezterm/issues/553) ### 20210314-114017-04b7cedd diff --git a/window/src/os/windows/window.rs b/window/src/os/windows/window.rs index 21753c32a..e1656340f 100644 --- a/window/src/os/windows/window.rs +++ b/window/src/os/windows/window.rs @@ -729,16 +729,21 @@ unsafe fn wm_ncdestroy( fn enable_blur_behind(hwnd: HWND) { use winapi::shared::minwindef::*; use winapi::um::dwmapi::*; - - let bb = DWM_BLURBEHIND { - dwFlags: DWM_BB_ENABLE, - fEnable: TRUE, - hRgnBlur: null_mut(), - fTransitionOnMaximized: FALSE, - }; + use winapi::um::wingdi::*; unsafe { + let region = CreateRectRgn(0, 0, -1, -1); + + let bb = DWM_BLURBEHIND { + dwFlags: DWM_BB_ENABLE | DWM_BB_BLURREGION, + fEnable: TRUE, + hRgnBlur: region, + fTransitionOnMaximized: FALSE, + }; + DwmEnableBlurBehindWindow(hwnd, &bb); + + DeleteObject(region as _); } }