Cause: lightweight mode (#580) let go of the main window once two of its
30 s looks found it "not shown", and it asked Wails' IsVisible, which on
the Mac is the window's occlusion state. A window the user had
Command-Tabbed away from, covered by the other app's window, counted as
closed: 30-60 s later its webview was dropped and the window closed, and
Command-Tab back to magpie found a blank shell or no window at all. Hidden
with magpie (Command-H) it went the same way, since hiding orders every
window out.
Change: windowUp says whether a window is up as the user sees it:
ordered in on any Space, covered or not, minimised, or open as magpie was
hidden (watchHide records those on NSApplicationWillHideNotification).
Only a window magpie closed itself is down. lighten (through lightShown)
and mainShown use it, so the Dock-while-open setting and a restart to
update also keep a covered window as open. Elsewhere windowUp is
IsVisible as before (visible there covers covered and minimised).
Run:
- Reproduced with a sandbox build of origin/main (own HOME and
CFFIXED_USER_HOME, port 3481, dock+lightweight on): with the open
window covered by a full-screen window of a helper process for 70 s the
log said "the main window's webview let go" and the window was a blank
white shell. With this change, the same run let go only the closed
panel and the window kept its page (screenshot of the window).
- Activation itself was checked by handing activation from the helper to
magpie (NSRunningApplication activateFromApplication): with the window
there it came forward. A real Command-Tab keystroke was not sent.
- New TestCoveredWindowStaysUp (AppKit, own process): open, covered by
another window (until IsVisible says false), hidden with the app,
minimised -> up; closed by magpie, also with the app hidden -> down.
With windowUp put back to IsVisible it fails: "open: the window counts
as up=false, want true"; without the hidden clause: "hidden with
magpie: the window counts as up=false, want true". Passes -count=10.
- gofmt -l; go vet ./internal/gui; GOOS=linux go vet -tags nogui and
GOOS=windows go vet (with and without nogui) ./internal/gui; go build,
GOOS=linux go build -tags nogui, GOOS=windows go build;
go test ./internal/gui and go test -tags nogui ./internal/gui under a
temp HOME: ok.