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).
32 lines
1.3 KiB
Go
32 lines
1.3 KiB
Go
package gui
|
|
|
|
import "testing"
|
|
|
|
// Joining the Dock while active is activated again by way of the Dock, so
|
|
// magpie leads Command-Tab's order (#1381); anything else is as before.
|
|
func TestDockStep(t *testing.T) {
|
|
cases := []struct {
|
|
regular, on, active, front bool
|
|
want dockMove
|
|
}{
|
|
// already where it should be: nothing, active or not
|
|
{true, true, true, true, dockMove{}},
|
|
{false, false, true, true, dockMove{}},
|
|
// the panel (active) opens the window: joins, activated again
|
|
{false, true, true, true, dockMove{policy: true, again: true, front: true}},
|
|
// the tray's Open or a second magpie (not active): joins, activated
|
|
{false, true, false, true, dockMove{policy: true, front: true}},
|
|
// joins for another reason, not to the front: not activated
|
|
{false, true, true, false, dockMove{policy: true}},
|
|
// the window closed: leaves, stays where it is
|
|
{true, false, true, false, dockMove{policy: true}},
|
|
// Settings takes it out with the window open: brought back to the front
|
|
{true, false, true, true, dockMove{policy: true, front: true}},
|
|
}
|
|
for _, c := range cases {
|
|
if got := dockStep(c.regular, c.on, c.active, c.front); got != c.want {
|
|
t.Errorf("dockStep(regular=%v, on=%v, active=%v, front=%v) = %+v, want %+v", c.regular, c.on, c.active, c.front, got, c.want)
|
|
}
|
|
}
|
|
}
|