Skip to content

Commit

Permalink
[v2] Support Enabling/Disabling swipe gestures (#2878)
Browse files Browse the repository at this point in the history
* [v2] Support Enabling/Disabling swipe gestures

* [v2] Update change log

* [v2] Remove old call to PutIsSwipeNavigationEnabled

* Use latest webview2

* Update go-webview2 mod version
  • Loading branch information
leaanthony authored Sep 19, 2023
1 parent eca6afc commit 3369327
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
12 changes: 8 additions & 4 deletions v2/internal/frontend/desktop/windows/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down
3 changes: 3 additions & 0 deletions v2/pkg/options/windows/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions website/docs/reference/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,13 @@ Setting this to `true` will disable GPU hardware acceleration for the webview.
Name: WebviewGpuIsDisabled<br/>
Type: `bool`

#### EnableSwipeGestures

Setting this to `true` will enable swipe gestures for the webview.

Name: EnableSwipeGestures<br/>
Type: `bool`

### Mac

This defines [Mac specific options](#mac).
Expand Down
4 changes: 2 additions & 2 deletions website/src/pages/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3369327

Please sign in to comment.