Removed WindowCloseBehaviour in favor of HideWindowOnClose (will use tray if available or dock if not)

This commit is contained in:
Barış Hamil 2026-03-14 16:35:20 +03:00
commit b57b57d2c0
4 changed files with 17 additions and 25 deletions

View file

@ -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,

View file

@ -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(

View file

@ -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()

View file

@ -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)