diff --git a/v2/go.mod b/v2/go.mod index 837f86b1214..f218f72a6ab 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -33,7 +33,7 @@ require ( github.com/tc-hib/winres v0.1.5 github.com/tidwall/sjson v1.1.7 github.com/tkrajina/go-reflector v0.5.6 - github.com/wailsapp/go-webview2 v1.0.1 + github.com/wailsapp/go-webview2 v1.0.6 github.com/wailsapp/mimetype v1.4.1 github.com/wzshiming/ctc v1.2.3 golang.org/x/mod v0.12.0 diff --git a/v2/go.sum b/v2/go.sum index d9180212401..c5a9c3cd101 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -214,8 +214,8 @@ github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyC github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= -github.com/wailsapp/go-webview2 v1.0.1 h1:dEJIeEApW/MhO2tTMISZBFZPuW7kwrFA1NtgFB1z1II= -github.com/wailsapp/go-webview2 v1.0.1/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo= +github.com/wailsapp/go-webview2 v1.0.6 h1:7qW+wVcepvlLh8yIFI52tLMAl1Le9jdeQBu+Pej+MKY= +github.com/wailsapp/go-webview2 v1.0.6/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo= github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs= github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o= github.com/wzshiming/ctc v1.2.3 h1:q+hW3IQNsjIlOFBTGZZZeIXTElFM4grF4spW/errh/c= diff --git a/v2/internal/frontend/desktop/windows/frontend.go b/v2/internal/frontend/desktop/windows/frontend.go index edfc21fe170..55e613af601 100644 --- a/v2/internal/frontend/desktop/windows/frontend.go +++ b/v2/internal/frontend/desktop/windows/frontend.go @@ -506,6 +506,14 @@ func (f *Frontend) setupChromium() { } chromium.Embed(f.mainWindow.Handle()) + + if chromium.HasCapability(edge.SwipeNavigation) { + swipeGesturesEnabled := f.frontendOptions.Windows != nil && f.frontendOptions.Windows.EnableSwipeGestures + err := chromium.PutIsSwipeNavigationEnabled(swipeGesturesEnabled) + if err != nil { + log.Fatal(err) + } + } chromium.Resize() settings, err := chromium.GetSettings() if err != nil { @@ -538,10 +546,6 @@ func (f *Frontend) setupChromium() { if err != nil { log.Fatal(err) } - err = settings.PutIsSwipeNavigationEnabled(false) - if err != nil { - log.Fatal(err) - } if f.debug && f.frontendOptions.Debug.OpenInspectorOnStartup { chromium.OpenDevToolsWindow() diff --git a/v2/pkg/options/windows/windows.go b/v2/pkg/options/windows/windows.go index ea6fdc35e1d..7adf0bf7237 100644 --- a/v2/pkg/options/windows/windows.go +++ b/v2/pkg/options/windows/windows.go @@ -113,6 +113,9 @@ type Options struct { // // !! Please keep in mind when disabling this feature, this also allows malicious software to inject into the WebView2 !! WebviewDisableRendererCodeIntegrity bool + + // Configure whether swipe gestures should be enabled + EnableSwipeGestures bool } func DefaultMessages() *Messages { diff --git a/website/docs/reference/options.mdx b/website/docs/reference/options.mdx index af772c8bd2d..1f96f154c23 100644 --- a/website/docs/reference/options.mdx +++ b/website/docs/reference/options.mdx @@ -687,6 +687,13 @@ Setting this to `true` will disable GPU hardware acceleration for the webview. Name: WebviewGpuIsDisabled
Type: `bool` +#### EnableSwipeGestures + +Setting this to `true` will enable swipe gestures for the webview. + +Name: EnableSwipeGestures
+Type: `bool` + ### Mac This defines [Mac specific options](#mac). diff --git a/website/src/pages/changelog.mdx b/website/src/pages/changelog.mdx index 064eea8a48f..77ceb3f8ce6 100644 --- a/website/src/pages/changelog.mdx +++ b/website/src/pages/changelog.mdx @@ -14,15 +14,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] - ### Added - +- Added support for enabling/disabling swipe gestures for Windows WebView2. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/2878) - When building with `-devtools` flag, CMD/CTRL+SHIFT+F12 can be used to open the devtools. Added by @leaanthony in [PR](https://github.com/wailsapp/wails/pull/2915) #### Fixed - Fixed typo on docs/reference/options page. Added by [@pylotlight](https://github.com/pylotlight) in [PR](https://github.com/wailsapp/wails/pull/2887) + ## v2.6.0 - 2023-09-06 ### Breaking Changes