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

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

Issue 251543003: Unified Gesture Recognizer (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 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/gestures/gesture_provider_aura.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
14 GestureProviderAura::GestureProviderAura(GestureProviderAuraClient* client)
15 : client_(client),
16 filtered_gesture_provider_(ui::DefaultGestureProviderConfig(), this) {
17 filtered_gesture_provider_.SetDoubleTapSupportForPlatformEnabled(false);
18 }
19
20 GestureProviderAura::~GestureProviderAura() {}
21
22 bool GestureProviderAura::OnTouchEvent(const TouchEvent& event) {
23 flags_ = event.flags();
24 bool pointer_id_is_active = false;
25 for (size_t i = 0; i < motion_event_.GetPointerCount(); ++i) {
26 if (event.touch_id() != motion_event_.GetPointerId(i))
27 continue;
28 pointer_id_is_active = true;
29 break;
30 }
31
32 if (event.type() == ET_TOUCH_PRESSED && pointer_id_is_active) {
33 // Ignore touch press events if we already believe the pointer is down.
34 return false;
35 } else if (event.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) {
36 // We could have an active touch stream transfered to us, resulting in touch
37 // move or touch up events without associated touch down events. Ignore
38 // them.
39 return false;
40 }
41
42 motion_event_.OnTouch(event);
43 DCHECK(motion_event_.GetPointerCount());
jdduke (slow) 2014/05/05 16:57:09 Probably don't need this DCHECK as we don't use th
tdresser 2014/05/05 17:45:14 Done.
44 bool result = filtered_gesture_provider_.OnTouchEvent(motion_event_);
45 motion_event_.CleanupRemovedTouchPoints(event);
46 return result;
47 }
48
49 void GestureProviderAura::OnTouchEventAck(bool event_consumed) {
50 return filtered_gesture_provider_.OnTouchEventAck(event_consumed);
jdduke (slow) 2014/05/05 16:57:09 Nit: no return.
tdresser 2014/05/05 17:45:14 Done.
51 }
52
53 void GestureProviderAura::OnGestureEvent(
54 const GestureEventData& gesture) {
55 scoped_ptr<ui::GestureEvent> event(
56 new ui::GestureEvent(gesture.type,
57 gesture.x,
58 gesture.y,
59 flags_,
60 gesture.time - base::TimeTicks(),
61 gesture.details,
62 // ui::GestureEvent stores a bitfield indicating the
63 // ids of active touch points. This is currently only
64 // used when one finger is down, and will eventually
65 // be cleaned up. See crbug.com/366707.
66 1 << gesture.motion_event_id));
67 client_->OnGestureEvent(event.Pass());
68 }
69
70 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698