OLD | NEW |
---|---|
(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 last_touch_event_flags_ = event.flags(); | |
24 bool pointer_id_is_active = false; | |
25 for (size_t i = 0; i < pointer_state_.GetPointerCount(); ++i) { | |
26 if (event.touch_id() != pointer_state_.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 pointer_state_.OnTouch(event); | |
43 bool result = filtered_gesture_provider_.OnTouchEvent(pointer_state_); | |
44 pointer_state_.CleanupRemovedTouchPoints(event); | |
45 return result; | |
46 } | |
47 | |
48 void GestureProviderAura::OnTouchEventAck(bool event_consumed) { | |
49 filtered_gesture_provider_.OnTouchEventAck(event_consumed); | |
50 } | |
51 | |
52 void GestureProviderAura::OnGestureEvent( | |
53 const GestureEventData& gesture) { | |
54 scoped_ptr<ui::GestureEvent> event( | |
sadrul
2014/05/07 13:42:17
Why scoped_ptr<>? Can't we just create this on the
tdresser
2014/05/07 14:04:17
Done.
| |
55 new ui::GestureEvent(gesture.type, | |
56 gesture.x, | |
57 gesture.y, | |
58 last_touch_event_flags_, | |
59 gesture.time - base::TimeTicks(), | |
60 gesture.details, | |
61 // ui::GestureEvent stores a bitfield indicating the | |
62 // ids of active touch points. This is currently only | |
63 // used when one finger is down, and will eventually | |
64 // be cleaned up. See crbug.com/366707. | |
65 1 << gesture.motion_event_id)); | |
66 client_->OnGestureEvent(event.Pass()); | |
67 } | |
68 | |
69 } // namespace content | |
OLD | NEW |