fix(layout): place joined windows after the stack's current column
- commit
- bfb04cb29ea2b331a58f68f4c5cb4c42d452d346
- author
- brice · · 2026-09-25 20:23 UTC
- parent
- 3bc98da
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +15 -1
M internal/core/monitor.go +2 -1
| @@ -367,7 +367,8 @@ func (m *Monitor) leaveFullscreen(fs *Workspace, focus bool) { | |||
| 367 | 367 | origin, back, id := fs.origin, fs.back, fs.back.id | |
| 368 | 368 | fs.origin, fs.back = nil, origPlace{} | |
| 369 | 369 | fs.RemoveWindow(id) | |
| 370 | - | defer m.foldInto(fs, origin, back.col+1, focus, back.tiled) | |
| 370 | + | // A closure: back.col is where the window lands, known after the switch. | |
| 371 | + | defer func() { m.foldInto(fs, origin, back.col+1, focus, back.tiled) }() | |
| 371 | 372 | switch prev := origin.Focus; { | |
| 372 | 373 | case back.float != nil && focus: | |
| 373 | 374 | origin.AddFloating(id, back.float.W, back.float.H) | |
| @@ -367,7 +367,8 @@ func (m *Monitor) leaveFullscreen(fs *Workspace, focus bool) { | |||||
| 367 | origin, back, id := fs.origin, fs.back, fs.back.id | 367 | origin, back, id := fs.origin, fs.back, fs.back.id | ||
| 368 | fs.origin, fs.back = nil, origPlace{} | 368 | fs.origin, fs.back = nil, origPlace{} | ||
| 369 | fs.RemoveWindow(id) | 369 | fs.RemoveWindow(id) | ||
| 370 | - | defer m.foldInto(fs, origin, back.col+1, focus, back.tiled) | 370 | + | // A closure: back.col is where the window lands, known after the switch. |
| 371 | + | defer func() { m.foldInto(fs, origin, back.col+1, focus, back.tiled) }() | |||
| 371 | switch prev := origin.Focus; { | 372 | switch prev := origin.Focus; { | ||
| 372 | case back.float != nil && focus: | 373 | case back.float != nil && focus: | ||
| 373 | origin.AddFloating(id, back.float.W, back.float.H) | 374 | origin.AddFloating(id, back.float.W, back.float.H) | ||
M internal/core/monitor_test.go +13 -0
| @@ -500,6 +500,19 @@ func TestMonitorFixedFullscreenEdges(t *testing.T) { | |||
| 500 | 500 | t.Fatal(got, m.Active) | |
| 501 | 501 | } | |
| 502 | 502 | }) | |
| 503 | + | t.Run("a joined window lands after its stack when columns shifted", func(t *testing.T) { | |
| 504 | + | m := fixed() | |
| 505 | + | w := m.Current() | |
| 506 | + | w.Columns = []Column{{Windows: []WindowID{1}}, {Windows: []WindowID{5}}, {Windows: []WindowID{2, 3}}, {Windows: []WindowID{6}}} | |
| 507 | + | w.FocusID(3) | |
| 508 | + | m.ToggleFullscreen() | |
| 509 | + | m.AddWindow(7) | |
| 510 | + | m.RemoveWindow(1) | |
| 511 | + | m.ToggleFullscreen() | |
| 512 | + | if got := windows(m); !reflect.DeepEqual(got, [][]WindowID{{5, 2, 3, 7, 6}, {}}) { | |
| 513 | + | t.Fatal(got) | |
| 514 | + | } | |
| 515 | + | }) | |
| 503 | 516 | t.Run("the bind from a dialog returns the fullscreen window", func(t *testing.T) { | |
| 504 | 517 | m := fixed() | |
| 505 | 518 | m.Current().FocusID(2) | |
| @@ -500,6 +500,19 @@ func TestMonitorFixedFullscreenEdges(t *testing.T) { | |||||
| 500 | t.Fatal(got, m.Active) | 500 | t.Fatal(got, m.Active) | ||
| 501 | } | 501 | } | ||
| 502 | }) | 502 | }) | ||
| 503 | + | t.Run("a joined window lands after its stack when columns shifted", func(t *testing.T) { | |||
| 504 | + | m := fixed() | |||
| 505 | + | w := m.Current() | |||
| 506 | + | w.Columns = []Column{{Windows: []WindowID{1}}, {Windows: []WindowID{5}}, {Windows: []WindowID{2, 3}}, {Windows: []WindowID{6}}} | |||
| 507 | + | w.FocusID(3) | |||
| 508 | + | m.ToggleFullscreen() | |||
| 509 | + | m.AddWindow(7) | |||
| 510 | + | m.RemoveWindow(1) | |||
| 511 | + | m.ToggleFullscreen() | |||
| 512 | + | if got := windows(m); !reflect.DeepEqual(got, [][]WindowID{{5, 2, 3, 7, 6}, {}}) { | |||
| 513 | + | t.Fatal(got) | |||
| 514 | + | } | |||
| 515 | + | }) | |||
| 503 | t.Run("the bind from a dialog returns the fullscreen window", func(t *testing.T) { | 516 | t.Run("the bind from a dialog returns the fullscreen window", func(t *testing.T) { | ||
| 504 | m := fixed() | 517 | m := fixed() | ||
| 505 | m.Current().FocusID(2) | 518 | m.Current().FocusID(2) | ||