Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(390)

Side by Side Diff: ui/events/gestures/gesture_provider_aura.cc

Issue 680413006: Re-enable Eager Gesture Recognition on Aura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address sadrul's comments. Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/events/gestures/gesture_provider_aura.h ('k') | ui/events/gestures/gesture_recognizer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_(DefaultGestureProviderConfig(), this), 18 filtered_gesture_provider_(DefaultGestureProviderConfig(), this),
19 handling_event_(false) { 19 handling_event_(false),
20 last_unique_touch_event_id_(
21 std::numeric_limits<unsigned long long>::max()) {
20 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false); 22 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false);
21 } 23 }
22 24
23 GestureProviderAura::~GestureProviderAura() {} 25 GestureProviderAura::~GestureProviderAura() {}
24 26
25 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) { 27 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) {
28 last_unique_touch_event_id_ = event.unique_event_id();
26 int index = pointer_state_.FindPointerIndexOfId(event.touch_id()); 29 int index = pointer_state_.FindPointerIndexOfId(event.touch_id());
27 bool pointer_id_is_active = index != -1; 30 bool pointer_id_is_active = index != -1;
28 31
29 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { 32 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) {
30 // Ignore touch press events if we already believe the pointer is down. 33 // Ignore touch press events if we already believe the pointer is down.
31 return false; 34 return false;
32 } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { 35 } 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 36 // 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 37 // move or touch up events without associated touch down events. Ignore
35 // them. 38 // them.
36 return false; 39 return false;
37 } 40 }
38 41
39 // If this is a touchmove event, and it isn't different from the last 42 // If this is a touchmove event, and it isn't different from the last
40 // event, ignore it. 43 // event, ignore it.
41 if (event.type() == ET_TOUCH_MOVED && 44 if (event.type() == ET_TOUCH_MOVED &&
42 event.x() == pointer_state_.GetX(index) && 45 event.x() == pointer_state_.GetX(index) &&
43 event.y() == pointer_state_.GetY(index)) { 46 event.y() == pointer_state_.GetY(index)) {
44 return false; 47 return false;
45 } 48 }
46 49
47 last_touch_event_latency_info_ = *event.latency(); 50 last_touch_event_latency_info_ = *event.latency();
48 pointer_state_.OnTouch(event); 51 pointer_state_.OnTouch(event);
49 52
50 bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); 53 bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_);
51 pointer_state_.CleanupRemovedTouchPoints(event); 54 pointer_state_.CleanupRemovedTouchPoints(event);
52 return result; 55 return result;
53 } 56 }
54 57
55 void GestureProviderAura::OnTouchEventAck(bool event_consumed) { 58 void GestureProviderAura::OnAsyncTouchEventAck(bool event_consumed) {
56 DCHECK(pending_gestures_.empty()); 59 DCHECK(pending_gestures_.empty());
57 DCHECK(!handling_event_); 60 DCHECK(!handling_event_);
58 base::AutoReset<bool> handling_event(&handling_event_, true); 61 base::AutoReset<bool> handling_event(&handling_event_, true);
59 filtered_gesture_provider_.OnTouchEventAck(event_consumed); 62 filtered_gesture_provider_.OnAsyncTouchEventAck(event_consumed);
60 last_touch_event_latency_info_.Clear(); 63 last_touch_event_latency_info_.Clear();
61 } 64 }
62 65
66 void GestureProviderAura::OnSyncTouchEventAck(const uint64 unique_event_id,
67 bool event_consumed) {
68 DCHECK_EQ(last_unique_touch_event_id_, unique_event_id);
69 DCHECK(pending_gestures_.empty());
70 DCHECK(!handling_event_);
71 base::AutoReset<bool> handling_event(&handling_event_, true);
72 filtered_gesture_provider_.OnSyncTouchEventAck(event_consumed);
73 last_touch_event_latency_info_.Clear();
74 }
75
63 void GestureProviderAura::OnGestureEvent( 76 void GestureProviderAura::OnGestureEvent(
64 const GestureEventData& gesture) { 77 const GestureEventData& gesture) {
65 GestureEventDetails details = gesture.details; 78 GestureEventDetails details = gesture.details;
66 details.set_oldest_touch_id(gesture.motion_event_id); 79 details.set_oldest_touch_id(gesture.motion_event_id);
67 80
68 if (gesture.type() == ET_GESTURE_TAP) { 81 if (gesture.type() == ET_GESTURE_TAP) {
69 int tap_count = 1; 82 int tap_count = 1;
70 if (previous_tap_ && IsConsideredDoubleTap(*previous_tap_, gesture)) 83 if (previous_tap_ && IsConsideredDoubleTap(*previous_tap_, gesture))
71 tap_count = 1 + (previous_tap_->details.tap_count() % 3); 84 tap_count = 1 + (previous_tap_->details.tap_count() % 3);
72 details.set_tap_count(tap_count); 85 details.set_tap_count(tap_count);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 float double_tap_slop_square = 143 float double_tap_slop_square =
131 GestureConfiguration::GetInstance() 144 GestureConfiguration::GetInstance()
132 ->max_distance_between_taps_for_double_tap(); 145 ->max_distance_between_taps_for_double_tap();
133 double_tap_slop_square *= double_tap_slop_square; 146 double_tap_slop_square *= double_tap_slop_square;
134 const float delta_x = previous_tap.x - current_tap.x; 147 const float delta_x = previous_tap.x - current_tap.x;
135 const float delta_y = previous_tap.y - current_tap.y; 148 const float delta_y = previous_tap.y - current_tap.y;
136 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square); 149 return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square);
137 } 150 }
138 151
139 } // namespace content 152 } // namespace content
OLDNEW
« no previous file with comments | « ui/events/gestures/gesture_provider_aura.h ('k') | ui/events/gestures/gesture_recognizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698