Skip to content

Commit

Permalink
fix: fix acrylic on win11 22h2
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Nov 18, 2022
1 parent 63da4fa commit d20161f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
5 changes: 5 additions & 0 deletions .changes/acrylic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"window-vibrancy": "patch"
---

Fix `apply_acrylic` on Windows 11 22H2.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ apply_blur(&window, Some((18, 18, 18, 125))).expect("Unsupported platform! 'appl

## Available functions

| Function | Supported platforms | Notes |
| :--- | :---: | :--- |
| `apply_blur`&`clear_blur` | Windows 7/10/11 | |
| `apply_acrylic`&`clear_acrylic` | Windows 10/11 | has bad performance when resizing/dragging the window on Windows 10 v1903+ and Windows 11 build 22000. |
| `apply_mica`&`clear_mica` | Windows 11 | |
| `apply_vibrancy` | macOS 10.10 and newer | |
| Function | Supported platforms | Notes |
| :--- | :---: | :--- |
| `apply_blur`&`clear_blur` | Windows 7/10/11 (22H1 only) | |
| `apply_acrylic`&`clear_acrylic` | Windows 10/11 | has bad performance when resizing/dragging the window on Windows 10 v1903+ and Windows 11 build 22000. |
| `apply_mica`&`clear_mica` | Windows 11 | |
| `apply_vibrancy` | macOS 10.10 and newer | |

## Screenshots

Expand Down
2 changes: 1 addition & 1 deletion examples/tao.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() {
.unwrap();

#[cfg(target_os = "windows")]
apply_blur(&window, Some((18, 18, 18, 125)))
apply_acrylic(&window, None)
.expect("Unsupported platform! 'apply_blur' is only supported on Windows");

#[cfg(target_os = "macos")]
Expand Down
2 changes: 1 addition & 1 deletion examples/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() {
.unwrap();

#[cfg(target_os = "windows")]
apply_blur(&window, Some((18, 18, 18, 125)))
apply_acrylic(&window, None)
.expect("Unsupported platform! 'apply_blur' is only supported on Windows");

#[cfg(target_os = "macos")]
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub use macos::{NSVisualEffectMaterial, NSVisualEffectState};
/// a tuple of RGBA colors. Each value has minimum of 0 and maximum of 255.
pub type Color = (u8, u8, u8, u8);

/// Applies blur effect to window. Works only on Windows 7, Windows 10 v1809 or newer and Windows 11.
/// Applies blur effect to window. Works only on Windows 7, Windows 10 v1809 or newer up to Windows 11 22H1.
///
/// ## Argumesnts:
///
Expand All @@ -53,7 +53,7 @@ pub fn apply_blur(
}
}

/// Clears blur effect applied to window. Works only on Windows 7, Windows 10 v1809 or newer and Windows 11.
/// Clears blur effect applied to window. Works only on Windows 7, Windows 10 v1809 or newer up to Windows 11 22H1.
///
/// ## Platform-specific
///
Expand Down
4 changes: 2 additions & 2 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub fn apply_acrylic(hwnd: HWND, color: Option<Color>) -> Result<(), Error> {
unsafe {
DwmSetWindowAttribute(
hwnd,
DWMWA_USE_IMMERSIVE_DARK_MODE,
DWMWA_SYSTEMBACKDROP_TYPE,
&DWM_SYSTEMBACKDROP_TYPE::DWMSBT_TRANSIENTWINDOW as *const _ as _,
4,
);
Expand All @@ -92,7 +92,7 @@ pub fn clear_acrylic(hwnd: HWND) -> Result<(), Error> {
unsafe {
DwmSetWindowAttribute(
hwnd,
DWMWA_USE_IMMERSIVE_DARK_MODE,
DWMWA_SYSTEMBACKDROP_TYPE,
&DWM_SYSTEMBACKDROP_TYPE::DWMSBT_DISABLE as *const _ as _,
4,
);
Expand Down

0 comments on commit d20161f

Please sign in to comment.