From 950662958620ed55d8a04d5355b48e20e0e96546 Mon Sep 17 00:00:00 2001 From: Philip Peterson <1326208+philip-peterson@users.noreply.github.com> Date: Tue, 25 Aug 2026 03:00:32 -0800 Subject: [PATCH] Allow swipe to go back --- desktop/src-tauri/Cargo.lock | 24 ++++++++++++++++++++++++ desktop/src-tauri/Cargo.toml | 3 +++ desktop/src-tauri/src/lib.rs | 14 ++++++++++++++ 3 files changed, 41 insertions(+) diff --git a/desktop/src-tauri/Cargo.lock b/desktop/src-tauri/Cargo.lock index 465b2da4..768c4144 100644 --- a/desktop/src-tauri/Cargo.lock +++ b/desktop/src-tauri/Cargo.lock @@ -2070,6 +2070,16 @@ dependencies = [ "objc2-core-foundation", ] +[[package]] +name = "objc2-javascript-core" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a1e6550c4caed348956ce3370c9ffeca70bb1dbed4fa96112e7c6170e074586" +dependencies = [ + "objc2", + "objc2-core-foundation", +] + [[package]] name = "objc2-quartz-core" version = "0.3.2" @@ -2082,6 +2092,17 @@ dependencies = [ "objc2-foundation", ] +[[package]] +name = "objc2-security" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "709fe137109bd1e8b5a99390f77a7d8b2961dafc1a1c5db8f2e60329ad6d895a" +dependencies = [ + "bitflags 2.13.1", + "objc2", + "objc2-core-foundation", +] + [[package]] name = "objc2-ui-kit" version = "0.3.2" @@ -2125,6 +2146,8 @@ dependencies = [ "objc2-app-kit", "objc2-core-foundation", "objc2-foundation", + "objc2-javascript-core", + "objc2-security", ] [[package]] @@ -2430,6 +2453,7 @@ name = "quintodrome" version = "0.1.0" dependencies = [ "libc", + "objc2-web-kit", "serde_json", "tauri", "tauri-build", diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml index a1130ad9..a7132131 100644 --- a/desktop/src-tauri/Cargo.toml +++ b/desktop/src-tauri/Cargo.toml @@ -21,6 +21,9 @@ thiserror = "1" [target.'cfg(unix)'.dependencies] libc = "0.2" +[target.'cfg(target_os = "macos")'.dependencies] +objc2-web-kit = { version = "0.3", features = ["WKWebView"] } + [features] # This feature is used for production builds or when `devPath` points to the # filesystem and the built-in dev server is disabled. diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rs index 0795a315..46c7fd0a 100644 --- a/desktop/src-tauri/src/lib.rs +++ b/desktop/src-tauri/src/lib.rs @@ -38,6 +38,17 @@ fn navigate(app: tauri::AppHandle, url: String) { } } +/// Enables two-finger swipe-to-navigate (back/forward) in the content webview. +#[cfg(target_os = "macos")] +fn enable_swipe_navigation(app: &tauri::AppHandle) { + if let Some(content) = app.get_webview("content") { + let _ = content.with_webview(|webview| unsafe { + let view: &objc2_web_kit::WKWebView = &*webview.inner().cast(); + view.setAllowsBackForwardNavigationGestures(true); + }); + } +} + /// Positions the toolbar strip at the top and the content webview below it. fn layout(app: &tauri::AppHandle) { let Some(window) = app.get_window("main") else { @@ -114,6 +125,9 @@ pub fn run() { layout(app.handle()); + #[cfg(target_os = "macos")] + enable_swipe_navigation(app.handle()); + if let Some(toolbar) = app.get_webview("main") { let _ = toolbar.emit("url-changed", &navidrome_url); }