From 20854c18f6071b7c8457a8aeba643a63d852f606 Mon Sep 17 00:00:00 2001 From: yujonglee Date: Tue, 29 Apr 2025 10:45:33 -0700 Subject: [PATCH 1/2] wip --- Cargo.lock | 1 + apps/desktop/src-tauri/Cargo.toml | 2 +- apps/desktop/src/styles/globals.css | 5 +++++ plugins/windows/Cargo.toml | 3 ++- plugins/windows/src/errors.rs | 2 ++ plugins/windows/src/ext.rs | 20 ++++++++++++++++++++ 6 files changed, 31 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a2f0f057c..8df97d141 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13531,6 +13531,7 @@ dependencies = [ "tauri-specta", "thiserror 2.0.12", "tracing", + "window-vibrancy", ] [[package]] diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 9b1be3c63..ef5ae2b7b 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -48,7 +48,7 @@ tauri-plugin-template = { workspace = true } tauri-plugin-tray = { workspace = true } tauri-plugin-windows = { workspace = true } -tauri = { workspace = true, features = ["specta", "macos-private-api"] } +tauri = { workspace = true } tauri-plugin-autostart = "2" tauri-plugin-clipboard-manager = "2" tauri-plugin-decorum = { workspace = true } diff --git a/apps/desktop/src/styles/globals.css b/apps/desktop/src/styles/globals.css index f070d58c7..6770fd449 100644 --- a/apps/desktop/src/styles/globals.css +++ b/apps/desktop/src/styles/globals.css @@ -16,6 +16,11 @@ margin: 0; } +html, +body { + background: transparent; +} + body { line-height: 1.5; -webkit-font-smoothing: antialiased; diff --git a/plugins/windows/Cargo.toml b/plugins/windows/Cargo.toml index ca41ce4ae..8bfac37a2 100644 --- a/plugins/windows/Cargo.toml +++ b/plugins/windows/Cargo.toml @@ -18,9 +18,10 @@ serde = { workspace = true } specta = { workspace = true } strum = { workspace = true, features = ["derive"] } -tauri = { workspace = true, features = ["test"] } +tauri = { workspace = true, features = ["macos-private-api"] } tauri-plugin-decorum = { workspace = true } tauri-specta = { workspace = true, features = ["derive", "typescript"] } +window-vibrancy = "0.6.0" thiserror = { workspace = true } tracing = { workspace = true } diff --git a/plugins/windows/src/errors.rs b/plugins/windows/src/errors.rs index 1459cdbce..94c757b46 100644 --- a/plugins/windows/src/errors.rs +++ b/plugins/windows/src/errors.rs @@ -4,6 +4,8 @@ use serde::{ser::Serializer, Serialize}; pub enum Error { #[error(transparent)] TauriError(#[from] tauri::Error), + #[error(transparent)] + WindowVibrancyError(#[from] window_vibrancy::Error), #[error("monitor not found")] MonitorNotFound, } diff --git a/plugins/windows/src/ext.rs b/plugins/windows/src/ext.rs index 6c04c2b89..17e8b39eb 100644 --- a/plugins/windows/src/ext.rs +++ b/plugins/windows/src/ext.rs @@ -239,6 +239,8 @@ impl HyprWindow { }; if created { + self.apply_vibrancy(&window)?; + #[cfg(target_os = "macos")] { use tauri_plugin_decorum::WebviewWindowExt; @@ -369,9 +371,26 @@ impl HyprWindow { window.set_focus()?; window.show()?; + Ok(window) } + fn apply_vibrancy(&self, window: &WebviewWindow) -> Result<(), crate::Error> { + #[cfg(target_os = "macos")] + { + use window_vibrancy::{apply_vibrancy, NSVisualEffectMaterial}; + apply_vibrancy(window, NSVisualEffectMaterial::HudWindow, None, None)?; + } + + #[cfg(target_os = "windows")] + { + use window_vibrancy::apply_blur; + apply_blur(&window, Some((18, 18, 18, 125)))?; + } + + Ok(()) + } + fn window_builder<'a>( &'a self, app: &'a AppHandle, @@ -379,6 +398,7 @@ impl HyprWindow { ) -> WebviewWindowBuilder<'a, tauri::Wry, AppHandle> { let mut builder = WebviewWindow::builder(app, self.label(), WebviewUrl::App(url.into())) .title(self.title()) + .transparent(true) .decorations(true) .disable_drag_drop_handler(); From 95e19f7f81e6cd0b49095f2a6fc83d7209165165 Mon Sep 17 00:00:00 2001 From: yujonglee Date: Tue, 29 Apr 2025 10:50:03 -0700 Subject: [PATCH 2/2] fix --- apps/desktop/src-tauri/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index ef5ae2b7b..356c20f40 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -48,7 +48,7 @@ tauri-plugin-template = { workspace = true } tauri-plugin-tray = { workspace = true } tauri-plugin-windows = { workspace = true } -tauri = { workspace = true } +tauri = { workspace = true, features = ["macos-private-api"] } tauri-plugin-autostart = "2" tauri-plugin-clipboard-manager = "2" tauri-plugin-decorum = { workspace = true }