Skip to content

Commit b06e866

Browse files
gquicheCQ Bot
authored andcommitted
[ui][input-pipeline] gestures: enable drag recognizer
Enable the drag recognizer, by adding it to the set of recognizers instantiated by `gesture_arena::make_input_handler`. Along the way, rename `one_finger_drag::Contender` to `one_finger_drag::InitialContender`, to match the naming in other recognizers. Note: after I release the touchpad button, the selected text is no longer highlighted. I'll file a separate bug to improve that. Bug: None Test: manual Manual test ----------- 1. Opened an article in Wikipedia. 2. Pointed at a word. 3. Pressed touchpad down with one finger. 4. Moved finger until pointer was at end of sentence. 5. Saw that the text from the initial word to the end of the sentence was highlighted. Change-Id: Ic46ccef2ce6f2431078a8961e91cf1888c7b2d5b Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/707546 Fuchsia-Auto-Submit: Mukesh Agrawal <quiche@google.com> Reviewed-by: Jianpeng Chao <chaopeng@google.com> Commit-Queue: Auto-Submit <auto-submit@fuchsia-infra.iam.gserviceaccount.com>
1 parent df9dddd commit b06e866

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/ui/lib/input_pipeline/src/gestures/gesture_arena.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
use {
6-
super::{click, motion, primary_tap, secondary_tap},
6+
super::{click, motion, one_finger_drag, primary_tap, secondary_tap},
77
crate::{input_device, input_handler::UnhandledInputHandler, mouse_binding, touch_binding},
88
anyhow::{format_err, Error},
99
async_trait::async_trait,
@@ -34,6 +34,9 @@ pub fn make_input_handler() -> std::rc::Rc<dyn crate::input_handler::InputHandle
3434
max_finger_displacement_in_mm: MAX_TAP_MOVEMENT_IN_MM,
3535
max_time_elapsed: TAP_TIMEOUT,
3636
}),
37+
Box::new(one_finger_drag::InitialContender {
38+
min_movement_in_mm: SPURIOUS_TO_INTENTIONAL_MOTION_THRESHOLD_MM,
39+
}),
3740
]
3841
}))
3942
}

src/ui/lib/input_pipeline/src/gestures/one_finger_drag.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ use {
1919

2020
/// The initial state of this recognizer, before a finger contact has been detected.
2121
#[derive(Debug)]
22-
struct Contender {
22+
pub(super) struct InitialContender {
2323
/// The minimum movement in millimeters on surface to recognize as a motion.
24-
min_movement_in_mm: f32,
24+
pub(super) min_movement_in_mm: f32,
2525
}
2626

2727
/// The state when this recognizer has detected a finger pressed buttondown, before finger
@@ -47,7 +47,7 @@ struct Winner {
4747
last_position: Position,
4848
}
4949

50-
impl Contender {
50+
impl InitialContender {
5151
fn into_button_down_contender(
5252
self: Box<Self>,
5353
initial_position: Position,
@@ -59,7 +59,7 @@ impl Contender {
5959
}
6060
}
6161

62-
impl gesture_arena::Contender for Contender {
62+
impl gesture_arena::Contender for InitialContender {
6363
fn examine_event(self: Box<Self>, event: &TouchpadEvent) -> ExamineEventResult {
6464
if event.contacts.len() != 1 {
6565
return ExamineEventResult::Mismatch("wanted 1 contact");
@@ -286,7 +286,7 @@ mod test {
286286
#[fuchsia::test]
287287
fn initial_contender_examine_event_mismatch(event: TouchpadEvent) {
288288
let contender: Box<dyn gesture_arena::Contender> =
289-
Box::new(Contender { min_movement_in_mm: 10.0 });
289+
Box::new(InitialContender { min_movement_in_mm: 10.0 });
290290

291291
let got = contender.examine_event(&event);
292292
assert_matches!(got, ExamineEventResult::Mismatch(_));
@@ -295,7 +295,7 @@ mod test {
295295
#[fuchsia::test]
296296
fn initial_contender_examine_event_button_down_contender() {
297297
let contender: Box<dyn gesture_arena::Contender> =
298-
Box::new(Contender { min_movement_in_mm: 10.0 });
298+
Box::new(InitialContender { min_movement_in_mm: 10.0 });
299299
let event = TouchpadEvent {
300300
timestamp: zx::Time::ZERO,
301301
pressed_buttons: vec![1],

0 commit comments

Comments
 (0)