Chromium Code Reviews| Index: ui/events/gestures/gesture_provider_aura.cc |
| diff --git a/ui/events/gestures/gesture_provider_aura.cc b/ui/events/gestures/gesture_provider_aura.cc |
| index c73d3179bc6b711afdd23e82587b33a83fe04cd2..73801ff5931d4fed06b56687324932ba43e2ee0e 100644 |
| --- a/ui/events/gestures/gesture_provider_aura.cc |
| +++ b/ui/events/gestures/gesture_provider_aura.cc |
| @@ -8,6 +8,7 @@ |
| #include "ui/events/event.h" |
| #include "ui/events/gesture_detection/gesture_config_helper.h" |
| #include "ui/events/gesture_detection/gesture_event_data.h" |
| +#include "ui/events/gestures/gesture_configuration.h" |
| namespace ui { |
| @@ -40,6 +41,7 @@ bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { |
| } |
| pointer_state_.OnTouch(event); |
| + |
| bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); |
| pointer_state_.CleanupRemovedTouchPoints(event); |
| return result; |
| @@ -51,12 +53,25 @@ void GestureProviderAura::OnTouchEventAck(bool event_consumed) { |
| void GestureProviderAura::OnGestureEvent( |
| const GestureEventData& gesture) { |
| + GestureEventDetails details = gesture.details; |
| + |
| + int tap_count = 1; |
|
jdduke (slow)
2014/05/21 20:02:00
Nit: Move tap_count into the if case?
tdresser
2014/05/22 12:56:47
Done.
|
| + if (gesture.type == ET_GESTURE_TAP) { |
| + if (previous_tap_ && IsConsideredDoubleTap(*previous_tap_, gesture)) |
| + tap_count = 1 + (previous_tap_->details.tap_count() % 3); |
| + details = GestureEventDetails(ET_GESTURE_TAP, tap_count, 0); |
|
jdduke (slow)
2014/05/21 20:02:00
Feel free to add a GestureEventDetails::set_tap_co
tdresser
2014/05/22 12:56:47
Done.
|
| + previous_tap_.reset(new GestureEventData(gesture)); |
|
jdduke (slow)
2014/05/21 20:02:00
if (!previous_tap_)
previous_tap_.reset(new gest
tdresser
2014/05/22 12:56:47
Done.
|
| + previous_tap_->details = details; |
| + } else if (gesture.type == ET_GESTURE_TAP_CANCEL) { |
| + previous_tap_.reset(); |
| + } |
| + |
| ui::GestureEvent event(gesture.type, |
| gesture.x, |
| gesture.y, |
| last_touch_event_flags_, |
| gesture.time - base::TimeTicks(), |
| - gesture.details, |
| + details, |
| // ui::GestureEvent stores a bitfield indicating the |
| // ids of active touch points. This is currently only |
| // used when one finger is down, and will eventually |
| @@ -65,4 +80,22 @@ void GestureProviderAura::OnGestureEvent( |
| client_->OnGestureEvent(&event); |
| } |
| +bool GestureProviderAura::IsConsideredDoubleTap( |
| + const GestureEventData& previous_tap, |
| + const GestureEventData& current_tap) const { |
| + if (current_tap.time - previous_tap.time > |
| + base::TimeDelta::FromMilliseconds( |
| + ui::GestureConfiguration::max_seconds_between_double_click() * |
| + 1000)) { |
| + return false; |
| + } |
| + |
| + double double_tap_slop_square = |
| + GestureConfiguration::max_distance_between_taps_for_double_tap(); |
| + double_tap_slop_square *= double_tap_slop_square; |
| + const float delta_x = previous_tap.x - current_tap.x; |
| + const float delta_y = previous_tap.y - current_tap.y; |
| + return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); |
| +} |
| + |
| } // namespace content |