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

+39
View File
@@ -39,6 +39,13 @@ class PointerSink(Protocol):
def button(self, output: str, code: int, state: int) -> None:
"""An evdev button code and a ``wl_pointer.button_state``."""
def axis(self, output: str, axis: int, value: float) -> None:
"""Scroll by ``value`` wheel clicks along ``axis`` (a ``wl_pointer_axis``).
Positive vertical is *down* and positive horizontal is *right*, which is
the protocol's direction and not a choice of ours.
"""
def frame(self, output: str) -> None:
"""Commit the queued events. Nothing is delivered until this."""
@@ -107,6 +114,37 @@ class Dispatcher:
self._pressed.pop(name, None)
return {"ok": True}
def _op_axis(self, request: dict) -> dict[str, Any]:
"""Scroll the aimed output.
The output is implicit, like ``button``: there is one cursor, and a
scroll belongs to whatever it is currently over. A caller that wants to
scroll somewhere else warps first, which is also what makes the gesture
serialisable by the lease.
"""
name = request.get("axis", "vertical")
if not isinstance(name, str):
raise Rejected("'axis' must be a string")
try:
code = buttons.axis_for(name)
except ValueError as exc:
raise Rejected(str(exc)) from None
value = request.get("value", 1.0)
if isinstance(value, bool) or not isinstance(value, (int, float)):
raise Rejected("'value' must be a number of wheel clicks")
value = float(value)
if value != value or value in (float("inf"), float("-inf")):
raise Rejected("'value' must be finite")
if abs(value) > buttons.MAX_AXIS_VALUE:
raise Rejected(
f"'value' {value} exceeds the {buttons.MAX_AXIS_VALUE:g} wheel-click limit"
)
self._sink.axis(self._aimed(), code, value)
return {"ok": True}
def _op_frame(self, request: dict) -> dict[str, Any]:
self._sink.frame(self._aimed())
return {"ok": True}
@@ -131,6 +169,7 @@ class Dispatcher:
_ops = {
"warp": _op_warp,
"button": _op_button,
"axis": _op_axis,
"frame": _op_frame,
"pressed": _op_pressed,
"release_all": _op_release_all,