chore: log the window geometry that is saved and restored
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.
This commit is contained in:
@@ -1653,6 +1653,11 @@ func (a *App) saveWindowState() {
|
|||||||
x, y := wruntime.WindowGetPosition(a.ctx)
|
x, y := wruntime.WindowGetPosition(a.ctx)
|
||||||
ws.X, ws.Y = x, y
|
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)
|
writeWindowState(a.dataDir, ws)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1667,15 +1672,20 @@ func (a *App) restoreWindowPosition() {
|
|||||||
}
|
}
|
||||||
ws, ok := readWindowState(a.dataDir)
|
ws, ok := readWindowState(a.dataDir)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
applog.Printf("window: no saved geometry — opening where Windows puts it")
|
||||||
return
|
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,
|
// 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.
|
// 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
|
// Un-maximise, move to the saved corner (which names the monitor), maximise
|
||||||
// again — all while the window is still hidden, so nothing flickers.
|
// again — all while the window is still hidden, so nothing flickers.
|
||||||
if ws.Maximised {
|
if ws.Maximised {
|
||||||
if ws.X == 0 && ws.Y == 0 {
|
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) {
|
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)
|
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.WindowUnmaximise(a.ctx)
|
||||||
wruntime.WindowSetPosition(a.ctx, ws.X, ws.Y)
|
wruntime.WindowSetPosition(a.ctx, ws.X, ws.Y)
|
||||||
wruntime.WindowMaximise(a.ctx)
|
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
|
return
|
||||||
}
|
}
|
||||||
if ws.Width < normalMinW || ws.Height < normalMinH || ws.Width > maxW || ws.Height > maxH {
|
if ws.Width < normalMinW || ws.Height < normalMinH || ws.Width > maxW || ws.Height > maxH {
|
||||||
|
|||||||
Reference in New Issue
Block a user