fix: bug keeping location and size of the window

This commit is contained in:
2026-07-15 22:22:14 +02:00
parent 5b96f53930
commit 75548812d0
2 changed files with 45 additions and 20 deletions
+27 -6
View File
@@ -49,19 +49,40 @@ func main() {
app := NewApp()
app.startupProfile = profileArg(os.Args[1:])
// Restore the window's SIZE and maximised state at CREATION, from the geometry
// saved on last close. Doing it here (not after startup) is what makes the
// window open already at the right size instead of maximising then snapping
// smaller. Position can't be set through options, so it is applied while the
// window is still hidden (domReady) — invisible, so no jump. First run, or a
// window closed maximised, keeps the historical maximised default.
width, height := 1400, 900
startState := options.Maximised
if dataDir, err := userDataDir(); err == nil {
if ws, ok := readWindowState(dataDir); ok && !ws.Maximised &&
ws.Width >= 1100 && ws.Height >= 700 && ws.Width <= 8000 && ws.Height <= 6000 {
width, height = ws.Width, ws.Height
startState = options.Normal
}
}
// Create application with options
err := wails.Run(&options.App{
Title: "OpsLog",
Width: 1400,
Height: 900,
MinWidth: 1100,
MinHeight: 700,
WindowStartState: options.Maximised,
Title: "OpsLog",
Width: width,
Height: height,
MinWidth: 1100,
MinHeight: 700,
WindowStartState: startState,
// Start hidden and reveal only once the saved position has been applied and
// the DOM has painted (OnDomReady → domReady) — so the window appears
// already at its final size and position, with no post-launch jump.
StartHidden: true,
AssetServer: &assetserver.Options{
Assets: assets,
},
BackgroundColour: &options.RGBA{R: 250, G: 250, B: 249, A: 1},
OnStartup: app.startup,
OnDomReady: app.domReady,
OnBeforeClose: app.beforeClose,
OnShutdown: app.shutdown,
Bind: []interface{}{