Git Product home page Git Product logo

window-vibrancy's Introduction

window-vibrancy

Chat Server

Make your windows vibrant.

Tip

If you're using tauri@v1, you need to use version 0.4 of this crate.

Platform-specific

  • Linux: Unsupported, Blur and any vibrancy effects are controlled by the compositor installed on the end-user system.

Example

use window_vibrancy::{apply_blur, apply_vibrancy, NSVisualEffectMaterial};

#[cfg(target_os = "macos")]
apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, None, None).expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");

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

Tauri

if you are using tauri, don't forget to:

For a more complete example of usage with tauri, see examples/tauri.

Available functions

Function Supported platforms Notes
apply_blur&clear_blur Windows 7/10/11 (22H1 only) Bad performance when resizing/dragging the window on Windows 11 build 22621.
apply_acrylic&clear_acrylic Windows 10/11 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

apply_blur apply_acrylic apply_mica apply_vibrancy
apply_blur screenshot apply_blur screenshot apply_mica screenshot apply_vibrancy screenshot

window-vibrancy's People

Contributors

aizcutei avatar amrbashir avatar at-manos avatar cafuchino avatar deminearchiver avatar fabianlars avatar github-actions[bot] avatar just-moh-it avatar kittuov avatar renovate[bot] avatar rhysd avatar selyss avatar vojgin avatar youngsing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

window-vibrancy's Issues

Can the app be published to the MacOS App Store?

Hello,

I am considering moving from Electron to Tauri, but the problem is that I really need transparent windows and I saw this warning:

WARNING: Using private APIs on macOS prevents your application from being accepted to the App Store.

Is it true that Apple will reject my app for this reason? That would be a deal breaker :(

Apply_blur() on windows 10

2022-10-27.21-24-08.mov

I think the video speaks for itself, but I'm happy to provide further context if needed.

Windows 10

No web content is displayed when vibrancy is applied.

When I apply this plugin in macOS 10.13.6, I got an empty window with vibrancy applied:

Screen Shot 2022-07-07 at 4 32 12 PM

If I remove the setup code, the content is correctly displayed:

Screen Shot 2022-07-07 at 4 31 38 PM

I created the project with npm create tauri-app, and used the svelte framework. Any idea how to fix it?

My configs:

src-tauri/src/main.rs

#![cfg_attr(
    all(not(debug_assertions), target_os = "windows"),
    windows_subsystem = "windows"
)]

use tauri::Manager;
use window_vibrancy::{apply_vibrancy, NSVisualEffectMaterial};

fn main() {
    let context = tauri::generate_context!();
    tauri::Builder::default()
        .menu(if cfg!(target_os = "macos") {
            tauri::Menu::os_default(&context.package_info().name)
        } else {
            tauri::Menu::default()
        })
        .setup(|app| {
            let window = app.get_window("main").unwrap();

            #[cfg(target_os = "macos")]
            apply_vibrancy(&window, NSVisualEffectMaterial::Sidebar)
                .expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");

            Ok(())
        })
        .run(context)
        .expect("error while running tauri application");
}

public/index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Welcome to Tauri!</title>
  </head>
  <style>
    html,
    body {
      background: transparent;
    }
  </style>

  <body>
    <h1>Welcome to Tauri!</h1>
  </body>
</html>

src-tauri/Cargo.toml

[package]
name = "app"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
default-run = "app"
edition = "2021"
rust-version = "1.57"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
tauri-build = { version = "1.0.2", features = [] }

