ttmouse on v0.1.1168: open magpie's window, Command-Tab to another app,
Command-Tab back, and magpie is last in the switcher.
Cause: magpie is out of the Dock (Accessory) until the window opens.
With Settings > Dock set to "while the window is open" (or a full-screen
window), the quick panel's focus activates magpie while it is still
Accessory, and it joins the Dock (Regular) after that. An app activated
before it joins stays last in LaunchServices' front-to-back order
(lsappinfo visibleProcessList), which Command-Tab follows, though it is
frontmost. Wails' Focus only calls activateIgnoringOtherApps when the
app isn't active, and calling it again while active is a no-op. setDock
also ran async (dispatch_async), so openMain's Show/Focus could come
before the policy change.
Fix:
- setDock runs on the main thread at once (InvokeSync), so openMain
joins before it shows the window.
- A pure dockStep(regular, on, active, front) decides the move. Joining
while already active activates the Dock and then magpie again
(activateAgain), which puts magpie first in the order. Joining while
not active just activates it; leaving never re-activates.
- The full-screen join does the same once the window is in full screen
(DidEnterFullScreen) if magpie was active when it joined.
- Dock "off" (the default) is unchanged: magpie stays out of the Dock
and out of Command-Tab, by design. The tray panel's behaviour is
unchanged.
- docs/subsystems/gui-shell.md: Runtime path item 7 for the Dock setting.
Run:
- TestDockStep (table, pure). TestDockJoinLeadsCommandTab (darwin GUI
build): a real Accessory Wails app activated, then setDock(true,
true) + window Show/Focus, asserts it is first in lsappinfo's order.
Red with `again` forced false (front was the test, kitty first in the
order), green with the fix.
- go test ./internal/gui (GUI build, darwin) passes; full
go test -tags nogui ./... passes; gofmt -l clean; go vet ./internal/gui
(darwin) and GOOS=linux / GOOS=windows go vet -tags nogui clean.
- Real build on this Mac, sandbox HOME, own bundle id, port 3481,
DockWindow on: launched with the quick panel, window opened through the
Mac's reopen, then two osascript Command-Tabs. Old build: magpie front
but 11th of 11 in the order (the report). New build: magpie 1st; after
Command-Tab, the other app 1st and magpie 2nd; Command-Tab again brings
magpie back. Dock "always": magpie 1st, round trip works. Dock "off":
stays UIElement, not in the order.
Not tried: the full-screen path in the real build, a human Command-Tab
(only osascript keystrokes), real accounts (not involved).