diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index d19d4749..324b0ffb 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -54,7 +54,7 @@ window_titles = { git = "https://github.com/SpikeHD/window_titles", branch = "ma mundy = { version = "0.1.1", features = ["accent-color", "callback"] } [target."cfg(any(target_os = \"linux\", target_os = \"dragonfly\", target_os = \"freebsd\", target_os = \"openbsd\", target_os = \"netbsd\"))".dependencies] -webkit2gtk = "2.0" +webkit2gtk = { version = "2.0", features = ["v2_4"] } wgpu = { version = "22", default-features = false } [target.'cfg(target_os = "macos")'.dependencies] diff --git a/src-tauri/src/functionality/window.rs b/src-tauri/src/functionality/window.rs index 6587aa77..eb4a09d7 100644 --- a/src-tauri/src/functionality/window.rs +++ b/src-tauri/src/functionality/window.rs @@ -84,12 +84,41 @@ pub fn after_build(window: &tauri::WebviewWindow) { config.blur.unwrap_or("none".to_string()).as_str(), ); - // Set user-agent through WebkitGTK config + // Set WebkitGTK config #[cfg(target_os = "linux")] { + use std::path::PathBuf; + + use tauri::path::BaseDirectory; + use webkit2gtk::WebContextExt; + use webkit2gtk::WebViewExt; + use crate::gpu::disable_hardware_accel_linux; + disable_hardware_accel_linux(window); enable_webrtc(window); + + let handle = app.clone(); + + // Extension patch + window + .with_webview(move |webview| { + let webview = webview.inner(); + let context = webview.context(); + let path = handle + .path() + .resolve(PathBuf::from("extension_webkit"), BaseDirectory::Resource) + .unwrap_or_default(); + + if let Some(context) = context { + let path_str = path.as_os_str().to_str(); + + if let Some(path_str) = path_str { + context.set_web_extensions_directory(path_str); + } + } + }) + .unwrap_or_else(|e| log!("Failed to set web extensions directory: {:?}", e)); } match super::tray::create_tray(app) {