Skip to content

Commit

Permalink
fix: disable webview2 SwipeNavigation
Browse files Browse the repository at this point in the history
  • Loading branch information
keiko233 committed Mar 13, 2024
1 parent 8039a56 commit b1d83aa
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions backend/tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ windows-sys = { version = "0.52", features = [
"Win32_System_LibraryLoader",
"Win32_System_SystemInformation",
] }
webview2-com = "0.19"
windows = "0.39"

[target.'cfg(windows)'.dependencies.tauri]
version = "1.5.4"
Expand Down
17 changes: 17 additions & 0 deletions backend/tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use crate::{
};
use anyhow::Context;
use tauri::{api, Manager, SystemTray};
use webview2_com::Microsoft::Web::WebView2::Win32::ICoreWebView2Settings6;
use windows::core::Interface;

rust_i18n::i18n!("../../locales");

Expand Down Expand Up @@ -130,6 +132,21 @@ fn main() -> std::io::Result<()> {
handle.emit_all("scheme-request-received", request).unwrap();
}
));
let window = app.get_window("main").unwrap();
#[cfg(target_os = "windows")]
window
.with_webview(|webview| unsafe {
let settings = webview
.controller()
.CoreWebView2()
.unwrap()
.Settings()
.unwrap();
let settings: ICoreWebView2Settings6 =
settings.cast::<ICoreWebView2Settings6>().unwrap();
settings.SetIsSwipeNavigationEnabled(false).unwrap();
})
.unwrap();
Ok(())
})
.on_system_tray_event(core::tray::Tray::on_system_tray_event)
Expand Down

0 comments on commit b1d83aa

Please sign in to comment.