detached 43a1ce7

test(wayland): wait for the output change before counting surface enters

commit
43a1ce78d2548a6da57c936293bf1e3437901330
author
brice · · 2026-10-22 15:42 UTC
committer
brice · · 2026-10-22 17:54 UTC
parent
1b0bfc7
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +18 -5
M internal/adapters/wayland/x11window_test.go +18 -5
@@ -533,6 +533,22 @@ func TestX11ConfineRegionHasNoOffset(t *testing.T) {
533533 }
534534 }
535535
536+// waitOn waits until window id's surface is on output name: commands reach
537+// the display goroutine asynchronously.
538+func (r *x11Rig) waitOn(id ports.WindowID, name string) {
539+ r.t.Helper()
540+ waitTrue(r.t, "surface on "+name, func() bool {
541+ ok := false
542+ r.state(func() {
543+ if w := r.s.windows[id]; w != nil {
544+ on := w.surf().on
545+ ok = on != nil && on.name() == name
546+ }
547+ })
548+ return ok
549+ })
550+}
551+
536552 // An X11 window is on one output only, even straddling two: a single
537553 // wl_surface.enter, and a leave only when its output changes.
538554 func TestX11WindowEntersOneOutput(t *testing.T) {
@@ -575,10 +591,7 @@ func TestX11WindowEntersOneOutput(t *testing.T) {
575591 // Straddling both outputs, configured on A.
576592 r.commands <- ports.PlaceWindow{ID: m.ID, X: 1900, Y: 0}
577593 r.commands <- ports.ConfigureWindow{ID: m.ID, Width: 200, Height: 100, Visible: true, Output: "A"}
578- if err := r.xc.Roundtrip(); err != nil {
579- t.Fatal(err)
580- }
581- r.state(func() {})
594+ r.waitOn(m.ID, "A")
582595 if err := r.xc.Roundtrip(); err != nil {
583596 t.Fatal(err)
584597 }
@@ -604,7 +617,7 @@ func TestX11WindowEntersOneOutput(t *testing.T) {
604617
605618 // Moving to B leaves A and enters B once.
606619 r.commands <- ports.ConfigureWindow{ID: m.ID, Width: 200, Height: 100, Visible: true, Output: "B"}
607- r.state(func() {})
620+ r.waitOn(m.ID, "B")
608621 if err := r.xc.Roundtrip(); err != nil {
609622 t.Fatal(err)
610623 }
@@ -533,6 +533,22 @@ func TestX11ConfineRegionHasNoOffset(t *testing.T) {
533 }533 }
534 }534 }
535 535
536+// waitOn waits until window id's surface is on output name: commands reach
537+// the display goroutine asynchronously.
538+func (r *x11Rig) waitOn(id ports.WindowID, name string) {
539+ r.t.Helper()
540+ waitTrue(r.t, "surface on "+name, func() bool {
541+ ok := false
542+ r.state(func() {
543+ if w := r.s.windows[id]; w != nil {
544+ on := w.surf().on
545+ ok = on != nil && on.name() == name
546+ }
547+ })
548+ return ok
549+ })
550+}
551+
536 // An X11 window is on one output only, even straddling two: a single552 // An X11 window is on one output only, even straddling two: a single
537 // wl_surface.enter, and a leave only when its output changes.553 // wl_surface.enter, and a leave only when its output changes.
538 func TestX11WindowEntersOneOutput(t *testing.T) {554 func TestX11WindowEntersOneOutput(t *testing.T) {
@@ -575,10 +591,7 @@ func TestX11WindowEntersOneOutput(t *testing.T) {
575 // Straddling both outputs, configured on A.591 // Straddling both outputs, configured on A.
576 r.commands <- ports.PlaceWindow{ID: m.ID, X: 1900, Y: 0}592 r.commands <- ports.PlaceWindow{ID: m.ID, X: 1900, Y: 0}
577 r.commands <- ports.ConfigureWindow{ID: m.ID, Width: 200, Height: 100, Visible: true, Output: "A"}593 r.commands <- ports.ConfigureWindow{ID: m.ID, Width: 200, Height: 100, Visible: true, Output: "A"}
578- if err := r.xc.Roundtrip(); err != nil {594+ r.waitOn(m.ID, "A")
579- t.Fatal(err)
580- }
581- r.state(func() {})
582 if err := r.xc.Roundtrip(); err != nil {595 if err := r.xc.Roundtrip(); err != nil {
583 t.Fatal(err)596 t.Fatal(err)
584 }597 }
@@ -604,7 +617,7 @@ func TestX11WindowEntersOneOutput(t *testing.T) {
604 617
605 // Moving to B leaves A and enters B once.618 // Moving to B leaves A and enters B once.
606 r.commands <- ports.ConfigureWindow{ID: m.ID, Width: 200, Height: 100, Visible: true, Output: "B"}619 r.commands <- ports.ConfigureWindow{ID: m.ID, Width: 200, Height: 100, Visible: true, Output: "B"}
607- r.state(func() {})620+ r.waitOn(m.ID, "B")
608 if err := r.xc.Roundtrip(); err != nil {621 if err := r.xc.Roundtrip(); err != nil {
609 t.Fatal(err)622 t.Fatal(err)
610 }623 }

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. Elsewhere: into the side 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
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
esc
close a dialog, leave a field

Branches 26

Tags 10

↑↓ moveenter openesc close