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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/events/gesture_detection/ui_gesture_provider.h"
6
7 #include "base/logging.h"
8 #include "ui/events/event.h"
9 #include "ui/events/gesture_detection/gesture_config_helper.h"
10 #include "ui/events/gesture_detection/gesture_event_data.h"
11
12 namespace ui {
13 namespace {
14
15 ui::GestureEvent CreateGesture(const ui::GestureEventData& data, int flags) {
16 return ui::GestureEvent(data.type,
17 data.x,
18 data.y,
19 flags,
20 data.time - base::TimeTicks(),
21 data.details,
22 // ui::GestureEvent stores a bitfield indicating the
23 // ids of active touch points. This is currently only
24 // used when one finger is down, and will eventually
25 // be cleaned up. See crbug.com/366707.
26 1 << data.motion_event_id);
27 }
28
29 } // namespace
30
31 UIGestureProvider* UIGestureProvider::Create(UIGestureProviderClient* client) {
32 return new UIGestureProvider(scoped_ptr<GestureProviderClientConverter>(
33 new GestureProviderClientConverter(client)));
34 }
35
36 UIGestureProvider::UIGestureProvider(
37 scoped_ptr<GestureProviderClientConverter> converter)
38 : FilteredGestureProvider(ui::DefaultGestureProviderConfig(),
39 converter.get()),
40 converter_(converter.Pass()) {
41 SetDoubleTapSupportForPlatformEnabled(false);
42 }
43
44 UIGestureProvider::~UIGestureProvider() {}
45
46 bool UIGestureProvider::OnTouchEvent(const TouchEvent& event) {
47 converter_->set_flags(event.flags());
48 bool pointer_id_is_active = false;
49 for (size_t i = 0; i < motion_event_.GetPointerCount(); ++i) {
50 if (event.touch_id() != motion_event_.GetPointerId(i))
51 continue;
52 pointer_id_is_active = true;
53 break;
54 }
55
56 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) {
57 // Ignore touch press events if we already believe the pointer is down.
58 return false;
59 } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) {
60 // We could have an active touch stream transfered to us, resulting in touch
61 // move or touch up events without associated touch down events. Ignore
62 // them.
63 return false;
64 }
65
66 motion_event_.OnTouch(event);
67
68 DCHECK(motion_event_.GetPointerCount());
69 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.
70 motion_event_.CleanupRemovedTouchPoints(event);
71 return result;
72 }
73
74 void UIGestureProvider::GestureProviderClientConverter::OnGestureEvent(
75 const GestureEventData& gesture) {
76 ui::GestureEvent event = CreateGesture(gesture, flags_);
77 client_->OnGestureEvent(&event);
78 }
79
80 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698