diff --git a/app.go b/app.go index 8a7c347..79d578a 100644 --- a/app.go +++ b/app.go @@ -1653,6 +1653,11 @@ func (a *App) saveWindowState() { x, y := wruntime.WindowGetPosition(a.ctx) ws.X, ws.Y = x, y } + // Logged because this is the only evidence of WHAT was stored: an operator + // reporting "it reopens on the wrong screen" cannot tell a position that was + // never captured from one that was captured wrong, and the two need opposite + // fixes. + applog.Printf("window: saving %d,%d %dx%d maximised=%v compact=%v", ws.X, ws.Y, ws.Width, ws.Height, ws.Maximised, a.compact) writeWindowState(a.dataDir, ws) } @@ -1667,15 +1672,20 @@ func (a *App) restoreWindowPosition() { } ws, ok := readWindowState(a.dataDir) if !ok { + applog.Printf("window: no saved geometry — opening where Windows puts it") return } + applog.Printf("window: restoring %d,%d %dx%d maximised=%v", ws.X, ws.Y, ws.Width, ws.Height, ws.Maximised) // Maximised: Windows reopens it on the PRIMARY screen unless we say otherwise, // so a two-screen operator lost OpsLog to the wrong monitor at every launch. // Un-maximise, move to the saved corner (which names the monitor), maximise // again — all while the window is still hidden, so nothing flickers. if ws.Maximised { if ws.X == 0 && ws.Y == 0 { - return // never recorded (or genuinely the primary corner) — nothing to do + // Either never recorded, or genuinely the primary monitor's corner — + // indistinguishable, and both mean "leave it to Windows". + applog.Printf("window: maximised with corner 0,0 — nothing to restore") + return } if !onSomeMonitor(ws.X, ws.Y, normalMinW, normalMinH) { applog.Printf("window: saved maximised corner %d,%d is off every monitor — opening where Windows puts it", ws.X, ws.Y) @@ -1684,6 +1694,8 @@ func (a *App) restoreWindowPosition() { wruntime.WindowUnmaximise(a.ctx) wruntime.WindowSetPosition(a.ctx, ws.X, ws.Y) wruntime.WindowMaximise(a.ctx) + gx, gy := wruntime.WindowGetPosition(a.ctx) + applog.Printf("window: re-maximised at the saved corner — now at %d,%d", gx, gy) return } if ws.Width < normalMinW || ws.Height < normalMinH || ws.Width > maxW || ws.Height > maxH {