[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.2", features = ["api-all"] }
window-vibrancy = "0.1.3"

[features]
# by default Tauri runs in production mode
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
default = [ "custom-protocol" ]
# this feature is used used for production builds where `devPath` points to the filesystem
# DO NOT remove this
custom-protocol = [ "tauri/custom-protocol" ]

Vibrancy while keeping macOS window border

Pretty sure you have to make windows transparent to enable vibrancy currently. On macOS dark mode, windows have a bright border in order to better see windows. When you make a window transparent, that border is removed. Ideally there would be vibrancy while keeping the window border.

Windows Acrylic effect lag

I've experienced on both windows 11 and 10 that the acrylic effect causes the window to lag while moving and or resizing.
This seems to be an issue that exists not only for Tauri.

I've done a little research into this, and it seems Electron had the same issue.
And they managed to solve it by reducing the polling rate to the refresh rate of the monitor.

(Here is a link to the issue where this was discussed)
Electron Acrylic Window (Issue 6)

I'm not sure how to apply this fix to a Tauri app,
Nevertheless I thought I'd share this possible solution in case someone else does know. 😄

No effect on Windows 11

When I try to build the example on windows, this is the result for me, am I missing something?

image

Edition	Windows 11 Pro for Workstations
Version	22H2
Installed on	‎2022-‎09-‎22
OS build	22621.1635
Experience	Windows Feature Experience Pack 1000.22641.1000.0

❯ cargo --version     
cargo 1.69.0 (6e9a83356 2023-04-12)

window-vibrancy/examples/tauri on  dev [!?] is  v1.0.0 via  v16.18.0 on  (eu-north-1) 
❯ rustc --version
rustc 1.69.0 (84c898d65 2023-04-16)

apply_acrylic does not display properly in windows 22H2

I tried using this in fltk-rs.
Seems to work only for the menu bar.
I have tried it on windows 22H1 and it is displayed normally.
But this will not work properly in windows 22H2.

# Cargo.toml
[package]
name = "fltk-acrylic"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
fltk = { version = "1.3.22", features = ["rwh05"] }
window-vibrancy = "0.3"
# main.rs
use fltk::{prelude::*, *};
use window_vibrancy::apply_acrylic;

fn main() {
    let a = app::App::default().with_scheme(app::Scheme::Gtk);
    let mut win = window::Window::default().with_size(400, 400);
    win.end();
    win.show();

    apply_acrylic(&win, Some((10, 10, 10, 90))).expect("Unsupported");
    a.run().unwrap();
}

image

Is it possible at all to add vibrancy to an individual HTML element and not the entire window?

Hey all! I understand this plugin is specifically designed for adding vibrancy to the window, so apologies in advance if this isn't the perfect place.

In my case, ideally I'd want the 2 highlighted elements to have vibrancy, and not the background window.
Screenshot 2023-09-18 at 2 50 58 PM

As of right now, the only way that I can think of to achieve that effect is to create those 2 elements as individual windows. However, that would add some additional positioning and animation work.

I'm not too familiar with the native window APIs, is that possible at all?

Support Tabbed on Windows 11

Besides Mica, Windows 11 also adds a backdrop called Tabbed, could you please consider adding support for this backdrop? Thanks.

Failed to unregister class Chrome_WidgetWin_0. Error = 0

Trying this plugin with a fresh Tauri Svelte-TS project. Saw in the issues that we should use 0.1.3 until Tauri 1.1 comes out, but still having this issue:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src\main.rs:17:48
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[0912/170933.687:ERROR:window_impl.cc(114)] Failed to unregister class Chrome_WidgetWin_0. Error = 0
error Command failed with exit code 4294967295.

Full main.rs

#![cfg_attr(
    all(not(debug_assertions), target_os = "windows"),
    windows_subsystem = "windows"
)]

#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

use tauri::Manager;
use window_vibrancy::{apply_blur, apply_vibrancy, NSVisualEffectMaterial};

fn main() {
    tauri::Builder::default()
        .setup(|app| {
            let window = app.get_window("app").unwrap();

            #[cfg(target_os = "macos")]
            apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow)
                .expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");

            #[cfg(target_os = "windows")]
            apply_blur(&window, Some((18, 18, 18, 125)))
                .expect("Unsupported platform! 'apply_blur' is only supported on Windows");
            Ok(())
        })
        .invoke_handler(tauri::generate_handler![greet])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Full TOML:

[package]
name = "tauri-svelte"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
license = ""
repository = ""
edition = "2021"
rust-version = "1.57"

[build-dependencies]
tauri-build = { version = "1.0.0", features = [] }

[dependencies]
serde_json = "1.0"
window-vibrancy = { version = "0.1.3" }
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0", features = ["api-all", "macos-private-api"] }

[features]
default = [ "custom-protocol" ]
custom-protocol = [ "tauri/custom-protocol" ]

Thanks!

How to keep background transparent if I use apply_vibrancy

As you see, I only need the radius for window,

how to keep background transparent if I use apply_vibrancy

  #[cfg(target_os = "macos")]
  apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, None, Some(16.0))
      .expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");

Tauri Example + Next.js doesn't work in macOS Sonoma beta 14.0 (23A5286g)

image

🐞 Reproduce

https://github.com/ImBIOS/nextjs-tauri-macos-titlebar

💻 Environment

  System:
    OS: macOS 14.0
    CPU: (8) arm64 Apple M2
    Memory: 48.00 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.15.0 - ~/Library/Caches/fnm_multishells/19531_1688886298316/bin/node
    npm: 9.5.0 - ~/Library/Caches/fnm_multishells/19531_1688886298316/bin/npm
    pnpm: 8.6.6 - ~/Library/pnpm/pnpm
  Languages:
    Bash: 3.2.57 - /bin/bash
    Rust: 1.70.0 - /Users/ImBIOS/.cargo/bin/rustc
  Browsers:
    Chrome: 114.0.5735.198
    Safari: 17.0
  npmPackages:
    @tauri-apps/api: ^1.4.0 => 1.4.0 
    @tauri-apps/cli: ^1.4.0 => 1.4.0 
    @types/node: 20.4.1 => 20.4.1 
    @types/react: 18.2.14 => 18.2.14 
    @types/react-dom: 18.2.6 => 18.2.6 
    autoprefixer: 10.4.14 => 10.4.14 
    eslint: 8.44.0 => 8.44.0 
    eslint-config-next: 13.4.9 => 13.4.9 
    next: 13.4.9 => 13.4.9 
    postcss: 8.4.25 => 8.4.25 
    react: 18.2.0 => 18.2.0 
    react-dom: 18.2.0 => 18.2.0 
    tailwindcss: 3.3.2 => 3.3.2 
    typescript: 5.1.6 => 5.1.6 

