Gesture, Ui, project: Crafter.Graphics at 364d210, whose pointer and touch events carry their time
The pinned library dropped the compositor's time of every pointer and touch event, so the app dated them by its own clock at dispatch. Events queued while the main loop was busy — a List importing a backlog, each Import an fdatasync — all carried the time the loop came back: a swipe's backlog read as a few milliseconds' travel and flung the list to its far end, and a press whose down and up both waited out a stall had them at one time, a tap where the user held — on a Failed bubble a Retry, an SMS the user did not ask for. Crafter.Graphics 364d210 keeps the time on the window (lastInputTime, set before the event fires), one commit on the master of 2026-11-02, which added the library's review configuration and no code. The gesture detector now gets each event's own time, unwrapped past the wrap at 2^32 into one running clock (an event stamped 0, which the compositor's time reads for one millisecond in 2^32, gets the host's clock), and the long-press timer's expiry is the host's elapsed since the press put on that clock, so a press and its release keep their distance however late the loop dispatches them — and a release or a move the detector sees past the long-press time with no timer fired is the long press itself, at the press, where the press can be one, since the hold is measured on the events' clock (tests/Gesture pins both). The pin moves from 3f646ec; the contracts this app relies on are unchanged by the two commits between.
This commit is contained in:
parent
a679ac7e6e
commit
e6b343985d
4 changed files with 55 additions and 6 deletions
|
|
@ -40,7 +40,10 @@ export namespace ImsdMessages {
|
|||
|
||||
// One pointer at a time: a press that ends within the slop and before
|
||||
// the long-press time is a tap; a press held past that time without
|
||||
// moving is a long press (the host runs the timer and calls Timeout);
|
||||
// moving is a long press (the host runs the timer and calls Timeout —
|
||||
// or the first move or the release past that time is, when it comes
|
||||
// before the timer could: the host's loop dispatched the press and
|
||||
// what followed it together, behind a stall, each with its own time);
|
||||
// movement past the slop starts a drag whose release is a fling when it
|
||||
// was fast enough. Where the host says that what the press lands on has
|
||||
// no long press, a press held as long is still a tap at its release.
|
||||
|
|
@ -66,6 +69,15 @@ export namespace ImsdMessages {
|
|||
break;
|
||||
case PointerPhase::Move: {
|
||||
if (!pressed) break;
|
||||
if (longPress && !dragging && !longPressed && tMs - downAt >= longPressMs) {
|
||||
// Held past the long-press time with no Timeout yet (the
|
||||
// events of a stall dispatched before the timer): the
|
||||
// long press, before any movement is read.
|
||||
longPressed = true;
|
||||
e.kind = GestureEvent::Kind::LongPress;
|
||||
e.at = down;
|
||||
break;
|
||||
}
|
||||
if (!dragging && !longPressed && (std::abs(p.x - down.x) > slopPx || std::abs(p.y - down.y) > slopPx)) {
|
||||
dragging = true;
|
||||
e.kind = GestureEvent::Kind::DragStart;
|
||||
|
|
@ -106,6 +118,12 @@ export namespace ImsdMessages {
|
|||
} else if (!longPressed && (!longPress || tMs - downAt < longPressMs)) {
|
||||
e.kind = GestureEvent::Kind::Tap;
|
||||
e.at = down;
|
||||
} else if (!longPressed) {
|
||||
// Held past the long-press time with no Timeout yet: the
|
||||
// long press, at the release.
|
||||
longPressed = true;
|
||||
e.kind = GestureEvent::Kind::LongPress;
|
||||
e.at = down;
|
||||
} else {
|
||||
e.kind = GestureEvent::Kind::Release;
|
||||
e.at = p;
|
||||
|
|
|
|||
Loading…
Reference in a new issue