fix(window): check the saved position against the monitors, not their bounding box
Reported from a multi-monitor station: window.json held x=-7680 and the window opened where nobody could see it, with no way back short of editing the file — which nobody knows to do. The guard existed but asked the wrong question. It tested the position against the VIRTUAL SCREEN, the rectangle spanning every monitor, and monitors rarely tile that rectangle: a wide screen beside a tall one, or one mounted higher, leaves gaps inside the box that belong to no monitor. A window in a gap passes a bounding-box test and is invisible. The test now walks the monitors themselves, through EnumDisplayMonitors, and uses each one's WORK area — a title bar under the taskbar cannot be dragged either. A position that is genuinely lost is now MOVED onto the nearest monitor, keeping the window's size. Handing it back to Windows lost the size too and dropped the window on the primary screen wherever Windows chose. The arithmetic is in screenclamp.go with no Win32 in it, and tested against the reporter's four-monitor layout and against a gap between two: this fault is invisible by definition and cannot be reproduced without the reporter's screens, so a table test is the only place it can be held. The layout is also logged at every start, since the first question after 'OpsLog does not open' is what the screens looked like.
This commit is contained in:
@@ -2,6 +2,13 @@
|
||||
|
||||
package main
|
||||
|
||||
// virtualScreenBounds is Windows-only; elsewhere we cannot tell, and the caller
|
||||
// treats "cannot tell" as "trust the saved position".
|
||||
// The screen geometry helpers are Windows-only; elsewhere we cannot tell where
|
||||
// the monitors are, and the callers treat "cannot tell" as "trust the operator's
|
||||
// saved position" rather than second-guessing it.
|
||||
func virtualScreenBounds() (x, y, w, h int, ok bool) { return 0, 0, 0, 0, false }
|
||||
|
||||
func onSomeMonitorImpl(x, y, w, h int) bool { return true }
|
||||
|
||||
func clampToVisible(x, y, w, h int) (int, int, bool) { return x, y, false }
|
||||
|
||||
func logMonitorLayout() {}
|
||||
|
||||
Reference in New Issue
Block a user