Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

1.7 KB
Raw Blame
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0

//! macOS system window material.

use tauri::{Runtime, Webview};

#[tauri::command]
pub fn set_native_vibrancy<R: Runtime>(webview: Webview<R>, enabled: bool) -> Result<bool, String> {
    #[cfg(target_os = "macos")]
    {
        use tauri::window::{Effect, EffectState, EffectsBuilder};
        let window = webview.window();
        if !enabled {
            window
                .set_effects(None)
                .map_err(|error| error.to_string())?;
            return Ok(true);
        }
        webview
            .with_webview(|platform| {
                use objc2_app_kit::NSView;
                use objc2_foundation::{ns_string, NSNumber, NSObjectNSKeyValueCoding};
                // Safety: wry's live WKWebView, on the main thread. Private KVC key, as wry's `transparent` option uses.
                unsafe {
                    let view = &*(platform.inner() as *const NSView);
                    view.setValue_forKey(
                        Some(&NSNumber::numberWithBool(false)),
                        ns_string!("drawsBackground"),
                    );
                }
            })
            .map_err(|error| error.to_string())?;
        window
            .set_effects(
                EffectsBuilder::new()
                    .effect(Effect::Sidebar)
                    .state(EffectState::FollowsWindowActiveState)
                    .build(),
            )
            .map_err(|error| error.to_string())?;
        Ok(true)
    }
    #[cfg(not(target_os = "macos"))]
    {
        let _ = (webview, enabled);
        Ok(false)
    }
}