| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/events/gestures/gesture_provider_aura.h" | 5 #include "ui/events/gestures/gesture_provider_aura.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "ui/events/event.h" | 9 #include "ui/events/event.h" |
| 10 #include "ui/events/gesture_detection/gesture_config_helper.h" | 10 #include "ui/events/gesture_detection/gesture_config_helper.h" |
| 11 #include "ui/events/gesture_detection/gesture_event_data.h" | 11 #include "ui/events/gesture_detection/gesture_event_data.h" |
| 12 #include "ui/events/gestures/gesture_configuration.h" | 12 #include "ui/events/gestures/gesture_configuration.h" |
| 13 | 13 |
| 14 namespace ui { | 14 namespace ui { |
| 15 | 15 |
| 16 GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client) | 16 GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client) |
| 17 : client_(client), | 17 : client_(client), |
| 18 filtered_gesture_provider_(ui::DefaultGestureProviderConfig(), this), | 18 filtered_gesture_provider_(ui::DefaultGestureProviderConfig(), this), |
| 19 handling_event_(false) { | 19 handling_event_(false) { |
| 20 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); | 20 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); |
| 21 } | 21 } |
| 22 | 22 |
| 23 GestureProviderAura::~GestureProviderAura() {} | 23 GestureProviderAura::~GestureProviderAura() {} |
| 24 | 24 |
| 25 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { | 25 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { |
| 26 bool pointer_id_is_active = | 26 int index = pointer_state_.FindPointerIndexOfId(event.touch_id()); |
| 27 pointer_state_.FindPointerIndexOfId(event.touch_id()) != -1; | 27 bool pointer_id_is_active = index != -1; |
| 28 | 28 |
| 29 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { | 29 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { |
| 30 // Ignore touch press events if we already believe the pointer is down. | 30 // Ignore touch press events if we already believe the pointer is down. |
| 31 return false; | 31 return false; |
| 32 } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { | 32 } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { |
| 33 // We could have an active touch stream transfered to us, resulting in touch | 33 // We could have an active touch stream transfered to us, resulting in touch |
| 34 // move or touch up events without associated touch down events. Ignore | 34 // move or touch up events without associated touch down events. Ignore |
| 35 // them. | 35 // them. |
| 36 return false; | 36 return false; |
| 37 } | 37 } |
| 38 | 38 |
| 39 // If this is a touchmove event, and it isn't different from the last |
| 40 // event, ignore it. |
| 41 if (event.type() == ET_TOUCH_MOVED && |
| 42 event.x() == pointer_state_.GetX(index) && |
| 43 event.y() == pointer_state_.GetY(index)) { |
| 44 return false; |
| 45 } |
| 46 |
| 39 last_touch_event_flags_ = event.flags(); | 47 last_touch_event_flags_ = event.flags(); |
| 40 last_touch_event_latency_info_ = *event.latency(); | 48 last_touch_event_latency_info_ = *event.latency(); |
| 41 pointer_state_.OnTouch(event); | 49 pointer_state_.OnTouch(event); |
| 42 | 50 |
| 43 bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); | 51 bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); |
| 44 pointer_state_.CleanupRemovedTouchPoints(event); | 52 pointer_state_.CleanupRemovedTouchPoints(event); |
| 45 return result; | 53 return result; |
| 46 } | 54 } |
| 47 | 55 |
| 48 void GestureProviderAura::OnTouchEventAck(bool event_consumed) { | 56 void GestureProviderAura::OnTouchEventAck(bool event_consumed) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 130 |
| 123 double double_tap_slop_square = | 131 double double_tap_slop_square = |
| 124 GestureConfiguration::max_distance_between_taps_for_double_tap(); | 132 GestureConfiguration::max_distance_between_taps_for_double_tap(); |
| 125 double_tap_slop_square *= double_tap_slop_square; | 133 double_tap_slop_square *= double_tap_slop_square; |
| 126 const float delta_x = previous_tap.x - current_tap.x; | 134 const float delta_x = previous_tap.x - current_tap.x; |
| 127 const float delta_y = previous_tap.y - current_tap.y; | 135 const float delta_y = previous_tap.y - current_tap.y; |
| 128 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); | 136 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); |
| 129 } | 137 } |
| 130 | 138 |
| 131 } // namespace content | 139 } // namespace content |
| OLD | NEW |