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

Unified Diff: ui/events/gesture_detection/ui_gesture_provider.cc

Issue 251543003: Unified Gesture Recognizer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows linking Created 6 years, 8 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
Index: ui/events/gesture_detection/ui_gesture_provider.cc
diff --git a/ui/events/gesture_detection/ui_gesture_provider.cc b/ui/events/gesture_detection/ui_gesture_provider.cc
new file mode 100644
index 0000000000000000000000000000000000000000..77a60258d2bcacefc66c844465303ab3a0a41867
--- /dev/null
+++ b/ui/events/gesture_detection/ui_gesture_provider.cc
@@ -0,0 +1,80 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/events/gesture_detection/ui_gesture_provider.h"
+
+#include "base/logging.h"
+#include "ui/events/event.h"
+#include "ui/events/gesture_detection/gesture_config_helper.h"
+#include "ui/events/gesture_detection/gesture_event_data.h"
+
+namespace ui {
+namespace {
+
+ui::GestureEvent CreateGesture(const ui::GestureEventData& data, int flags) {
+ return ui::GestureEvent(data.type,
+ data.x,
+ data.y,
+ flags,
+ data.time - base::TimeTicks(),
+ data.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
+ // be cleaned up. See crbug.com/366707.
+ 1 << data.motion_event_id);
+}
+
+} // namespace
+
+UIGestureProvider* UIGestureProvider::Create(UIGestureProviderClient* client) {
+ return new UIGestureProvider(scoped_ptr<GestureProviderClientConverter>(
+ new GestureProviderClientConverter(client)));
+}
+
+UIGestureProvider::UIGestureProvider(
+ scoped_ptr<GestureProviderClientConverter> converter)
+ : FilteredGestureProvider(ui::DefaultGestureProviderConfig(),
+ converter.get()),
+ converter_(converter.Pass()) {
+ SetDoubleTapSupportForPlatformEnabled(false);
+}
+
+UIGestureProvider::~UIGestureProvider() {}
+
+bool UIGestureProvider::OnTouchEvent(const TouchEvent& event) {
+ converter_->set_flags(event.flags());
+ bool pointer_id_is_active = false;
+ for (size_t i = 0; i < motion_event_.GetPointerCount(); ++i) {
+ if (event.touch_id() != motion_event_.GetPointerId(i))
+ continue;
+ pointer_id_is_active = true;
+ break;
+ }
+
+ if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) {
+ // Ignore touch press events if we already believe the pointer is down.
+ return false;
+ } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) {
+ // We could have an active touch stream transfered to us, resulting in touch
+ // move or touch up events without associated touch down events. Ignore
+ // them.
+ return false;
+ }
+
+ motion_event_.OnTouch(event);
+
+ DCHECK(motion_event_.GetPointerCount());
+ bool result = FilteredGestureProvider::OnTouchEvent(motion_event_);
jdduke (slow) 2014/05/02 17:56:43 I think this will be a little cleaner if the Filte
tdresser 2014/05/05 15:42:35 Done.
+ motion_event_.CleanupRemovedTouchPoints(event);
+ return result;
+}
+
+void UIGestureProvider::GestureProviderClientConverter::OnGestureEvent(
+ const GestureEventData& gesture) {
+ ui::GestureEvent event = CreateGesture(gesture, flags_);
+ client_->OnGestureEvent(&event);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698