Skip to content

Commit

Permalink
feat: load webkit extension maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
SpikeHD committed Oct 23, 2024
1 parent 728d9ba commit 4992141
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
31 changes: 30 additions & 1 deletion src-tauri/src/functionality/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4992141

Please sign in to comment.