tests: anchor layer bars left+right so they map

A zero width without the opposite edge anchors is a protocol error,
so wlroots killed the test bar before it mapped and the exclusive
test failed (800 -> 800) while the zero-exclusive sibling passed
vacuously. Both bars now anchor left+right, the zero-exclusive test
asserts [layer] map so it cannot pass without a mapped bar, and
wltest documents the anchor rule.
This commit is contained in:
Andrew Hamilton 2026-09-04 11:05:26 +10:00
parent d8164ce315
commit 05c3e5dd2b
2 changed files with 14 additions and 3 deletions

View file

@ -3550,9 +3550,12 @@ def test_layer_exclusive_reserves_tabs():
assert base is not None, "no [diag] commit for RED"
base_w, base_h = base[0], base[1]
# Launch a 40-px top bar with exclusive zone 40.
# Launch a 40-px top bar with exclusive zone 40. Width 0 means
# "full width" but the protocol demands the matching opposite
# anchors (left+right), or the compositor kills the client.
layer_proc = subprocess.Popen(
[WL, "--layer", "top", "--layer-anchor", "top",
"--layer-anchor", "left", "--layer-anchor", "right",
"--exclusive-zone", "40", "--layer-size", "0", "40",
"#00ff00"],
env=dict(os.environ, WAYLAND_DISPLAY=s.socket),
@ -3598,8 +3601,10 @@ def test_layer_zero_exclusive_does_not_resize():
base_w, base_h = base[0], base[1]
# Launch a 40-px top bar with exclusive zone 0 (no reservation).
# Same anchor rule as above: width 0 needs left+right anchors.
layer_proc = subprocess.Popen(
[WL, "--layer", "top", "--layer-anchor", "top",
"--layer-anchor", "left", "--layer-anchor", "right",
"--exclusive-zone", "0", "--layer-size", "0", "40",
"#00ff00"],
env=dict(os.environ, WAYLAND_DISPLAY=s.socket),
@ -3608,7 +3613,10 @@ def test_layer_zero_exclusive_does_not_resize():
start_new_session=True,
preexec_fn=_preexec_death(os.getpid()))
try:
# Give it time to appear; geometry must NOT change.
# The bar must actually map (a client killed by a protocol
# error would leave geometry trivially unchanged and the
# test would pass vacuously); geometry must then NOT change.
s.wait_for(r"\[layer\] map pid=\d+")
time.sleep(2.0)
new_geom = _parse_diag_geom(s.read_log(), 0)
assert new_geom is not None, "no [diag] commit for RED"

View file

@ -2731,7 +2731,10 @@ static void print_usage(const char *argv0) {
" --primary-demand-expect pulls until the payload equals "
"<text>, then writes it to <file> and exits\n"
" --layer creates a wlr-layer-shell surface (zwp_layer_surface_v1)\n"
" --layer-anchor may be repeated to OR anchors (default: top)\n"
" --layer-anchor may be repeated to OR anchors (default: top);\n"
" a zero width/height needs the opposite edge anchors\n"
" (left+right / top+bottom) or the compositor kills\n"
" the client per protocol",
" --exclusive-zone sets the exclusive zone (default: 0)\n"
" --layer-size sets the requested width/height (default: 0 0)\n"
" --foreign binds the taskbar protocols (wlr-foreign-toplevel\n"