diff --git a/.changes/win-linux-backwards-navigation.md b/.changes/win-linux-backwards-navigation.md new file mode 100644 index 000000000..41b39d1f7 --- /dev/null +++ b/.changes/win-linux-backwards-navigation.md @@ -0,0 +1,5 @@ +--- +"wry": "patch" +--- + +On Windows and Linux, implement `WebviewBuilder::with_back_forward_navigation_gestures` and `WebviewAttributes::back_forward_navigation_gestures` to control swipe navigation. Disabled by default. diff --git a/src/webview/mod.rs b/src/webview/mod.rs index c5f6e1621..a15ecac72 100644 --- a/src/webview/mod.rs +++ b/src/webview/mod.rs @@ -220,10 +220,9 @@ pub struct WebViewAttributes { /// Indicates whether horizontal swipe gestures trigger backward and forward page navigation. /// - /// ## Platform-specific + /// ## Platform-specific: /// - /// This configuration only impacts macOS. - /// [Documentation](https://developer.apple.com/documentation/webkit/wkwebview/1414995-allowsbackforwardnavigationgestu). + /// - **Android / iOS:** Unsupported. pub back_forward_navigation_gestures: bool, /// Set a handler closure to process the change of the webview's document title. @@ -339,10 +338,9 @@ impl<'a> WebViewBuilder<'a> { /// Indicates whether horizontal swipe gestures trigger backward and forward page navigation. /// - /// ## Platform-specific + /// ## Platform-specific: /// - /// This configuration only impacts macOS. - /// [Documentation](https://developer.apple.com/documentation/webkit/wkwebview/1414995-allowsbackforwardnavigationgestu). + /// - **Android / iOS:** Unsupported. pub fn with_back_forward_navigation_gestures(mut self, gesture: bool) -> Self { self.webview.back_forward_navigation_gestures = gesture; self diff --git a/src/webview/webkitgtk/mod.rs b/src/webview/webkitgtk/mod.rs index c2903291f..1f3c87f8f 100644 --- a/src/webview/webkitgtk/mod.rs +++ b/src/webview/webkitgtk/mod.rs @@ -270,6 +270,8 @@ impl InnerWebView { if let Some(settings) = WebViewExt::settings(&*webview) { settings.set_enable_webgl(true); settings.set_enable_webaudio(true); + settings + .set_enable_back_forward_navigation_gestures(attributes.back_forward_navigation_gestures); // Enable clipboard if attributes.clipboard { diff --git a/src/webview/webview2/mod.rs b/src/webview/webview2/mod.rs index 147de2d18..2d708a65e 100644 --- a/src/webview/webview2/mod.rs +++ b/src/webview/webview2/mod.rs @@ -249,13 +249,8 @@ impl InnerWebView { .SetIsZoomControlEnabled(attributes.zoom_hotkeys_enabled) .map_err(webview2_com::Error::WindowsError)?; settings - .SetAreDevToolsEnabled(false) + .SetAreDevToolsEnabled(attributes.devtools) .map_err(webview2_com::Error::WindowsError)?; - if attributes.devtools { - settings - .SetAreDevToolsEnabled(true) - .map_err(webview2_com::Error::WindowsError)?; - } if !pl_attrs.browser_accelerator_keys { if let Ok(settings3) = settings.cast::() { settings3 @@ -265,7 +260,14 @@ impl InnerWebView { } let settings5 = settings.cast::()?; - let _ = settings5.SetIsPinchZoomEnabled(attributes.zoom_hotkeys_enabled); + settings5 + .SetIsPinchZoomEnabled(attributes.zoom_hotkeys_enabled) + .map_err(webview2_com::Error::WindowsError)?; + + let settings6 = settings.cast::()?; + settings6 + .SetIsSwipeNavigationEnabled(attributes.back_forward_navigation_gestures) + .map_err(webview2_com::Error::WindowsError)?; let mut rect = RECT::default(); win32wm::GetClientRect(hwnd, &mut rect);