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_configuration.h" | 10 #include "ui/events/gesture_detection/gesture_configuration.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/gesture_detection/gesture_provider_config_helper.h" | 12 #include "ui/events/gesture_detection/gesture_provider_config_helper.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_( | 18 filtered_gesture_provider_( |
19 GetGestureProviderConfig(GestureProviderConfigType::CURRENT_PLATFORM), | 19 GetGestureProviderConfig(GestureProviderConfigType::CURRENT_PLATFORM), |
20 this), | 20 this), |
21 handling_event_(false), | 21 handling_event_(false), |
22 last_unique_touch_event_id_( | 22 last_unique_touch_event_id_( |
23 std::numeric_limits<unsigned long long>::max()) { | 23 std::numeric_limits<unsigned long long>::max()) { |
24 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); | 24 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); |
25 } | 25 } |
26 | 26 |
27 GestureProviderAura::~GestureProviderAura() {} | 27 GestureProviderAura::~GestureProviderAura() {} |
28 | 28 |
29 bool GestureProviderAura::OnTouchEvent(TouchEvent* event) { | 29 bool GestureProviderAura::OnTouchEvent(TouchEvent* event) { |
30 DCHECK(event); | |
31 last_unique_touch_event_id_ = event->unique_event_id(); | 30 last_unique_touch_event_id_ = event->unique_event_id(); |
jdduke (slow)
2015/01/05 22:35:14
Should we only update these if |pointer_state_.OnT
tdresser
2015/01/06 14:20:16
The latency info should definitely only be set if
| |
32 int index = pointer_state_.FindPointerIndexOfId(event->touch_id()); | 31 last_touch_event_latency_info_ = *event->latency(); |
33 bool pointer_id_is_active = index != -1; | 32 if (!pointer_state_.OnTouch(*event)) |
34 | |
35 if (event->type() == ET_TOUCH_PRESSED && pointer_id_is_active) { | |
36 // Ignore touch press events if we already believe the pointer is down. | |
37 return false; | 33 return false; |
38 } else if (event->type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { | |
39 // We could have an active touch stream transfered to us, resulting in touch | |
40 // move or touch up events without associated touch down events. Ignore | |
41 // them. | |
42 return false; | |
43 } | |
44 | |
45 // If this is a touchmove event, and it isn't different from the last | |
46 // event, ignore it. | |
47 if (event->type() == ET_TOUCH_MOVED && | |
48 event->x() == pointer_state_.GetX(index) && | |
49 event->y() == pointer_state_.GetY(index)) { | |
50 return false; | |
51 } | |
52 | |
53 last_touch_event_latency_info_ = *event->latency(); | |
54 pointer_state_.OnTouch(*event); | |
55 | 34 |
56 auto result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); | 35 auto result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); |
57 if (!result.succeeded) | 36 if (!result.succeeded) |
58 return false; | 37 return false; |
59 | 38 |
60 event->set_may_cause_scrolling(result.did_generate_scroll); | 39 event->set_may_cause_scrolling(result.did_generate_scroll); |
61 pointer_state_.CleanupRemovedTouchPoints(*event); | 40 pointer_state_.CleanupRemovedTouchPoints(*event); |
62 return true; | 41 return true; |
63 } | 42 } |
64 | 43 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 float double_tap_slop_square = | 129 float double_tap_slop_square = |
151 GestureConfiguration::GetInstance() | 130 GestureConfiguration::GetInstance() |
152 ->max_distance_between_taps_for_double_tap(); | 131 ->max_distance_between_taps_for_double_tap(); |
153 double_tap_slop_square *= double_tap_slop_square; | 132 double_tap_slop_square *= double_tap_slop_square; |
154 const float delta_x = previous_tap.x - current_tap.x; | 133 const float delta_x = previous_tap.x - current_tap.x; |
155 const float delta_y = previous_tap.y - current_tap.y; | 134 const float delta_y = previous_tap.y - current_tap.y; |
156 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); | 135 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); |
157 } | 136 } |
158 | 137 |
159 } // namespace content | 138 } // namespace content |
OLD | NEW |