corner radius implementation

Great crate :)

would be nice if it had option for corner radius on windows also.

I had to implement that on it's own.

DwmSetWindowAttribute(
                    handle.hwnd as _,
                    DWMWA_WINDOW_CORNER_PREFERENCE,
                    &DWMWCP_ROUND as *const _ as _,
                    4,
                );

Dependency Dashboard

This issue provides visibility into Renovate updates and their statuses. Learn more

Repository problems

These problems occurred while renovating this repository.

  • WARN: App has not been granted permissions to update Workflows - aborting branch.

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • chore(deps): update actions/checkout action to v3

  • Check this box to trigger a request for Renovate to run again on this repository

Rounded corners not possible with window-vibrancy

Here, without window-vibrancy, I have a transparent window with decorations off; the background of the html is rgba(16, 17, 20, 0.25). I've added a green border to the html content (which uses border-radius), so you can see the rounded corners and how it clips the content so the frame of the window is rounded, which is what I want.

image

Here, with window-vibrancy, you can see that the window content actually goes past the rounded corners.

image

Is there a way to disable this, or have it clip to the rounded corners defined in the webview? This crate essentially does exactly what I want for the background, but I also need rounded corners for my app as well. Hopefully there's an easy way to do this.

cc @amrbashir

Failed to compile with tauri 1.0.5

I tried to run the example and got this report:

error[E0277]: the trait bound `Window: HasRawWindowHandle` is not satisfied
   --> src/main.rs:40:22
    |
40  |       apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow)
    |       -------------- ^^^^^^^ the trait `HasRawWindowHandle` is not implemented for `Window`
    |       |
    |       required by a bound introduced by this call
    |
    = help: the trait `HasRawWindowHandle` is implemented for `&'a T`
    = note: required because of the requirements on the impl of `HasRawWindowHandle` for `&Window`
note: required by a bound in `apply_vibrancy`
   --> /Users/dyf/.cargo/registry/src/github.com-1ecc6299db9ec823/window-vibrancy-0.2.0/src/lib.rs:147:16
    |
147 |   window: impl raw_window_handle::HasRawWindowHandle,
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `apply_vibrancy`

source code:

fn main() {
  tauri::Builder::default()
    .setup(|app| {
      let window = app.get_window("main").unwrap();

      #[cfg(target_os = "macos")]
      apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow)
        .expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");

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

      Ok(())
    })
    .run(tauri::generate_context!())
    .expect("error while running tauri application");
}

rustc version: 1.59.0
tauri version: 1.0.5

After using window vibrancy, the application's drag and drop slows down and becomes transparent during the drag process

a7f7382028d5d856d00f9112508b56b9.mp4
[] Environment
    - OS: Windows 10.0.22621 X64WebView2: 120.0.2210.61MSVC: Visual Studio Professional 2022rustc: 1.71.0 (8ede3aae2 2023-07-12)cargo: 1.71.0 (cfd3bbd8f 2023-06-08)rustup: 1.26.0 (5af9b9484 2023-04-05)
     Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 18.16.0
    - pnpm: 8.5.1
    - yarn: 1.22.17
    - npm: 9.5.1

[-] Packages
    - tauri [RUST]: 1.5.3
    - tauri-build [RUST]: 1.5.0
    - wry [RUST]: 0.24.6
    - tao [RUST]: 0.16.5
    - @tauri-apps/api [NPM]: 1.5.1 (outdated, latest: 1.5.2)
    - @tauri-apps/cli [NPM]: 1.5.6 (outdated, latest: 1.5.8)

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - framework: Vue.js
    - bundler: Vite

and i just use like this
https://github.com/tauri-apps/window-vibrancy/blob/dev/examples/tauri/src-tauri/src/main.rs

Window shadow blurred if decorations are set to enabled in rust setup.

While messing with blurred windows I ran into tauri-apps/tauri#8632. I went with the fix suggested in #40 though, which is to enable decorations in rust, rather than js, since it's much more noticeable when the decorations are enabled in js.
However, I'm noticing that if the decorations are enabled in the setup, from what I can see it also applies the blur to the window shadow, or at least that's what it looks like:
image
As you can see in the image, the lighter window is the actual window with the blur, which is correct. But there's also the 6-ish pixel darker border around the edge, which I can only guess is supposed to be the window shadow, but somehow it's being affected by the blur. Maximising the window, the "border" dissapears like a shadow would so it's not extending the window.
The specific window is configured as shown:

