detached f38f228

#129 fix(stash): let a fullscreen stash member leave the stash

state
merged · 9483d13 · merge commit
branch
fix/stash-fullscreen-unstash → main
opened
bnema ·
updated

A window opened while the stash is shown joins it (stash.capture). When that window then asks for fullscreen (a Wine game), toggle-window-stash did nothing: ToggleWindowStash returned early for any fullscreen window.

Now a fullscreen stash member leaves the stash, back to its former column (or free float), and stays fullscreen. Fullscreen windows outside the stash are still not stashed. Capture is unchanged.

Checks: make check, make race, make mocks-check, staticcheck ./..., headless e2e (testpattern -fullscreen captured, unstashed with Super+Shift+s, still fullscreen in a column).

CommitSubjectAuthorDateSignatureStatus
f38f228fix(stash): let a fullscreen stash member leave the stashbrice GPG Verified

Checks 1

3 files · +102 -3
1/1
M internal/core/stash_spawn_test.go +27 -0
@@ -233,3 +233,30 @@ func TestFourFingerSwipeEmptyStashDoesNotRefillSlots(t *testing.T) {
233233
234234 })
235235 }
236+
237+func TestCapturedMappedFullscreenCanUnstash(t *testing.T) {
238+ for _, floating := range []bool{false, true} {
239+ synctest.Test(t, func(t *testing.T) {
240+ r := stashSpawnRig(t, func(c *domain.Config) { c.Stash.Capture = true })
241+ r.mapWindow(t, 1)
242+ r.key(t, "s", domain.ModAlt|domain.ModShift)
243+ r.client <- ports.WindowMapped{ID: 2, Floating: floating, Fullscreen: true}
244+ set := receive(t, r.scenes)
245+ if w, ok := sceneWindow(set, 2); !ok || !w.Fullscreen || !w.Floating || w.Hidden {
246+ t.Fatalf("captured: %+v", w)
247+ }
248+ for len(r.commands) > 0 {
249+ <-r.commands
250+ }
251+ set = r.key(t, "s", domain.ModAlt|domain.ModShift)
252+ if w, ok := sceneWindow(set, 2); !ok || !w.Fullscreen || w.Floating || w.Hidden || !w.Focused {
253+ t.Fatalf("unstashed: %+v", w)
254+ }
255+ for len(r.commands) > 0 {
256+ if cmd, ok := (<-r.commands).(ports.ConfigureWindow); ok && cmd.ID == 2 && !cmd.Fullscreen {
257+ t.Fatalf("lost fullscreen configure: %+v", cmd)
258+ }
259+ }
260+ })
261+ }
262+}
@@ -233,3 +233,30 @@ func TestFourFingerSwipeEmptyStashDoesNotRefillSlots(t *testing.T) {
233 233
234 })234 })
235 }235 }
236+
237+func TestCapturedMappedFullscreenCanUnstash(t *testing.T) {
238+ for _, floating := range []bool{false, true} {
239+ synctest.Test(t, func(t *testing.T) {
240+ r := stashSpawnRig(t, func(c *domain.Config) { c.Stash.Capture = true })
241+ r.mapWindow(t, 1)
242+ r.key(t, "s", domain.ModAlt|domain.ModShift)
243+ r.client <- ports.WindowMapped{ID: 2, Floating: floating, Fullscreen: true}
244+ set := receive(t, r.scenes)
245+ if w, ok := sceneWindow(set, 2); !ok || !w.Fullscreen || !w.Floating || w.Hidden {
246+ t.Fatalf("captured: %+v", w)
247+ }
248+ for len(r.commands) > 0 {
249+ <-r.commands
250+ }
251+ set = r.key(t, "s", domain.ModAlt|domain.ModShift)
252+ if w, ok := sceneWindow(set, 2); !ok || !w.Fullscreen || w.Floating || w.Hidden || !w.Focused {
253+ t.Fatalf("unstashed: %+v", w)
254+ }
255+ for len(r.commands) > 0 {
256+ if cmd, ok := (<-r.commands).(ports.ConfigureWindow); ok && cmd.ID == 2 && !cmd.Fullscreen {
257+ t.Fatalf("lost fullscreen configure: %+v", cmd)
258+ }
259+ }
260+ })
261+ }
262+}
M internal/core/workspace/layout.go +10 -3
@@ -693,9 +693,16 @@ func (w *Workspace) ImposedFloat(id WindowID) bool {
693693 // stashed window to its column. A native float becomes a new column.
694694 func (w *Workspace) ToggleWindowStash() {
695695 id, ok := w.Focused()
696- // A fullscreen window (a Wine game in scanout) keeps its place: it
697- // leaves fullscreen first, then may float.
698- if !ok || id == w.Fullscreen {
696+ if !ok {
697+ return
698+ }
699+ if id == w.Fullscreen {
700+ // Fullscreen tiles and native floats keep their place. A stash
701+ // member may return to its column (or free float), still fullscreen.
702+ if i := w.StashIndex(id); i >= 0 {
703+ w.unstash(i) // RemoveWindow clears the old fullscreen state.
704+ w.SetFullscreen(id, true)
705+ }
699706 return
700707 }
701708 switch {
@@ -693,9 +693,16 @@ func (w *Workspace) ImposedFloat(id WindowID) bool {
693 // stashed window to its column. A native float becomes a new column.693 // stashed window to its column. A native float becomes a new column.
694 func (w *Workspace) ToggleWindowStash() {694 func (w *Workspace) ToggleWindowStash() {
695 id, ok := w.Focused()695 id, ok := w.Focused()
696- // A fullscreen window (a Wine game in scanout) keeps its place: it696+ if !ok {
697- // leaves fullscreen first, then may float.697+ return
698- if !ok || id == w.Fullscreen {698+ }
699+ if id == w.Fullscreen {
700+ // Fullscreen tiles and native floats keep their place. A stash
701+ // member may return to its column (or free float), still fullscreen.
702+ if i := w.StashIndex(id); i >= 0 {
703+ w.unstash(i) // RemoveWindow clears the old fullscreen state.
704+ w.SetFullscreen(id, true)
705+ }
699 return706 return
700 }707 }
701 switch {708 switch {
M internal/core/workspace/stash_test.go +65 -0
@@ -58,3 +58,68 @@ func TestActivateHiddenStashOverScrollFullscreen(t *testing.T) {
5858
5959 })
6060 }
61+
62+func TestFullscreenStashMemberReturns(t *testing.T) {
63+ for _, kind := range []string{"captured", "former column", "free float"} {
64+ t.Run(kind, func(t *testing.T) {
65+ synctest.Test(t, func(t *testing.T) {
66+ w := workspace()
67+ w.AddWindow(1)
68+ w.ToggleWindowStash()
69+ if kind == "captured" {
70+ if !w.CaptureStash(2) {
71+ t.Fatal("not captured")
72+ }
73+ } else {
74+ w.AddWindow(2)
75+ w.FocusID(2)
76+ if kind == "free float" {
77+ w.Apply(ActionToggleFloating)
78+ }
79+ w.ToggleWindowStash()
80+ }
81+ w.SetFullscreen(2, true)
82+ if w.Cover() != 2 {
83+ t.Fatal("setup has no cover")
84+ }
85+ w.ToggleWindowStash()
86+ if w.StashIndex(2) >= 0 || w.Fullscreen != 2 || w.Cover() != 2 || w.stashFocus || w.hiddenFullscreen != 0 || w.stashOver != 0 {
87+ t.Fatalf("bad restored state: %+v", w)
88+ }
89+ if id, _ := w.Focused(); id != 2 {
90+ t.Fatalf("focused %d", id)
91+ }
92+ if kind == "free float" {
93+ if i := w.floatIndex(2); i < 0 || !w.Floats[i].free {
94+ t.Fatal("free float not restored")
95+ }
96+ } else if len(w.Columns) != 1 || w.Columns[0].Windows[0] != 2 {
97+ t.Fatal(w.Columns)
98+ }
99+ for _, p := range w.Layout() {
100+ if p.ID == 2 && (!p.Fullscreen || p.Hidden || p.Rect != w.Output) {
101+ t.Fatalf("placement %+v", p)
102+ }
103+ }
104+ })
105+ })
106+ }
107+}
108+
109+func TestFullscreenOutsideStashKeepsPlace(t *testing.T) {
110+ for _, floating := range []bool{false, true} {
111+ synctest.Test(t, func(t *testing.T) {
112+ w := workspace()
113+ if floating {
114+ w.AddFloating(1, 100, 80)
115+ } else {
116+ w.AddWindow(1)
117+ }
118+ w.SetFullscreen(1, true)
119+ w.ToggleWindowStash()
120+ if w.StashIndex(1) >= 0 || w.Fullscreen != 1 || w.Cover() != 1 {
121+ t.Fatal("fullscreen window moved")
122+ }
123+ })
124+ }
125+}
@@ -58,3 +58,68 @@ func TestActivateHiddenStashOverScrollFullscreen(t *testing.T) {
58 58
59 })59 })
60 }60 }
61+
62+func TestFullscreenStashMemberReturns(t *testing.T) {
63+ for _, kind := range []string{"captured", "former column", "free float"} {
64+ t.Run(kind, func(t *testing.T) {
65+ synctest.Test(t, func(t *testing.T) {
66+ w := workspace()
67+ w.AddWindow(1)
68+ w.ToggleWindowStash()
69+ if kind == "captured" {
70+ if !w.CaptureStash(2) {
71+ t.Fatal("not captured")
72+ }
73+ } else {
74+ w.AddWindow(2)
75+ w.FocusID(2)
76+ if kind == "free float" {
77+ w.Apply(ActionToggleFloating)
78+ }
79+ w.ToggleWindowStash()
80+ }
81+ w.SetFullscreen(2, true)
82+ if w.Cover() != 2 {
83+ t.Fatal("setup has no cover")
84+ }
85+ w.ToggleWindowStash()
86+ if w.StashIndex(2) >= 0 || w.Fullscreen != 2 || w.Cover() != 2 || w.stashFocus || w.hiddenFullscreen != 0 || w.stashOver != 0 {
87+ t.Fatalf("bad restored state: %+v", w)
88+ }
89+ if id, _ := w.Focused(); id != 2 {
90+ t.Fatalf("focused %d", id)
91+ }
92+ if kind == "free float" {
93+ if i := w.floatIndex(2); i < 0 || !w.Floats[i].free {
94+ t.Fatal("free float not restored")
95+ }
96+ } else if len(w.Columns) != 1 || w.Columns[0].Windows[0] != 2 {
97+ t.Fatal(w.Columns)
98+ }
99+ for _, p := range w.Layout() {
100+ if p.ID == 2 && (!p.Fullscreen || p.Hidden || p.Rect != w.Output) {
101+ t.Fatalf("placement %+v", p)
102+ }
103+ }
104+ })
105+ })
106+ }
107+}
108+
109+func TestFullscreenOutsideStashKeepsPlace(t *testing.T) {
110+ for _, floating := range []bool{false, true} {
111+ synctest.Test(t, func(t *testing.T) {
112+ w := workspace()
113+ if floating {
114+ w.AddFloating(1, 100, 80)
115+ } else {
116+ w.AddWindow(1)
117+ }
118+ w.SetFullscreen(1, true)
119+ w.ToggleWindowStash()
120+ if w.StashIndex(1) >= 0 || w.Fullscreen != 1 || w.Cover() != 1 {
121+ t.Fatal("fullscreen window moved")
122+ }
123+ })
124+ }
125+}

Comments11 unresolved

  1. bnema

    Review (go-reviewer): one finding. In cascade, unstashing a fullscreen free float turns it into a column. Rejected: cascade already promotes any float that enters fullscreen to a column and keeps it tiled after fullscreen ends (TestUserFloatedToggleFullscreenPromotes, TestLegacyFullscreenCascadeFloatBand). Unstash follows the same rule.

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. On pages with a side panel: into the panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit; in a file, click a line number to select it, shift-click for a range
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
l
merge request: the list of files (j k move, enter opens, esc back)
M
merge request: the merge menu; there 1–3 pick the mode, D deletes the branch, enter merges
R
merge request: mark the head read
esc
close a dialog, leave a field

Branches 33

Tags 15

↑↓ moveenter openesc close