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

Unified Diff: ui/events/gestures/gesture_provider_aura.cc

Issue 289373009: Support tap_count in ui::GestureProvider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address jdduke comments. Created 6 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/events/gestures/gesture_provider_aura.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..0a0bab03320722106a50580a79ed71c37b5d5e26 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,12 @@ bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) {
}
pointer_state_.OnTouch(event);
+
+ if (pointer_state_.GetAction() == MotionEvent::ACTION_DOWN) {
+ previous_down_event_ = current_down_event_.Pass();
+ current_down_event_ = pointer_state_.Clone();
+ }
+
bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_);
pointer_state_.CleanupRemovedTouchPoints(event);
return result;
@@ -51,12 +58,28 @@ void GestureProviderAura::OnTouchEventAck(bool event_consumed) {
void GestureProviderAura::OnGestureEvent(
const GestureEventData& gesture) {
+ GestureEventDetails details = gesture.details;
+
+ int tap_count = 1;
+ if (gesture.type == ET_GESTURE_TAP) {
+ if (previous_down_event_ && current_down_event_ &&
+ IsConsideredDoubleTap(
jdduke (slow) 2014/05/21 19:00:30 The reason I suggested just caching the tap detail
tdresser 2014/05/21 19:50:43 I hesitated because it does change the behavior (W
+ *previous_down_event_, previous_tap_->time, *current_down_event_)) {
+ tap_count = 1 + (previous_tap_->details.tap_count() % 3);
+ }
+ details = GestureEventDetails(ET_GESTURE_TAP, tap_count, 0);
+ previous_tap_.reset(new GestureEventData(gesture));
+ 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 +88,23 @@ void GestureProviderAura::OnGestureEvent(
client_->OnGestureEvent(&event);
}
+bool GestureProviderAura::IsConsideredDoubleTap(
+ const MotionEvent& previous_down,
+ const base::TimeTicks previous_tap_time,
+ const MotionEvent& current_down) const {
+ if (current_down.GetEventTime() - 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_down.GetX() - current_down.GetX();
+ const float delta_y = previous_down.GetY() - current_down.GetY();
+ return (delta_x * delta_x + delta_y * delta_y < double_tap_slop_square);
+}
+
} // namespace content
« no previous file with comments | « ui/events/gestures/gesture_provider_aura.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698