mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
[v3 windows] Add close handling: HideOnClose, QuitOnLastWindowClosed and DisableQuitOnLastWindowClosed
This commit is contained in:
+2
-2
@@ -164,7 +164,7 @@ An 'X' indicates that the option is not supported by the platform.
|
||||
| AlwaysOnTop | Y | | | |
|
||||
| URL | | | | |
|
||||
| DisableResize | Y | | | |
|
||||
| Frameless | | | | |
|
||||
| Frameless | Y | | | |
|
||||
| MinWidth | Y | | | |
|
||||
| MinHeight | Y | | | |
|
||||
| MaxWidth | Y | | | |
|
||||
@@ -178,7 +178,7 @@ An 'X' indicates that the option is not supported by the platform.
|
||||
| CSS | | | | |
|
||||
| X | | | | |
|
||||
| Y | | | | |
|
||||
| HideOnClose | | | | |
|
||||
| HideOnClose | Y | | | |
|
||||
| FullscreenButtonEnabled | | | | |
|
||||
| Hidden | Y | | | |
|
||||
| EnableFraudulentWebsiteWarnings | | | | |
|
||||
|
||||
@@ -220,7 +220,7 @@ func (m *windowsApp) unregisterWindow(w *windowsWebviewWindow) {
|
||||
delete(m.windowMap, w.hwnd)
|
||||
|
||||
// If this was the last window...
|
||||
if len(m.windowMap) == 0 {
|
||||
if len(m.windowMap) == 0 && !m.parent.options.Windows.DisableQuitOnLastWindowClosed {
|
||||
w32.PostQuitMessage(0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ type WindowsApplicationOptions struct {
|
||||
// If `shouldReturn` is `true` then `returnCode` will be returned by the main message loop.
|
||||
// If `shouldReturn` is `false` then returnCode will be ignored and the message will be processed by the main message loop.
|
||||
WndProcInterceptor func(hwnd uintptr, msg uint32, wParam, lParam uintptr) (returnCode uintptr, shouldReturn bool)
|
||||
|
||||
// DisableQuitOnLastWindowClosed disables the auto quit of the application if the last window has been closed.
|
||||
DisableQuitOnLastWindowClosed bool
|
||||
}
|
||||
|
||||
type BackdropType int32
|
||||
|
||||
@@ -5,11 +5,12 @@ package application
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/samber/lo"
|
||||
"strconv"
|
||||
"unicode/utf16"
|
||||
"unsafe"
|
||||
|
||||
"github.com/samber/lo"
|
||||
|
||||
"github.com/wailsapp/wails/v3/pkg/events"
|
||||
"github.com/wailsapp/wails/v3/pkg/w32"
|
||||
)
|
||||
@@ -609,11 +610,14 @@ func (w *windowsWebviewWindow) WndProc(msg uint32, wparam, lparam uintptr) uintp
|
||||
case w32.WM_SIZE:
|
||||
return 0
|
||||
case w32.WM_CLOSE:
|
||||
w32.PostMessage(w.hwnd, w32.WM_QUIT, 0, 0)
|
||||
if w.parent.options.HideOnClose {
|
||||
w.hide()
|
||||
return 0 // Do not let the DefWindowProc allow to close us
|
||||
}
|
||||
|
||||
// Unregister the window with the application
|
||||
windowsApp := globalApplication.impl.(*windowsApp)
|
||||
windowsApp.unregisterWindow(w)
|
||||
return 0
|
||||
case w32.WM_GETMINMAXINFO:
|
||||
mmi := (*w32.MINMAXINFO)(unsafe.Pointer(lparam))
|
||||
hasConstraints := false
|
||||
|
||||
Reference in New Issue
Block a user