_PointerEcho
One trackpad page's pointer echo. The page draws the pointer at the last
echo it was sent, moved on by each delta it sent past the message that echo
includes and held inside that display after each, as the pointer is, so an
echo that would leave it drawn where it is goes unsent: where the page draws
it, with the deltas the position includes, is followed here and compared with
the position. On Wayland a message counts once the compositor has applied the
move numbered when it was injected (pointer_location); X11 applies a move
before the next request it reads.
Attributes
attributeseq= seqFunctions
constructor__init__(seq) -> NoneSource Code
def __init__(self, seq: int) -> None:
self.seq = seq
self._sent: Optional[Tuple[str, float, float, float]] = None
self._x = 0.0
self._y = 0.0
self._pending: deque = deque()paramseqintReturns
Nonefuncapplied(motion, seq, dx, dy) -> NoneOne of the page's pointer messages applied, with its delta (zero for an absolute position, which the page does not draw ahead of the echo) and the number of the move it ended at, None on X11.
Source Code
def applied(self, motion: Optional[int], seq: int, dx: float, dy: float) -> None:
"""One of the page's pointer messages applied, with its delta (zero for an
absolute position, which the page does not draw ahead of the echo) and the
number of the move it ended at, None on X11."""
if motion is None:
self._include(seq, dx, dy)
else:
self._pending.append((motion, seq, dx, dy))parammotionOptional[int]paramseqintparamdxfloatparamdyfloatReturns
Nonefunc_include(seq, dx, dy) -> NoneSource Code
def _include(self, seq: int, dx: float, dy: float) -> None:
self.seq = max(self.seq, seq)
if self._sent is not None:
_, scale, w, h = self._sent
self._x = min(max(self._x + dx * scale, 0.0), max(0.0, w - 1))
self._y = min(max(self._y + dy * scale, 0.0), max(0.0, h - 1))paramseqintparamdxfloatparamdyfloatReturns
Nonefuncthrough(motion) -> intThe last message the position of move number motion includes.
Source Code
def through(self, motion: Optional[int]) -> int:
"""The last message the position of move number `motion` includes."""
if motion is not None:
while self._pending and self._pending[0][0] <= motion:
self._include(*self._pending.popleft()[1:])
return self.seqparammotionOptional[int]Returns
intfuncdrawn_at(did, x, y) -> boolWhether the page already draws the pointer at (x, y) on did.
Source Code
def drawn_at(self, did: str, x: float, y: float) -> bool:
"""Whether the page already draws the pointer at (x, y) on `did`."""
return (self._sent is not None and self._sent[0] == did
and abs(self._x - x) < 0.5 and abs(self._y - y) < 0.5)paramdidstrparamxfloatparamyfloatReturns
boolfuncechoed(did, x, y, scale, w, h) -> NoneSource Code
def echoed(self, did: str, x: float, y: float, scale: float, w: float, h: float) -> None:
self._sent = (did, scale, w, h)
self._x = x
self._y = yparamdidstrparamxfloatparamyfloatparamscalefloatparamwfloatparamhfloatReturns
None