Skip to main content

tauri_plugin_wayland_nvidia_quirk/
lib.rs

1//! Fixes the Wayland/Nvidia startup failure in Tauri v2 apps without giving up
2//! hardware acceleration.
3
4#![deny(missing_docs)]
5
6mod status;
7
8pub use status::{Error, NotAffectedReason, SessionType, Status};
9
10#[cfg(target_os = "linux")]
11mod detect;
12#[cfg(target_os = "linux")]
13mod imp;
14
15use tauri::{
16    plugin::{Builder, TauriPlugin},
17    Runtime, WebviewWindow,
18};
19
20/// Registers the quirk.
21pub fn init<R: Runtime>() -> TauriPlugin<R> {
22    Builder::new("wayland-nvidia-quirk")
23        .setup(|_app, _api| {
24            #[cfg(target_os = "linux")]
25            imp::setup(_app);
26            Ok(())
27        })
28        .build()
29}
30
31/// Applies the quirk to a single window.
32pub fn apply<R: Runtime>(window: &WebviewWindow<R>) -> Result<(), Error> {
33    #[cfg(target_os = "linux")]
34    {
35        imp::apply(window)
36    }
37    #[cfg(not(target_os = "linux"))]
38    {
39        let _ = window;
40        Ok(())
41    }
42}
43
44/// What the quirk decided and whether it worked.
45pub fn status() -> Status {
46    #[cfg(target_os = "linux")]
47    {
48        imp::status()
49    }
50    #[cfg(not(target_os = "linux"))]
51    {
52        Status::NotAffected {
53            reason: NotAffectedReason::NotLinux,
54        }
55    }
56}