[v3 windows] Support irregular shaped windows. Centered option.

This commit is contained in:
Lea Anthony 2023-05-06 20:22:28 +10:00
commit 42b1807c36
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405
4 changed files with 13 additions and 3 deletions

View file

@ -23,7 +23,7 @@ type WebviewWindowOptions struct {
MaxWidth int
MaxHeight int
StartState WindowState
Mac MacWindow
Centered bool
BackgroundType BackgroundType
BackgroundColour RGBA
HTML string
@ -37,6 +37,7 @@ type WebviewWindowOptions struct {
EnableFraudulentWebsiteWarnings bool
Zoom float64
EnableDragAndDrop bool
Mac MacWindow
Windows WindowsWindow
}

View file

@ -33,7 +33,8 @@ type WindowsWindow struct {
DisableFramelessWindowDecorations bool
// WindowMask is used to set the window shape. Use a PNG with an alpha channel to create a custom shape.
WindowMask []byte
WindowMask []byte
WindowMaskDraggable bool
}
type Theme int

View file

@ -446,6 +446,7 @@ func (w *WebviewWindow) handleMessage(message string) {
// Center centers the window on the screen
func (w *WebviewWindow) Center() {
if w.impl == nil {
w.options.Centered = true
return
}
invokeSync(w.impl.center)

View file

@ -185,6 +185,10 @@ func (w *windowsWebviewWindow) run() {
w.setWindowMask(options.Windows.WindowMask)
}
if options.Centered {
w.center()
}
w.setForeground()
if !options.Hidden {
@ -649,7 +653,10 @@ func (w *windowsWebviewWindow) WndProc(msg uint32, wparam, lparam uintptr) uintp
if w.parent.options.Windows.WindowMask != nil {
switch msg {
case w32.WM_NCHITTEST:
return w32.HTCAPTION
if w.parent.options.Windows.WindowMaskDraggable {
return w32.HTCAPTION
}
return w32.HTCLIENT
}
}