{
    "fullscreen": false,
    "height": 600,
    "resizable": true,
    "title": "window",
    "width": 800,
    "visible": true,
    "label": "edtr",
    "transparent": true,
    "url": "edtr",
    "decorations": false
},
tauri::Builder::default()
        .invoke_handler(tauri::generate_handler![get_cli_args])
        .setup(|app| {
            if let Ok(matches) = app.get_cli_matches() {
                let mut args = CliArgs::default();

                if matches.args["devtools"].occurrences >= 1 {
                    args.dev_tools = true;

                    app.get_window("main").unwrap().open_devtools();
                }

                if matches.args["debug"].occurrences >= 1 {
                    args.debug = true;
                }

                app.manage(args);
            }

            let window = app.get_window("edtr").unwrap();

            // window shadows
            //set_shadow(&window, true).unwrap();

            // background blur
            // #[cfg(target_os = "macos")]
            // apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow, None, Some(50)).unwrap();

            #[cfg(target_os = "windows")]
            apply_blur(&window, Some((21, 21, 21, 200))).unwrap();

            window.set_decorations(true).unwrap(); // https://github.com/tauri-apps/tauri/issues/8632

            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
tauri = { version = "1.0.0", features = ["api-all", "cli", "macos-private-api"] }
window-vibrancy = "0.3.0"
window-shadows = "0.2.0"

It doesn't matter whether the decorations are enabled before or after the window blur (that only affects whether the title bar is blurred or not, which I don't know if that's intended either). The border still appears either way.

Focus change breaks shadow & border on macos sonoma

I tried the tauri example.

Before focus change
Screenshot 2023-11-17 at 15 34 23

After the focus change
Screenshot 2023-11-17 at 15 34 36

The visual difference is not that big but it seems like the border & shadow is now around a much smaller box in one corner of the window.

Acrylic dark on Windows 11 build 22563.1

This plugin appears to be broken on Windows with Tauri v1.0.0-rc.3. I am testing the example project in this repo, except I updated the Tauri version to 1.0.0-rc.3. The background of the application is fully opaque black (also with some grain effect), even with transparency enabled. The window is transparent when tauri-plugin-vibrancy is disabled.

  • Windows version: Windows 11, build 22563.1
  • WebView2 version: 98.0.4758.102

Get round corners on MacOS

Through I successfully got vibrancy window on macOS, a sharp window looks pretty weird on MacOS12.
I had already set "decorations": false to hide the title bar.
However, I still need the round corner.

I have tried setting "border-radius" on and it is not working.

May I ask, how can I get round corners back when using this awesome plugin?

Thanks for your reply.

[Feature Request] Having an option to round corners

Scenario Reproduction

  1. Create a Tauri Project
  2. Make window transparent
  3. Apply a backdrop and round its corner using border-radius in CSS
  4. Use Window Vibrancy's Tauri example on Github

Feature Request

Ability to round corners as currently the backdrop has rounded corners but the Window Vibrancy's window corners are sharp and visible.

Am I able to do this myself

Currently I'm a Rust beginner and don't have enough skill to add this feature. Thus this request is a humble plea to add this feature.

Blur Effects Causing White Background

apply_mica and apply_blur is causing white background in window.
Here is screenshot with apply_mica effect
image
Here is screenshot without apply_mica effect
image
In transparency is set to true in both conditions
Window decorations is set to false

Mica Background in Tauri JS

How can I enable the mica / blur background in Tauri JS?, I followed some threads here but can't get it working.

Deleteing / setting to transparent any css property about background results in a white background:
image

Cargo.toml

#...

[dependencies]
tauri = { version = "1.0.3", features = ["api-all"] }
window-vibrancy = "0.1.3"

#...

main.rs

#[cfg(target_os = "windows")]
use window_vibrancy::{apply_mica, apply_blur};

//...

  let main_window = app.get_window("main").unwrap();
  #[cfg(target_os = "windows")]
  {
       apply_mica(&main_window)
                .expect("Unsupported platform! 'apply_mica' is only supported on Windows");
  }

//...

tauri.conf.json

"windows": [
  {
    "fullscreen": false,
    "height": 600,
    "resizable": true,
    "title": "Title",
    "width": 800,
    "visible": true,
    "transparent": true,
    "center": true
  }

Windows 11 feedback

I don't see a Discussions tab in this repo, but feel free to redirect me if this should be posted elsewhere.

  1. Using apply_blur, the effect is much less strong than what's typical in first-party Windows apps. Here's a comparison between Tauri on the left and the built-in calculator app on the right.

tauri-vibrancy-vs-winui-acrylic

I took a peek at your code, but I don't see where this would even be configurable in the Windows APIs you're using, so I have no idea if this is fixable, just figured I'd mention it. As it stands, the blur effect is not really strong enough to be useful (IMO), since the background is sharp enough to interfere with the legibility of the foreground app.
2. If I move the Tauri window around while there's an Explorer window behind it, whatever is immediately behind the Explorer's header area flickers into view every so often, like there's some Z-fighting type of thing happening.

Code from v0.1.3 can't work under v0.2.0

Code:

let main_window = app.get_window("main").unwrap();

#[cfg(target_os = "macos")]
apply_vibrancy(&main_window, NSVisualEffectMaterial::FullScreenUI)
    .expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");

Works fine with v0.1.3, but after I change to v0.2.0, the complier throw an error.

Message from complier:

error[E0277]: the trait bound `Window: raw_window_handle::HasRawWindowHandle` is not satisfied
   --> src/app/window.rs:16:20
    |
16  |     apply_vibrancy(&main_window, NSVisualEffectMaterial::FullScreenUI)
    |     -------------- ^^^^^^^^^^^^ the trait `raw_window_handle::HasRawWindowHandle` is not implemented for `Window`
    |     |
    |     required by a bound introduced by this call
    |
help: trait impl with same name found
   --> /Users/user/.cargo/registry/src/github.com-1ecc6299db9ec823/tauri-1.0.3/src/window.rs:492:1
    |
492 | / unsafe impl<R: Runtime> raw_window_handle::HasRawWindowHandle for Window<R> {
493 | |   fn raw_window_handle(&self) -> raw_window_handle::RawWindowHandle {
494 | |     self.window.dispatcher.raw_window_handle().unwrap()
495 | |   }
496 | | }
    | |_^
    = note: perhaps two different versions of crate `raw_window_handle` are being used?
    = note: required because of the requirements on the impl of `raw_window_handle::HasRawWindowHandle` for `&Window`
note: required by a bound in `apply_vibrancy`
   --> /Users/user/.cargo/registry/src/github.com-1ecc6299db9ec823/window-vibrancy-0.2.0/src/lib.rs:147:16
    |
147 |   window: impl raw_window_handle::HasRawWindowHandle,
    |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `apply_vibrancy`

For more information about this error, try `rustc --explain E0277`.

Effect not applied on Windows 11 with decoration enable

Hey first of all thanks for the library, it currently works well for me on macOS but I have some trouble with it on Windows 11.
The vibrancy effect (I tried the blur and the mica) is not applied until the window is resized. Then the effect will only be applied to the resized area.

From what I have tested, it only appears when you enable the window decoration.

I took some screenshots to give you a better idea :
Capture d’écran 2022-05-21 100642
Capture d’écran 2022-05-21 100707

This should look like this without the weird artifact:
Capture d’écran 2022-05-21 100732

I didn't create a test repository but it should be easy to reproduce, it can be still reproduced on my project: https://github.com/zenoxs/tauri-appcenter-companion

Thanks!

the trait bound `Window: raw_window_handle::HasRawWindowHandle` is not satisfied.

main.rs

#![cfg_attr(
    all(not(debug_assertions), target_os = "windows"),
    windows_subsystem = "windows"
)]

use tauri::Manager;
use window_vibrancy::apply_blur;

fn main() {
    tauri::Builder::default()
        .setup(|app| {
            let window = app.get_window("main").unwrap();

            #[cfg(target_os = "macos")]
            {
                use window_vibrancy::{apply_vibrancy, NSVisualEffectMaterial};
                apply_vibrancy(&window, NSVisualEffectMaterial::HudWindow)
                .expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");
            }

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

            Ok(())
        })
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Error

image

Tauri version

Environment
  › OS: Windows 10.0.22000 X64
  › Webview2: 103.0.1264.71
  › MSVC: 
      - Visual Studio Community 2022
      - Visual Studio Build Tools 2019
  › Node.js: 16.15.0
  › npm: 8.5.5
  › pnpm: Not installed!
  › yarn: Not installed!
  › rustup: 1.25.1
  › rustc: 1.62.1
  › cargo: 1.62.1
  › Rust toolchain: stable-x86_64-pc-windows-msvc 

Packages
  › @tauri-apps/cli [NPM]: 1.0.5
  › @tauri-apps/api [NPM]: 1.0.2
  › tauri [RUST]: 1.0.5,
  › tauri-build [RUST]: 1.0.4,
  › tao [RUST]: 0.12.2,
  › wry [RUST]: 0.19.0,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../dist
  › devPath: http://localhost:3000/

App directory structure
  ├─ dist
  ├─ node_modules
  ├─ src
  └─ src-tauri

Tauri example does not work

When using the tauri example verbatim, you will encounter

= note: perhaps two different versions of crate `raw_window_handle` are being used?
    = help: the trait `raw_window_handle::HasRawWindowHandle` is implemented for `&'a T`
    = note: required because of the requirements on the impl of `raw_window_handle::HasRawWindowHandle` for `&Window`

as a build error.

Dark Mode override

Thank you for creating this plugin, it works great for macOS in my uses so far!

Wondering if it's possible to manually set the appearance to dark or light based on an application setting (not just the system setting)?

The use case would be a dark mode toggle in an app that allows the user to override and/or differ from the system. Is this something that can be exposed to Rust via this plugin?

If not, I'll gladly close this. Thank you!

it doesn't work! while I set "background": true on win11

When I set transparent to true in tauri.conf.json, it does not take effect on the platform.

os: Windows 11 professional edition
os_version: 22H2 (22621.1265)
node: v16.18.1
npm: 8.19.2
rustc: 1.67.1 (d5a82bbd2 2023-02-07)
cargo: 1.67.1 (8ecd4f20a 2023-01-10)

I have done the following:

// index.html
html, body {
    background-color: transparent !important;
}
// tauri.conf.json
{
  "build": {
    "beforeDevCommand": "npm run dev",
    "beforeBuildCommand": "npm run build",
    "devPath": "http://localhost:1420",
    "distDir": "../dist",
    "withGlobalTauri": true
  },
  "package": {
    "productName": "t1",
    "version": "0.0.0"
  },
  "tauri": {
    "allowlist": {
      "all": false,
      "shell": {
        "all": false,
        "open": true
      }
    },
    "bundle": {
      "active": true,
      "category": "DeveloperTool",
      "copyright": "",
      "deb": {
        "depends": []
      },
      "externalBin": [],
      "icon": [
        "icons/32x32.png",
        "icons/128x128.png",
        "icons/[email protected]",
        "icons/icon.icns",
        "icons/icon.ico"
      ],
      "identifier": "com.tauri.dev",
      "longDescription": "",
      "macOS": {
        "entitlements": null,
        "exceptionDomain": "",
        "frameworks": [],
        "providerShortName": null,
        "signingIdentity": null
      },
      "resources": [],
      "shortDescription": "",
      "targets": "all",
      "windows": {
        "certificateThumbprint": null,
        "digestAlgorithm": "sha256",
        "timestampUrl": ""
      }
    },
    "security": {
      "csp": null
    },
    "updater": {
      "active": false
    },
    "windows": [
      {
        "fullscreen": false,
        "height": 600,
        "resizable": true,
        "title": "t1",
        "width": 800,
        "transparent": true
      }
    ]
  }
}

How to use?

The README.md doesn't explain how to implement this in a Tauri project. It just gives you some rust code but doesn't explain where and how to use it.

Failed to compiled for Tauri.

I just updated this library from 0.4 to 0.5, and got a compile error. And my code has no different with your examples.
So I clone this project and try compiling the example.

Compile Logs
PS F:\tauri\window-vibrancy\examples\tauri
> cargo tauri build
    Updating crates.io index
  Downloaded tauri-winrt-notification v0.1.3
  Downloaded notify-rust v4.10.0
  Downloaded quick-xml v0.30.0
  Downloaded 3 crates (260.1 KB) in 3.73s
   Compiling proc-macro2 v1.0.78
   Compiling unicode-ident v1.0.12
   Compiling cfg-if v1.0.0
   Compiling serde v1.0.197
   Compiling windows_x86_64_msvc v0.48.5
   Compiling autocfg v1.1.0
   Compiling siphasher v0.3.11
   Compiling ppv-lite86 v0.2.17
   Compiling syn v1.0.109
   Compiling windows_x86_64_msvc v0.52.4
   Compiling getrandom v0.1.16
   Compiling parking_lot_core v0.9.9
   Compiling thiserror v1.0.57
   Compiling proc-macro-hack v0.5.20+deprecated
   Compiling serde_json v1.0.114
   Compiling fnv v1.0.7
   Compiling itoa v1.0.10
   Compiling memchr v2.7.1
   Compiling ryu v1.0.17
   Compiling ident_case v1.0.1
   Compiling strsim v0.10.0
   Compiling log v0.4.21
   Compiling once_cell v1.19.0
   Compiling smallvec v1.13.1
   Compiling libc v0.2.153
   Compiling cc v1.0.89
   Compiling convert_case v0.4.0
   Compiling winapi v0.3.9
   Compiling getrandom v0.2.12
   Compiling phf_shared v0.10.0
   Compiling phf_shared v0.8.0
   Compiling phf_shared v0.11.2
   Compiling equivalent v1.0.1
   Compiling hashbrown v0.14.3
   Compiling rand_core v0.6.4
   Compiling new_debug_unreachable v1.0.4
   Compiling scopeguard v1.2.0
   Compiling byteorder v1.5.0
   Compiling aho-corasick v1.1.2
   Compiling lock_api v0.4.11
   Compiling precomputed-hash v0.1.1
   Compiling windows-tokens v0.39.0
   Compiling mac v0.1.1
   Compiling semver v1.0.22
   Compiling regex-syntax v0.8.2
   Compiling bitflags v1.3.2
   Compiling crc32fast v1.4.0
   Compiling tinyvec_macros v0.1.1
   Compiling rand_chacha v0.3.1
   Compiling dtoa v1.0.9
   Compiling pin-project-lite v0.2.13
   Compiling utf-8 v0.7.6
   Compiling indexmap v2.2.5
   Compiling indexmap v1.9.3
   Compiling windows-targets v0.48.5
   Compiling rand_core v0.5.1
   Compiling windows-targets v0.52.4
   Compiling rand v0.8.5
   Compiling futf v0.1.5
   Compiling dtoa-short v0.3.4
   Compiling windows-sys v0.52.0
   Compiling windows-sys v0.48.0
   Compiling quote v1.0.35
   Compiling tinyvec v1.6.0
   Compiling rand_chacha v0.2.2
   Compiling rand_pcg v0.2.1
   Compiling phf v0.10.1
   Compiling alloc-no-stdlib v2.0.4
   Compiling matches v0.1.10
   Compiling itoa v0.4.8
   Compiling windows_x86_64_msvc v0.39.0
   Compiling nodrop v0.1.14
   Compiling typenum v1.17.0
   Compiling phf_generator v0.10.0
   Compiling phf_generator v0.11.2
   Compiling crossbeam-utils v0.8.19
   Compiling regex-automata v0.4.6
   Compiling tendril v0.4.3
   Compiling syn v2.0.52
   Compiling version_check v0.9.4
   Compiling stable_deref_trait v1.2.0
   Compiling rand v0.7.3
   Compiling phf_codegen v0.10.0
   Compiling string_cache_codegen v0.5.2
   Compiling parking_lot v0.12.1
   Compiling servo_arc v0.1.1
   Compiling winapi-util v0.1.6
   Compiling alloc-stdlib v0.2.2
   Compiling fxhash v0.2.1
   Compiling uuid v1.7.0
   Compiling windows-metadata v0.39.0
   Compiling unicode-normalization v0.1.23
   Compiling thin-slice v0.1.1
   Compiling hashbrown v0.12.3
   Compiling unicode-bidi v0.3.15
   Compiling generic-array v0.14.7
   Compiling percent-encoding v2.3.1
   Compiling phf_generator v0.8.0
   Compiling vswhom-sys v0.1.2
   Compiling slab v0.4.9
   Compiling markup5ever v0.11.0
   Compiling brotli-decompressor v2.5.1
   Compiling same-file v1.0.6
   Compiling regex v1.10.3
   Compiling darling_core v0.20.8
   Compiling form_urlencoded v1.2.1
   Compiling phf_codegen v0.8.0
   Compiling cfb v0.7.3
   Compiling windows_x86_64_msvc v0.42.2
   Compiling idna v0.5.0
   Compiling anyhow v1.0.80
   Compiling simd-adler32 v0.3.7
   Compiling futures-core v0.3.30
   Compiling num_cpus v1.16.0
   Compiling windows-bindgen v0.39.0
   Compiling socket2 v0.5.6
   Compiling mio v0.8.11
   Compiling brotli v3.4.0
   Compiling walkdir v2.5.0
   Compiling infer v0.13.0
   Compiling selectors v0.22.0
   Compiling windows-version v0.1.0
   Compiling num-traits v0.2.18
   Compiling tracing-core v0.1.32
   Compiling winnow v0.5.40
   Compiling winnow v0.6.5
   Compiling dunce v1.0.4
   Compiling adler v1.0.2
   Compiling glob v0.3.1
   Compiling serde_derive v1.0.197
   Compiling thiserror-impl v1.0.57
   Compiling cssparser-macros v0.6.1
   Compiling phf_macros v0.11.2
   Compiling ctor v0.2.7
   Compiling heck v0.4.1
   Compiling phf_macros v0.8.0
   Compiling cssparser v0.27.2
   Compiling html5ever v0.26.0
   Compiling darling_macro v0.20.8
   Compiling derive_more v0.99.17
   Compiling windows-implement v0.39.0
   Compiling miniz_oxide v0.7.2
   Compiling tracing v0.1.40
   Compiling futures-macro v0.3.30
   Compiling pin-utils v0.1.0
   Compiling httparse v1.8.0
   Compiling futures-task v0.3.30
   Compiling futures-sink v0.3.30
   Compiling raw-window-handle v0.5.2
   Compiling native-tls v0.2.11
   Compiling darling v0.20.8
   Compiling phf v0.11.2
   Compiling windows v0.39.0
   Compiling phf v0.8.0
   Compiling vswhom v0.1.0
   Compiling serde_with_macros v3.6.1
   Compiling block-buffer v0.10.4
   Compiling crypto-common v0.1.6
   Compiling webview2-com-macros v0.6.0
   Compiling fdeflate v0.3.4
   Compiling schannel v0.1.23
   Compiling flate2 v1.0.28
   Compiling rustc_version v0.4.0
   Compiling tao v0.16.7
   Compiling windows_x86_64_msvc v0.37.0
   Compiling try-lock v0.2.5
   Compiling futures-util v0.3.30
   Compiling color_quant v1.1.0
   Compiling bytemuck v1.14.3
   Compiling want v0.3.1
   Compiling digest v0.10.7
   Compiling winreg v0.51.0
   Compiling png v0.17.13
   Compiling futures-channel v0.3.30
   Compiling crossbeam-channel v0.5.12
   Compiling dirs-sys-next v0.1.2
   Compiling image v0.24.9
   Compiling windows-core v0.51.1
   Compiling instant v0.1.12
   Compiling unicode-segmentation v1.11.0
   Compiling error-code v3.2.0
   Compiling cpufeatures v0.2.12
   Compiling httpdate v1.0.3
   Compiling tower-service v0.3.2
   Compiling tauri-runtime v0.14.2
   Compiling wry v0.24.7
   Compiling lazy_static v1.4.0
   Compiling dirs-next v2.0.0
   Compiling ico v0.3.0
   Compiling clipboard-win v5.2.0
   Compiling sha2 v0.10.8
   Compiling windows-targets v0.42.2
   Compiling crossbeam-epoch v0.9.18
   Compiling windows v0.51.1
   Compiling toml_datetime v0.6.5
   Compiling string_cache v0.8.7
   Compiling serde_spanned v0.6.5
   Compiling url v2.5.0
   Compiling serde_with v3.6.1
   Compiling bytes v1.5.0
   Compiling quick-xml v0.30.0
   Compiling toml_edit v0.22.6
   Compiling toml_edit v0.19.15
   Compiling http v0.2.12
   Compiling tokio v1.36.0
   Compiling bstr v1.9.1
   Compiling tauri-runtime-wry v0.14.5
   Compiling treediff v4.0.3
   Compiling http-range v0.1.5
   Compiling base64 v0.21.7
   Compiling rfd v0.10.0
   Compiling json-patch v1.2.0
   Compiling webview2-com-sys v0.19.0
   Compiling http-body v0.4.6
   Compiling toml v0.8.10
   Compiling globset v0.4.14
   Compiling rustls-pemfile v1.0.4
   Compiling toml v0.7.8
   Compiling arboard v3.3.2
   Compiling crossbeam-deque v0.8.5
   Compiling windows-sys v0.45.0
   Compiling serde_urlencoded v0.7.1
   Compiling embed-resource v2.4.1
   Compiling windows v0.37.0
   Compiling windows-sys v0.42.0
   Compiling kuchikiki v0.8.2
   Compiling tauri-winrt-notification v0.1.3
   Compiling tauri-winres v0.1.1
   Compiling cargo_toml v0.15.3
   Compiling tauri v1.6.1
   Compiling serialize-to-javascript-impl v0.1.1
   Compiling winreg v0.50.0
   Compiling filetime v0.2.23
   Compiling encoding_rs v0.8.33
   Compiling fastrand v2.0.1
   Compiling ipnet v2.9.0
   Compiling sync_wrapper v0.1.2
   Compiling tokio-util v0.7.10
   Compiling tokio-native-tls v0.3.1
   Compiling mime v0.3.17
   Compiling open v3.2.0
   Compiling sys-locale v0.2.4
   Compiling notify-rust v4.10.0
   Compiling tauri-utils v1.5.3
   Compiling tempfile v3.10.1
   Compiling tar v0.4.40
   Compiling ignore v0.4.22
   Compiling h2 v0.3.24
   Compiling os_info v3.7.0
   Compiling serialize-to-javascript v0.1.1
   Compiling serde_repr v0.1.18
   Compiling os_pipe v1.1.5
   Compiling shared_child v1.0.0
   Compiling raw-window-handle v0.6.0
   Compiling state v0.5.3
   Compiling window-vibrancy v0.5.0 (F:\tauri\window-vibrancy)
   Compiling hyper v0.14.28
   Compiling tauri-build v1.5.1
   Compiling tauri-codegen v1.4.2
   Compiling tauri-macros v1.4.3
   Compiling app v0.1.0 (F:\tauri\window-vibrancy\examples\tauri\src-tauri)
   Compiling hyper-tls v0.5.0
   Compiling reqwest v0.11.24
   Compiling webview2-com v0.19.1
warning: unused imports: `NSVisualEffectMaterial`, `apply_vibrancy`
  --> src\main.rs:11:35
   |
11 | use window_vibrancy::{apply_blur, apply_vibrancy, NSVisualEffectMaterial};
   |                                   ^^^^^^^^^^^^^^  ^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

error[E0277]: the trait bound `Window: raw_window_handle::borrowed::HasWindowHandle` is not satisfied
  --> src\main.rs:23:19
   |
23 |       apply_blur(&window, Some((18, 18, 18, 125)))
   |       ----------  ^^^^^^ the trait `raw_window_handle::borrowed::HasWindowHandle` is not implemented for `Window`, which is required by `&Window: raw_window_handle::borrowed::HasWindowHandle`
   |       |
   |       required by a bound introduced by this call
   |
   = help: the following other types implement trait `raw_window_handle::borrowed::HasWindowHandle`:
             raw_window_handle::borrowed::WindowHandle<'_>
             &H
             &mut H
   = note: required for `&Window` to implement `raw_window_handle::borrowed::HasWindowHandle`
note: required by a bound in `apply_blur`
  --> F:\tauri\window-vibrancy\src\lib.rs:48:18
   |
47 | pub fn apply_blur(
   |        ---------- required by a bound in this function
48 |     window: impl raw_window_handle::HasWindowHandle,
   |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `apply_blur`

For more information about this error, try `rustc --explain E0277`.
warning: `app` (bin "app") generated 1 warning
error: could not compile `app` (bin "app") due to 1 previous error; 1 warning emitted
       Error failed to build app: failed to build app

Keep the inactive window vibrancy on macOS

I hope to make a program can keep vibrancy style even when it is inactive. I find there is a NSVisualEffectState enum can control it, but seems it is fixed in this repository (/src/macos.rs line 105):

blurred_view.setState_(NSVisualEffectState::FollowsWindowActiveState);

Is there any plan to expose it like appearance: NSVisualEffectMaterial as a changeable parameter?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.