From b57b57d2c07fde84efe9cd5f6277b33bf0669208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Hamil?= Date: Sat, 14 Mar 2026 16:35:20 +0300 Subject: [PATCH] Removed WindowCloseBehaviour in favor of HideWindowOnClose (will use tray if available or dock if not) --- v2/internal/frontend/desktop/darwin/window.go | 9 +++++--- v2/internal/frontend/desktop/linux/window.go | 9 +++++--- .../frontend/desktop/windows/frontend.go | 3 +-- v2/pkg/options/options.go | 21 ++++--------------- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/v2/internal/frontend/desktop/darwin/window.go b/v2/internal/frontend/desktop/darwin/window.go index c53254926..314c45e0c 100644 --- a/v2/internal/frontend/desktop/darwin/window.go +++ b/v2/internal/frontend/desktop/darwin/window.go @@ -121,9 +121,12 @@ func NewWindow(frontendOptions *options.App, debug bool, devtools bool) *Window appearance = c.String(string(mac.Appearance)) } - hideWindowOnClose := int(frontendOptions.WindowCloseBehaviour) - if hideWindowOnClose == int(options.CloseWindow) && frontendOptions.HideWindowOnClose { - hideWindowOnClose = int(options.HideWindow) + hideWindowOnClose := 0 + if frontendOptions.HideWindowOnClose { + hideWindowOnClose = 1 + if frontendOptions.Tray != nil { + hideWindowOnClose = 2 + } } var context *C.WailsContext = C.Create(title, width, height, frameless, resizable, zoomable, fullscreen, fullSizeContent, diff --git a/v2/internal/frontend/desktop/linux/window.go b/v2/internal/frontend/desktop/linux/window.go index 36a60f9bd..51fd9c923 100644 --- a/v2/internal/frontend/desktop/linux/window.go +++ b/v2/internal/frontend/desktop/linux/window.go @@ -100,9 +100,12 @@ func NewWindow(appoptions *options.App, debug bool, devtoolsEnabled bool) *Windo webviewGpuPolicy = int(linux.WebviewGpuPolicyNever) } - hideWindowOnClose := int(appoptions.WindowCloseBehaviour) - if hideWindowOnClose == int(options.CloseWindow) && appoptions.HideWindowOnClose { - hideWindowOnClose = int(options.HideWindow) + hideWindowOnClose := 0 + if appoptions.HideWindowOnClose { + hideWindowOnClose = 1 + if appoptions.Tray != nil { + hideWindowOnClose = 2 + } } webview := C.SetupWebview( diff --git a/v2/internal/frontend/desktop/windows/frontend.go b/v2/internal/frontend/desktop/windows/frontend.go index c66b06e66..5df13ed98 100644 --- a/v2/internal/frontend/desktop/windows/frontend.go +++ b/v2/internal/frontend/desktop/windows/frontend.go @@ -212,8 +212,7 @@ func (f *Frontend) Run(ctx context.Context) error { }) mainWindow.OnClose().Bind(func(arg *winc.Event) { - behaviour := f.frontendOptions.WindowCloseBehaviour - if behaviour == options.HideWindow || behaviour == options.HideWindowAndDock || (behaviour == options.CloseWindow && f.frontendOptions.HideWindowOnClose) { + if f.frontendOptions.HideWindowOnClose { f.WindowHide() } else { f.Quit() diff --git a/v2/pkg/options/options.go b/v2/pkg/options/options.go index c66a797ea..e70caf0b6 100644 --- a/v2/pkg/options/options.go +++ b/v2/pkg/options/options.go @@ -28,14 +28,6 @@ const ( Fullscreen WindowStartState = 3 ) -type WindowCloseBehaviour int - -const ( - CloseWindow WindowCloseBehaviour = 0 - HideWindow WindowCloseBehaviour = 1 - HideWindowAndDock WindowCloseBehaviour = 2 -) - type Experimental struct{} // App contains options for creating the App @@ -51,11 +43,10 @@ type App struct { MaxWidth int MaxHeight int StartHidden bool - // HideWindowOnClose is deprecated. Use WindowCloseBehaviour instead. - // If set to true, WindowCloseBehaviour will be set to HideWindow if it is currently CloseWindow. - HideWindowOnClose bool - WindowCloseBehaviour WindowCloseBehaviour - AlwaysOnTop bool + // HideWindowOnClose controls close button behavior. + // If true and a tray icon is configured, close behaves like HideWindowAndDock. + HideWindowOnClose bool + AlwaysOnTop bool // BackgroundColour is the background colour of the window // You can use the options.NewRGB and options.NewRGBA functions to create a new colour BackgroundColour *RGBA @@ -189,10 +180,6 @@ func MergeDefaults(appoptions *App) { } } - if appoptions.HideWindowOnClose && appoptions.WindowCloseBehaviour == CloseWindow { - appoptions.WindowCloseBehaviour = HideWindow - } - // Ensure max and min are valid processMinMaxConstraints(appoptions)