scroll: one verb, two axes, and the sign carries the direction

A session could move a cursor and press it, but not scroll. The protocol
already had the request -- zwlr_virtual_pointer_v1.axis(time, axis, value) --
it had simply never been implemented, in the driver or the broker.

  hhstream session pointer scroll <id> --axis vertical --amount 3

Positive is down (vertical) or right (horizontal): the protocol's direction,
not a choice of ours, which is why direction travels in the sign and there is
deliberately no up/down vocabulary layered over it. The output is whatever the
last warp aimed at, exactly like a button, so scrolling somewhere else is a
warp first -- and the lease is what keeps the whole gesture atomic. Bounded at
100 wheel clicks per request on both sides, because a decimal-point slip should
be a refusal rather than a session scrolled somewhere unrecoverable.

The resume point is re-stamped, not moved: the cursor did not go anywhere, so
the coordinates are re-affirmed and only the stamp advances. Recorded in the
contract as an amendment to the frozen op set, because adding an op to a frozen
interface should be visible rather than implied.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
HermenixandClaude Opus 5 committed 2026-10-03 19:05:39 +00:00
1 parent d0efba0877
commit 6b395305e0
17 files changed
+642 -2

No files matched your search

+104
View File
@@ -24,6 +24,10 @@ from hhstreamd.registry import ContainerState, Session, State, container_record
LEFT = 0x110
DOWN, UP = 1, 0
#: ``wl_pointer_axis``, mirrored from the driver for the same reason the button
#: codes above are: these tests assert the events, so they name the wire values.
VERTICAL, HORIZONTAL = 0, 1
def make_session(session_id: str = "foot-aaaaaa", *, container: bool = True) -> Session:
return Session(
@@ -590,3 +594,103 @@ def test_the_sweeper_expires_a_lease_nobody_came_back_for(short_tmpdir: Path):
if manager.driver is not None:
manager.driver.close()
fake.stop()
# ---------------------------------------------------------------------------
# scrolling
# ---------------------------------------------------------------------------
def test_scroll_drives_axis_then_frame_on_the_sessions_own_output(harness):
harness.add()
lease = harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))["lease_id"]
harness.fake.sink.calls.clear()
reply = harness.run(harness.manager.pointer_scroll("foot-aaaaaa", lease, "vertical", 3))
assert (reply["axis"], reply["amount"]) == ("vertical", 3.0)
assert harness.fake.sink.calls == [
("axis", "hh-foot-aaaaaa", VERTICAL, 3.0),
("frame", "hh-foot-aaaaaa"),
]
def test_scrolling_up_is_the_sign_and_not_a_different_verb(harness):
"""One verb, one axis name, and the protocol's sign carries the direction."""
harness.add()
lease = harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))["lease_id"]
harness.fake.sink.calls.clear()
harness.run(harness.manager.pointer_scroll("foot-aaaaaa", lease, "vertical", -3))
assert harness.fake.sink.calls == [
("axis", "hh-foot-aaaaaa", VERTICAL, -3.0),
("frame", "hh-foot-aaaaaa"),
]
def test_a_horizontal_scroll_uses_the_other_axis(harness):
harness.add()
lease = harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))["lease_id"]
harness.fake.sink.calls.clear()
harness.run(harness.manager.pointer_scroll("foot-aaaaaa", lease, "horizontal", 2))
assert harness.fake.sink.calls == [
("axis", "hh-foot-aaaaaa", HORIZONTAL, 2.0),
("frame", "hh-foot-aaaaaa"),
]
def test_a_scroll_restamps_the_resume_point_without_moving_it(harness):
"""The cursor stays put -- and the record must not pretend otherwise."""
session = harness.add()
lease = harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))["lease_id"]
before = dict(session.pointer["bookmark"])
harness.clock.advance(7.0)
reply = harness.run(harness.manager.pointer_scroll("foot-aaaaaa", lease, "vertical", 3))
assert (reply["bookmark"]["x"], reply["bookmark"]["y"]) == (before["x"], before["y"])
assert reply["bookmark"]["output"] == before["output"]
assert reply["bookmark"]["at"] != before["at"], "the session acted, so the stamp moved"
assert harness.manager.pointer.state()["holder"] == "foot-aaaaaa"
@pytest.mark.parametrize("bad", [0, 0.0, 101, -101, "three", True, None])
def test_a_scroll_amount_off_the_wire_is_bounded(harness, bad):
harness.add()
lease = harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))["lease_id"]
with pytest.raises(ManagerError) as exc:
harness.run(harness.manager.pointer_scroll("foot-aaaaaa", lease, "vertical", bad))
assert exc.value.error == "invalid_argument"
def test_an_unknown_axis_is_refused_by_the_driver_not_invented(harness):
harness.add()
lease = harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))["lease_id"]
harness.fake.sink.calls.clear()
with pytest.raises(ManagerError) as exc:
harness.run(harness.manager.pointer_scroll("foot-aaaaaa", lease, "diagonal", 3))
assert exc.value.error == "driver_refused"
assert harness.fake.sink.calls == [], "a refused scroll must emit nothing"
def test_a_scroll_without_the_lease_is_refused(harness):
session = harness.add()
harness.run(harness.manager.pointer_acquire("foot-aaaaaa"))
harness.fake.sink.calls.clear()
with pytest.raises(ManagerError):
harness.run(
harness.manager.pointer_scroll("foot-aaaaaa", "not-this-lease", "vertical", 3)
)
assert harness.fake.sink.calls == []
assert session.pointer.get("bookmark") is not None, "a refused scroll changes nothing"