From 71bde30e245fdb55b38e279ab9ec3f98cd83e4ed Mon Sep 17 00:00:00 2001 From: rouggy Date: Tue, 28 Jul 2026 15:35:57 +0200 Subject: [PATCH] chore: log the window geometry that is saved and restored MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reported as a regression — reopens on the wrong screen — but the window code is untouched since it was verified working: the only change to main.go since is the background colour. So the fault is in the DATA, and there was no way to see it. Both ends now log their coordinates, plus where the window actually landed after the un-maximise / move / re-maximise dance. That separates the cases, which need opposite fixes: nothing was captured, something wrong was captured, or the right corner was captured and Windows moved the window anyway. --- app.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 {