diff --git a/v3/examples/oauth/README.md b/v3/examples/oauth/README.md
deleted file mode 100644
index ad19fb612..000000000
--- a/v3/examples/oauth/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# OAuth Example
-
-This example is not ready for testing yet.
diff --git a/v3/examples/oauth/assets/index.html b/v3/examples/oauth/assets/index.html
deleted file mode 100644
index 3963a01b2..000000000
--- a/v3/examples/oauth/assets/index.html
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
- Google SignIn
-
-
-
-
-
-
-
Social Authentication
-
Login or Register with:
-
SignIn with Github
-
-
-
-
-
-
diff --git a/v3/examples/oauth/main.go b/v3/examples/oauth/main.go
deleted file mode 100644
index 14818c47f..000000000
--- a/v3/examples/oauth/main.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package main
-
-import (
- "embed"
- _ "embed"
- "log"
- "os"
-
- "github.com/markbates/goth"
- "github.com/markbates/goth/providers/github"
- "github.com/wailsapp/wails/v3/pkg/application"
- "github.com/wailsapp/wails/v3/plugins/oauth"
-)
-
-//go:embed assets
-var assets embed.FS
-
-func main() {
-
- oAuthPlugin := oauth.NewPlugin(oauth.Config{
- Providers: []goth.Provider{
- github.New(
- os.Getenv("clientkey"),
- os.Getenv("secret"),
- "http://localhost:9876/auth/github/callback",
- "email",
- "profile"),
- },
- })
-
- app := application.New(application.Options{
- Name: "OAuth Demo",
- Description: "A demo of the oauth Plugin",
- Mac: application.MacOptions{
- ApplicationShouldTerminateAfterLastWindowClosed: true,
- },
- Assets: application.AssetOptions{
- Handler: application.AssetFileServerFS(assets),
- },
- Plugins: map[string]application.Plugin{
- "github.com/wailsapp/wails/v3/plugins/oauth": oAuthPlugin,
- },
- })
-
- app.NewWebviewWindowWithOptions(application.WebviewWindowOptions{
- Title: "OAuth Demo",
- DevToolsEnabled: true,
- OpenInspectorOnStartup: true,
- Mac: application.MacWindow{
- Backdrop: application.MacBackdropTranslucent,
- TitleBar: application.MacTitleBarHiddenInsetUnified,
- InvisibleTitleBarHeight: 50,
- },
- })
-
- app.Events.On("github-login", func(e *application.WailsEvent) {
- oAuthPlugin.Github()
- })
- app.Events.On("github-logout", func(e *application.WailsEvent) {
- oAuthPlugin.LogoutGithub()
- })
-
- err := app.Run()
-
- if err != nil {
- log.Fatal(err.Error())
- }
-}
diff --git a/v3/pkg/application/webview_window.go b/v3/pkg/application/webview_window.go
index 5503c29b7..0e4f4e436 100644
--- a/v3/pkg/application/webview_window.go
+++ b/v3/pkg/application/webview_window.go
@@ -20,6 +20,14 @@ var Enabled = u.True
// Disabled means the feature should be disabled
var Disabled = u.False
+// LRTB is a struct that holds Left, Right, Top, Bottom values
+type LRTB struct {
+ Left int
+ Right int
+ Top int
+ Bottom int
+}
+
type (
webviewWindowImpl interface {
setTitle(title string)
@@ -81,6 +89,7 @@ type (
setAbsolutePosition(x int, y int)
flash(enabled bool)
handleKeyEvent(acceleratorString string)
+ getBorderSizes() *LRTB
}
)
@@ -400,6 +409,13 @@ func (w *WebviewWindow) SetURL(s string) Window {
return w
}
+func (w *WebviewWindow) GetBorderSizes() *LRTB {
+ if w.impl != nil {
+ return InvokeSyncWithResult(w.impl.getBorderSizes)
+ }
+ return &LRTB{}
+}
+
// SetZoom sets the zoom level of the window.
func (w *WebviewWindow) SetZoom(magnification float64) Window {
w.options.Zoom = magnification
diff --git a/v3/pkg/application/webview_window_darwin.go b/v3/pkg/application/webview_window_darwin.go
index f6ba30382..32ba67655 100644
--- a/v3/pkg/application/webview_window_darwin.go
+++ b/v3/pkg/application/webview_window_darwin.go
@@ -776,6 +776,10 @@ func (w *macosWebviewWindow) handleKeyEvent(acceleratorString string) {
w.parent.processKeyBinding(accelerator.String())
}
+func (w *macosWebviewWindow) getBorderSizes() *LRTB {
+ return &LRTB{}
+}
+
func (w *macosWebviewWindow) isFocused() bool {
return bool(C.windowIsFocused(w.nsWindow))
}
diff --git a/v3/pkg/application/webview_window_linux.go b/v3/pkg/application/webview_window_linux.go
index 5de7a354f..49586cabe 100644
--- a/v3/pkg/application/webview_window_linux.go
+++ b/v3/pkg/application/webview_window_linux.go
@@ -167,6 +167,10 @@ func (w *linuxWebviewWindow) setMinSize(width, height int) {
w.setMinMaxSize(width, height, w.parent.options.MaxWidth, w.parent.options.MaxHeight)
}
+func (w *linuxWebviewWindow) getBorderSizes() *LRTB {
+ return &LRTB{}
+}
+
func (w *linuxWebviewWindow) setMaxSize(width, height int) {
w.setMinMaxSize(w.parent.options.MinWidth, w.parent.options.MinHeight, width, height)
}
diff --git a/v3/pkg/application/webview_window_windows.go b/v3/pkg/application/webview_window_windows.go
index f9ebc329a..88494efd9 100644
--- a/v3/pkg/application/webview_window_windows.go
+++ b/v3/pkg/application/webview_window_windows.go
@@ -69,9 +69,23 @@ func (w *windowsWebviewWindow) handleKeyEvent(_ string) {
// Unused on windows
}
+// getBorderSizes returns the extended border size for the window
+func (w *windowsWebviewWindow) getBorderSizes() *LRTB {
+ var result LRTB
+ var frame w32.RECT
+ w32.DwmGetWindowAttribute(w.hwnd, w32.DWMWA_EXTENDED_FRAME_BOUNDS, unsafe.Pointer(&frame), unsafe.Sizeof(frame))
+ rect := w32.GetWindowRect(w.hwnd)
+ result.Left = int(frame.Left - rect.Left)
+ result.Top = int(frame.Top - rect.Top)
+ result.Right = int(rect.Right - frame.Right)
+ result.Bottom = int(rect.Bottom - frame.Bottom)
+ return &result
+}
+
func (w *windowsWebviewWindow) setAbsolutePosition(x int, y int) {
// Set the window's absolute position
- w32.SetWindowPos(w.hwnd, 0, x, y, 0, 0, w32.SWP_NOSIZE|w32.SWP_NOZORDER)
+ borderSize := w.getBorderSizes()
+ w32.SetWindowPos(w.hwnd, 0, x-borderSize.Left, y-borderSize.Top, 0, 0, w32.SWP_NOSIZE|w32.SWP_NOZORDER)
}
func (w *windowsWebviewWindow) absolutePosition() (int, int) {
@@ -482,6 +496,9 @@ func (w *windowsWebviewWindow) setRelativePosition(x int, y int) {
//x, y = w.scaleWithWindowDPI(x, y)
info := w32.GetMonitorInfoForWindow(w.hwnd)
workRect := info.RcWork
+ borderSize := w.getBorderSizes()
+ x -= borderSize.Left
+ y -= borderSize.Top
w32.SetWindowPos(w.hwnd, w32.HWND_TOP, int(workRect.Left)+x, int(workRect.Top)+y, 0, 0, w32.SWP_NOSIZE)
}
diff --git a/v3/pkg/w32/dwmapi.go b/v3/pkg/w32/dwmapi.go
index b25310db2..1b911efc3 100644
--- a/v3/pkg/w32/dwmapi.go
+++ b/v3/pkg/w32/dwmapi.go
@@ -11,6 +11,7 @@ var (
moddwmapi = syscall.NewLazyDLL("dwmapi.dll")
procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute")
+ procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute")
procDwmExtendFrameIntoClientArea = moddwmapi.NewProc("DwmExtendFrameIntoClientArea")
)
@@ -23,6 +24,15 @@ func DwmSetWindowAttribute(hwnd HWND, dwAttribute DWMWINDOWATTRIBUTE, pvAttribut
return HRESULT(ret)
}
+func DwmGetWindowAttribute(hwnd HWND, dwAttribute DWMWINDOWATTRIBUTE, pvAttribute unsafe.Pointer, cbAttribute uintptr) HRESULT {
+ ret, _, _ := procDwmGetWindowAttribute.Call(
+ hwnd,
+ uintptr(dwAttribute),
+ uintptr(pvAttribute),
+ cbAttribute)
+ return HRESULT(ret)
+}
+
func dwmExtendFrameIntoClientArea(hwnd uintptr, margins *MARGINS) error {
ret, _, _ := procDwmExtendFrameIntoClientArea.Call(
hwnd,