diff --git a/v2/cmd/wails/internal/commands/generate/template/base/main.go.tmpl b/v2/cmd/wails/internal/commands/generate/template/base/main.go.tmpl
index 1d2502b5c..268a44348 100644
--- a/v2/cmd/wails/internal/commands/generate/template/base/main.go.tmpl
+++ b/v2/cmd/wails/internal/commands/generate/template/base/main.go.tmpl
@@ -55,6 +55,7 @@ func main() {
DisableWindowIcon: false,
// DisableFramelessWindowDecorations: false,
WebviewUserDataPath: "",
+ ZoomFactor: 1.0,
},
// Mac platform specific options
Mac: &mac.Options{
diff --git a/v2/cmd/wails/internal/commands/initialise/templates/generate/plain/main.go.tmpl b/v2/cmd/wails/internal/commands/initialise/templates/generate/plain/main.go.tmpl
index 329af5718..8f37a961a 100644
--- a/v2/cmd/wails/internal/commands/initialise/templates/generate/plain/main.go.tmpl
+++ b/v2/cmd/wails/internal/commands/initialise/templates/generate/plain/main.go.tmpl
@@ -56,6 +56,8 @@ func main() {
DisableWindowIcon: false,
// DisableFramelessWindowDecorations: false,
WebviewUserDataPath: "",
+ IsZoomControlEnabled: false,
+ ZoomFactor: float64,
},
Mac: &mac.Options{
TitleBar: &mac.TitleBar{
diff --git a/v2/internal/frontend/desktop/windows/frontend.go b/v2/internal/frontend/desktop/windows/frontend.go
index 6e09b369f..7135f5d03 100644
--- a/v2/internal/frontend/desktop/windows/frontend.go
+++ b/v2/internal/frontend/desktop/windows/frontend.go
@@ -434,10 +434,19 @@ func (f *Frontend) setupChromium() {
if err != nil {
log.Fatal(err)
}
- err = settings.PutIsZoomControlEnabled(false)
- if err != nil {
- log.Fatal(err)
+
+
+ if opts := f.frontendOptions.Windows; opts != nil {
+ if opts.ZoomFactor > 0.0 {
+ chromium.PutZoomFactor(opts.ZoomFactor)
+ }
+ err = settings.PutIsZoomControlEnabled(opts.IsZoomControlEnabled)
+ if err != nil {
+ log.Fatal(err)
+ }
+
}
+
err = settings.PutIsStatusBarEnabled(false)
if err != nil {
log.Fatal(err)
diff --git a/v2/internal/frontend/desktop/windows/go-webview2/pkg/edge/ICoreWebView2Controller.go b/v2/internal/frontend/desktop/windows/go-webview2/pkg/edge/ICoreWebView2Controller.go
index 8ecdd57e4..5aef01856 100644
--- a/v2/internal/frontend/desktop/windows/go-webview2/pkg/edge/ICoreWebView2Controller.go
+++ b/v2/internal/frontend/desktop/windows/go-webview2/pkg/edge/ICoreWebView2Controller.go
@@ -1,10 +1,10 @@
package edge
import (
- "unsafe"
-
"github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/go-webview2/internal/w32"
"golang.org/x/sys/windows"
+ "math"
+ "unsafe"
)
type _ICoreWebView2ControllerVtbl struct {
@@ -130,3 +130,28 @@ func (i *ICoreWebView2Controller) NotifyParentWindowPositionChanged() error {
}
return nil
}
+
+func (i *ICoreWebView2Controller) PutZoomFactor(zoomFactor float64) error {
+ var err error
+ _, _, err = i.vtbl.PutZoomFactor.Call(
+ uintptr(unsafe.Pointer(i)),
+ uintptr(math.Float64bits(zoomFactor)),
+ )
+ if err != windows.ERROR_SUCCESS {
+ return err
+ }
+ return nil
+}
+
+func (i *ICoreWebView2Controller) GetZoomFactor() (float64, error) {
+ var err error
+ var zoomFactorUint64 uint64
+ _, _, err = i.vtbl.GetZoomFactor.Call(
+ uintptr(unsafe.Pointer(i)),
+ uintptr(unsafe.Pointer(&zoomFactorUint64)),
+ )
+ if err != windows.ERROR_SUCCESS {
+ return 0.0, err
+ }
+ return math.Float64frombits(zoomFactorUint64), nil
+}
diff --git a/v2/internal/frontend/desktop/windows/go-webview2/pkg/edge/chromium.go b/v2/internal/frontend/desktop/windows/go-webview2/pkg/edge/chromium.go
index 785140917..a2d5c92c7 100644
--- a/v2/internal/frontend/desktop/windows/go-webview2/pkg/edge/chromium.go
+++ b/v2/internal/frontend/desktop/windows/go-webview2/pkg/edge/chromium.go
@@ -372,3 +372,10 @@ func (e *Chromium) Focus() {
log.Fatal(err)
}
}
+
+func (e *Chromium) PutZoomFactor(zoomFactor float64) {
+ err := e.controller.PutZoomFactor(zoomFactor)
+ if err != nil {
+ log.Fatal(err)
+ }
+}
\ No newline at end of file
diff --git a/v2/pkg/options/windows/windows.go b/v2/pkg/options/windows/windows.go
index 95c446fd9..166e58f7a 100644
--- a/v2/pkg/options/windows/windows.go
+++ b/v2/pkg/options/windows/windows.go
@@ -64,6 +64,9 @@ type Options struct {
WindowIsTranslucent bool
DisableWindowIcon bool
+ IsZoomControlEnabled bool
+ ZoomFactor float64
+
// Disable all window decorations in Frameless mode, which means no "Aero Shadow" and no "Rounded Corner" will be shown.
// "Rounded Corners" are only available on Windows 11.
DisableFramelessWindowDecorations bool
diff --git a/website/docs/reference/options.mdx b/website/docs/reference/options.mdx
index 723a58708..daf9a1034 100644
--- a/website/docs/reference/options.mdx
+++ b/website/docs/reference/options.mdx
@@ -42,6 +42,8 @@ func main() {
WindowStartState: options.Maximised,
CSSDragProperty: "--wails-draggable",
CSSDragValue: "drag",
+ ZoomFactor: 1.0,
+ IsZoomControlEnabled: false,
Bind: []interface{}{
app,
},
@@ -361,6 +363,21 @@ Indicates what value the `CSSDragProperty` style should have to drag the window.
Name: CSSDragValue
Type: `string`
+### ZoomFactor
+
+Name: ZoomFactor
+Type: `float64`
+
+This defines the zoom factor for the WebView2. This is the option matching the Edge user activated zoom in or out.
+
+### IsZoomControlEnabled
+
+Name: IsZoomControlEnabled
+Type: `bool`
+
+This enables the zoom factor to be changed by the user. Please note that the zoom factor can be set in the options while
+disallowing the user to change it at runtime (f.e. for a kiosk application or similar).
+
### Bind
A slice of struct instances defining methods that need to be bound to the frontend.