Skip to content

Commit 0303c4a

Browse files
author
Artale
authored
fix: apply Mica/Acrylic vibrancy on Windows to prevent transparent background (#12)
* fix: apply Mica/Acrylic vibrancy on Windows to prevent transparent background The window config has transparent:true for macOS vibrancy, but only macOS got an apply_vibrancy() call. On Windows, this left the window fully see-through — you could see other apps through the editor. Adds a #[cfg(target_os = "windows")] block that tries Mica first (Windows 11 native material) and falls back to Acrylic (Windows 10 1809+). Applied in both the main window setup and create_editor_window. The RGBA (18, 18, 18, 200) gives a dark semi-opaque base that matches the dark theme defaults. fixes #10 * fix: use None for Mica dark_mode, add log::warn! fallback, reword comment Addresses code review feedback: - Use None instead of Some(true) for Mica dark_mode, letting the system decide - Add log::warn! when Mica is unavailable and Acrylic fallback is used - Reword comment for clarity
1 parent 7922b80 commit 0303c4a

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src-tauri/src/lib.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ fn create_editor_window(app: &tauri::AppHandle) -> tauri::Result<()> {
5656
.ok();
5757
}
5858

59+
#[cfg(target_os = "windows")]
60+
{
61+
// Mica (Win11) provides a native translucent material; Acrylic (Win10 1809+)
62+
// is the fallback. Either prevents raw transparency from tauri.conf.json.
63+
if window_vibrancy::apply_mica(&window, None).is_err() {
64+
log::warn!("Mica not available, falling back to Acrylic");
65+
window_vibrancy::apply_acrylic(&window, Some((18, 18, 18, 200)))
66+
.ok();
67+
}
68+
}
69+
5970
Ok(())
6071
}
6172

@@ -359,5 +370,15 @@ fn setup_desktop_menu(app: &tauri::App) -> Result<(), Box<dyn std::error::Error>
359370
.ok();
360371
}
361372

373+
#[cfg(target_os = "windows")]
374+
{
375+
let window = app.get_webview_window("main").unwrap();
376+
if window_vibrancy::apply_mica(&window, None).is_err() {
377+
log::warn!("Mica not available, falling back to Acrylic");
378+
window_vibrancy::apply_acrylic(&window, Some((18, 18, 18, 200)))
379+
.ok();
380+
}
381+
}
382+
362383
Ok(())
363384
}

0 commit comments

Comments
 (0)