class GestureArena
Defined at line 130 of file ../../src/ui/a11y/lib/gesture_manager/arena/gesture_arena.h
The Gesture Arena for accessibility services.
The Gesture Arena manages several recognizers which are trying to interpret a gesture that is
being performed. It respects the following rules:
* Contests begin when a touch pointer is added and continue until every member has either
claimed a win or declared defeat.
* Of the members that claim a win, the win is awarded to the highest priority member.
All members must eventually claim a win or declare defeat. Once a member has claimed a win or
declared defeat, it may not change its declaration.
Recognizers continue to receive incoming pointer events until they release their |ContestMember|
or are defeated. After the winning recognizer releases its |ContestMember|, the next interaction
will begin a new contest.
The order in which recognizers are added to the arena determines event dispatch order and win
priority. When routing pointer events to recognizers, they see the event in order they were
added. Then they have the chance to claim a win before the next recognizer in the list has the
chance to act. Then, during resolution, if multiple recognizers claim a win, the one that was
added first is awarded the win.
In this model, it is important to notice that there are two layers of abstraction:
1. Raw pointer events, which come from the input system, arrive at the arena and are dispatched
to recognizers via a PointerStreamTracker.
2. Gestures, which are sequences of pointer events with a semantic meaning, are identified by
recognizers.
With that in mind, each recognizer defines the semantic meaning for the sequence of pointer
events that it is receiving. In another words, it is expected that a recognizer could identify a
single tap, another a double tap, and so on.
Claiming a win indicates that a recognizer identified a gesture. However, the win will not
necessarily be awarded to that recognizer. Recognizers are free to handle their events
optimistically, but if they do then they must undo/reset any changes they effect if they are
eventually defeated.
Recognizers should not destroy the arena.
If any member claims a win, the input system is immediately notified that the pointer event
streams were consumed (as would be any new pointer event streams until the end of the gesture).
If no member claims a win, the input system is notified that the pointer event streams were
rejected.
Implementation notes: this arena is heavily influenced by Fluttter's gesture arena:
https://flutter.dev/docs/development/ui/advanced/gestures For those familiar how Flutter version
works, here are the important main differences:
- The arena here is not per finger (a.k.a. per pointer ID), which means that
recognizers receive the whole interaction with the screen.
- There are not default wins or mutiple levels of acceptance. Recognizers must be certain when
they claim a win.
Public Methods
void GestureArena (PointerStreamTracker::OnStreamHandledCallback on_stream_handled_callback)
This arena takes |on_stream_handled_callback|, which is called whenever a
stream of pointer events is handled (e.g., is consumed or rejected).
Defined at line 142 of file ../../src/ui/a11y/lib/gesture_manager/arena/gesture_arena.cc
void ~GestureArena ()
Defined at line 145 of file ../../src/ui/a11y/lib/gesture_manager/arena/gesture_arena.h
void Add (GestureRecognizer * recognizer)
Adds a new recognizer to the arena. The new recognizer starts participating in the next
contest.
Defined at line 145 of file ../../src/ui/a11y/lib/gesture_manager/arena/gesture_arena.cc
void OnEvent (const fuchsia::ui::input::accessibility::PointerEvent & pointer_event)
Dispatches a new pointer event to this arena. This event gets sent to all arena members which
are active at the moment.
Virtual for testing; overridden by a mock.
Defined at line 155 of file ../../src/ui/a11y/lib/gesture_manager/arena/gesture_arena.cc
void TryToResolve ()
Tries to resolve the arena if it is not resolved already.
It follows two rules:
* Contests continue until every member has either claimed a win or declared defeat.
* Of the members that claim a win, the win is awarded to the highest priority member.
A resolved arena will continue to be so until the winner releases its |ContestMember|, which
resets the arena for a new contest.
Defined at line 167 of file ../../src/ui/a11y/lib/gesture_manager/arena/gesture_arena.cc
State GetState ()
Get the state of the gesture arena.
Virtual for testing; overridden by a mock.
Defined at line 188 of file ../../src/ui/a11y/lib/gesture_manager/arena/gesture_arena.cc
Enumerations
enum State
| Name | Value |
|---|---|
| kIdle | 0 |
| kInProgress | 1 |
| kWinnerAssigned | 2 |
| kAllDefeated | 3 |
| kContestEndedWinnerAssigned | 4 |
| kContestEndedAllDefeated | 5 |
Defined at line 132 of file ../../src/ui/a11y/lib/gesture_manager/arena/gesture_arena.h