refactor(core): remove the appear, leave and Monitor.overviewAt wrappers
Only tests called them; they call appearAt, leaveFrom and overviewIn directly.
- commit
- 9865a275ba257b0c52edf24435637f28b04328a5
- author
- brice · · 2026-10-05 02:45 UTC
- parent
- ac8eeb6
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
9 files · +17 -22
M internal/core/overview.go +5 -10
| @@ -813,16 +813,11 @@ func overviewOutline(layout []Placement, b int) []ports.Separator { | |||
| 813 | 813 | // overviewClickFade is the fade from which a card takes no click. | |
| 814 | 814 | const overviewClickFade = 0.5 | |
| 815 | 815 | ||
| 816 | - | // overviewAt is the preview under the output-local point, if any. Front | |
| 817 | - | // cards take priority over peeks, including peeks appended after a front | |
| 818 | - | // tile in another row's layout. | |
| 819 | - | func (m *Monitor) overviewAt(x, y float64) WindowID { | |
| 820 | - | return overviewIn(m.Layout(), x, y) | |
| 821 | - | } | |
| 822 | - | ||
| 823 | - | // overviewIn is overviewAt in a given layout: the click path passes the | |
| 824 | - | // shown one, so a card is hit where it is drawn while it moves. A card | |
| 825 | - | // that is nearly invisible (still fading in) is not clickable. | |
| 816 | + | // overviewIn is the preview under the output-local point in layout, if | |
| 817 | + | // any. Front cards take priority over peeks, including peeks appended after | |
| 818 | + | // a front tile in another row's layout. The click path passes the shown | |
| 819 | + | // layout, so a card is hit where it is drawn while it moves. A card that is | |
| 820 | + | // nearly invisible (still fading in) is not clickable. | |
| 826 | 821 | func overviewIn(layout []Placement, x, y float64) WindowID { | |
| 827 | 822 | for i := len(layout) - 1; i >= 0; i-- { | |
| 828 | 823 | p := layout[i] | |
| @@ -813,16 +813,11 @@ func overviewOutline(layout []Placement, b int) []ports.Separator { | |||||
| 813 | // overviewClickFade is the fade from which a card takes no click. | 813 | // overviewClickFade is the fade from which a card takes no click. | ||
| 814 | const overviewClickFade = 0.5 | 814 | const overviewClickFade = 0.5 | ||
| 815 | 815 | ||||
| 816 | - | // overviewAt is the preview under the output-local point, if any. Front | 816 | + | // overviewIn is the preview under the output-local point in layout, if |
| 817 | - | // cards take priority over peeks, including peeks appended after a front | 817 | + | // any. Front cards take priority over peeks, including peeks appended after |
| 818 | - | // tile in another row's layout. | 818 | + | // a front tile in another row's layout. The click path passes the shown |
| 819 | - | func (m *Monitor) overviewAt(x, y float64) WindowID { | 819 | + | // layout, so a card is hit where it is drawn while it moves. A card that is |
| 820 | - | return overviewIn(m.Layout(), x, y) | 820 | + | // nearly invisible (still fading in) is not clickable. |
| 821 | - | } | |||
| 822 | - | ||||
| 823 | - | // overviewIn is overviewAt in a given layout: the click path passes the | |||
| 824 | - | // shown one, so a card is hit where it is drawn while it moves. A card | |||
| 825 | - | // that is nearly invisible (still fading in) is not clickable. | |||
| 826 | func overviewIn(layout []Placement, x, y float64) WindowID { | 821 | func overviewIn(layout []Placement, x, y float64) WindowID { | ||
| 827 | for i := len(layout) - 1; i >= 0; i-- { | 822 | for i := len(layout) - 1; i >= 0; i-- { | ||
| 828 | p := layout[i] | 823 | p := layout[i] | ||
M internal/core/overview_named_test.go +1 -1
| @@ -304,7 +304,7 @@ func TestOverviewNamedNeighborPick(t *testing.T) { | |||
| 304 | 304 | if p.Hidden { | |
| 305 | 305 | t.Fatal("named stash neighbor hidden") | |
| 306 | 306 | } | |
| 307 | - | id := m.overviewAt(float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2)) | |
| 307 | + | id := overviewIn(m.Layout(), float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2)) | |
| 308 | 308 | if id != 6 { | |
| 309 | 309 | t.Fatalf("stash hit: %d", id) | |
| 310 | 310 | } | |
| @@ -304,7 +304,7 @@ func TestOverviewNamedNeighborPick(t *testing.T) { | |||||
| 304 | if p.Hidden { | 304 | if p.Hidden { | ||
| 305 | t.Fatal("named stash neighbor hidden") | 305 | t.Fatal("named stash neighbor hidden") | ||
| 306 | } | 306 | } | ||
| 307 | - | id := m.overviewAt(float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2)) | 307 | + | id := overviewIn(m.Layout(), float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2)) |
| 308 | if id != 6 { | 308 | if id != 6 { | ||
| 309 | t.Fatalf("stash hit: %d", id) | 309 | t.Fatalf("stash hit: %d", id) | ||
| 310 | } | 310 | } | ||
M internal/core/overview_regression_test.go +1 -1
| @@ -62,7 +62,7 @@ func TestOverviewSingleCoveringFloat(t *testing.T) { | |||
| 62 | 62 | } | |
| 63 | 63 | } | |
| 64 | 64 | if click { | |
| 65 | - | id := m.overviewAt(float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2)) | |
| 65 | + | id := overviewIn(m.Layout(), float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2)) | |
| 66 | 66 | if id != 9 { | |
| 67 | 67 | t.Fatalf("hit %d, want 9", id) | |
| 68 | 68 | } | |
| @@ -62,7 +62,7 @@ func TestOverviewSingleCoveringFloat(t *testing.T) { | |||||
| 62 | } | 62 | } | ||
| 63 | } | 63 | } | ||
| 64 | if click { | 64 | if click { | ||
| 65 | - | id := m.overviewAt(float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2)) | 65 | + | id := overviewIn(m.Layout(), float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2)) |
| 66 | if id != 9 { | 66 | if id != 9 { | ||
| 67 | t.Fatalf("hit %d, want 9", id) | 67 | t.Fatalf("hit %d, want 9", id) | ||
| 68 | } | 68 | } | ||
M internal/core/overview_stack_test.go +2 -2
| @@ -115,12 +115,12 @@ func TestOverviewStackClickAndHitPriority(t *testing.T) { | |||
| 115 | 115 | if frontColumn { | |
| 116 | 116 | x = front.Rect.X + front.Rect.W/2 | |
| 117 | 117 | } | |
| 118 | - | if got := m.overviewAt(float64(x), float64(y)); got != front.ID { | |
| 118 | + | if got := overviewIn(m.Layout(), float64(x), float64(y)); got != front.ID { | |
| 119 | 119 | t.Fatalf("overlap hit %d want %d (front %+v back %+v)", got, front.ID, front.Rect, back.Rect) | |
| 120 | 120 | } | |
| 121 | 121 | // The up/right exposed corner belongs to the peeking card. | |
| 122 | 122 | x, y = back.Rect.X+back.Rect.W-1, back.Rect.Y+1 | |
| 123 | - | if got := m.overviewAt(float64(x), float64(y)); got != back.ID { | |
| 123 | + | if got := overviewIn(m.Layout(), float64(x), float64(y)); got != back.ID { | |
| 124 | 124 | t.Fatalf("peek hit %d want %d", got, back.ID) | |
| 125 | 125 | } | |
| 126 | 126 | m.OverviewPick(back.ID) | |
| @@ -115,12 +115,12 @@ func TestOverviewStackClickAndHitPriority(t *testing.T) { | |||||
| 115 | if frontColumn { | 115 | if frontColumn { | ||
| 116 | x = front.Rect.X + front.Rect.W/2 | 116 | x = front.Rect.X + front.Rect.W/2 | ||
| 117 | } | 117 | } | ||
| 118 | - | if got := m.overviewAt(float64(x), float64(y)); got != front.ID { | 118 | + | if got := overviewIn(m.Layout(), float64(x), float64(y)); got != front.ID { |
| 119 | t.Fatalf("overlap hit %d want %d (front %+v back %+v)", got, front.ID, front.Rect, back.Rect) | 119 | t.Fatalf("overlap hit %d want %d (front %+v back %+v)", got, front.ID, front.Rect, back.Rect) | ||
| 120 | } | 120 | } | ||
| 121 | // The up/right exposed corner belongs to the peeking card. | 121 | // The up/right exposed corner belongs to the peeking card. | ||
| 122 | x, y = back.Rect.X+back.Rect.W-1, back.Rect.Y+1 | 122 | x, y = back.Rect.X+back.Rect.W-1, back.Rect.Y+1 | ||
| 123 | - | if got := m.overviewAt(float64(x), float64(y)); got != back.ID { | 123 | + | if got := overviewIn(m.Layout(), float64(x), float64(y)); got != back.ID { |
| 124 | t.Fatalf("peek hit %d want %d", got, back.ID) | 124 | t.Fatalf("peek hit %d want %d", got, back.ID) | ||
| 125 | } | 125 | } | ||
| 126 | m.OverviewPick(back.ID) | 126 | m.OverviewPick(back.ID) | ||
M internal/core/overview_test.go +4 -4
| @@ -116,7 +116,7 @@ func TestOverviewPick(t *testing.T) { | |||
| 116 | 116 | m := overviewMonitor() | |
| 117 | 117 | m.ToggleOverview() | |
| 118 | 118 | below := previewOf(t, m.Layout(), 4).Rect | |
| 119 | - | id := m.overviewAt(float64(below.X+1), float64(below.Y+1)) | |
| 119 | + | id := overviewIn(m.Layout(), float64(below.X+1), float64(below.Y+1)) | |
| 120 | 120 | if id != 4 { | |
| 121 | 121 | t.Fatalf("hit %d", id) | |
| 122 | 122 | } | |
| @@ -173,7 +173,7 @@ func TestOverviewFullscreenFloatPickAndCancel(t *testing.T) { | |||
| 173 | 173 | m := gameMonitor(OverflowFixed) | |
| 174 | 174 | m.ToggleOverview() | |
| 175 | 175 | r := previewOf(t, m.Layout(), 2).Rect | |
| 176 | - | if id := m.overviewAt(float64(r.X+1), float64(r.Y+1)); id != 2 { | |
| 176 | + | if id := overviewIn(m.Layout(), float64(r.X+1), float64(r.Y+1)); id != 2 { | |
| 177 | 177 | t.Fatalf("hit %d", id) | |
| 178 | 178 | } | |
| 179 | 179 | m.OverviewMove(0, 1) | |
| @@ -412,7 +412,7 @@ func TestOverviewPilePick(t *testing.T) { | |||
| 412 | 412 | m := pileMonitor() | |
| 413 | 413 | m.ToggleOverview() | |
| 414 | 414 | r := previewOf(t, m.Layout(), 7).Rect | |
| 415 | - | id := m.overviewAt(float64(r.X+1), float64(r.Y+r.H-1)) | |
| 415 | + | id := overviewIn(m.Layout(), float64(r.X+1), float64(r.Y+r.H-1)) | |
| 416 | 416 | if id != 7 { | |
| 417 | 417 | t.Fatalf("hit %d", id) | |
| 418 | 418 | } | |
| @@ -486,7 +486,7 @@ func TestOverviewFixedOverflowGeometry(t *testing.T) { | |||
| 486 | 486 | t.Fatalf("%d overlaps %d", id, other) | |
| 487 | 487 | } | |
| 488 | 488 | } | |
| 489 | - | if p.Rect.W > 0 && p.Rect.H > 0 && m.overviewAt(float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2)) != id { | |
| 489 | + | if p.Rect.W > 0 && p.Rect.H > 0 && overviewIn(m.Layout(), float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2)) != id { | |
| 490 | 490 | t.Fatalf("%d not hit at %+v", id, p.Rect) | |
| 491 | 491 | } | |
| 492 | 492 | } | |
| @@ -116,7 +116,7 @@ func TestOverviewPick(t *testing.T) { | |||||
| 116 | m := overviewMonitor() | 116 | m := overviewMonitor() | ||
| 117 | m.ToggleOverview() | 117 | m.ToggleOverview() | ||
| 118 | below := previewOf(t, m.Layout(), 4).Rect | 118 | below := previewOf(t, m.Layout(), 4).Rect | ||
| 119 | - | id := m.overviewAt(float64(below.X+1), float64(below.Y+1)) | 119 | + | id := overviewIn(m.Layout(), float64(below.X+1), float64(below.Y+1)) |
| 120 | if id != 4 { | 120 | if id != 4 { | ||
| 121 | t.Fatalf("hit %d", id) | 121 | t.Fatalf("hit %d", id) | ||
| 122 | } | 122 | } | ||
| @@ -173,7 +173,7 @@ func TestOverviewFullscreenFloatPickAndCancel(t *testing.T) { | |||||
| 173 | m := gameMonitor(OverflowFixed) | 173 | m := gameMonitor(OverflowFixed) | ||
| 174 | m.ToggleOverview() | 174 | m.ToggleOverview() | ||
| 175 | r := previewOf(t, m.Layout(), 2).Rect | 175 | r := previewOf(t, m.Layout(), 2).Rect | ||
| 176 | - | if id := m.overviewAt(float64(r.X+1), float64(r.Y+1)); id != 2 { | 176 | + | if id := overviewIn(m.Layout(), float64(r.X+1), float64(r.Y+1)); id != 2 { |
| 177 | t.Fatalf("hit %d", id) | 177 | t.Fatalf("hit %d", id) | ||
| 178 | } | 178 | } | ||
| 179 | m.OverviewMove(0, 1) | 179 | m.OverviewMove(0, 1) | ||
| @@ -412,7 +412,7 @@ func TestOverviewPilePick(t *testing.T) { | |||||
| 412 | m := pileMonitor() | 412 | m := pileMonitor() | ||
| 413 | m.ToggleOverview() | 413 | m.ToggleOverview() | ||
| 414 | r := previewOf(t, m.Layout(), 7).Rect | 414 | r := previewOf(t, m.Layout(), 7).Rect | ||
| 415 | - | id := m.overviewAt(float64(r.X+1), float64(r.Y+r.H-1)) | 415 | + | id := overviewIn(m.Layout(), float64(r.X+1), float64(r.Y+r.H-1)) |
| 416 | if id != 7 { | 416 | if id != 7 { | ||
| 417 | t.Fatalf("hit %d", id) | 417 | t.Fatalf("hit %d", id) | ||
| 418 | } | 418 | } | ||
| @@ -486,7 +486,7 @@ func TestOverviewFixedOverflowGeometry(t *testing.T) { | |||||
| 486 | t.Fatalf("%d overlaps %d", id, other) | 486 | t.Fatalf("%d overlaps %d", id, other) | ||
| 487 | } | 487 | } | ||
| 488 | } | 488 | } | ||
| 489 | - | if p.Rect.W > 0 && p.Rect.H > 0 && m.overviewAt(float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2)) != id { | 489 | + | if p.Rect.W > 0 && p.Rect.H > 0 && overviewIn(m.Layout(), float64(p.Rect.X+p.Rect.W/2), float64(p.Rect.Y+p.Rect.H/2)) != id { |
| 490 | t.Fatalf("%d not hit at %+v", id, p.Rect) | 490 | t.Fatalf("%d not hit at %+v", id, p.Rect) | ||
| 491 | } | 491 | } | ||
| 492 | } | 492 | } | ||
M internal/core/publish_alloc_test.go +1 -1
| @@ -185,7 +185,7 @@ func TestPublishLeavingAllocations(t *testing.T) { | |||
| 185 | 185 | for i, p := range layout { | |
| 186 | 186 | if i < 2 { | |
| 187 | 187 | sc.mon.RemoveWindow(p.ID) | |
| 188 | - | c.leave(sc, p, t0) | |
| 188 | + | c.leaveFrom(sc, p, nil, t0) | |
| 189 | 189 | continue | |
| 190 | 190 | } | |
| 191 | 191 | sc.rects[p.ID] = rectMotion{ | |
| @@ -185,7 +185,7 @@ func TestPublishLeavingAllocations(t *testing.T) { | |||||
| 185 | for i, p := range layout { | 185 | for i, p := range layout { | ||
| 186 | if i < 2 { | 186 | if i < 2 { | ||
| 187 | sc.mon.RemoveWindow(p.ID) | 187 | sc.mon.RemoveWindow(p.ID) | ||
| 188 | - | c.leave(sc, p, t0) | 188 | + | c.leaveFrom(sc, p, nil, t0) |
| 189 | continue | 189 | continue | ||
| 190 | } | 190 | } | ||
| 191 | sc.rects[p.ID] = rectMotion{ | 191 | sc.rects[p.ID] = rectMotion{ | ||
M internal/core/refresh_bench_test.go +1 -1
| @@ -42,7 +42,7 @@ func BenchmarkRefreshShown(b *testing.B) { | |||
| 42 | 42 | } | |
| 43 | 43 | for i, p := range sc.settledLayout[24:] { | |
| 44 | 44 | sc.mon.RemoveWindow(p.ID) | |
| 45 | - | c.leave(sc, p, t0) | |
| 45 | + | c.leaveFrom(sc, p, nil, t0) | |
| 46 | 46 | _ = i | |
| 47 | 47 | } | |
| 48 | 48 | sc.rectsWS = sc.mon.Current() | |
| @@ -42,7 +42,7 @@ func BenchmarkRefreshShown(b *testing.B) { | |||||
| 42 | } | 42 | } | ||
| 43 | for i, p := range sc.settledLayout[24:] { | 43 | for i, p := range sc.settledLayout[24:] { | ||
| 44 | sc.mon.RemoveWindow(p.ID) | 44 | sc.mon.RemoveWindow(p.ID) | ||
| 45 | - | c.leave(sc, p, t0) | 45 | + | c.leaveFrom(sc, p, nil, t0) |
| 46 | _ = i | 46 | _ = i | ||
| 47 | } | 47 | } | ||
| 48 | sc.rectsWS = sc.mon.Current() | 48 | sc.rectsWS = sc.mon.Current() | ||
M internal/core/transition_overview_internal_test.go +1 -1
| @@ -271,7 +271,7 @@ func TestOverviewClickDuringOpenUsesShownCards(t *testing.T) { | |||
| 271 | 271 | if x < float64(settled.Rect.X+settled.Rect.W) { | |
| 272 | 272 | t.Fatalf("setup: x %v is inside the settled card %+v", x, settled.Rect) | |
| 273 | 273 | } | |
| 274 | - | if id := sc.mon.overviewAt(x, y); id == 2 { | |
| 274 | + | if id := overviewIn(sc.mon.Layout(), x, y); id == 2 { | |
| 275 | 275 | t.Fatalf("setup: the settled layout picks 2 at %v,%v", x, y) | |
| 276 | 276 | } | |
| 277 | 277 | c.cursorX, c.cursorY = x+float64(sc.x), y+float64(sc.y) | |
| @@ -271,7 +271,7 @@ func TestOverviewClickDuringOpenUsesShownCards(t *testing.T) { | |||||
| 271 | if x < float64(settled.Rect.X+settled.Rect.W) { | 271 | if x < float64(settled.Rect.X+settled.Rect.W) { | ||
| 272 | t.Fatalf("setup: x %v is inside the settled card %+v", x, settled.Rect) | 272 | t.Fatalf("setup: x %v is inside the settled card %+v", x, settled.Rect) | ||
| 273 | } | 273 | } | ||
| 274 | - | if id := sc.mon.overviewAt(x, y); id == 2 { | 274 | + | if id := overviewIn(sc.mon.Layout(), x, y); id == 2 { |
| 275 | t.Fatalf("setup: the settled layout picks 2 at %v,%v", x, y) | 275 | t.Fatalf("setup: the settled layout picks 2 at %v,%v", x, y) | ||
| 276 | } | 276 | } | ||
| 277 | c.cursorX, c.cursorY = x+float64(sc.x), y+float64(sc.y) | 277 | c.cursorX, c.cursorY = x+float64(sc.x), y+float64(sc.y) | ||
M internal/core/transition_stash_internal_test.go +1 -1
| @@ -438,7 +438,7 @@ func TestWithLeavingOrderIsDeterministic(t *testing.T) { | |||
| 438 | 438 | sc.mon.RemoveWindow(5) | |
| 439 | 439 | c.applyAction(ActionToggleStashVisible) | |
| 440 | 440 | for _, p := range left { | |
| 441 | - | c.leave(sc, p, ic.now) | |
| 441 | + | c.leaveFrom(sc, p, nil, ic.now) | |
| 442 | 442 | } | |
| 443 | 443 | var want []WindowID | |
| 444 | 444 | for i := range 40 { | |
| @@ -438,7 +438,7 @@ func TestWithLeavingOrderIsDeterministic(t *testing.T) { | |||||
| 438 | sc.mon.RemoveWindow(5) | 438 | sc.mon.RemoveWindow(5) | ||
| 439 | c.applyAction(ActionToggleStashVisible) | 439 | c.applyAction(ActionToggleStashVisible) | ||
| 440 | for _, p := range left { | 440 | for _, p := range left { | ||
| 441 | - | c.leave(sc, p, ic.now) | 441 | + | c.leaveFrom(sc, p, nil, ic.now) |
| 442 | } | 442 | } | ||
| 443 | var want []WindowID | 443 | var want []WindowID | ||
| 444 | for i := range 40 { | 444 | for i := range 40 { | ||